:root {
  --navy: #1b2a4a;
  --navy-soft: #2f4470;
  --red: #c8443c;
  --red-soft: #e0685f;
  --paper: #f7f5f1;
  --card: #ffffff;
  --ink: #1d2433;
  --ink-soft: #5d6675;
  --line: #e3ded5;
  --green: #3f8a5f;
  --amber: #c98a2b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(27, 42, 74, .06), 0 8px 24px rgba(27, 42, 74, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 18px calc(96px + var(--safe-bottom));
  min-height: 100vh;
}

/* ---------- 通用 ---------- */

.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 4px 0 2px;
}

.page-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 20px;
  line-height: 1.5;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin: 26px 0 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--line);
}

.ru {
  font-family: "Times New Roman", "Noto Serif", Georgia, serif;
}

/* ---------- 首页 ---------- */

.hero {
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: #fff;
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 10px 30px rgba(27, 42, 74, .18);
}

.hero-date {
  font-size: 13px;
  opacity: .75;
  margin: 0 0 6px;
}

.hero-count {
  font-size: 34px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.02em;
}

.hero-count small { font-size: 15px; font-weight: 500; opacity: .8; }

.hero-note {
  font-size: 13px;
  opacity: .8;
  margin: 8px 0 0;
}

.hero-actions { margin-top: 18px; display: flex; gap: 10px; }
.hero .btn { background: #fff; color: var(--navy); }
.hero .btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 12px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat b { display: block; font-size: 22px; letter-spacing: -.01em; }
.stat span { font-size: 12px; color: var(--ink-soft); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.chip b { color: var(--ink); font-weight: 600; }
.chip.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.chip.is-active b { color: #fff; }

/* ---------- 分类词汇表 ---------- */

.word-list {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: none;
  background: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}
.word-row:last-child { border-bottom: none; }
.word-row:active { background: #f3f1ec; }

.word-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.word-row-main b { font-size: 17px; font-weight: 600; }
.word-row-main i {
  font-size: 13px;
  font-style: normal;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  border: 1.5px solid var(--line);
  background: transparent;
}
.dot.amber { background: var(--amber); border-color: var(--amber); }
.dot.green { background: var(--green); border-color: var(--green); }

/* ---------- 学习卡片 ---------- */

.study-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.progress-track {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex: 1;
  margin: 0 14px;
}
.progress-fill {
  height: 100%;
  background: var(--navy);
  border-radius: 999px;
  transition: width .3s ease;
}

.card-stage { perspective: 1200px; }

.flashcard {
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  min-height: 320px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  cursor: pointer;
  position: relative;
}

.flashcard .prompt-hint {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.flashcard .term {
  font-size: 42px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -.01em;
  word-break: break-word;
}
.flashcard .term.zh-term { font-size: 34px; }

.flashcard .answer {
  font-size: 26px;
  font-weight: 600;
  color: var(--navy);
}

.flashcard .meta {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.tap-hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 6px;
}

.speak-btn {
  border: none;
  background: #eef1f7;
  color: var(--navy);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.speak-btn svg { width: 22px; height: 22px; fill: currentColor; }
.speak-btn:active { transform: scale(.94); }

/* 朗读按钮钉在卡片右下角：放在正中间会挡住"点一下看答案"的点击区，
   用户点卡片只想翻面，结果点到按钮上，看起来像没反应 */
.flashcard .speak-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
}

.grade-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.action-label {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  margin: 18px 0 0;
}

.next-row { margin-top: 16px; }

.grade {
  border: none;
  border-radius: 14px;
  padding: 16px 8px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  line-height: 1.3;
}
.grade small { display: block; font-size: 11px; font-weight: 500; opacity: .8; margin-top: 3px; }
.grade-again { background: var(--red); }
.grade-hard { background: var(--amber); }
.grade-good { background: var(--green); }
.grade:active { transform: scale(.97); }

.study-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}

.link-btn {
  background: none;
  border: none;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 会话结束 ---------- */

.done-card { text-align: center; padding: 34px 22px; }
.done-card .big { font-size: 46px; margin-bottom: 8px; }
.done-card h2 { margin: 0 0 6px; font-size: 22px; }
.done-card p { color: var(--ink-soft); font-size: 14px; margin: 0 0 22px; line-height: 1.6; }

.done-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 24px;
}
.done-stats div b { display: block; font-size: 24px; }
.done-stats div span { font-size: 12px; color: var(--ink-soft); }

/* ---------- 统计 ---------- */

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-item .bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.bar-head span:last-child { color: var(--ink-soft); }
.bar-track { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 999px; }
.bar-fill.green { background: var(--green); }
.bar-fill.amber { background: var(--amber); }

.empty-note {
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
  padding: 28px 10px;
  line-height: 1.6;
}

/* ---------- 底部导航 ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}

.tab {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-soft);
  font-size: 11px;
  cursor: pointer;
}
.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab.is-active { color: var(--navy); }

/* ---------- 详情抽屉 ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 40, .4);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(28px + var(--safe-bottom));
  z-index: 31;
  animation: sheet-up .22s ease;
}

@keyframes sheet-up {
  from { transform: translateY(14px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin: 8px auto 16px;
}

.sheet h3 { margin: 0; font-size: 14px; color: var(--ink-soft); font-weight: 600; }

.detail-word {
  font-size: 34px;
  font-weight: 600;
  margin: 6px 0 2px;
}

.detail-zh { font-size: 19px; font-weight: 600; color: var(--navy); margin: 0 0 14px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.pill {
  font-size: 12px;
  background: #eceff5;
  color: var(--navy);
  border-radius: 999px;
  padding: 4px 10px;
}

.paradigm { margin-bottom: 18px; }
.paradigm h4 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}
.form-grid div {
  padding: 9px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.form-grid div:nth-child(odd) { color: var(--ink-soft); font-size: 13px; }
.form-grid div:nth-last-child(-n+2) { border-bottom: none; }
.form-grid .ru { font-weight: 600; font-size: 16px; }

.note-box {
  background: #fdf6e8;
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: #7a5a1c;
  line-height: 1.6;
  margin-bottom: 18px;
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(27, 42, 74, .95);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 40;
  animation: toast-in .2s ease;
  max-width: 84vw;
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.hidden { display: none !important; }
