:root {
  --red: #c4372e;
  --red-dark: #8f281f;
  --gold: #f4b63f;
  --ink: #1f1b24;
  --muted: #625b68;
  --bg: #fff8f3;
  --card: #ffffff;
  --line: #f0e6de;
  --ok: #2fa66a;
  --bad: #e0443a;
  --t1: #e8453c;
  --t2: #f08c00;
  --t3: #2fa66a;
  --t4: #3b6fe0;
  --t5: #8a8494;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(80, 30, 10, 0.08);
  --page: #f3ebe4;
  --surface: #ffffff;
  --soft: #fff1ea;
  --soft2: #fff4ec;
  --ok-bg: #e8f7ef;
  --bad-bg: #fdecea;
  --blue-bg: #eaf0fd;
  --ok-ink: #1f7a4c;
  --blue-ink: #2a50a8;
  --solid: #1f1b24;
  --solid-sub: #d8d0dc;
  --focus: #2a50a8;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  padding-bottom: 84px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
}

.brand { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; }

.logo {
  display: inline-grid;
  font-family: "Microsoft YaHei", sans-serif;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #c4372e, #b45309);
  color: #fff;
  font-size: 20px;
}

.top-stats { display: flex; gap: 12px; font-weight: 700; }

main { padding: 6px 16px 16px; }

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0 0 12px; font-size: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.hero {
  background: linear-gradient(135deg, #c4372e 0%, #b8441a 55%, #b45309 100%);
  color: #fff;
  display: flex;
  gap: 16px;
  align-items: center;
}

.hero .big { font-size: 34px; font-weight: 800; line-height: 1; }
.hero .label { opacity: 0.9; font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.stat { text-align: center; padding: 12px 8px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.tile .ic { font-size: 26px; }
.tile b { font-size: 15px; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.primary { background: var(--solid); color: #fff; }
.tile.primary span { color: var(--solid-sub); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 0 var(--red-dark);
  transition: transform 0.05s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--red-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: 0 3px 0 var(--line); border: 2px solid var(--line); }
.btn.dark { background: var(--solid); box-shadow: 0 4px 0 #000; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.hanzi-big {
  font-family: "KaiTi", "STKaiti", "Microsoft YaHei", serif;
  font-size: 88px;
  line-height: 1.1;
  text-align: center;
  margin: 6px 0;
}
.pinyin { text-align: center; font-size: 22px; font-weight: 600; letter-spacing: 0.5px; }
.meaning { text-align: center; font-size: 18px; margin-top: 6px; }
.meaning small { display: block; color: var(--muted); font-size: 13px; }

.t1 { color: var(--t1); }
.t2 { color: var(--t2); }
.t3 { color: var(--t3); }
.t4 { color: var(--t4); }
.t5 { color: var(--t5); }

.example {
  background: var(--soft2);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 15px;
}
.example .zh { font-size: 19px; font-family: "Microsoft YaHei", sans-serif; }
.example .py { color: var(--muted); font-size: 13px; }

.options { display: grid; gap: 10px; margin-top: 12px; }
.option {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.option.zh { font-size: 26px; text-align: center; font-family: "Microsoft YaHei", sans-serif; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }

.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.rate button { padding: 12px 4px; font-size: 13px; }
.rate small { display: block; font-weight: 500; opacity: 0.85; font-size: 11px; }
.r1 { background: #b91c1c !important; box-shadow: 0 4px 0 #7f1d1d !important; }
.r2 { background: #b45309 !important; box-shadow: 0 4px 0 #7c3a06 !important; }
.r3 { background: #1f7a4c !important; box-shadow: 0 4px 0 #14532d !important; }
.r4 { background: #2a50a8 !important; box-shadow: 0 4px 0 #1e3a8a !important; }

.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 14px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); border-radius: 99px; transition: width 0.3s; }

.tone-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.tone-btn {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 4px;
  cursor: pointer;
  font: inherit;
}
.tone-btn svg { width: 100%; height: 40px; }
.tone-btn b { display: block; font-size: 13px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); height: 100%; justify-content: flex-end; }
.bars .bar i { display: block; width: 100%; background: linear-gradient(180deg, var(--gold), var(--red)); border-radius: 6px 6px 3px 3px; min-height: 3px; }

.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; font-size: 15px; }
.bubble .zh { font-size: 19px; font-family: "Microsoft YaHei", sans-serif; }
.bubble .py { font-size: 12px; opacity: 0.75; }
.bubble .tr { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.bubble.bot { background: var(--surface); box-shadow: var(--shadow); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.me { background: var(--red); color: #fff; align-self: flex-end; border-bottom-right-radius: 6px; }

.canvas-wrap { position: relative; width: 280px; height: 280px; margin: 8px auto; }
.canvas-wrap canvas { position: absolute; inset: 0; border-radius: 16px; touch-action: none; }
.canvas-grid {
  background:
    linear-gradient(var(--line), var(--line)) center / 2px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) center / 100% 2px no-repeat,
    var(--surface);
  border: 2px solid var(--line);
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tabbar a {
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  border-radius: 12px;
}
.tabbar a .ic { font-size: 21px; }
.tabbar a.active { color: var(--red); font-weight: 700; background: var(--soft); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  font-size: 14px;
  max-width: 90%;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 99px; background: var(--soft); color: var(--red-dark); font-size: 12px; font-weight: 700; }
.pill.green { background: var(--ok-bg); color: var(--ok-ink); }
.pill.blue { background: var(--blue-bg); color: var(--blue-ink); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .zh { font-size: 24px; font-family: "Microsoft YaHei", sans-serif; min-width: 64px; }

.meter { width: 100%; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; }

.center { text-align: center; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

select, input[type="number"] {
  font: inherit;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--surface);
}

/* ---- v2 additions: accessibility & new components ---- */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip { position: absolute; left: -999px; top: 8px; background: var(--solid); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
a.tile { text-decoration: none; }
button.tile { width: 100%; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 99px;
  padding: 7px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.chip.on { background: var(--solid); color: #fff; border-color: var(--solid); }
.search { width: 100%; font: inherit; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); }
.key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 12px;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: middle;
}
.btn .key { background: rgba(255, 255, 255, 0.25); margin: 0 0 0 6px; }
.pill.tiny { font-size: 11px; padding: 2px 7px; }
.small-text { font-size: 12px; }
.list-item {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
button.example, button.bubble { border: none; font: inherit; text-align: left; cursor: pointer; width: 100%; color: inherit; }
button.bubble { width: auto; }
button.bubble.me { color: #fff; }
.tone-btn.correct { border-color: var(--ok); background: var(--ok-bg); }
.tone-btn.wrong { border-color: var(--bad); background: var(--bad-bg); }
.write-box { position: relative; width: 280px; height: 280px; margin: 6px auto; }
.write-box svg { position: absolute; inset: 0; border-radius: 16px; }
#glyph {
  background:
    linear-gradient(var(--line), var(--line)) center / 2px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) center / 100% 2px no-repeat,
    var(--surface);
  border: 2px solid var(--line);
}
#ink { touch-action: none; cursor: crosshair; }
#glyph path { transition: fill 0.25s; }
.btn.recording { background: var(--bad); box-shadow: 0 0 0 6px rgba(224, 68, 58, 0.25); }
.level-tile { align-items: center; text-align: center; border: 2px solid transparent; }
.level-tile b { font-size: 18px; }
.level-card { gap: 12px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.shadow-box { margin-top: 10px; padding: 12px; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--red); }


/* ---------- Dark theme (automatic, or chosen in settings) ---------- */
:root[data-theme="dark"] {
  --ink: #f3eef6;
  --muted: #b9b0bf;
  --bg: #17141b;
  --card: #221e28;
  --line: #3b3442;
  --page: #0e0c11;
  --surface: #2a2531;
  --soft: #3b2522;
  --soft2: #33241f;
  --ok-bg: #173323;
  --bad-bg: #3d1e1c;
  --blue-bg: #1c2742;
  --ok-ink: #7fdca6;
  --blue-ink: #a9c1ff;
  --red: #ff8a80;
  --red-dark: #ffb7ae;
  --solid: #3a3342;
  --solid-sub: #d8d0dc;
  --focus: #a9c1ff;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f3eef6;
    --muted: #b9b0bf;
    --bg: #17141b;
    --card: #221e28;
    --line: #3b3442;
    --page: #0e0c11;
    --surface: #2a2531;
    --soft: #3b2522;
    --soft2: #33241f;
    --ok-bg: #173323;
    --bad-bg: #3d1e1c;
    --blue-bg: #1c2742;
    --ok-ink: #7fdca6;
    --blue-ink: #a9c1ff;
    --red: #ff8a80;
    --red-dark: #ffb7ae;
    --solid: #3a3342;
    --solid-sub: #d8d0dc;
    --focus: #a9c1ff;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] .hero, :root[data-theme="dark"] .bubble.me { color: #fff; }
select { background: var(--surface); color: var(--ink); border: 2px solid var(--line); border-radius: 10px; padding: 6px 8px; font: inherit; }

/* ---------- Delight ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: nadaku-fall 1.8s ease-in forwards; }
@keyframes nadaku-fall { to { top: 105%; transform: translateX(40px) rotate(540deg); opacity: 0.6; } }
.pop { animation: nadaku-pop 0.35s ease-out; }
@keyframes nadaku-pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.badge { display: inline-block; padding: 6px 10px; border-radius: 99px; border: 2px dashed var(--line); color: var(--muted); font-size: 13px; font-weight: 700; margin: 0 6px 6px 0; }
.badge.on { border-style: solid; border-color: var(--gold); color: var(--ink); background: var(--soft2); }
@media (prefers-reduced-motion: reduce) { .pop, .confetti i { animation: none; } }

/* ---------- Made for Indonesian speakers ---------- */
.indo-card { text-decoration: none; color: inherit; border: 2px solid var(--soft); }
.indo-card .ic { font-size: 26px; }
.loan { flex-wrap: wrap; gap: 8px; }
.loan-indo { font-weight: 800; min-width: 74px; }
.loan-mean { flex-basis: 100%; }
.trap { border-top: 1px solid var(--line); padding: 10px 0; }
.trap p { margin: 6px 0 8px; }

/* Nada the mascot */
.mascot { flex: none; display: inline-block; animation: nada-bob 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.mascot-cheer { animation: nada-hop 1.4s ease-in-out infinite; }
.card.center .mascot { margin: 0 auto 6px; display: block; }
.row > .mascot { margin-right: 8px; }
.mascot-say { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 14px; }
.say-bubble { position: relative; background: var(--surface, #fff); color: var(--ink, #1f1b24); border: 1px solid var(--line, #e7ddd3); border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-weight: 600; line-height: 1.4; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
@keyframes nada-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3px) rotate(-2deg); } }
@keyframes nada-hop { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-8px) scale(1.04, .97); } 60% { transform: translateY(0) scale(.98, 1.03); } }
@media (prefers-reduced-motion: reduce) { .mascot, .mascot-cheer { animation: none; } }

/* ---- v6 shared: line icons (no emoji) ---- */
.i { display: inline-block; flex-shrink: 0; vertical-align: -0.22em; }
.btn .i, .chip .i { vertical-align: -0.2em; }
.stat-chip { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.offline-note { display: flex; align-items: center; justify-content: center; gap: 6px; }
.say-ic { color: var(--muted); display: inline-flex; vertical-align: middle; }
.scene-ic { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--soft); color: var(--red-dark); }
.tile .ic { display: inline-flex; color: var(--red); }
.tile.primary .ic { color: #fff; }
.tabbar a .ic { display: inline-flex; }

.page-head { margin: 4px 0 10px; }
.page-head h1 { margin: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); background: var(--surface); }
.icon-btn:hover { border-color: var(--muted); }
.ring-track { stroke: rgba(255, 255, 255, .3); }
.ring-fill { stroke: #fff; }
.ring-text { fill: #fff; }


/* ======== v6 design: Practice paper (winner of the /design bracket; see design.md) ======== */
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/source-serif-4-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/source-serif-4-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/source-sans-3-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/source-sans-3-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/source-sans-3-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/source-sans-3-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* Direction B - Practice paper (ref: tian zi ge exercise books, seal red) */
:root {
  --red: #a8321f; --red-dark: #7d2414; --ink: #2a2521; --muted: #625a52; --bg: #f8f4ec; --card: #fffdf8;
  --line: #e2d8c6; --page: #efe8da; --surface: #fffdf8; --soft: #f6e7e1; --soft2: #f4efe4; --solid: #2a2521;
  --radius: 4px; --shadow: none; --focus: #1d4ed8; --seal: #a8321f; --solid-sub: #e3d9c6;
}
body { font-family: "Source Sans 3", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif; font-size: 16px; }
h1, h2, .brand, .hero .big, .tile b { font-family: "Source Serif 4", "Noto Serif CJK SC", serif; font-weight: 600; letter-spacing: -0.01em; }
.logo { background: var(--seal); border-radius: 3px; font-family: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.card { border: 1px solid var(--line); box-shadow: none; border-radius: 4px; }
.hero { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-top: 3px solid var(--red); }
.hero .label { color: var(--muted); opacity: 1; }

.tile { border: 1px solid var(--line) !important; }
.tile.primary { background: var(--seal); border-color: var(--seal) !important; color: #fff; }
.btn { box-shadow: none; border-radius: 4px; font-weight: 600; }
.btn:active { transform: none; box-shadow: none; }
.btn.ghost { border: 1px solid var(--ink); box-shadow: none; background: transparent; }
.btn.dark { box-shadow: none; }
.progress { height: 4px; border-radius: 0; }
.progress > div { background: var(--red); border-radius: 0; }
.bars .bar i { background: var(--red); border-radius: 0; }
.tabbar { background: var(--card); }
.tabbar a.active { background: transparent; color: var(--red); box-shadow: inset 0 -2px 0 var(--red); border-radius: 0; }
.hanzi-big { color: var(--ink); font-family: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif; width: 168px; height: 168px; margin: 8px auto; display: grid; place-items: center; font-size: 112px;
  background:
    linear-gradient(45deg, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)),
    linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat;
  border: 1.5px solid var(--red); }
.chip, .option, .tone-btn { border-width: 1px; border-radius: 4px; }
.pill { border-radius: 3px; }
.mascot { filter: saturate(.85); }
@media (min-width: 1000px) {
  #app { max-width: 760px; padding-bottom: 40px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding-top: 56px; }
  .tabbar { top: 0; bottom: auto; max-width: 760px; grid-template-columns: repeat(6, auto); justify-content: center; gap: 8px; border-top: none; border-bottom: 1px solid var(--line); padding: 8px; }
  .tabbar a { flex-direction: row; gap: 8px; font-size: 15px; padding: 8px 14px; }
  main { padding: 8px 48px 24px; }
  .topbar { padding: 18px 48px 8px; }
}

.hero .ring-track { stroke: var(--line); }
.hero .ring-fill { stroke: var(--red); }
.hero .ring-text { fill: var(--ink); }

.btn { background: var(--seal); }
.btn.dark { background: var(--solid); }
.bubble.me { background: var(--seal); }
.hero .ring-track { stroke: var(--line); }
.hero .ring-fill { stroke: var(--red); }
.hero .ring-text { fill: var(--ink); }
.logo { color: #fff; }

:root[data-theme="dark"] {
  --ink: #ece6dc; --muted: #b3a999; --bg: #1a1815; --card: #221f1b; --line: #3a342d; --page: #12100e;
  --surface: #2a2620; --soft: #3a2520; --soft2: #2a2620; --ok-bg: #17301f; --bad-bg: #3a1d19; --blue-bg: #1d2638;
  --ok-ink: #8fd8a8; --blue-ink: #a9c1ff; --red: #f08a74; --red-dark: #f5b3a3; --solid: #3a342d; --solid-sub: #d8cfc2;
  --focus: #a9c1ff; --seal: #a8321f; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece6dc; --muted: #b3a999; --bg: #1a1815; --card: #221f1b; --line: #3a342d; --page: #12100e;
    --surface: #2a2620; --soft: #3a2520; --soft2: #2a2620; --ok-bg: #17301f; --bad-bg: #3a1d19; --blue-bg: #1d2638;
    --ok-ink: #8fd8a8; --blue-ink: #a9c1ff; --red: #f08a74; --red-dark: #f5b3a3; --solid: #3a342d; --solid-sub: #d8cfc2;
    --focus: #a9c1ff; --seal: #a8321f; color-scheme: dark;
  }
}

/* practice-grid cells: one tian zi ge square per character */
.hanzi-big { width: auto; height: auto; border: none; background: none; display: flex; justify-content: center; margin: 10px auto; font-size: 92px; line-height: 1; }
.hanzi-big[data-len="2"] { font-size: 80px; }
.hanzi-big[data-len="3"] { font-size: 60px; }
.hanzi-big[data-len="4"] { font-size: 50px; }
.hanzi-big > span { display: flex; }
.hanzi-big [class^="t"], .hanzi-big:not(:has(span)) {
  width: 1.3em; height: 1.3em; display: grid; place-items: center;
  background:
    linear-gradient(45deg, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)),
    linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat,
    linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat;
  border: 1.5px solid var(--red);
}
.hanzi-big [class^="t"] + [class^="t"] { margin-left: -1.5px; }
.mascot { animation: none !important; }
.say-bubble { border-radius: 4px; }

/* desktop: one header row (brand, centred tabs, stats), 960px paper column */
@media (min-width: 1000px) {
  #app { max-width: 960px; padding-top: 64px; }
  .topbar { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: 960px; height: 64px; padding: 0 28px; z-index: 11; background: var(--card); border-bottom: 1px solid var(--line); }
  .tabbar { top: 0; height: 64px; left: 50%; transform: translateX(-50%); width: auto; max-width: none; z-index: 12; background: transparent; border: none; padding: 0; align-content: center; }
  .tabbar a { height: 64px; padding: 0 14px; }
  main { max-width: 760px; margin: 0 auto; padding: 24px 0 32px; }
}

.mt-tag { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 4px; vertical-align: 1px; }


/* ======== v7: HSK mock exam (exam_ui.js) + shared utilities ======== */
.small { font-size: 14px; }
.h3 { font-size: 17px; margin: 0 0 10px; }
.lead { margin-top: -4px; max-width: 60ch; }
.right { text-align: right; }
.tight { margin: 6px 0 0; }
.note { line-height: 1.5; margin: 18px 2px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.row.between { justify-content: space-between; align-items: center; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 10px; margin: 14px 0; }
.pill.red { background: var(--bad-bg); color: var(--red-dark); }

.seg { display: flex; gap: 0; margin: 14px 0; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--surface); }
.seg-btn { flex: 1; min-height: 44px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--ink); color: var(--bg); }

.paper-card .paper-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.paper-card h2 { margin: 0; font-size: 22px; }
.paper-table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; font-variant-numeric: tabular-nums; }
.paper-table th, .paper-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.paper-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.paper-table tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.paper-table .num { text-align: right; width: 72px; }
.paper-table tr.weak td:first-child { box-shadow: inset 3px 0 0 var(--red); padding-left: 10px; }
.practice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.resume-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-left: 3px solid var(--red); }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 64px 1fr 44px auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.history li:last-child { border-bottom: 0; }
.hist-bar, .rs-bar { height: 6px; background: var(--line); display: block; }
.hist-bar span, .rs-bar span { display: block; height: 100%; background: var(--muted); }
.hist-bar span.ok, .rs-bar span { background: var(--ink); }

/* runner */
.exam-run { display: flex; flex-direction: column; min-height: calc(100vh - 180px); }
.ex-bar { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 4px 0 8px; }
.ex-bar-left { display: flex; flex-direction: column; line-height: 1.25; }
.ex-bar-right { display: flex; align-items: center; gap: 6px; }
.ex-clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.ex-clock.low { color: #fff; background: var(--seal); border-color: var(--seal); }
.ex-clock.practice { color: var(--muted); font-weight: 600; }
.progress.thin { height: 3px; margin: 0 0 12px; }
.ex-ins { font-size: 14px; color: var(--muted); margin: 0 0 12px; padding: 8px 12px; background: var(--soft2); border-left: 3px solid var(--line); }
.ex-body { flex: 1; }
.ex-passage { background: var(--card); border: 1px solid var(--line); padding: 14px 16px; margin-bottom: 12px; max-height: 46vh; overflow: auto; }
.ex-passage.long { max-height: none; }
.ex-line { margin: 0 0 6px; font-size: 18px; line-height: 1.75; }
.ex-line:last-child { margin-bottom: 0; }
.ex-stem, .ex-word { font-size: 20px; line-height: 1.7; margin: 10px 0 14px; text-align: center; }
.ex-word { font-size: 26px; }
.ex-stem .ex-py, .ex-word .ex-py, .ex-bank .ex-py, .ex-chip .ex-py { display: block; font-size: 13px; color: var(--muted); line-height: 1.2; letter-spacing: .02em; }
.ex-q { font-size: 18px; font-weight: 600; margin: 12px 0 8px; }
.ex-stmt { font-size: 18px; margin: 12px 0; padding: 10px 12px; border: 1px dashed var(--line); }
.ex-choices { display: grid; gap: 8px; margin: 8px 0 14px; }
.ex-choices.grid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.ex-choices.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ex-choice { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; text-align: left; font: inherit; font-size: 17px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.ex-choices.grid .ex-choice { justify-content: center; text-align: center; }
.ex-choices.compact .ex-choice { font-weight: 700; padding: 10px 0; }
.ex-choice:hover { border-color: var(--muted); }
.ex-choice.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--soft2); }
.ex-choice .pic { color: var(--ink); }
.ex-letter { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 3px; font-size: 13px; font-weight: 700; color: var(--muted); font-family: "Source Sans 3", sans-serif; }
.ex-choice.on .ex-letter { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ex-pic-solo { display: grid; place-items: center; margin: 6px 0 10px; color: var(--ink); }
.ex-pic-solo .pic { padding: 18px; border: 1px solid var(--line); background: var(--card); width: 150px; height: 150px; }
.ex-pic-solo.small .pic { width: 72px; height: 72px; padding: 8px; }
.ex-pic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.ex-pic-grid figure, .ex-pic-row figure { margin: 0; position: relative; display: grid; place-items: center; padding: 10px 6px 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.ex-pic-grid .ex-letter, .ex-pic-row .ex-letter { position: absolute; top: 4px; left: 4px; min-width: 20px; height: 20px; font-size: 11px; }
.ex-pic-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.ex-pic-row figure { padding: 8px 8px 6px 22px; }
.ex-audio { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 4px 0 14px; border: 1px solid var(--line); background: var(--card); }
.ex-audio-ic { color: var(--seal); display: grid; }
.ex-audio .btn { margin-left: auto; }
.ex-bank { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.ex-bank li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); background: var(--card); font-size: 17px; }
.ex-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.ex-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); background: var(--card); font-size: 17px; }
.ex-order { display: grid; gap: 8px; margin: 8px 0; }
.ex-seg { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-size: 17px; line-height: 1.6; color: var(--ink); cursor: pointer; border-radius: 4px; }
.ex-seg.used { border-color: var(--ink); background: var(--soft2); }
.ex-seg.used .ex-letter { background: var(--ink); color: var(--bg); }
.ex-built { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; padding: 10px 12px; margin: 8px 0 12px; border-bottom: 2px solid var(--ink); min-height: 48px; font-size: 18px; }
.ex-built.tall { justify-content: flex-start; min-height: 60px; }
.ex-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.ex-tile { padding: 10px 14px; font: inherit; font-size: 19px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); cursor: pointer; min-height: 44px; }
.ex-tile.used { opacity: .35; }
.ex-tile.on { background: var(--soft2); border-color: var(--ink); }
.ex-blank { display: inline-flex; flex-direction: column; align-items: center; vertical-align: bottom; margin: 0 4px; }
.ex-char { width: 2.6em; text-align: center; font-size: 22px; padding: 4px; border: 0; border-bottom: 2px solid var(--ink); background: transparent; color: var(--ink); }
.ex-text { width: 100%; box-sizing: border-box; font: inherit; font-size: 18px; line-height: 1.7; padding: 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); resize: vertical; }
.ex-text:focus, .ex-char:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.ex-readbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--soft2); font-variant-numeric: tabular-nums; }
.ex-readbar .btn { margin-left: auto; }
.ex-feedback { padding: 12px 14px; margin: 4px 0 12px; border: 1px solid var(--line); border-left-width: 3px; background: var(--card); display: grid; gap: 4px; }
.ex-feedback.ok { border-left-color: var(--ok-ink); background: var(--ok-bg); }
.ex-feedback.bad { border-left-color: var(--red); background: var(--bad-bg); }
.ex-feedback p { margin: 2px 0; }
.ex-foot { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); margin-top: 8px; }
.ex-foot .btn.on { background: var(--soft2); border-color: var(--ink); }
.ex-foot .btn[disabled] { opacity: .4; cursor: not-allowed; }
.ex-intro { max-width: 560px; margin: 0 auto; }
.ex-intro h1 { margin: 0 0 4px; }
.ex-intro-meta { color: var(--muted); margin: 0 0 12px; }
.ex-parts { padding-left: 0; list-style: none; margin: 0 0 14px; display: grid; gap: 10px; }
.ex-parts li { padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); }
.ex-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(20, 16, 12, .45); }
.ex-dialog .card { width: min(440px, 100%); margin: 0; }
.ex-dialog .row { gap: 8px; margin-top: 12px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin: 10px 0; max-height: 50vh; overflow: auto; }
.sheet-cell { height: 44px; font: inherit; font-weight: 600; font-variant-numeric: tabular-nums; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 3px; cursor: pointer; position: relative; }
.sheet-cell.done { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sheet-cell.flag::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--seal); }
.sheet-cell.here { outline: 2px solid var(--seal); outline-offset: 1px; }
.sheet-cell[disabled] { cursor: default; }

/* results */
.result-hero { text-align: center; border-top: 3px solid var(--red); }
.result-score .big { font-family: "Source Serif 4", serif; font-size: 56px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.result-sections { display: grid; gap: 10px; margin: 16px auto 6px; max-width: 420px; text-align: left; }
.rs-row { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.rs-row b { text-align: right; }
.review-wrap { margin-top: 18px; }
.review-card { border-left: 3px solid var(--line); }
.review-card.ok { border-left-color: var(--ok-ink); }
.review-card.bad { border-left-color: var(--red); }
.review-stim .ex-line { font-size: 16px; margin-bottom: 2px; }
.review-card p { margin: 6px 0; }
details.review-card { padding: 0; margin-bottom: 8px; }
details.review-card.est { border-left-color: var(--muted, #8a8a8a); }
details.review-card > summary {
  list-style: none; cursor: pointer; display: grid; align-items: center; gap: 10px;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, max-content) 16px; padding: 12px 14px; min-height: 48px;
}
details.review-card > summary::-webkit-details-marker { display: none; }
details.review-card > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.rv-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.rv-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-ans { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.rv-caret { display: inline-flex; transition: transform .15s ease; color: var(--muted); }
details.review-card[open] .rv-caret { transform: rotate(90deg); }
.rv-body { padding: 0 14px 14px 54px; border-top: 1px solid var(--line); padding-top: 10px; }
.rv-body > .btn { margin-bottom: 6px; }
@media (max-width: 420px) { .rv-body { padding-left: 14px; } }

@media (max-width: 420px) {
  .ex-choices.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ex-bar { grid-template-columns: 1fr auto; }
  .ex-bar-mid { display: none; }
  .history li { grid-template-columns: 56px 1fr 40px; }
  .history li .pill { display: none; }
}
@media (min-width: 1000px) {
  .exam-run { min-height: auto; }
  .ex-pic-grid { grid-template-columns: repeat(6, 1fr); }
}
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 6px; }
.back-link:hover { color: var(--ink); }

/* v7: focus mode while a mock section runs - no tab bar, footer sits on the screen edge */
body.exam-focus .tabbar { display: none; }
body.exam-focus #app { padding-bottom: 16px; }
body.exam-focus .exam-run { min-height: calc(100vh - 96px); }

/* v7 polish: consistent focus ring, link-buttons without underline, level chips on one row */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
a.btn, a.btn:hover, .btn u { text-decoration: none; }
.level-chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 12px 0; }
.level-chips .chip { justify-content: center; padding-left: 0; padding-right: 0; white-space: nowrap; }
.chip svg, .btn svg { flex: none; }


/* ======== v8: Nada the guide (bakpao mascot, today's queue, floating helper) ======== */
.m-shadow { fill: rgba(0, 0, 0, 0.08); }
.m-body, .m-arm { fill: #fbf1e1; stroke: #e6d3b5; stroke-width: 1.5; }
.m-pleat { fill: none; stroke: #dcc49f; stroke-width: 1.6; stroke-linecap: round; }
.m-seal { fill: var(--seal); }
.m-blush { fill: #f2a49a; opacity: 0.7; }
.m-ink { fill: none; stroke: #2b2420; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.m-ink-fill { fill: #2b2420; }
.m-mouth { fill: #7a2a1e; }
.m-dot { fill: var(--muted); }
:root[data-theme="dark"] .m-shadow { fill: rgba(0, 0, 0, 0.35); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .m-shadow { fill: rgba(0, 0, 0, 0.35); }
}

.guide { padding: 18px; border-top: 3px solid var(--seal); }
.guide-head { display: flex; align-items: center; gap: 14px; }
.guide-head .mascot { margin: 0; }
.guide-say { flex: 1; min-width: 0; }
.guide-name { margin: 0 0 2px; font-size: 13px; color: var(--muted); letter-spacing: 0.02em; }
.guide-name b { color: var(--ink); font-family: "Source Serif 4", "Noto Serif CJK SC", serif; font-size: 16px; margin-right: 4px; }
.guide-line { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink); }
.guide-next { margin-top: 16px; min-height: 52px; font-size: 16px; justify-content: flex-start; padding-left: 18px; }
.guide-why { margin: 8px 2px 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.guide-why span { font-weight: 600; color: var(--ink); }
.guide-done { margin-top: 14px; padding: 12px 14px; background: var(--ok-bg); color: var(--ok-ink); border-radius: 4px; }
.guide-done b { display: block; margin-bottom: 8px; }
.guide-extra { flex-wrap: wrap; gap: 8px; }
.guide-extra .btn { color: var(--ink); min-height: 44px; }
.guide-plan { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.guide-plan-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.guide-plan-head .muted { font-weight: 400; }
.guide-bar { height: 4px; background: var(--line); margin-bottom: 6px; }
.guide-bar i { display: block; height: 100%; background: var(--seal); transition: width 0.4s ease; }
.guide-steps { list-style: none; margin: 0; padding: 0; }
.guide-steps li { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
.guide-steps li:last-child { border-bottom: none; }
.gs-mark { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); }
.gs-title { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; padding: 12px 0; font-size: 15px; }
.gs-title:hover { text-decoration: underline; }
.gs-min { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.guide-steps li.next .gs-mark { border-color: var(--seal); background: var(--seal); color: #fff; }
.guide-steps li.next .gs-title { font-weight: 600; }
.guide-steps li.done .gs-mark { border-color: var(--ok-ink); background: var(--ok-bg); color: var(--ok-ink); }
.guide-steps li.done .gs-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

/* hand-off strip on every session-complete screen */
.guide-after { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--seal); border-radius: 4px; }
.guide-after .mascot { margin: 0; animation: none; }
.guide-after-body { flex: 1; min-width: 0; }
.guide-after-title { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.guide-after-body .small { margin: 2px 0 0; color: var(--ink); font-size: 15px; }
.guide-after .btn { flex: none; min-height: 44px; }

/* floating Nada on the other screens */
.nada-fab {
  position: fixed; z-index: 11; right: max(16px, calc(50% - 240px + 16px)); bottom: calc(84px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 50%; box-shadow: 0 4px 14px rgba(42, 37, 33, 0.14);
}
.nada-fab .mascot { animation: none; margin: 0; }
.nada-fab:hover { border-color: var(--seal); }
.nada-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--seal); color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--card);
}
.nada-sheet { position: fixed; inset: 0; z-index: 30; background: rgba(20, 16, 12, 0.42); display: flex; align-items: flex-end; justify-content: center; }
.nada-sheet-card {
  width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto; background: var(--bg); color: var(--ink);
  border-radius: 12px 12px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: nada-sheet-in 0.22s ease-out;
}
.nada-sheet-card .guide-head .icon-btn { align-self: flex-start; }
.guide-tip { margin-top: 14px; padding: 12px 14px; background: var(--soft2); border-radius: 4px; }
.guide-tip b { font-size: 13px; }
.guide-tip p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.guide-honest { margin: 14px 0 0; font-size: 12px; line-height: 1.5; }
@keyframes nada-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .nada-sheet-card { animation: none; } .guide-bar i { transition: none; } }
body.exam-focus .nada-fab { display: none; }
@media (min-width: 1000px) {
  .nada-fab { right: max(24px, calc(50% - 380px - 80px)); bottom: 32px; }
  .nada-sheet { align-items: center; }
  .nada-sheet-card { border-radius: 8px; max-width: 520px; }
  .guide { padding: 22px 24px; }
}

/* v8 home: one compact stats strip under Nada's plan */
.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; }
.hs-item { display: flex; align-items: center; gap: 10px; padding: 14px 12px; min-height: 72px; color: inherit; text-decoration: none; border-right: 1px solid var(--line); }
.hs-item:last-child { border-right: none; }
.hs-item:hover { background: var(--soft2); }
.hs-item svg { flex: none; }
.hs-item b { display: block; font-size: 15px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hs-item small { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
.hs-num { flex: none; font-family: "Source Serif 4", "Noto Serif CJK SC", serif; font-size: 26px; font-weight: 600; line-height: 1; color: var(--red); font-variant-numeric: tabular-nums; }
.home-stats .ring-track { stroke: var(--line); }
.home-stats .ring-fill { stroke: var(--seal); }
.memory-num { font-family: "Source Serif 4", "Noto Serif CJK SC", serif; font-size: 34px; font-weight: 600; line-height: 1; }
@media (max-width: 380px) {
  .hs-item { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* v8 round 2: bakpao steam, Nada speaks in a bubble, desktop home in two columns */
.m-steam { fill: none; stroke: #d9c7aa; stroke-width: 1.6; stroke-linecap: round; opacity: 0.9; }
.guide > .guide-head .guide-say { position: relative; background: var(--soft2); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.guide > .guide-head .guide-say::before {
  content: ""; position: absolute; left: -7px; top: 24px; width: 12px; height: 12px; background: var(--soft2);
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg);
}
.guide-steps li { min-height: 44px; }
.gs-title { padding: 10px 0; }
@media (min-width: 1200px) {
  body[data-route="home"] #app { max-width: 1080px; }
  body[data-route="home"] .tabbar { max-width: 1080px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .home-grid .card { margin-bottom: 16px; }
  .home-side .home-stats { grid-template-columns: 1fr; }
  .home-side .hs-item { border-right: none; border-bottom: 1px solid var(--line); }
  .home-side .hs-item:last-child { border-bottom: none; }
  .home-side .offline-note { text-align: left; }
}

/* v8 round 3: a clear, rewarding all-done state */
.guide-done { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--ok-ink) 30%, transparent); }
.guide-done b { margin: 0 0 2px; font-family: "Source Serif 4", "Noto Serif CJK SC", serif; font-size: 17px; font-weight: 600; }
.guide-done p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
.gd-check { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-ink); color: var(--card); }
.guide-extra { margin-top: 12px; }
.guide-extra .btn { flex: 1 1 0; }

/* v8 round 4: calmer vocabulary rows, livelier cheer */
.v-pct { flex: none; min-width: 40px; text-align: right; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.m-spark { fill: none; stroke: var(--seal); stroke-width: 2; stroke-linecap: round; }

/* v8 round 5: next step visible without a tap on hub screens */
.nada-fab.nada-pill {
  width: auto; max-width: min(320px, calc(100vw - 32px)); height: 56px; padding: 0 16px 0 8px;
  display: flex; align-items: center; gap: 8px; border-radius: 28px; text-align: left;
}
.nada-pill-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.nada-pill-text small { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.nada-pill-text b { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nada-pill .nada-badge { top: -4px; right: -4px; }
#app { padding-bottom: 156px; }
@media (min-width: 1000px) { #app { padding-bottom: 96px; } }
.gs-min { font-size: 13px; }

/* v8 round 6: the next step is the first queue row, the pill tucks while scrolling, stats join the plan */
.guide-head + .guide-plan { margin-top: 16px; }
.guide-steps li.merged { display: block; padding: 6px 0 12px; }
.guide-steps li.merged .guide-next { margin-top: 0; min-height: 52px; gap: 12px; padding: 0 16px 0 12px; }
.guide-steps li.merged .gs-mark { border-color: rgba(255, 255, 255, 0.7); background: transparent; color: #fff; }
.gn-title { flex: 1; min-width: 0; text-align: left; font-size: 16px; font-weight: 600; }
.gn-min { flex: none; font-size: 13px; font-weight: 500; opacity: 0.85; font-variant-numeric: tabular-nums; }
.guide-steps li.merged .guide-why { margin: 8px 2px 0; }
.nada-sheet-card .guide-plan { margin-top: 14px; }
.nada-fab.nada-pill.tucked { width: 56px; padding: 0; justify-content: center; gap: 0; }
.nada-pill.tucked .nada-pill-text { display: none; }
@media (max-width: 1199px) {
  .home-main .guide { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .home-side > .home-stats:first-child { border-top: none; border-top-left-radius: 0; border-top-right-radius: 0; background: var(--soft2); }
  .home-side > .home-stats:first-child .hs-item:hover { background: var(--card); }
}

/* v8 round 7: the reason reads as part of the step, legible stats, steam visible at button size */
.guide-steps li.merged .guide-why { margin: 0; padding: 8px 12px; background: var(--soft2); border-radius: 0 0 4px 4px; color: var(--ink); }
.guide-steps li.merged .guide-next { border-radius: 4px 4px 0 0; }
.guide-why span { color: var(--seal); }
.hs-item { padding: 16px 12px; min-height: 80px; }
.hs-item b { font-size: 17px; }
.hs-item small { font-size: 13px; }
.hs-num { font-size: 28px; }
.hs-item b { white-space: nowrap; }
.hs-item { gap: 8px; }
.nada-fab .m-steam, .guide-after .m-steam { stroke-width: 2.6; stroke: #c9ae86; }

/* v8 round 8: on vocabulary only the tile for Nada's next step is filled */
.grid2 .tile { position: relative; }
.tile.quiet { background: var(--card); }
.tile.quiet b { font-size: 14px; font-weight: 600; }
.tile.quiet .ic { color: var(--muted); }
.tile-next {
  position: absolute; top: 10px; right: 10px; padding: 2px 8px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.2); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}

/* v9 round 10: one accent with intent. Red marks actions and things that need you; numbers are ink. */
.hs-num { color: var(--ink); }
.v-meter { margin-top: 6px; height: 4px; background: var(--line); }
.v-meter i { display: block; height: 100%; background: var(--ink); opacity: 0.55; }
.v-meter.fading i { background: var(--seal); opacity: 1; }
.v-pct.fading { color: var(--seal); }
.list-item .zh { color: var(--ink); }

/* v9: Nada sits on bakpao steamer paper stamped with the app's seal */
.m-paper { fill: #f3e8d2; stroke: #dcc8a6; stroke-width: 1.2; stroke-linejoin: round; }
:root[data-theme="dark"] .m-paper { fill: #4a4136; stroke: #6b5d4b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .m-paper { fill: #4a4136; stroke: #6b5d4b; } }

.ex-after-nada { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.ex-after-nada .mascot { animation: none; margin: 0; }
.ex-after-nada b { color: var(--ink); font-weight: 600; }

@media (max-width: 480px) {
  .home-stats .hs-item { flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 12px 12px; min-height: 84px; }
  .home-stats .hs-item:first-child { flex-direction: row; align-items: center; }
  .home-stats .hs-num { font-size: 24px; }
  .home-stats .hs-item b { font-size: 14px; }
}
.v-meter i { opacity: 0.32; }

/* v9 round 11: the queue visibly moves on; exam home follows Nada's pick */
@keyframes gs-pop { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); } }
.guide-steps li.just-done .gs-mark { animation: gs-pop 0.5s ease-out 0.15s both; }
@media (prefers-reduced-motion: reduce) { .guide-steps li.just-done .gs-mark { animation: none; } }
.tile-next.inline { position: static; margin-left: 8px; vertical-align: 1px; }
.practice-row .btn.nada-pick { min-height: 44px; }

/* v10: HSKK speaking mock */
.seg.seg-small { margin: 10px 0; }
.seg.seg-small .seg-btn { min-height: 38px; font-size: 14px; }
.hskk-card .paper-table td span[lang] { font-weight: 600; }
.hk-item, .hk-prep, .hk-intro { max-width: 620px; margin: 0 auto; }
.hk-part-title { font-size: 18px; margin: 2px 0 2px; }
.hk-prompt { margin: 16px 0 12px; min-height: 96px; display: flex; flex-direction: column; justify-content: center; }
.hk-listen { display: flex; align-items: center; gap: 10px; color: var(--muted); justify-content: center; padding: 22px 0; border: 1px dashed var(--line); border-radius: var(--radius); }
.hk-q { font-size: 20px; line-height: 1.5; margin: 6px 0; }
.hk-q .ex-py { font-size: 14px; }
.hk-passage { font-size: 19px; line-height: 1.9; margin: 0; padding: 14px 16px; background: var(--soft); border-radius: var(--radius); }
.hk-scene { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.hk-scene.small { justify-content: flex-start; padding: 6px 8px; gap: 8px; margin-bottom: 6px; }
.hk-rec { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font-weight: 600; }
.hk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.hk-rec.on .hk-dot { background: var(--red); animation: hk-pulse 1.2s ease-in-out infinite; }
@keyframes hk-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .hk-rec.on .hk-dot { animation: none; } }
.hk-clock { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 18px; }
.hk-meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 14px; }
.hk-meter i { display: block; height: 100%; width: 0; background: var(--ink); opacity: .45; transition: width .1s linear; }
.hk-prep-head { align-items: baseline; }
.hk-prep-part { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.hk-part-label { margin: 0 0 6px; font-size: 14px; }
.hk-review-part h2 { margin: 0; }
.hk-rev-list { list-style: none; padding: 0; margin: 8px 0 0; counter-reset: hk; }
.hk-rev-item { border-top: 1px solid var(--line); padding: 12px 0; }
.hk-rev-text { margin: 0 0 6px; display: flex; flex-direction: column; gap: 2px; }
.hk-rev-text span[lang] { font-size: 18px; }
.hk-model { margin: 4px 0 8px; font-size: 14px; }
.hk-model summary { cursor: pointer; color: var(--muted); }
.hk-model p { margin: 6px 0 0; display: flex; flex-direction: column; gap: 2px; }
.hk-rev-audio { gap: 10px; flex-wrap: wrap; align-items: center; }
.hk-rev-audio audio { height: 36px; max-width: 100%; }
.hk-rev-foot { gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.hk-rate { margin: 0; min-width: 210px; }
.hk-review-foot { position: sticky; bottom: 76px; display: flex; align-items: center; gap: 12px; z-index: 3; }
.hk-score { margin: 6px 0 10px; }
.hk-score b { font-size: 56px; font-family: "Source Serif 4"; line-height: 1; }
.hk-score span { color: var(--muted); margin-left: 6px; }
.hk-part-scores { list-style: none; padding: 0; margin: 16px 0 8px; text-align: left; }
.hk-part-scores li { display: grid; grid-template-columns: 1fr 90px 36px 36px; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.hk-bar { height: 6px; background: var(--line); display: block; }
.hk-bar i { display: block; height: 100%; background: var(--ink); opacity: .55; }
.hk-result-actions { justify-content: center; gap: 10px; margin: 12px 0 24px; }
@media (max-width: 480px) {
  .hk-part-scores li { grid-template-columns: 1fr 60px 32px 32px; }
  .hk-rate { min-width: 0; width: 100%; }
  .hk-q { font-size: 18px; }
  .hk-passage { font-size: 17px; }
}
body.hskk-on .nada-fab { display: none; }

/* v10 round 14: calmer HSKK review/result and exam home */
.hk-parts-detail { margin: 10px 0 4px; }
.hk-parts-detail > summary,
.hk-rubric > summary,
.hk-rev-long > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 6px 0;
  list-style-position: inside;
}
.hk-parts-detail[open] > summary,
.hk-rubric[open] > summary { color: var(--ink); }
.hk-rubric { margin: 2px 0 6px; }
.hk-rev-long > summary [lang="zh-CN"] { font-size: 1.05rem; color: var(--ink); }
.hk-focus { margin-top: 14px; }
.hk-focus .h3 { margin: 2px 0 6px; }
.hk-focus p.small { margin: 0 0 10px; }
.hk-result-actions { justify-content: center; gap: 22px; margin-top: 14px; }
.btn-text {
  background: none;
  border: 0;
  padding: 10px 4px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-text:hover,
.btn-text:focus-visible { color: var(--ink); }

/* v10 round 15: 44px tap targets in compact segments; room between the live meter and 'Done, next' */
.seg-small .seg-btn,
.hk-rate .seg-btn { min-height: 44px; }
.hk-meter { margin: 10px 0 28px; }

/* v10.1: linked official sample papers */
.papers-card summary { cursor: pointer; list-style-position: inside; }
.papers-card summary .h3 { display: inline; margin: 0; }
.papers-list { list-style: none; margin: 10px 0 8px; padding: 0; }
.papers-list li { border-top: 1px solid var(--line); line-height: 1.4; }
.papers-list li:last-child { border-bottom: 1px solid var(--line); }
.papers-list a { display: block; padding: 11px 0; color: var(--ink); text-underline-offset: 3px; }
.papers-card .tiny { font-size: 0.8rem; }
