/* ═══════════════════════════════════════════════
   Etch — "Etch it in."
   Restraint over decoration: near-monochrome, hairline
   rules instead of heavy shadow, one accent used sparingly,
   and space doing most of the work.
   ═══════════════════════════════════════════════ */

:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --hairline: rgba(0, 0, 0, .09);
  --hairline-strong: rgba(0, 0, 0, .16);

  --text: #1d1d1f;
  --text-dim: #6e6e73;
  --text-faint: #707075;

  --accent: #0071e3;
  --accent-press: #0060c0;
  --ink: #1d1d1f;

  --good: #1d8a54;
  --good-bg: #eaf6ef;
  --warn: #9a6712;
  --warn-bg: #fbf2e3;
  --bad: #c4362f;
  --bad-bg: #fbecea;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --pill: 980px;

  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-lift: 0 4px 16px rgba(0, 0, 0, .07);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-cn: 'Noto Sans TC', 'PingFang TC', 'Hiragino Sans TC', sans-serif;

  --ease: cubic-bezier(.32, .72, 0, 1);
}

/* Chinese interface. Inter stays first so Latin text — every English word
   on the page — keeps its shape, and CJK glyphs fall through to Noto Sans TC.
   Tight negative tracking suits Inter headlines but crushes Chinese
   characters, so it is released for the headline sizes. */
:root[lang|="zh"] {
  --font: 'Inter', 'Noto Sans TC', 'PingFang TC', 'Hiragino Sans TC', -apple-system,
          BlinkMacSystemFont, sans-serif;
}
:root[lang|="zh"] .page-title { letter-spacing: 0; }
:root[lang|="zh"] .card-heading { letter-spacing: .04em; }

/* Dark palette. Declared twice on purpose: once for an explicit choice in
   Settings, once for the system preference when no choice overrides it. */
:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --hairline: rgba(255, 255, 255, .13);
  --hairline-strong: rgba(255, 255, 255, .24);

  --text: #f5f5f7;
  --text-dim: #a1a1a6;
  --text-faint: #98989e;

  --accent: #2997ff;
  --accent-press: #0d84ff;
  --ink: #f5f5f7;

  --good: #48c78e;
  --good-bg: #102c1e;
  --warn: #d8a24a;
  --warn-bg: #2c2312;
  --bad: #ff6b6b;
  --bad-bg: #2e1615;

  --shadow: none;
  --shadow-lift: 0 4px 20px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --hairline: rgba(255, 255, 255, .13);
    --hairline-strong: rgba(255, 255, 255, .24);

    --text: #f5f5f7;
    --text-dim: #a1a1a6;
    --text-faint: #98989e;

    --accent: #2997ff;
    --accent-press: #0d84ff;
    --ink: #f5f5f7;

    --good: #48c78e;
    --good-bg: #102c1e;
    --warn: #d8a24a;
    --warn-bg: #2c2312;
    --bad: #ff6b6b;
    --bad-bg: #2e1615;

    --shadow: none;
    --shadow-lift: 0 4px 20px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ── Flowing background paths ───────────────
   A family of sweeping Béziers with a long dash travelling along each one.
   Kept deliberately faint: this is a study tool, and the words a student is
   trying to read must always win. Opacity drops further during a drill. */
.bg-paths {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  color: var(--text);
  opacity: 1;
  transition: opacity .8s var(--ease);
}

.bg-paths path {
  fill: none;
  stroke: currentColor;
  vector-effect: non-scaling-stroke;
}

/* The bundle slides by exactly one line-spacing and repeats. Because every
   line is identical, the end state is indistinguishable from the start, so
   it loops forever without a visible seam. A transform also stays on the
   compositor, which keeps this close to free. */
.bg-paths .drift {
  animation: drift 13s linear infinite;
  will-change: transform;
}

@keyframes drift {
  to { transform: translateY(var(--spacing)); }
}

.bg-paths .shimmer { animation: flow linear infinite; }

@keyframes flow {
  to { stroke-dashoffset: 0; }
}

/* During practice the background recedes so nothing competes with the word. */
body.drilling .bg-paths { opacity: .35; }

@media (prefers-reduced-motion: reduce) {
  .bg-paths path { animation: none; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Header ─────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

/* The hand-drawn E/H monogram with the burin cutting through it. It stands
   alone as the brand — the mark already contains the letters, so setting the
   name beside it would just make you read "Etch" twice. Supplied as
   ink-on-transparent, so a single invert carries it into dark mode. */
.brand-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  transition: transform .4s var(--ease);
}

.brand:hover .brand-mark { transform: rotate(-4deg) scale(1.06); }
.brand:active .brand-mark { transform: scale(.94); }

:root[data-theme="dark"] .brand-mark { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-mark { filter: invert(1); }
}

/* The wordmark is the one place a serif appears. It carries the whole
   "high class" note on its own, so the interface can stay quiet. */
.wordmark {
  font-family: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  font-size: 1.55rem;
  font-weight: 400;
  letter-spacing: -.005em;
  line-height: 1;
  white-space: nowrap;
  color: var(--text);
}

/* A single full stop: the mark of something set down for good. */
.wordmark-dot { color: var(--accent); }

.tabs {
  display: flex;
  gap: 2px;
  margin-left: auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 7px 9px;
  border-radius: var(--pill);
  cursor: pointer;
  transition: color .25s var(--ease), background .25s var(--ease);
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--text);
  background: var(--surface-2);
  font-weight: 600;
}

/* Language switch. Quiet like the tabs, but set apart by a hairline so it
   reads as a control rather than a seventh page. */
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin-left: -2px;
  padding: 6px 10px 6px 12px;
  border: none;
  border-left: 1px solid var(--hairline);
  border-radius: 0;
  background: none;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: color .25s var(--ease);
}

.lang-btn:hover { color: var(--text); }

/* Half a turn per switch, accumulated in JS so it always turns forward. */
.lang-globe {
  width: 15px;
  height: 15px;
  transform: rotate(var(--globe-turn, 0deg));
  transition: transform .6s var(--ease);
}

#lang-label { display: inline-block; min-width: 1.1em; text-align: center; }

/* ── Language switch transition ──
   Out: blur, fade and lift, quickly. In: start just below and settle up, a
   little slower. The EN/中 label travels further so it reads as a roll. */
.app,
.tabs,
#lang-label {
  transition: opacity .28s var(--ease), filter .28s var(--ease), transform .28s var(--ease);
}

:root.lang-out .app,
:root.lang-out .tabs {
  opacity: 0;
  filter: blur(5px);
  transform: translateY(-5px);
  transition-duration: .14s;
  transition-timing-function: ease-in;
}

:root.lang-out #lang-label {
  opacity: 0;
  transform: translateY(-9px);
  transition-duration: .14s;
  transition-timing-function: ease-in;
}

:root.lang-in .app,
:root.lang-in .tabs {
  opacity: 0;
  filter: blur(5px);
  transform: translateY(6px);
  transition: none;
}

:root.lang-in #lang-label {
  opacity: 0;
  transform: translateY(9px);
  transition: none;
}

/* Keep seven navigation labels on one line in compact previews and phones. */
@media (max-width: 760px) {
  .topbar-inner { gap: 12px; padding: 0 14px; }
  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
            mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 7px 9px; white-space: nowrap; }
  .lang-btn { margin-left: 0; padding-left: 10px; }
}

/* ── Layout ─────────────────────────────── */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 120px;
}

.view { display: none; }
.view.active { display: block; animation: enter .5s var(--ease); }

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.page-title {
  margin: 0;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.06;
}

.page-sub {
  margin: 10px 0 44px;
  font-size: 1.02rem;
  color: var(--text-dim);
  letter-spacing: -.01em;
}

.section { margin-top: 52px; }

.section-title {
  margin: 0 0 16px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── Stats ──────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  padding: 26px 16px;
  text-align: center;
  border-right: 1px solid var(--hairline);
  animation: enter .55s var(--ease) backwards;
}

.stat-card:nth-child(1) { animation-delay: .02s; }
.stat-card:nth-child(2) { animation-delay: .08s; }
.stat-card:nth-child(3) { animation-delay: .14s; }
.stat-card:nth-child(4) { animation-delay: .20s; }

.stat-card:last-child { border-right: none; }

@media (max-width: 560px) {
  .stat-card:nth-child(2n) { border-right: none; }
  .stat-card:nth-child(-n+2) { border-bottom: 1px solid var(--hairline); }
}

.stat-number {
  font-size: 2.3rem;
  font-weight: 600;
  letter-spacing: -.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 8px;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--text-faint);
  text-transform: uppercase;
}

/* ── Buttons ────────────────────────────── */
.btn {
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--pill);
  padding: 10px 20px;
  cursor: pointer;
  transition: background .25s var(--ease), opacity .25s var(--ease), transform .25s var(--ease);
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}

.btn.primary:hover { background: var(--accent-press); }

.btn.big {
  display: block;
  width: 100%;
  margin-top: 36px;
  padding: 15px;
  font-size: 1rem;
}

.btn.quiet {
  background: transparent;
  border-color: var(--hairline);
  color: var(--accent);
  padding: 8px 18px;
  font-size: .84rem;
}

.btn.quiet:hover { background: var(--surface-2); }
.btn.quiet.small { padding: 6px 14px; font-size: .78rem; }

.text-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 10px 12px;
  font-size: .85rem;
}

.text-btn:hover { background: none; color: var(--text-dim); }

/* ── Rows ───────────────────────────────── */
.row-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
}

.row-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--hairline);
}

.w-word, .m-word {
  font-weight: 500;
  letter-spacing: -.015em;
}

.w-def, .m-def {
  color: var(--text-faint);
  font-size: .87rem;
  font-family: var(--font-cn);
}

.w-def { margin-left: auto; }

.m-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.m-def { flex-basis: 100%; }

/* A word with no real Chinese meaning: say so and offer the fix inline. */
.m-missing { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--font); }
.m-missing-note { font-size: .78rem; color: var(--text-faint); }

.fix-zh-btn {
  font: inherit;
  font-size: .8rem;
  font-weight: 500;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border: none;
  border-radius: var(--pill);
  padding: 4px 11px;
  cursor: pointer;
}

.fix-zh-btn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.fix-zh-form { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.fix-zh-input { flex: 1; min-width: 0; font-family: var(--font-cn); }
.fix-zh-form .btn { padding: 7px 16px; font-size: .82rem; flex-shrink: 0; }

/* The definition standing in for a missing Chinese meaning is a sentence,
   not a two-character headline, so it is set smaller. */
.clue-chinese.clue-fallback { font-family: var(--font); font-size: 1.15rem; line-height: 1.5; }
.clue-chinese.clue-long { font-size: 1.45rem; line-height: 1.5; white-space: pre-line; text-wrap: balance; }

.m-status, .band-pill {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--pill);
  color: var(--text-dim);
  background: var(--surface-2);
}

.m-status.level-0 { color: var(--bad);  background: var(--bad-bg); }
.m-status.level-1,
.m-status.level-2 { color: var(--warn); background: var(--warn-bg); }
.m-status.level-3,
.m-status.level-4 { color: var(--accent); background: var(--surface-2); }
.m-status.level-5 { color: var(--good); background: var(--good-bg); }

.delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: .95rem;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
  transition: color .25s var(--ease);
}

.delete-btn:hover { color: var(--bad); }

/* ── Empty / notes ──────────────────────── */
.empty-msg { color: var(--text-faint); font-size: .9rem; margin: 0; padding: 14px 0; }

.note {
  font-size: .78rem;
  color: var(--text-faint);
  line-height: 1.6;
  margin: 12px 0 0;
}

.note.center { text-align: center; }

.empty-state {
  text-align: center;
  padding: 90px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  color: var(--text-dim);
}

.done-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── Settings pull out as the page opens ─── */
/* Each group slides out from the left in sequence, like drawers being pulled
   open, so the settings assemble themselves rather than just appearing. */
@keyframes drawerOut {
  from { opacity: 0; transform: translateX(-26px); }
  to   { opacity: 1; transform: none; }
}

#view-setup > .card,
#view-setup > .card-heading,
#view-setup > .why-box,
#view-setup > .btn,
#view-setup > .note,
#view-analysis > .card {
  animation: drawerOut .62s var(--ease) backwards;
}

#view-setup > *:nth-child(3)  { animation-delay: .05s; }
#view-setup > *:nth-child(4)  { animation-delay: .11s; }
#view-setup > *:nth-child(5)  { animation-delay: .17s; }
#view-setup > *:nth-child(6)  { animation-delay: .23s; }
#view-setup > *:nth-child(7)  { animation-delay: .29s; }
#view-setup > *:nth-child(8)  { animation-delay: .35s; }
#view-setup > *:nth-child(9)  { animation-delay: .41s; }
#view-setup > *:nth-child(10) { animation-delay: .47s; }

/* Rows inside each card follow a beat later, so the drawer has contents. */
#view-setup .card-row,
#view-setup .pick {
  animation: rowSlide .5s var(--ease) backwards;
}

@keyframes rowSlide {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}

#view-setup .card-row:nth-child(1), #view-setup .pick:nth-child(1) { animation-delay: .20s; }
#view-setup .card-row:nth-child(2), #view-setup .pick:nth-child(2) { animation-delay: .26s; }
#view-setup .card-row:nth-child(3), #view-setup .pick:nth-child(3) { animation-delay: .32s; }
#view-setup .card-row:nth-child(4), #view-setup .pick:nth-child(4) { animation-delay: .38s; }

/* ── Grouped settings cards ─────────────── */
.card-heading {
  margin: 34px 0 10px 18px;
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px;
  min-height: 58px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
}

.card-row:last-child { border-bottom: none; }

.row-label {
  font-size: .95rem;
  letter-spacing: -.01em;
}

.row-hint {
  display: block;
  font-style: normal;
  font-size: .8rem;
  color: var(--text-faint);
  margin-top: 2px;
}

.row-value {
  font-size: .92rem;
  color: var(--text-faint);
  text-align: right;
}

a.row-value { color: var(--accent); text-decoration: none; }
a.row-value:hover { text-decoration: underline; }

.card-row.stacked {
  display: block;
}

.card-row.stacked .field-row { margin-top: 10px; }

/* Rows that behave like buttons (Export, Import, Delete) */
.action-row {
  width: 100%;
  font-family: inherit;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  transition: background .2s var(--ease);
}

.action-row:last-child { border-bottom: none; }
.action-row:hover { background: var(--surface-2); }
.action-row.danger .row-label { color: var(--bad); }

.row-chevron {
  color: var(--text-faint);
  font-size: 1.15rem;
  line-height: 1;
}

/* ── Home actions ───────────────────────── */
.home-actions {
  display: flex;
  gap: 10px;
  margin-top: 36px;
}

.home-actions .btn.big { margin-top: 0; flex: 1; }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.secondary:hover { background: var(--surface-2); }

@media (max-width: 520px) {
  .home-actions { flex-direction: column; }
}

/* ── Needs practice (collapsible) ───────── */
.weak-box { border-top: 1px solid var(--hairline); padding-top: 4px; }

.weak-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 2px;
  cursor: pointer;
  list-style: none;
}

.weak-summary::-webkit-details-marker { display: none; }

.weak-summary::before {
  content: '›';
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-faint);
  transition: transform .25s var(--ease);
}

.weak-box[open] .weak-summary::before { transform: rotate(90deg); }

.weak-summary-label {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.weak-count {
  margin-left: auto;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: var(--pill);
  padding: 2px 10px;
  font-variant-numeric: tabular-nums;
}

.weak-box[open] .row-list { animation: unfold .38s var(--ease); }

/* ── Add-word shortcut ─────────────────────── */
.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  padding: 11px 22px;
}

.add-plus { font-size: 1.1rem; line-height: 1; font-weight: 400; }

@keyframes panelOpen {
  from { opacity: 0; transform: translateY(-10px) scaleY(.97); transform-origin: top; }
  to   { opacity: 1; transform: none; }
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* iOS-style segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.seg {
  font-family: inherit;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 13px;
  cursor: pointer;
  transition: color .2s var(--ease), background .28s var(--ease), box-shadow .28s var(--ease);
}

.seg:hover { color: var(--text); }

.seg.selected {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

:root[data-theme="dark"] .seg.selected { background: #48484a; box-shadow: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg.selected { background: #48484a; box-shadow: none; }
}

/* Single-choice list rows */
.pick {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  font-family: inherit;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 13px 18px;
  min-height: 62px;
  cursor: pointer;
  color: var(--text);
  transition: background .2s var(--ease);
}

.pick:last-child { border-bottom: none; }
.pick:hover { background: var(--surface-2); }

.pick-text { display: flex; flex-direction: column; gap: 2px; }
.pick-text strong { font-size: .95rem; font-weight: 400; letter-spacing: -.01em; }
.pick-text em { font-style: normal; font-size: .82rem; color: var(--text-faint); }

.pick.selected strong { color: var(--accent); font-weight: 550; }

.pick.selected::after {
  content: '';
  margin-left: auto;
  width: 14px;
  height: 8px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg) translateY(-3px);
  animation: tick .3s var(--ease);
}

@keyframes tick {
  from { opacity: 0; transform: rotate(-45deg) translateY(-3px) scale(.4); }
  to   { opacity: 1; transform: rotate(-45deg) translateY(-3px) scale(1); }
}

/* Collapsible rationale — available, not shouting */
.why-box {
  margin-top: 28px;
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
}

.why-box summary {
  font-size: .86rem;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.why-box summary::-webkit-details-marker { display: none; }

.why-box summary::before {
  content: '›';
  font-size: 1.15rem;
  line-height: 1;
  color: var(--text-faint);
  transition: transform .25s var(--ease);
}

.why-box[open] summary::before { transform: rotate(90deg); }

.why-list {
  margin: 14px 0 0;
  padding: 0 0 0 22px;
  font-size: .84rem;
  color: var(--text-faint);
  line-height: 1.75;
  animation: unfold .4s var(--ease);
}

/* details can't transition its own height, so the contents do the work. */
@keyframes unfold {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

.why-list li { animation: rowSlide .45s var(--ease) backwards; }
.why-list li:nth-child(1) { animation-delay: .04s; }
.why-list li:nth-child(2) { animation-delay: .09s; }
.why-list li:nth-child(3) { animation-delay: .14s; }
.why-list li:nth-child(4) { animation-delay: .19s; }
.why-list li:nth-child(5) { animation-delay: .24s; }

.why-list strong { color: var(--text-dim); font-weight: 550; }

/* iOS-style toggle */
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 50px;
  height: 30px;
  border-radius: var(--pill);
  background: var(--hairline-strong);
  position: relative;
  cursor: pointer;
  transition: background .3s var(--ease);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
  transition: transform .3s var(--ease);
}

.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }

/* ── Practice ───────────────────────────── */
.practice-head { text-align: center; margin-bottom: 34px; }

.practice-progress {
  font-size: .8rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.sep { opacity: .4; margin: 0 6px; }

.stage-stepper { display: flex; gap: 4px; justify-content: center; margin: 14px 0 10px; }

.step {
  width: 26px;
  height: 3px;
  border-radius: var(--pill);
  background: var(--hairline-strong);
  transition: background .4s var(--ease);
}

.step.done, .step.current { background: var(--text); }
.step.current { opacity: 1; }
.step.done { opacity: .45; }

.stage-badge { font-size: .74rem; color: var(--text-faint); letter-spacing: -.005em; }

/* Shown when a word has become well known and Etch withdraws all scaffolding */
.advanced-tag {
  display: inline-block;
  margin-top: 9px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--pill);
  padding: 4px 12px;
  animation: badgeIn .5s var(--ease) backwards;
  animation-delay: .25s;
}

@keyframes badgeIn {
  from { opacity: 0; transform: scale(.82); }
  to   { opacity: 1; transform: none; }
}

/* "Recommended" marker on the default focus option */
.rec-tag {
  margin-left: 7px;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--pill);
  padding: 3px 8px;
  vertical-align: middle;
}

.clue-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 46px 32px 34px;
  text-align: center;
}

.clue-chinese {
  font-family: var(--font-cn);
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: .01em;
  line-height: 1.2;
}

.clue-meta { margin-top: 16px; }

.clue-synonym { font-size: .9rem; color: var(--text-dim); }

.clue-definition {
  margin-top: 6px;
  font-size: .95rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.clue-example {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
  font-size: .93rem;
  line-height: 1.9;
  color: var(--text);
  text-align: left;
}

.clue-card .btn.quiet { margin-top: 28px; }

/* ── Letter boxes ───────────────────────── */
.letterboxes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 40px 0 28px;
}

.letter-box {
  width: 32px;
  height: 44px;
  text-align: center;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 500;
  text-transform: lowercase;
  border: none;
  border-bottom: 2px solid var(--hairline-strong);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  transition: border-color .25s var(--ease), color .25s var(--ease);
}

.letter-box:focus { outline: none; border-bottom-color: var(--accent); }

/* Letters deal in one by one as a card appears */
.letter-box {
  animation: dealIn .42s var(--ease) backwards;
}

@keyframes dealIn {
  from { opacity: 0; transform: translateY(9px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

/* On a correct answer the letters light up left to right */
.letter-box.cascade { animation: lift .45s var(--ease) backwards; }

@keyframes lift {
  0%   { transform: none; }
  45%  { transform: translateY(-7px); }
  100% { transform: none; }
}

/* A hinted letter is shown as a faint ghost the student types over. */
.letter-box.hint::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

.letter-box.hint {
  border-bottom-color: var(--accent);
  border-bottom-style: dotted;
  border-bottom-width: 3px;
}

.letter-box.fixed { border: none; color: var(--text-faint); }
.letter-box.box-correct { border-bottom-color: var(--good); color: var(--good); }
.letter-box.box-wrong { border-bottom-color: var(--bad); color: var(--bad); }

/* ── Feedback ───────────────────────────── */
.feedback-banner {
  text-align: center;
  font-size: .9rem;
  font-weight: 500;
  padding: 13px;
  border-radius: var(--r-md);
  margin-bottom: 24px;
}

.feedback-banner.success { background: var(--good-bg); color: var(--good); }
.feedback-banner.error { background: var(--bad-bg); color: var(--bad); }

/* ── Reveal ─────────────────────────────── */
.reveal-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 28px 28px 8px;
  margin-bottom: 26px;
  animation: enter .4s var(--ease);
}

.reveal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-bottom: 22px;
}

/* The moment the word is revealed — the payoff. Set in the display serif so
   it echoes the wordmark instead of feeling like another UI label. */
.reveal-word {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: -.01em;
  line-height: 1.1;
}

.reveal-list { margin: 0; padding: 0; }

.reveal-item {
  display: flex;
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
}

.reveal-item dt {
  flex: 0 0 82px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-top: 3px;
}

.reveal-item dd { margin: 0; flex: 1; font-size: .94rem; line-height: 1.6; }
#reveal-chinese { font-family: var(--font-cn); }

.reveal-item mark {
  background: none;
  color: var(--text);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 1px;
}

.practice-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

/* ── Forms ──────────────────────────────── */
.select {
  font-family: inherit;
  font-size: .92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  padding: 13px 15px;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ── Word suggestions (typeahead) ───────── */
.suggest-wrap { position: relative; flex: 1; min-width: 0; }
.suggest-wrap input { width: 100%; }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lift);
  max-height: 262px;
  overflow-y: auto;
  animation: suggestIn .22s var(--ease);
}

@keyframes suggestIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

.suggestion {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: .93rem;
  display: flex;
  align-items: baseline;
  gap: 9px;
  transition: background .14s var(--ease);
}

.suggestion:hover,
.suggestion.active { background: var(--surface-2); }

/* The part the student has already typed stays quiet; the completion leads. */
.suggestion .typed { color: var(--text-faint); }
.suggestion .rest { color: var(--text); font-weight: 550; }

.suggestion .already {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field-row { display: flex; gap: 10px; }
.field-row input, .field-row .select { flex: 1; min-width: 0; }
.field-row .btn { white-space: nowrap; flex-shrink: 0; }

.select { cursor: pointer; }

/* ── Analysis ───────────────────────────── */
.verdict {
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-lg);
  padding: 34px 30px;
  text-align: center;
}

:root[data-theme="dark"] .verdict {
  background: var(--surface); color: var(--text); border: 1px solid var(--hairline);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .verdict {
    background: var(--surface); color: var(--text); border: 1px solid var(--hairline);
  }
}

.verdict-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .5;
}

.verdict-level {
  font-family: var(--font-display);
  font-size: 3.6rem;
  font-weight: 400;
  letter-spacing: -.01em;
  line-height: 1.05;
  margin-top: 4px;
}

.verdict-text { font-size: .92rem; opacity: .75; margin-top: 10px; line-height: 1.6; }

.verdict-bar {
  height: 4px;
  border-radius: var(--pill);
  background: color-mix(in srgb, currentColor 20%, transparent);
  margin: 26px 0 10px;
  overflow: hidden;
}

.verdict-fill {
  height: 100%;
  width: 0;
  border-radius: var(--pill);
  background: currentColor;
  transition: width .9s var(--ease);
}

.verdict-band {
  font-size: .8rem;
  letter-spacing: .01em;
  opacity: .55;
  margin-top: 7px;
}

/* What the next level up costs. Sits inside the dark verdict card, so every
   colour here is derived from currentColor rather than a palette token. */
.next-block {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.next-head { display: flex; align-items: baseline; justify-content: center; gap: 9px; }

.next-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .45;
}

.next-level { font-family: var(--font-display); font-size: 1.35rem; letter-spacing: -.01em; }

.next-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
}

.next-list li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, currentColor 7%, transparent);
  font-size: .85rem;
}

.req-axis {
  flex: 0 0 68px;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  opacity: .5;
}

.req-text { opacity: .9; line-height: 1.5; }

.band-chart { display: flex; flex-direction: column; }

.band-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--hairline);
}

.band-row:first-child { border-top: 1px solid var(--hairline); }

.band-name { flex: 0 0 108px; font-size: .86rem; font-weight: 500; }

.band-name small {
  display: block;
  font-weight: 400;
  color: var(--text-faint);
  font-size: .72rem;
}

.band-track {
  flex: 1;
  height: 6px;
  border-radius: var(--pill);
  background: var(--surface-2);
  display: flex;
  overflow: hidden;
}

.band-seg { height: 100%; transition: width .8s var(--ease); }
.band-seg.mastered { background: var(--good); }
.band-seg.learning { background: var(--warn); }
.band-seg.new { background: var(--hairline-strong); }

.band-count {
  flex: 0 0 26px;
  text-align: right;
  font-size: .84rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* Whether the band is held, how close it is, or how many more words it needs */
.band-state {
  flex: 0 0 52px;
  text-align: right;
  font-size: .74rem;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.band-state.held { color: var(--good); }

.analysis-stats { margin-top: 20px; }

.band-row.target .band-name { color: var(--accent); }

.legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 20px;
  font-size: .74rem;
  color: var(--text-faint);
}

.legend span { display: flex; align-items: center; gap: 7px; }

.sw { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sw-mastered { background: var(--good); }
.sw-learning { background: var(--warn); }
.sw-new { background: var(--hairline-strong); }

/* ── The three axes ─────────────────────── */
/* One grid for all three rows so the bands line up vertically: the axis that
   is holding the level back is then obvious without reading anything. */
.axis-grid {
  display: grid;
  grid-template-columns: 7.5rem repeat(5, 1fr);
  gap: 0 6px;
  align-items: center;
  border-top: 1px solid var(--hairline);
  margin-top: 4px;
  padding-top: 12px;
}

.axis-scale {
  font-size: .66rem;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: .03em;
  padding-bottom: 11px;
}

.axis-name { font-size: .86rem; font-weight: 500; padding: 11px 0; }

.axis-name small {
  display: block;
  font-weight: 400;
  font-size: .72rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.axis-name.limiting { color: var(--accent); }

.axis-pip {
  height: 6px;
  border-radius: var(--pill);
  background: var(--surface-2);
  transition: background .6s var(--ease);
}

.axis-pip.on { background: var(--ink); }
.axis-pip.gap { background: color-mix(in srgb, var(--accent) 30%, transparent); }

.axis-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 2px 0 14px;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--text-faint);
  border-bottom: 1px solid var(--hairline);
}

.axis-note.limiting { color: var(--text-dim); }
.axis-grid > .axis-note:last-child { border-bottom: none; padding-bottom: 2px; }

.axis-foot { font-size: .78rem; color: var(--text-faint); margin: 15px 0 0; line-height: 1.55; }

@media (max-width: 520px) {
  .axis-grid { grid-template-columns: 5.4rem repeat(5, 1fr); gap: 0 4px; }
  .axis-scale { font-size: .6rem; }
  .axis-name { font-size: .8rem; }
}

/* ── Words added per day ────────────────── */
.growth { color: var(--accent); margin-top: 2px; }

.growth-svg { display: block; width: 100%; height: auto; overflow: visible; }

.g-grid { stroke: var(--hairline); stroke-width: 1; }

.g-ylab, .g-xlab {
  fill: var(--text-faint);
  font-family: var(--font);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.g-ylab { text-anchor: end; }

.g-area { stroke: none; }

.g-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  animation: drawLine 1.2s var(--ease) forwards;
}

/* The seven-day mean is the quieter line on purpose — it is context for the
   daily count, not the headline. */
.g-mean {
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
  opacity: .75;
}

.g-dot { fill: currentColor; stroke: var(--bg); stroke-width: 2; }

@keyframes drawLine { to { stroke-dashoffset: 0; } }

.growth-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 14px;
  font-size: .74rem;
  color: var(--text-faint);
}

.growth-legend span { display: flex; align-items: center; gap: 7px; }

.sw-line, .sw-mean { width: 14px; height: 2px; border-radius: 2px; }
.sw-line { background: var(--accent); }
.sw-mean { background: var(--text-faint); }

.growth-foot {
  margin: 12px 0 0;
  font-size: .78rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ── Motion preferences ─────────────────── */
/* Some people get motion sick, and some just want it to stop moving.
   Honour the system setting rather than insisting on the animation. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Reading ────────────────────────────── */
.reading-dots { display: flex; gap: 6px; }

.reading-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-strong);
  transition: background .3s var(--ease), border-color .3s var(--ease);
}

.reading-dot.filled { background: var(--good); border-color: var(--good); }

.reading-row .row-label { font-weight: 450; }
.reading-done-tick { color: var(--good); font-size: 1rem; }

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

.reading-head .text-btn { padding-left: 0; }

.reading-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: -.01em;
  line-height: 1.12;
}

.reading-meta {
  margin: 8px 0 0;
  font-size: .8rem;
  color: var(--text-faint);
}

/* Generous measure and leading — this is the one place in the app meant for
   sustained reading rather than scanning. */
.reading-body {
  margin: 30px 0 44px;
  font-size: 1.08rem;
  line-height: 1.78;
  letter-spacing: -.003em;
  max-width: 62ch;
}

.reading-body p { margin: 0 0 1.25em; }

.reading-body mark.target {
  background: none;
  color: inherit;
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 1px;
}

.target-row .row-label { font-weight: 500; }

.target-zh {
  font-family: var(--font-cn);
  font-size: .9rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}

.target-zh .already {
  font-family: var(--font);
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-left: 6px;
}

/* ── Comprehension questions ────────────── */
.quiz-question {
  margin: 0 0 20px;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.4;
  max-width: 54ch;
}

.quiz-options { margin-bottom: 20px; }

.quiz-option {
  width: 100%;
  font-family: inherit;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  cursor: pointer;
  transition: background .18s var(--ease);
}

.quiz-option:last-child { border-bottom: none; }
.quiz-option:hover:not(:disabled) { background: var(--surface-2); }
.quiz-option:disabled { cursor: default; }

.quiz-option.correct {
  background: var(--good-bg);
}

.quiz-option.correct .row-label { color: var(--good); font-weight: 550; }

.quiz-option.wrong { background: var(--bad-bg); }
.quiz-option.wrong .row-label { color: var(--bad); }

.quiz-why {
  font-size: .92rem;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  animation: enter .3s var(--ease);
}

.quiz-why.good { background: var(--good-bg); color: var(--good); }
.quiz-why.bad { background: var(--bad-bg); color: var(--bad); }

#reading-done .card { width: 100%; margin-bottom: 8px; }
#reading-score { font-size: 1.15rem; font-weight: 550; color: var(--text); }
