/* ============ 考研英语词汇速记平台 ============ */
:root {
  --bg: #f4f1ea;
  --paper: #ffffff;
  --ink: #26281f;
  --ink-soft: #66635a;
  --line: #e6e1d3;
  --brand: #1f5c55;
  --brand-soft: #e3efec;
  --brand-deep: #174641;
  --accent: #c97b3d;
  --high: #2e8b7f;
  --low: #6d8496;
  --danger: #b4554a;
  --shadow: 0 1px 3px rgba(60, 54, 38, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}

a { color: var(--brand); text-decoration: none; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--brand-deep);
  color: #f3f7f6;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #7fd4c8;
  display: inline-block;
}
.nav { display: flex; gap: 6px; margin-left: auto; }
.nav a {
  color: #cfe3e0;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 14px;
}
.nav a.active,
.nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ---------- 页面容器 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 80px; }

/* ---------- 统计概览 ---------- */
.stats-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 14px;
}
.stat .num { font-size: 24px; font-weight: 700; color: var(--brand-deep); }
.stat .lbl { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.progress-track {
  margin-top: 14px;
  height: 12px;
  background: #ece7d9;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--high), var(--brand));
  border-radius: 999px;
  width: 0%;
  transition: width 0.35s ease;
}
.progress-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}

/* ---------- 工具条：层级 / 分组方式 / 搜索 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.seg {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.search-box {
  margin-left: auto;
  position: relative;
}
.search-box input {
  width: 260px;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  font-size: 14px;
  color: var(--ink);
}
.search-box input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.search-box::before {
  content: "🔍";
  position: absolute;
  left: 12px; top: 8px;
  font-size: 14px;
  opacity: 0.55;
}

/* ---------- 分组卡片 ---------- */
.group {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  cursor: pointer;
  user-select: none;
}
.group-head:hover { background: #faf8f2; }
.group-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}
.basis-tag {
  font-size: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 7px;
  padding: 3px 9px;
  white-space: nowrap;
}
.group-progress {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.group-progress b { color: var(--brand-deep); }
.group-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-deep); }
.btn.danger-ghost { color: var(--danger); border-color: #eccfc9; }
.btn.danger-ghost:hover { background: #fbeeed; }
.caret {
  width: 10px; height: 10px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg);
  transition: transform 0.2s;
}
.group.collapsed .caret { transform: rotate(-45deg); }
.group-body { padding: 4px 18px 18px; }
.group.collapsed .group-body { display: none; }

/* ---------- 单词卡片网格 ---------- */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.word-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #fff;
  transition: opacity 0.2s, transform 0.2s, border-color 0.15s;
  position: relative;
}
.word-card:hover { border-color: var(--brand); }
.word-card.fade-out { opacity: 0; transform: scale(0.96); pointer-events: none; }
.word-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.word-text {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.word-alt { font-size: 12px; color: var(--ink-soft); }
.word-tags { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.tag {
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 8px;
  color: #fff;
}
.tag.high { background: var(--high); }
.tag.low { background: var(--low); }
.tag.cefr { background: #d9d3c2; color: #5d594b; }
.tag.exam { background: var(--accent); }
.word-meaning { margin-top: 6px; color: var(--ink); font-size: 14px; }
.word-example {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink-soft);
  display: none;
}
.word-example .en { font-family: Georgia, serif; }
.word-example .cn { margin-top: 3px; }
.word-card.open-example .word-example { display: block; }
.word-foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  border: 0;
  background: #f2efe6;
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 15px;
  color: var(--brand-deep);
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--brand-soft); }
.icon-btn.speaking { background: var(--brand); color: #fff; font-size: 13px; }
.mark-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #cfe0dc;
  background: #f3faf8;
  color: var(--high);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.mark-btn:hover { background: var(--brand-soft); }
.mark-btn.checked { background: var(--high); color: #fff; border-color: var(--high); }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty .big { font-size: 34px; margin-bottom: 10px; }

/* ---------- 复习页 ---------- */
.day-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.day-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  cursor: pointer;
}
.day-head:hover { background: #faf8f2; }
.day-title { font-size: 16px; font-weight: 700; }
.day-meta { font-size: 13px; color: var(--ink-soft); }
.day-body { padding: 4px 18px 18px; }
.day-section.collapsed .day-body { display: none; }

.flip-card { cursor: pointer; }
.meaning-mask {
  display: inline-block;
  background: #f2efe6;
  color: var(--ink-soft);
  border-radius: 7px;
  padding: 2px 10px;
  font-size: 13px;
}
.flip-card.revealed .meaning-mask { display: none; }
.flip-card .meaning-hidden-only { display: none; }
.flip-card.revealed .meaning-hidden-only { display: inline; }

/* ---------- 提示 toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: var(--brand-deep);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 50;
}
.toast.show { opacity: 0.95; }

/* ============================================================
   响应式适配：桌面 → 平板(≤1024) → 手机(≤768 / ≤480)
   ============================================================ */

/* ---------- 平板 ---------- */
@media (max-width: 1024px) {
  .wrap { padding: 18px 16px 70px; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 16px 12px; }
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
}

/* ---------- 手机横屏 / 小屏 ---------- */
@media (max-width: 768px) {
  html, body { font-size: 14.5px; }
  .wrap { padding: 14px 12px 64px; }

  /* 顶栏 */
  .topbar-inner { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .brand { font-size: 16px; flex: 1 1 auto; }
  .nav { margin-left: 0; width: 100%; }
  .nav a { flex: 1; text-align: center; padding: 9px 10px; }

  /* 统计 */
  .stats-panel { padding: 14px 14px; margin-bottom: 14px; border-radius: 12px; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
  .stat .num { font-size: 21px; }
  .stat .lbl { font-size: 12px; }
  .progress-meta { flex-direction: column; gap: 2px; }

  /* 工具条：纵向堆叠，分段控件全宽 */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1 1 0; padding: 11px 8px; font-size: 13.5px; min-height: 44px; white-space: normal; line-height: 1.35; }
  .search-box { margin-left: 0; width: 100%; }
  .search-box input { width: 100%; min-height: 44px; font-size: 15px; }

  /* 分组头部：纵向堆叠，避免横向挤压 */
  .group { margin-bottom: 12px; border-radius: 12px; }
  .group-head { flex-wrap: wrap; gap: 8px 10px; padding: 13px 14px; }
  .caret { flex: 0 0 auto; }
  .group-title { flex: 1 1 60%; font-size: 15.5px; }
  .basis-tag { order: 2; font-size: 11.5px; }
  .group-progress { order: 3; font-size: 12.5px; white-space: normal; }
  .group-actions { order: 4; margin-left: auto; }
  .group-actions .btn { min-height: 40px; }
  .group-body { padding: 2px 12px 14px; }

  /* 单词卡片单列 */
  .word-grid { grid-template-columns: 1fr; gap: 10px; }
  .word-card { padding: 12px 13px; }
  .word-line { flex-wrap: wrap; gap: 6px 8px; }
  .word-tags { margin-left: auto; justify-content: flex-end; }
  .word-foot { flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .word-foot .btn,
  .mark-btn { min-height: 40px; }
  .icon-btn { width: 40px; height: 40px; }

  /* 复习日头部 */
  .day-section { border-radius: 12px; margin-bottom: 12px; }
  .day-head { flex-wrap: wrap; gap: 6px 10px; padding: 13px 14px; }
  .day-title { flex: 1 1 50%; }
  .day-meta { flex: 1 1 100%; font-size: 12.5px; }
  .day-body { padding: 2px 12px 14px; }
}

/* ---------- 手机竖屏 ---------- */
@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
  .stat .num { font-size: 19px; }
  .stat .lbl { font-size: 11.5px; }

  .brand { font-size: 15px; }
  .nav a { padding: 8px 6px; font-size: 13.5px; }

  .seg button { font-size: 12.5px; padding: 10px 6px; }
  .group-title { font-size: 15px; flex: 1 1 55%; }

  .word-text { font-size: 18px; }
  .tag { font-size: 10.5px; padding: 2px 7px; }

  /* 卡片底部操作：发音+例句靠左，已背按钮占满剩余行 */
  .word-foot { gap: 8px; }
  .word-foot .btn { flex: 1 1 auto; }
  .mark-btn { margin-left: 0; flex: 1 1 100%; justify-content: center; }
  .empty { padding: 44px 16px; }
}
