/* ═══════════════════════════════════════════
   詞流 WordFlow — styles
   概念：溫潤紙張 × 硯墨 × 朱紅，像一本會說話的辭典
   ═══════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-word: clamp(2.75rem, 1.6rem + 4.6vw, 4.75rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;

  --shadow-sm: 0 1px 2px rgba(30, 28, 20, 0.05), 0 4px 12px -6px rgba(30, 28, 20, 0.12);
  --shadow-md: 0 2px 4px rgba(30, 28, 20, 0.04), 0 14px 34px -14px rgba(30, 28, 20, 0.22);
  --shadow-lg: 0 30px 60px -24px rgba(30, 28, 20, 0.3);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

:root,
[data-theme="light"] {
  --bg: #f4efe4;
  --bg-grain: #efe7d8;
  --surface: #fffdf7;
  --surface-2: #f0e9da;
  --surface-3: #e6ddca;
  --ink: #1d2420;
  --ink-2: #46504a;
  --muted: #7a8277;
  --faint: #a8ae9f;
  --line: #e2d9c7;
  --line-strong: #cec3ac;
  --accent: #c0472a;
  --accent-hover: #a63a20;
  --accent-soft: #f8e4d9;
  --accent-ink: #fff9f4;
  --teal: #1b6157;
  --teal-soft: #dcebe4;
  --gold: #9c741f;
  --gold-soft: #f3e9cf;
  --ok: #3f7a3a;
  --console-bg: #1e2522;
  --console-ink: #f3eee2;
  --console-muted: #a9b1a6;
  --console-line: #37413c;
  --console-btn: #2a332e;
  --ring: rgba(192, 71, 42, 0.35);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121615;
  --bg-grain: #161b19;
  --surface: #1a1f1d;
  --surface-2: #232927;
  --surface-3: #2b3230;
  --ink: #f0ebdf;
  --ink-2: #ccc6b8;
  --muted: #8f978e;
  --faint: #6a7369;
  --line: #2c3431;
  --line-strong: #3d4642;
  --accent: #e06f4b;
  --accent-hover: #ef825e;
  --accent-soft: #3a241c;
  --accent-ink: #1a110d;
  --teal: #82c8b7;
  --teal-soft: #1d302b;
  --gold: #d6a949;
  --gold-soft: #2f2a1a;
  --ok: #86bd7c;
  --console-bg: #0d100f;
  --console-ink: #f2ecdf;
  --console-muted: #98a196;
  --console-line: #2a322e;
  --console-btn: #1b201e;
  --ring: rgba(224, 111, 75, 0.4);
  color-scheme: dark;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, dl, dd, dt, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { display: block; width: 1.25em; height: 1.25em; }
::selection { background: var(--accent-soft); color: var(--ink); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Shell ── */
.app {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-4);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-grain), var(--bg) 60%);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--bg);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text {
  display: flex;
  flex-direction: column;
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
}
.brand-text em {
  font-style: normal;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav-item svg { width: 20px; height: 20px; color: var(--muted); transition: color 0.18s; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--ink); color: var(--bg); }
.nav-item.is-active svg { color: var(--bg); }

.side-foot { margin-top: auto; }
.streak-card {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.streak-top { display: flex; align-items: baseline; gap: var(--space-2); }
.streak-flame { display: inline-flex; color: var(--accent); align-self: center; }
.streak-flame svg { width: 15px; height: 15px; }
.streak-num { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; line-height: 1; }
.streak-unit { font-size: var(--text-xs); color: var(--muted); }
.today-bar {
  margin: var(--space-3) 0 var(--space-2);
  height: 5px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.today-bar span {
  display: block; height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.5s var(--ease);
}
.side-note { font-size: var(--text-xs); color: var(--muted); }

/* ── Stage ── */
.stage { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-8) var(--space-5);
  max-width: 1340px;
  width: 100%;
  margin: 0 auto;
}
.tb-left h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.tb-left p { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--muted); }
.tb-right { display: flex; gap: var(--space-2); }
.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.96); }
#themeBtn .i-moon { display: none; }
[data-theme="dark"] #themeBtn .i-sun { display: none; }
[data-theme="dark"] #themeBtn .i-moon { display: block; }

main {
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 var(--space-8) var(--space-16);
  flex: 1;
}
.view { display: none; animation: viewIn 0.35s var(--ease); }
.view.is-active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── Study layout ── */
.study-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.8fr);
  gap: var(--space-6);
  align-items: start;
}
.study-col { min-width: 0; }

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: nowrap;
}
.chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 1 1 auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.filter-right { flex: none; }
.chip {
  flex: none;
  white-space: nowrap;
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.18s var(--ease);
}
.chip:hover { border-color: var(--line-strong); background: var(--surface); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .n { opacity: 0.55; margin-left: 4px; font-variant-numeric: tabular-nums; }

.mini-select {
  appearance: none;
  padding: 7px 30px 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8277' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: var(--text-xs);
  color: var(--ink-2);
  cursor: pointer;
}
.mini-select:hover { border-color: var(--line-strong); }

/* ── Word card ── */
.word-card {
  position: relative;
  padding: var(--space-6) var(--space-8) var(--space-5);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 100% 0%, var(--accent-soft) 0%, transparent 52%),
    var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.word-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
[data-theme="dark"] .word-card::after { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); }
.wc-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pos-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--teal-soft);
  color: var(--teal);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
}
.wc-tools { display: flex; gap: var(--space-2); }
.chip-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: all 0.18s var(--ease);
}
.chip-btn svg { width: 18px; height: 18px; }
.chip-btn:hover { border-color: var(--line-strong); color: var(--ink); transform: translateY(-1px); }
.chip-btn[aria-pressed="true"] { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.chip-btn[aria-pressed="true"] svg path { fill: currentColor; }

.headword {
  margin-top: var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-word);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.025em;
  word-break: break-word;
}
.ipa-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-2); }
.ipa { font-family: var(--font-display); font-size: var(--text-base); color: var(--muted); letter-spacing: 0.02em; }
.level-dot { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--muted); }
.level-dot i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.level-dot[data-level="new"] i { background: var(--faint); }
.level-dot[data-level="learning"] i { background: var(--gold); }
.level-dot[data-level="mastered"] i { background: var(--teal); }

.meaning { margin-top: var(--space-5); min-height: 2.2em; }
.zh {
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: filter 0.25s var(--ease), opacity 0.25s;
}
.meaning.is-blurred .zh { filter: blur(9px); opacity: 0.6; user-select: none; cursor: pointer; }
.reveal-hint { margin-top: var(--space-2); }
.ghost-btn {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: all 0.18s var(--ease);
}
.ghost-btn:hover { background: var(--surface-2); color: var(--ink); }
.ghost-btn.danger { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 35%, transparent); }
.ghost-btn.danger:hover { background: var(--accent-soft); }

.example {
  margin-top: var(--space-5);
  padding: var(--space-4) 0 0;
  border-top: 1px dashed var(--line-strong);
}
.ex-en { font-family: var(--font-display); font-size: var(--text-base); line-height: 1.5; color: var(--ink); }
.ex-zh { margin-top: 4px; font-size: var(--text-sm); color: var(--muted); }
.wc-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}
.meta { font-size: var(--text-xs); color: var(--faint); font-variant-numeric: tabular-nums; }

/* ── Playback console ── */
.console {
  margin-top: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-radius: var(--radius-xl);
  background: var(--console-bg);
  color: var(--console-ink);
  box-shadow: var(--shadow-md);
}
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.console-live { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); letter-spacing: 0.08em; color: var(--console-muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--console-line); transition: background 0.2s; }
.console.is-playing .live-dot { background: #7bd88f; box-shadow: 0 0 0 0 rgba(123, 216, 143, 0.6); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(123, 216, 143, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(123, 216, 143, 0); }
  100% { box-shadow: 0 0 0 0 rgba(123, 216, 143, 0); }
}
.console-progress { font-size: var(--text-xs); color: var(--console-muted); font-variant-numeric: tabular-nums; }

.console-controls {
  display: grid;
  grid-template-columns: 1.25fr 1.15fr 1.05fr auto;
  gap: var(--space-2);
}
.pbtn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: var(--space-3);
  border-radius: 14px;
  background: var(--console-btn);
  color: var(--console-ink);
  border: 1px solid transparent;
  text-align: left;
  transition: background 0.18s var(--ease), border-color 0.18s, transform 0.12s;
  min-height: 76px;
}
.pbtn:hover { background: color-mix(in oklab, var(--console-btn) 78%, #fff 8%); border-color: rgba(255, 255, 255, 0.08); }
.pbtn:active { transform: scale(0.985); }
.pbtn svg { width: 22px; height: 22px; margin-bottom: 6px; color: var(--console-muted); }
.pbtn-label { font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.02em; line-height: 1.3; }
.pbtn-sub { font-size: 11px; color: var(--console-muted); letter-spacing: 0.02em; line-height: 1.35; }
.pbtn .ico-stop { display: none; }
.pbtn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.pbtn[aria-pressed="true"] svg { color: var(--accent-ink); }
.pbtn[aria-pressed="true"] .pbtn-sub { color: color-mix(in oklab, var(--accent-ink) 72%, transparent); }
.pbtn[aria-pressed="true"] .ico-play { display: none; }
.pbtn[aria-pressed="true"] .ico-stop { display: block; }
.pbtn-main { position: relative; }
.pbtn-main::before {
  content: "";
  position: absolute; left: 0; top: 14px; bottom: 14px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.pbtn-main[aria-pressed="true"]::before { opacity: 0; }
.pbtn-stepper { justify-content: space-between; cursor: default; }
.pbtn-stepper:hover { background: var(--console-btn); border-color: transparent; }
.stepper-head { display: flex; flex-direction: column; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); width: 100%; margin-top: auto; padding-top: 4px; }
.stepper button {
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid var(--console-line);
  background: transparent;
  color: var(--console-ink);
  font-size: 16px;
  line-height: 1;
  display: grid; place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.stepper button:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--console-muted); }
.repeat-val { display: flex; align-items: baseline; gap: 3px; font-variant-numeric: tabular-nums; }
.repeat-val b { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; line-height: 1; }
.repeat-val small { font-size: 11px; color: var(--console-muted); }
.pbtn-quiet { min-width: 68px; align-items: center; justify-content: center; text-align: center; color: var(--console-muted); }
.pbtn-quiet svg { margin-bottom: 4px; }
.pbtn-quiet .pbtn-label { font-weight: 500; font-size: var(--text-xs); }
.pbtn-quiet:hover { color: var(--console-ink); }

.console-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--console-line);
  flex-wrap: wrap;
}
.seg-mini {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
}
.seg-mini button {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 11px;
  color: var(--console-muted);
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.seg-mini button:hover { color: var(--console-ink); }
.seg-mini button.is-on { background: rgba(255, 255, 255, 0.12); color: var(--console-ink); }
.voice-mini { font-size: 11px; color: var(--console-muted); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Rating ── */
.rate-block { margin-top: var(--space-5); }
.rate-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.rate-head p { font-size: var(--text-sm); font-weight: 700; }
.rate-head span { font-size: var(--text-xs); color: var(--muted); }
.rate-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.rate {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all 0.16s var(--ease);
}
.rate b { font-size: var(--text-sm); font-weight: 700; }
.rate small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rate:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.rate.r-again:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rate.r-hard:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.rate.r-good:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.rate.r-easy:hover { border-color: var(--ink); background: var(--surface-2); }

.card-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-4); }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-sm);
  transition: all 0.16s var(--ease);
}
.nav-btn svg { width: 16px; height: 16px; }
.nav-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.nav-btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.nav-btn-ghost:hover { background: var(--surface-2); }

/* ── Playlist ── */
.playlist-panel {
  position: sticky;
  top: var(--space-6);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 11rem);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}
.pl-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.pl-head h3 { font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.04em; }
.pl-head span { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.pl-hint { margin-top: 2px; font-size: 11px; color: var(--faint); }
.playlist { margin-top: var(--space-3); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.pl-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 7px 8px;
  border-radius: 9px;
  text-align: left;
  transition: background 0.15s;
}
.pl-item:hover { background: var(--surface-2); }
.pl-item.is-current { background: var(--accent-soft); }
.pl-item.is-current .pl-w { color: var(--accent); }
.pl-idx { font-family: var(--font-display); font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pl-main { min-width: 0; }
.pl-w { display: block; font-family: var(--font-display); font-size: var(--text-sm); font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-zh { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-mark { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.pl-item[data-level="learning"] .pl-mark { background: var(--gold); }
.pl-item[data-level="mastered"] .pl-mark { background: var(--teal); }
.pl-item.is-current .pl-mark { background: var(--accent); }
.pl-item.is-speaking .pl-w { color: var(--accent); }

/* ── Library ── */
.lib-toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.search-wrap input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--text-sm);
}
.search-wrap input::placeholder { color: var(--faint); }
.search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.lib-count { font-size: var(--text-xs); color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.lib-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-2);
}
.lib-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
  text-align: left;
  width: 100%;
}
.lib-row:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.lib-w { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.lib-w b { font-family: var(--font-display); font-size: var(--text-base); font-weight: 500; letter-spacing: -0.01em; }
.lib-w i { font-style: normal; font-size: 11px; color: var(--faint); }
.lib-open { all: unset; display: block; min-width: 0; text-align: left; cursor: pointer; border-radius: 8px; }
.lib-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.lib-sub { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; display: flex; gap: var(--space-2); align-items: center; }
.lib-tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.lib-actions { display: flex; align-items: center; gap: 4px; }
.lib-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--faint); }
.lib-btn:hover { background: var(--surface-2); color: var(--ink); }
.lib-btn svg { width: 16px; height: 16px; }
.lib-btn.is-star { color: var(--gold); }
.lib-btn.is-star svg path { fill: currentColor; }
.empty { padding: var(--space-10); text-align: center; color: var(--muted); font-size: var(--text-sm); }

/* ── Quiz ── */
.quiz-shell { max-width: 760px; margin: 0 auto; }
.quiz-setup, .quiz-play, .quiz-result {
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.section-title { font-size: var(--text-lg); font-weight: 700; }
.section-sub { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--muted); }
.setup-group { margin-top: var(--space-6); }
.setup-label { display: block; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; color: var(--muted); margin-bottom: var(--space-2); }
.seg-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-2); }
.seg-cards-sm { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.seg-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  transition: all 0.16s var(--ease);
}
.seg-card b { font-size: var(--text-sm); font-weight: 700; }
.seg-card small { font-size: 11px; color: var(--muted); }
.seg-card:hover { border-color: var(--line-strong); }
.seg-card.is-on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.seg-card.is-on small { color: color-mix(in oklab, var(--bg) 70%, transparent); }
.seg-pills { display: flex; gap: var(--space-2); }
.pill {
  padding: 7px 16px;
  border-radius: 99px;
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--ink-2);
  transition: all 0.16s;
}
.pill:hover { border-color: var(--line-strong); }
.pill.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: background 0.18s, transform 0.12s;
  margin-top: var(--space-8);
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: scale(0.985); }

.quiz-top { display: flex; align-items: center; gap: var(--space-4); }
.text-btn { font-size: var(--text-sm); color: var(--muted); }
.text-btn:hover { color: var(--ink); }
.quiz-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.quiz-bar span { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: inherit; transition: width 0.35s var(--ease); }
.quiz-score { font-family: var(--font-display); font-size: var(--text-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.quiz-kicker { margin-top: var(--space-6); font-size: var(--text-xs); letter-spacing: 0.06em; color: var(--muted); }
.quiz-question {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  min-height: 1.2em;
}
.listen-ico { display: inline-flex; color: var(--accent); }
.listen-ico svg { width: 0.85em; height: 0.85em; }
.listen-btn {
  margin-top: var(--space-3);
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--ink-2);
}
.listen-btn:hover { background: var(--surface-2); }
.quiz-options { display: grid; gap: var(--space-2); margin-top: var(--space-6); }
.opt {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  font-size: var(--text-sm);
  transition: all 0.16s var(--ease);
}
.opt:hover:not(:disabled) { border-color: var(--ink); background: var(--surface-2); }
.opt .k { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); font-size: 11px; color: var(--muted); flex: none; }
.opt.is-correct { border-color: var(--ok); background: var(--teal-soft); color: var(--teal); }
.opt.is-wrong { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.is-correct .k { background: var(--ok); color: #fff; }
.opt.is-wrong .k { background: var(--accent); color: #fff; }
.quiz-spell { display: flex; gap: var(--space-2); margin-top: var(--space-6); }
.quiz-spell input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: 0.04em;
}
.quiz-spell input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.quiz-spell .primary-btn { margin-top: 0; padding: 12px 20px; }
.quiz-feedback { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); }
.quiz-feedback.is-correct { background: var(--teal-soft); color: var(--teal); }
.quiz-feedback.is-wrong { background: var(--accent-soft); color: var(--accent); }
.quiz-feedback b { font-family: var(--font-display); }
#nextQuestion { margin-top: var(--space-4); }
.quiz-result { text-align: center; padding: var(--space-12) var(--space-8); }
.result-kicker { font-size: var(--text-xs); letter-spacing: 0.1em; color: var(--muted); }
.result-score { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 500; margin-top: var(--space-2); }
.result-msg { margin-top: var(--space-2); color: var(--muted); font-size: var(--text-sm); }
.result-actions { display: flex; gap: var(--space-3); justify-content: center; margin-top: var(--space-6); flex-wrap: wrap; }
.result-actions .primary-btn { margin-top: 0; }

/* ── Stats ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); margin-bottom: var(--space-4); }
.kpi {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column;
}
.kpi-label { font-size: var(--text-xs); color: var(--muted); letter-spacing: 0.04em; }
.kpi b { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 500; line-height: 1.2; margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.kpi small { font-size: 11px; color: var(--faint); }
.stats-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.panel {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.panel-head h3 { font-size: var(--text-sm); font-weight: 700; letter-spacing: 0.03em; }
.panel-head span { font-size: var(--text-xs); color: var(--muted); }

.chart { display: flex; align-items: flex-end; gap: var(--space-2); height: 190px; padding-top: var(--space-4); }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-val { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-bar {
  width: 100%;
  max-width: 42px;
  border-radius: 6px 6px 2px 2px;
  background: var(--surface-3);
  min-height: 3px;
  transition: height 0.6s var(--ease), background 0.2s;
  position: relative;
}
.chart-bar.is-today { background: var(--accent); }
.chart-col:hover .chart-bar { background: var(--ink-2); }
.chart-col:hover .chart-bar.is-today { background: var(--accent-hover); }
.chart-day { font-size: 11px; color: var(--faint); }

.mastery-wrap { display: flex; align-items: center; gap: var(--space-5); }
.donut {
  position: relative;
  width: 120px; height: 120px;
  border-radius: 50%;
  flex: none;
  display: grid; place-items: center;
  background: conic-gradient(var(--teal) 0deg, var(--surface-3) 0deg);
  transition: background 0.4s;
}
.donut::before { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--surface); }
.donut span { position: relative; font-family: var(--font-display); font-size: var(--text-lg); font-weight: 500; }
.legend { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-xs); color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: var(--space-2); }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.legend .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.cat-progress { display: flex; flex-direction: column; gap: var(--space-3); }
.cat-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 58px; align-items: center; gap: var(--space-3); }
.cat-name { font-size: var(--text-xs); color: var(--ink-2); }
.cat-track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.cat-fill { height: 100%; border-radius: inherit; background: var(--teal); transition: width 0.6s var(--ease); }
.cat-num { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Settings ── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--space-4); align-items: start; }
.field { margin-bottom: var(--space-5); }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; color: var(--ink-2); margin-bottom: var(--space-2); }
.field label b { color: var(--accent); margin-left: 6px; font-variant-numeric: tabular-nums; }
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--text-sm);
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 24px;
}
.field-hint { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.field-row label { margin-bottom: 0; }
.field-row .field-hint { margin-top: 2px; }
.switch {
  flex: none;
  width: 44px; height: 25px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  padding: 2px;
  transition: background 0.2s;
}
.switch span { display: block; width: 19px; height: 19px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.15); transition: transform 0.22s var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(19px); }
.data-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.about { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line); font-size: 11px; color: var(--faint); line-height: 1.7; }
.about p + p { margin-top: 4px; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--space-4); background: rgba(20, 22, 18, 0.5); backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-card {
  width: min(440px, 100%);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: viewIn 0.25s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.modal-head h3 { font-size: var(--text-base); font-weight: 700; }
.modal-head .icon-btn { width: 32px; height: 32px; border: 0; background: var(--surface-2); font-size: 13px; }
.keys { display: flex; flex-direction: column; gap: var(--space-2); }
.keys div { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 6px 0; border-bottom: 1px solid var(--line); }
.keys div:last-child { border-bottom: 0; }
.keys dt { display: flex; gap: 4px; }
.keys dd { font-size: var(--text-xs); color: var(--ink-2); }
kbd {
  font-family: var(--font-body);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  box-shadow: 0 1px 0 var(--line);
}
.modal-note { margin-top: var(--space-4); font-size: 11px; color: var(--muted); }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-8);
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 80;
  max-width: calc(100vw - 32px);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Responsive ── */
@media (max-width: 1180px) {
  .study-grid { grid-template-columns: minmax(0, 1fr); }
  .playlist-panel { position: static; max-height: 340px; order: 2; }
  .console-controls { grid-template-columns: 1fr 1fr; }
  .pbtn-quiet { grid-column: 1 / -1; flex-direction: row; min-height: 0; gap: 8px; }
  .pbtn-quiet svg { margin-bottom: 0; }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    height: auto;
    z-index: 50;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: color-mix(in oklab, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 3px; padding: 6px 10px; font-size: 11px; flex: 1; align-items: center; }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.is-active { background: transparent; color: var(--accent); }
  .nav-item.is-active svg { color: var(--accent); }
  .stage { padding-bottom: 74px; }
  .topbar { padding: var(--space-5) var(--space-4) var(--space-4); align-items: center; }
  .tb-left p { display: none; }
  main { padding: 0 var(--space-4) var(--space-10); }
  .study-grid { gap: var(--space-4); }
  .word-card { padding: var(--space-5); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .headword { margin-top: var(--space-4); }
  .console { padding: var(--space-4); }
  .console-controls { grid-template-columns: 1fr 1fr; gap: 6px; }
  .pbtn { min-height: 70px; padding: var(--space-3); }
  .pbtn-quiet { grid-column: auto; }
  .console-foot { gap: var(--space-2); }
  .voice-mini { display: none; }
  .seg-mini { width: 100%; }
  .seg-mini button { flex: 1; }
  .rate-row { grid-template-columns: repeat(2, 1fr); }
  .rate-head { flex-direction: column; gap: 0; }
  .card-nav { gap: 4px; }
  .nav-btn { padding: 9px 10px; font-size: var(--text-xs); }
  .lib-list { grid-template-columns: 1fr; }
  .quiz-setup, .quiz-play, .quiz-result { padding: var(--space-5); }
  .seg-cards { grid-template-columns: 1fr; }
  .seg-cards-sm { grid-template-columns: 1fr 1fr; }
  .mastery-wrap { flex-direction: column; align-items: flex-start; gap: var(--space-4); }
  .legend { width: 100%; }
  .cat-row { grid-template-columns: 80px minmax(0, 1fr) 52px; }
  .lib-count { margin-left: 0; }
  .chart { height: 150px; gap: 4px; }
  .chart-val { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ═══ 學測專區 ═══ */
.gsat-top {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.gsat-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: linear-gradient(160deg, var(--accent-soft), transparent 62%), var(--surface);
}
.gsat-kicker {
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 600;
}
.gsat-count {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-family: var(--font-display);
  line-height: 1;
}
.gsat-count b {
  font-size: clamp(3rem, 2rem + 4vw, 4.4rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.gsat-count span {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.gsat-date {
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.gsat-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: var(--space-2);
}
.gsat-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #d98b55);
  transition: width 0.5s var(--ease);
}
.mission-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.mission {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.mission:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}
.mission-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mission-body b {
  font-size: var(--text-sm);
  font-weight: 600;
}
.mission-body em {
  font-style: normal;
  font-family: var(--font-display);
  font-size: 1.3em;
  color: var(--accent);
  margin: 0 2px;
}
.mission-body small {
  font-size: var(--text-xs);
  color: var(--muted);
}
.mission-go {
  font-size: var(--text-xs);
  color: var(--accent);
  white-space: nowrap;
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
  padding-bottom: 1px;
}
.gsat-bottom {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.mistake-list { display: flex; flex-direction: column; }
.mistake-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px dashed var(--line);
}
.mistake-row:last-child { border-bottom: none; }
.mistake-row b {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 500;
  margin-right: var(--space-2);
}
.mistake-row .mz {
  font-size: var(--text-xs);
  color: var(--muted);
}
.mistake-n {
  font-size: var(--text-xs);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ghost-btn.sm {
  padding: 4px 10px;
  font-size: var(--text-xs);
}
.quiz-question.is-sentence {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: 1.75;
  max-width: 34em;
  letter-spacing: 0;
}
.quiz-blank {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}
@media (max-width: 960px) {
  .gsat-top, .gsat-bottom { grid-template-columns: 1fr; }
}
.fb-zh {
  display: inline-block;
  margin-top: 4px;
  font-size: var(--text-sm);
  opacity: 0.8;
}
.gsat-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line);
}
.gsat-mini div { display: flex; flex-direction: column; gap: 2px; }
.gsat-mini b {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1;
}
.gsat-mini span { font-size: var(--text-xs); color: var(--muted); letter-spacing: 0.04em; }
.mistake-row b { margin-right: var(--space-3); }

/* ── 歷屆試題 ── */
.exam-strip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.exam-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.exam-open {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong, var(--line));
}
.lib-tag-exam {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
body.is-locked { overflow: hidden; }

.exam-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  backdrop-filter: blur(6px);
}
.exam-modal[hidden] { display: none; }
.exam-sheet {
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface, var(--bg));
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -30px color-mix(in srgb, var(--ink) 60%, transparent);
  overflow: hidden;
}
.exam-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--line);
}
.exam-kicker {
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.exam-head h3 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.15;
}
.exam-sub {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.6;
}
.exam-filters {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
}
.exam-body {
  overflow-y: auto;
  padding: var(--space-4) var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.exam-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface-2, transparent);
}
.exam-item-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.exam-year { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.exam-type {
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.exam-type.is-gsat { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.exam-rate { margin-left: auto; font-variant-numeric: tabular-nums; }
.exam-sentence {
  font-size: var(--text-base);
  line-height: 1.8;
  margin-bottom: var(--space-3);
}
.exam-opts {
  list-style: none;
  display: grid;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.exam-opts li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid transparent;
  font-size: var(--text-sm);
}
.exam-opts li b {
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.exam-opts li.is-right {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.exam-opts li.is-right b { color: var(--accent); }
.exam-opt-w { font-weight: 500; }
.exam-opt-zh { color: var(--muted); font-size: var(--text-xs); }
.exam-opts li.is-target .exam-opt-w {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.exam-tr {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.8;
  padding-top: var(--space-2);
  border-top: 1px dashed var(--line);
}
.exam-verdict { margin-top: 6px; font-size: var(--text-xs); color: var(--muted); }
.exam-verdict b { color: var(--ink); }

@media (max-width: 620px) {
  .exam-modal { padding: 0; align-items: flex-end; }
  .exam-sheet {
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .exam-head { padding: var(--space-4); }
  .exam-filters { padding: var(--space-3) var(--space-4); }
  .exam-body { padding: var(--space-3) var(--space-4) var(--space-6); }
  .exam-opts li { flex-wrap: wrap; }
}

/* ── 離線狀態 ── */
.offline-box {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}
.offline-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  margin-bottom: 6px;
}
.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.offline-dot[data-state="ok"] { background: #3f8f5f; box-shadow: 0 0 0 4px color-mix(in srgb, #3f8f5f 18%, transparent); }
.offline-dot[data-state="off"] { background: var(--accent); }
.offline-dot[data-state="idle"] { background: #c9a227; }
.offline-box .field-hint { margin: 0 0 var(--space-3); }
.offline-box .ghost-btn { width: 100%; }
.offline-box .ghost-btn[hidden] { display: none; }

/* ── 級別色彩語言 ── */
:root {
  --lv1: #4b7c6a;
  --lv2: #3d6d90;
  --lv3: #5a6394;
  --lv4: #b07c2b;
  --lv5: #c0472a;
  --lv6: #7d4a66;
}
[data-theme="dark"] {
  --lv1: #7fb6a2;
  --lv2: #7ba8c9;
  --lv3: #949acd;
  --lv4: #d3a75c;
  --lv5: #e07a5f;
  --lv6: #c08aa3;
}
[data-cat="1"], [data-lv="1"] { --lvc: var(--lv1); }
[data-cat="2"], [data-lv="2"] { --lvc: var(--lv2); }
[data-cat="3"], [data-lv="3"] { --lvc: var(--lv3); }
[data-cat="4"], [data-lv="4"] { --lvc: var(--lv4); }
[data-cat="5"], [data-lv="5"] { --lvc: var(--lv5); }
[data-cat="6"], [data-lv="6"] { --lvc: var(--lv6); }

/* 分類 chip：色點 ＋ 選取時以級別色描邊 */
.chip[data-cat]:not([data-cat="all"]) { display: inline-flex; align-items: center; gap: 6px; }
.chip[data-cat]:not([data-cat="all"])::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lvc);
  flex: none;
}
.chip[data-cat].is-on:not([data-cat="all"]) {
  background: color-mix(in srgb, var(--lvc) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--lvc) 55%, transparent);
  color: var(--ink);
}

/* 單字卡：級別色頂線與詞性標籤 */
.word-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--lvc, var(--accent));
  opacity: 0.9;
}
.word-card .pos-badge {
  background: color-mix(in srgb, var(--lvc, var(--teal)) 14%, transparent);
  color: var(--lvc, var(--teal));
}

/* 播放清單：序號以級別色標示 */
.pl-item .pl-idx { color: color-mix(in srgb, var(--lvc, var(--faint)) 75%, var(--muted)); }
.pl-item.is-current .pl-idx { color: var(--lvc, var(--accent)); font-weight: 600; }

/* 單字庫：級別標籤上色 */
.lib-row .lib-tag:first-of-type {
  color: var(--lvc, var(--muted));
  background: color-mix(in srgb, var(--lvc, var(--muted)) 10%, transparent);
}

/* 進度條：依級別上色 */
.cat-row .cat-fill { background: var(--lvc, var(--teal)); }
.cat-row .cat-num { color: color-mix(in srgb, var(--lvc, var(--muted)) 70%, var(--muted)); }

/* 單字庫：標籤不擠壓、中文過長省略 */
.lib-sub { flex-wrap: wrap; row-gap: 4px; }
.lib-sub > span:first-child {
  flex: 1 1 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-sub .lib-tag { flex: none; white-space: nowrap; }

/* ═══════════════════════════════════════════
   查字：單字辨識器
   ═══════════════════════════════════════════ */
.rate.r-stuck:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.rate-legend {
  margin-top: var(--space-2);
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

.lookup {
  position: fixed;
  inset: 0;
  z-index: 78;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}
.lookup[hidden] { display: none; }
.lookup-sheet {
  width: min(620px, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -30px color-mix(in srgb, var(--ink) 60%, transparent);
}
.lookup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.lookup-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}
.lookup-head h2 { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.2; }

.lookup-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.lookup-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.lookup-ico { width: 18px; height: 18px; flex: none; color: var(--muted); }
.lookup-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: var(--text-sm);
  font-family: inherit;
  outline: none;
}
.lookup-field input::placeholder { color: var(--faint); }
.lookup-clear {
  flex: none;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.lookup-hint { font-size: var(--text-xs); color: var(--muted); line-height: 1.6; }

.lookup-results { display: flex; flex-direction: column; gap: 6px; }
.lk-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: all 0.16s var(--ease);
}
.lk-item:hover { border-color: var(--lvc, var(--accent)); background: color-mix(in srgb, var(--lvc, var(--accent)) 8%, var(--surface)); }
.lk-item b { font-family: var(--font-display); font-size: var(--text-base); }
.lk-item .lk-ipa { font-size: 11px; color: var(--faint); }
.lk-item .lk-zh { flex: 1; min-width: 0; font-size: var(--text-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-item .lk-lv { flex: none; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; color: var(--lvc, var(--muted)); background: color-mix(in srgb, var(--lvc, var(--muted)) 14%, transparent); }

/* ── 單字頁 ── */
.word-detail[hidden] { display: none; }
.wd { display: flex; flex-direction: column; gap: var(--space-4); }
.wd-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); border-top: 3px solid var(--lvc, var(--accent)); padding-top: var(--space-4); }
.wd-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-2); }
.wd-line h3 { font-family: var(--font-display); font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem); line-height: 1.1; }
.wd-ipa { font-size: var(--text-sm); color: var(--muted); }
.wd-zh { margin-top: 6px; font-size: var(--text-base); color: var(--ink-2); }
.wd-speak {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--accent);
}
.wd-speak svg { width: 19px; height: 19px; }
.wd-speak:hover { background: var(--accent-soft); border-color: var(--accent); }

.wd-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.wd-tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--bg); }
.wd-tag.is-lv { color: var(--lvc, var(--accent)); border-color: color-mix(in srgb, var(--lvc, var(--accent)) 45%, transparent); background: color-mix(in srgb, var(--lvc, var(--accent)) 10%, transparent); font-weight: 700; }
.wd-tag.is-stuck { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); font-weight: 700; }

.wd-ex { padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.wd-ex-en { font-family: var(--font-display); font-size: var(--text-sm); }
.wd-ex-zh { font-size: var(--text-xs); color: var(--muted); }

.wd-section-head { font-size: 11px; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.wd-state-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.wd-st {
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  transition: all 0.16s var(--ease);
}
.wd-st:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--accent); color: var(--accent); }
.wd-st[data-state="easy"]:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.wd-st[data-state="stuck"]:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.wd-st[data-state="again"]:hover { background: var(--accent-soft); }

.wd-links { border-top: 1px dashed var(--line-strong); padding-top: var(--space-4); }
.wd-link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.wd-link {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  transition: all 0.16s var(--ease);
}
.wd-link b { font-size: 13px; font-weight: 700; color: var(--ink); }
.wd-link span { font-size: 11px; color: var(--muted); }
.wd-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.wd-link:hover b { color: var(--accent); }
.wd-link.is-primary { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); }
.wd-link.is-primary b { color: var(--accent); }
.wd-note { margin-top: var(--space-2); font-size: 11px; color: var(--faint); }

@media (max-width: 620px) {
  .lookup { padding: 0; }
  .lookup-sheet {
    margin: 0;
    min-height: 100%;
    border-radius: 0;
    border: 0;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4) var(--space-8);
  }
  .wd-link-grid { grid-template-columns: 1fr; }
  .wd-state-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── 學習集 ── */
.set-bar {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.set-bar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.set-bar-title { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; color: var(--ink-2); }
.set-bar-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.set-bar-actions .text-btn { font-size: 12px; }
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
.set-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink-2);
  font-size: 12px;
  transition: all 0.16s var(--ease);
}
.set-chip:hover { border-color: var(--accent); color: var(--accent); }
.set-chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.set-chip small { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.set-chip.is-on small { color: color-mix(in srgb, var(--accent) 70%, var(--muted)); }
.set-chip .set-del {
  display: grid;
  place-items: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 13px;
  line-height: 1;
}
.set-chip .set-del:hover { background: var(--accent); color: #fff; }
.set-empty { font-size: 12px; color: var(--muted); padding: 2px 0; }

/* 挑選器 */
.set-picker {
  position: fixed;
  inset: 0;
  z-index: 86;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  backdrop-filter: blur(6px);
}
.set-picker[hidden] { display: none; }
.set-picker-sheet {
  width: min(420px, 100%);
  max-height: min(80vh, 620px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -30px color-mix(in srgb, var(--ink) 60%, transparent);
}
.set-picker-word { font-size: var(--text-sm); color: var(--muted); }
.set-picker-word b { font-family: var(--font-display); font-size: var(--text-lg); color: var(--ink); margin-right: 6px; }
.set-picker-list { display: flex; flex-direction: column; gap: 6px; }
.set-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 13px;
  text-align: left;
  transition: all 0.16s var(--ease);
}
.set-pick-row:hover { border-color: var(--accent); }
.set-pick-row.is-in { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }
.set-pick-row span { color: var(--muted); font-size: 11px; }
.set-pick-row.is-in span { color: var(--teal); }
.set-picker-new { display: flex; gap: 6px; border-top: 1px dashed var(--line-strong); padding-top: var(--space-3); }
.set-picker-new input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
}
.set-picker-new input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.wd-addset {
  align-self: flex-start;
  margin-top: 2px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
}
.wd-addset:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
@media (max-width: 620px) {
  .set-bar { padding: var(--space-3); }
  .set-bar-actions { gap: var(--space-2); }
  .set-picker { padding: 0; align-items: flex-end; }
  .set-picker-sheet { width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 86vh; }
}
.set-bar-actions .text-btn { color: var(--accent); }
.set-bar-actions .text-btn:hover { color: var(--accent-hover); }
#setPickerCreate {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}
#setPickerCreate:hover { background: var(--accent-hover); }
.exam-none-note { font-size: 11px; color: var(--muted); }
.set-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
}
.exam-strip.is-none {
  background: transparent;
  border-style: dashed;
  padding: var(--space-2) var(--space-3);
}
.exam-strip.is-none .exam-tag {
  color: var(--muted);
  font-weight: 500;
  background: none;
  padding: 0;
}
.opt-zh {
  display: block;
  margin-top: 3px;
  font-style: normal;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  font-weight: 400;
}
.opt.is-correct .opt-zh { color: color-mix(in srgb, var(--teal) 80%, var(--muted)); }
.opt.is-wrong .opt-zh { color: color-mix(in srgb, var(--accent) 75%, var(--muted)); }
.exam-loading {
  padding: var(--space-8) 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ═══ 側欄收合 ═══ */
.app { transition: grid-template-columns 0.24s var(--ease); }
.app.is-collapsed { grid-template-columns: 74px minmax(0, 1fr); }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.sb-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  color: var(--muted);
  transition: background 0.18s, color 0.18s, transform 0.24s var(--ease);
}
.sb-toggle svg { width: 18px; height: 18px; }
.sb-toggle:hover { background: var(--surface-2); color: var(--ink); }
.app.is-collapsed .brand-text,
.app.is-collapsed .brand { display: none; }
.app.is-collapsed .side-head { justify-content: center; }
.app.is-collapsed .sb-toggle { transform: rotate(180deg); }
.app.is-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.app.is-collapsed .nav-item span { display: none; }
.app.is-collapsed .side-foot { display: none; }
.app.is-collapsed .sidebar { padding-left: var(--space-2); padding-right: var(--space-2); align-items: center; }
.app.is-collapsed .nav { width: 100%; }
@media (max-width: 960px) {
  .app, .app.is-collapsed { grid-template-columns: 1fr; }
  .side-head, .sb-toggle { display: none; }
}

/* ═══ 匯入單字 ═══ */
.imp-sheet { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; gap: var(--space-3); }
.imp-format {
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.imp-format-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  margin-bottom: var(--space-2);
}
.imp-sample {
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
}
.imp-rules {
  margin: 0;
  padding-left: 1.1em;
  font-size: var(--text-xs);
  line-height: 1.8;
  color: var(--muted);
}
.imp-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-2);
}
.imp-text {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
}
.imp-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.imp-file-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.imp-count { font-size: 12px; color: var(--muted); }
.imp-count.is-warn { color: var(--accent); }
.imp-target {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--line-strong);
}
.imp-radio { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--ink-2); white-space: nowrap; }
.imp-radio input { accent-color: var(--accent); }
.imp-name, #importSet {
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--ink);
  min-width: 0;
}
.imp-name:focus, #importSet:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.imp-actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding-top: var(--space-2); }
@media (max-width: 620px) {
  .imp-target { grid-template-columns: 1fr; }
  .imp-sheet { max-height: 92vh; }
}

/* 自訂單字級別色 */
[data-cat="0"], [data-lv="0"] { --lvc: var(--accent); }

/* ═══ 新版本提示 ═══ */
.update-bar {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px 10px 16px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--ink) 18%, transparent);
  font-size: var(--text-sm);
  color: var(--ink);
  white-space: nowrap;
}
.update-bar[hidden] { display: none; }
.update-bar .mini-btn { border-radius: 99px; }
.update-bar .text-btn { font-size: 12px; }
@media (max-width: 960px) {
  .update-bar { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

/* ═══ 更多選單 ═══ */
.more-wrap { position: relative; }
.more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--ink) 16%, transparent);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.more-menu[hidden] { display: none; }
.more-menu.is-card { min-width: 200px; }
.more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: var(--text-sm);
  color: var(--ink-2);
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.more-item:hover { background: var(--surface-2); color: var(--ink); }
.more-item svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.more-item .i-moon { display: none; }
[data-theme="dark"] .more-item .i-sun { display: none; }
[data-theme="dark"] .more-item .i-moon { display: block; }
.more-state { margin-left: auto; font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }
#starBtn[aria-pressed="true"] { color: var(--accent); }
#starBtn[aria-pressed="true"] svg { color: var(--accent); fill: color-mix(in srgb, var(--accent) 18%, transparent); }
@media (max-width: 620px) {
  .more-menu { min-width: 176px; }
}

/* ═══ 題幹出現標記 ═══ */
.exam-marker {
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* ═══ 播放器誠實提示 ═══ */
.console-note {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* ═══ 存檔失敗橫幅 ═══ */
.save-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: 12px;
  background: var(--gold-soft);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.45;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--ink) 14%, transparent);
}
.save-banner[hidden] { display: none; }
.save-banner .text-btn { white-space: nowrap; font-weight: 700; }

/* ═══ 考前衝刺 ═══ */
.sprint-list { display: flex; flex-direction: column; gap: 2px; }
.sprint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  text-align: left;
  transition: background 0.15s;
}
.sprint-row:hover { background: var(--surface-2); }
.sprint-row b { font-size: var(--text-md); letter-spacing: -0.01em; }
.sprint-row .mz { margin-left: 8px; color: var(--muted); font-size: var(--text-sm); }
.sprint-row .sprint-why { flex: none; font-size: 11px; color: var(--muted); text-align: right; line-height: 1.4; }

/* ═══ 單字掃描 ═══ */
.scan-sheet { max-width: 560px; max-height: min(92vh, 720px); overflow-y: auto; gap: var(--space-3); }
.scan-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  max-height: min(56vh, 420px);
  margin-top: var(--space-2);
  border-radius: 14px;
  overflow: hidden;
  background: #0d0d0f;
}
#scanVideo { width: 100%; height: 100%; object-fit: contain; background: #0d0d0f; }
.scan-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  font-size: var(--text-sm);
  line-height: 1.5;
}
.scan-placeholder[hidden] { display: none; }
.scan-placeholder svg { width: 42px; height: 42px; opacity: 0.75; }
.scan-frame {
  position: absolute;
  inset: 30% 8%;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.26);
  pointer-events: none;
}
.scan-status {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--ink-2);
  min-height: 1.4em;
}
.scan-actions { display: flex; gap: 10px; margin-top: var(--space-3); flex-wrap: wrap; }
.scan-actions .primary-btn { flex: 1 1 160px; }
.scan-results { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-3); }
.scan-results[hidden] { display: none; }
.scan-cand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  text-align: left;
  min-width: 0;
  transition: background 0.15s;
}
.scan-cand:hover { background: var(--surface-2); }
.scan-cand b { font-size: var(--text-md); }
.scan-cand > span:first-child { min-width: 0; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-cand .sc-zh { margin-left: 8px; color: var(--muted); font-size: var(--text-sm); }
.scan-cand .sc-tag { flex: none; font-size: 11px; color: var(--muted); }
.scan-cand.is-best { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.scan-review { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.scan-review[hidden] { display: none; }
.scan-shot { display: flex; align-items: center; gap: 12px; }
.scan-shot img {
  width: 108px; height: 64px; flex: none;
  border-radius: 9px; background: var(--surface-2);
  object-fit: contain;
  border: 1px solid var(--line);
}
.scan-shot img:not([src]) { display: none; }
.scan-read { margin: 0 0 4px; font-size: var(--text-sm); color: var(--ink-2); }
.scan-results { gap: 2px; }
.scan-cand .sc-ocr { flex: none; font-size: 11px; color: var(--faint); }
.scan-cand .sc-tag, .scan-cand .sc-tag.is-junk { white-space: nowrap; }
.sc-tag.is-junk { color: var(--faint); opacity: .8; }
.scan-cand.is-lemma b { font-weight: 600; color: var(--ink-2); }
.scan-cand.is-unknown b { color: var(--ink-2); font-weight: 600; }
.scan-manual {
  display: flex; gap: 8px; align-items: center;
  position: sticky; bottom: 0; z-index: 2;
  padding: 8px 0 4px;
  background: linear-gradient(to top, var(--surface) 72%, transparent);
}
.scan-manual input {
  flex: 1; min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--text-sm);
  font-family: inherit;
}
.scan-manual input::placeholder { color: var(--faint); }
.scan-manual input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }


/* ═══ iPhone 主畫面提示 ═══ */
.ios-tip {
  margin-top: var(--space-3);
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
}
.ios-tip[hidden] { display: none; }
.ios-tip b { font-size: var(--text-sm); }
.ios-tip p { margin: 6px 0 0; font-size: var(--text-xs, 12px); line-height: 1.55; color: var(--ink-2); }

.scan-stage.is-idle .scan-frame { display: none; }

/* 歷屆統計說明：只在第一次開啟時出現 */
.exam-note {
  margin: 14px 2px 4px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
}
