/* ===========================================================================
   Hanzi Master — "the scholar's studio" design system (2026-07 redesign)
   Ink · gold · one ceremonial seal-red. Editorial layout over card walls.
   Signature motif: the 田字格 practice square (drawn in pure CSS).
   =========================================================================== */
/* Two themes, one system (toggle in the topbar; default DARK):
   • DARK  = 黑金 "black & gold" — deep near-black paper, warm gold accent
     (--accent #d8b873), the original beloved look.
   • LIGHT = 墨朱 "ink & cinnabar" — porcelain paper, one vermilion accent.
   Everything is driven by CSS vars, so the whole app re-skins on toggle.
   The brand wordmark + .uic icons recolour per theme via --brand-ink / --ui-icon
   (gold on dark, cinnabar on light) instead of showing a flat black negative. */
:root{
  --bg:#faf7f0; --card:#fffefb; --card-2:#f3f0e7; --ink:#1e1c17; --muted:#6f6b60;
  --line:#e7e2d5; --line-strong:#d6d0bf; --stroke-outline:#c5bfae;
  --accent:#c23f27; --accent-soft:rgba(194,63,39,.10); --accent-ink:#a33115;
  --seal:#96291a; --seal-soft:rgba(150,41,26,.10);
  --grad-gold:linear-gradient(180deg,#d95b3e,#bd3a22);
  --good:#22a377; --good-soft:#e2f4ec; --bad:#d94a4f; --bad-soft:#fbecec;
  --warn:#d28f1f;
  --shadow:0 10px 30px rgba(40,30,20,.10); --shadow-sm:0 2px 8px rgba(40,30,20,.06);
  --t1:#c93a35; --t2:#cf8619; --t3:#31875a; --t4:#3c63c4; --t5:#8a877d;
  --tz:rgba(194,63,39,.22);
  --radius:12px; --radius-lg:16px; --tap:48px; --ui-icon:#c23f27; --brand-ink:#c23f27;
  --serif:'Fraunces',Georgia,'Times New Roman',serif;
  --sans:'Spline Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
}
@media (prefers-color-scheme: dark){
  :root{ --bg:#0a0a0c; --card:#16151b; --card-2:#100f14; --ink:#f5f1e8; --muted:#9b958a;
    --line:#272219; --line-strong:#3a3324; --stroke-outline:#585041;
    --accent:#d8b873; --accent-soft:rgba(216,184,115,.13); --accent-ink:#f1dca0;
    --seal:#c39a45; --seal-soft:rgba(195,154,69,.16);
    --good:#33c08e; --good-soft:#13261f; --bad:#ff6b6f; --bad-soft:#341a1c;
    --warn:#e8961e;
    --shadow:0 12px 34px rgba(0,0,0,.55); --shadow-sm:0 3px 12px rgba(0,0,0,.4);
    --t1:#ff6b6b; --t2:#f5b14d; --t3:#4fd07e; --t4:#6f9bff; --t5:#aab0c4;
    --grad-gold:linear-gradient(120deg,#e7c87e,#cda24e 58%,#b9923a);
    --tz:rgba(216,184,115,.18); --ui-icon:#d8b873; --brand-ink:#d8b873; }
}
html[data-theme="dark"]{ --bg:#0a0a0c; --card:#16151b; --card-2:#100f14; --ink:#f5f1e8; --muted:#9b958a;
  --line:#272219; --line-strong:#3a3324; --stroke-outline:#585041; --ui-icon:#d8b873;
  --accent:#d8b873; --accent-soft:rgba(216,184,115,.13); --accent-ink:#f1dca0;
  --seal:#c39a45; --seal-soft:rgba(195,154,69,.16);
  --good:#33c08e; --good-soft:#13261f; --bad:#ff6b6f; --bad-soft:#341a1c; --warn:#e8961e;
  --shadow:0 12px 34px rgba(0,0,0,.55); --shadow-sm:0 3px 12px rgba(0,0,0,.4);
  --t1:#ff6b6b; --t2:#f5b14d; --t3:#4fd07e; --t4:#6f9bff; --t5:#aab0c4;
  --grad-gold:linear-gradient(120deg,#e7c87e,#cda24e 58%,#b9923a);
  --tz:rgba(216,184,115,.18); --brand-ink:#d8b873; }
html[data-theme="light"]{ --bg:#faf7f0; --card:#fffefb; --card-2:#f3f0e7; --ink:#1e1c17; --muted:#6f6b60;
  --line:#e7e2d5; --line-strong:#d6d0bf; --stroke-outline:#c5bfae; --ui-icon:#c23f27; --brand-ink:#c23f27;
  --accent:#c23f27; --accent-soft:rgba(194,63,39,.10); --accent-ink:#a33115;
  --seal:#96291a; --seal-soft:rgba(150,41,26,.10);
  --good:#22a377; --good-soft:#e2f4ec; --bad:#d94a4f; --bad-soft:#fbecec; --warn:#d28f1f;
  --shadow:0 10px 30px rgba(40,30,20,.10); --shadow-sm:0 2px 8px rgba(40,30,20,.06);
  --t1:#c93a35; --t2:#cf8619; --t3:#31875a; --t4:#3c63c4; --t5:#8a877d;
  --tz:rgba(194,63,39,.22); }

/* Chinese text renders in a local CJK *serif* (Songti / Noto Serif / SimSun) so
   glyphs read like print, not system UI. Latin inside mixed prose stays in the
   body face: the .han stack starts with Spline Sans (no CJK glyphs → CJK falls
   through to the serif). No webfont download — local() only. */
@font-face{ font-family:"HanSerif"; src:local("Songti SC"), local("STSongti-SC-Regular"), local("STSong");
  unicode-range:U+2E80-303F,U+3400-9FFF,U+F900-FAFF,U+FE30-FE4F; }
@font-face{ font-family:"HanSerifN"; src:local("Noto Serif CJK SC"), local("Noto Serif SC"), local("NSimSun"), local("SimSun");
  unicode-range:U+2E80-303F,U+3400-9FFF,U+F900-FAFF,U+FE30-FE4F; }

*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg); color:var(--ink);
  font-family:var(--sans),"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  -webkit-font-smoothing:antialiased; line-height:1.55;
  padding-top:calc(56px + env(safe-area-inset-top));
  padding-bottom:calc(64px + env(safe-area-inset-bottom));
  overscroll-behavior-y:none;
}
.han{ font-family:'Spline Sans',"HanSerif","HanSerifN","Songti SC","SimSun","PingFang SC","Hiragino Sans GB","Microsoft YaHei",serif; }
button{ font-family:inherit; cursor:pointer; color:inherit; }
a{ color:inherit; text-decoration:none; }
::selection{ background:rgba(226,84,58,.25); }

/* ---- 田字格: the practice square, our signature motif (pure CSS) ---- */
.tzg{ position:relative; border:1px solid var(--tz); border-radius:10px; background:var(--card-2); }
.tzg::before{ content:""; position:absolute; inset:6%; pointer-events:none; opacity:.9;
  background:
    repeating-linear-gradient(to bottom, var(--tz) 0 5px, transparent 5px 11px) calc(50% - .5px) 0/1px 100% no-repeat,
    repeating-linear-gradient(to right,  var(--tz) 0 5px, transparent 5px 11px) 0 calc(50% - .5px)/100% 1px no-repeat; }
.tzg > *{ position:relative; z-index:1; }

/* ---- ambient background: one quiet enso, one faint warm glow ---- */
.bg-fx{ position:fixed; inset:0; z-index:0; pointer-events:none; overflow:hidden; }
.glow{ position:absolute; border-radius:50%; filter:blur(100px); opacity:.4; }
.glow-gold{ width:min(80vw,540px); height:min(80vw,540px); top:-190px; right:-150px;
  background:radial-gradient(circle, rgba(226,84,58,.12), transparent 65%); }
.glow-deep{ width:min(88vw,620px); height:min(88vw,620px); bottom:-260px; left:-220px;
  background:radial-gradient(circle, rgba(150,150,170,.08), transparent 65%); }
.enso{ position:absolute; top:-150px; right:-110px; width:min(92vw,520px); height:min(92vw,520px);
  border-radius:50%; border:1.5px solid rgba(226,84,58,.12);
  -webkit-mask:conic-gradient(from 200deg, transparent 0 8%, #000 12% 92%, transparent 96%);
  mask:conic-gradient(from 200deg, transparent 0 8%, #000 12% 92%, transparent 96%); }
html[data-theme="light"] .glow{ opacity:.5; }
html[data-theme="light"] .glow-gold{ background:radial-gradient(circle, rgba(194,63,39,.14), transparent 66%); }
html[data-theme="light"] .glow-deep{ background:radial-gradient(circle, rgba(120,120,140,.10), transparent 66%); }
html[data-theme="light"] .enso{ border-color:rgba(194,63,39,.20); }

/* ---- top bar: quiet, borderless, hairline below ---- */
.topbar{ position:fixed; top:0; left:0; right:0; z-index:40;
  background:color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line); padding-top:env(safe-area-inset-top); }
@supports not (background:color-mix(in srgb, red 50%, blue)){ .topbar{ background:var(--bg); } }
.topbar-inner{ height:56px; display:flex; align-items:center; justify-content:space-between; padding:0 16px; max-width:640px; margin:0 auto; }
.brand{ display:flex; align-items:center; }
/* Wordmark is a single alpha-masked element tinted by --brand-ink, so it
   recolours with the theme (gold on dark, cinnabar on light) — never a flat
   black "negative" of the gold original. */
.brand-logo{ height:38px; aspect-ratio:892 / 328; display:block;
  background-color:var(--brand-ink);
  -webkit-mask:url(/assets/logo-master.png?v=20260609b) center/contain no-repeat;
          mask:url(/assets/logo-master.png?v=20260609b) center/contain no-repeat; }
.topbar-right{ display:flex; align-items:center; gap:4px; }
.streak{ font-size:14px; font-weight:700; background:transparent; color:var(--ink); padding:6px 8px; border-radius:10px; }
.icon-btn{ border:none; background:transparent; color:var(--accent-ink); width:40px; height:40px; border-radius:10px; font-size:17px; display:grid; place-items:center; }
.icon-btn:active{ background:var(--accent-soft); }
/* "?" help → the mnemonic system */
.sys-help{ display:inline-flex; align-items:center; gap:8px; height:36px; padding:0 12px; border-radius:999px;
  background:transparent; color:var(--muted); border:1px solid var(--line);
  font-weight:600; font-size:12.5px; line-height:1; white-space:nowrap; }
.sys-help:active{ transform:scale(.96); }
.sys-help .sys-help-q{ display:grid; place-items:center; width:17px; height:17px; border-radius:50%;
  border:1.5px solid var(--accent); color:var(--accent-ink); background:transparent; font-size:11px; font-weight:800; flex:none; }
@media (max-width:560px){
  .sys-help{ width:36px; padding:0; gap:0; justify-content:center; border:none; }
  .sys-help .sys-help-label{ display:none; }
  .sys-help .sys-help-q{ width:22px; height:22px; font-size:13px; }
}
.progress-strip{ height:2px; background:transparent; }
.progress-strip-fill{ height:100%; width:0; background:var(--accent); opacity:.85; transition:width .5s ease; }

/* ---- layout ---- */
#app{ position:relative; z-index:1; max-width:640px; margin:0 auto; padding:20px 18px 8px; }
.view{ animation:fade .28s cubic-bezier(.22,.61,.36,1); }
@keyframes fade{ from{ opacity:0; transform:translateY(8px);} to{ opacity:1; transform:none;} }
@media (prefers-reduced-motion:reduce){ .view{ animation:none; } }
.h1{ font-family:var(--serif); font-size:31px; font-weight:600; letter-spacing:-.02em; line-height:1.12; margin:8px 0 14px; }
.sub{ color:var(--muted); font-size:14px; }
.card{ background:var(--card); border:1px solid var(--line); border-radius:var(--radius-lg); box-shadow:none; padding:18px; margin-bottom:14px; }
.row{ display:flex; gap:12px; }
.between{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.grid{ display:grid; gap:10px; }
.muted{ color:var(--muted); }
.center{ text-align:center; }

/* ---- buttons: flat, quiet, one gold primary ---- */
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:var(--tap);
  padding:0 18px; border-radius:var(--radius); border:1px solid var(--line-strong); background:transparent; color:var(--ink);
  font-weight:700; font-size:15px; transition:transform .08s ease, background .18s, border-color .18s; }
.btn:active{ transform:translateY(1px) scale(.99); }
.btn.primary{ background:var(--accent); border-color:var(--accent); color:#fff7f1; }
.btn.primary:active{ filter:brightness(.94); }
.btn.soft{ background:transparent; border-color:var(--line-strong); color:var(--accent-ink); }
.btn.good{ background:var(--good); border-color:var(--good); color:#fff; }
.btn.ghost{ background:transparent; border-color:transparent; color:var(--muted); }
.btn.block{ width:100%; }
.btn.lg{ min-height:54px; font-size:16px; }
.btn-row{ display:flex; gap:10px; flex-wrap:wrap; }
/* star toggle (character page) */
.btn.star-toggle{ background:transparent; border-color:var(--line-strong); color:var(--accent-ink); }
.btn.star-toggle .st-ic{ font-size:18px; line-height:1; color:var(--muted); }
.btn.star-toggle.on{ background:var(--accent); border-color:var(--accent); color:#fff7f1; }
.btn.star-toggle.on .st-ic{ color:#fff7f1; }
.btn.outline-toggle.on{ background:var(--accent); border-color:var(--accent); color:#fff7f1; }

/* ---- home: editorial header + quiet sections ---- */
.kicker{ font-size:11px; font-weight:800; letter-spacing:.18em; text-transform:uppercase; color:var(--accent-ink); margin:2px 0 8px; }
.home-head{ padding:10px 2px 20px; }
.home-head .h1{ font-size:34px; margin:0 0 8px; }
.home-head .sub{ font-size:15px; line-height:1.6; max-width:44ch; }
.home-head .btn-row{ margin-top:18px; }
.rule-sec{ border-top:1px solid var(--line); padding:16px 2px 4px; margin-top:6px; }
.hero{ background:transparent; border:none; }
.hero .h1{ color:var(--ink); }
.hero .sub{ color:var(--muted); }
.stat-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.stat{ background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:12px; text-align:center; }
.stat b{ font-family:var(--serif); font-size:27px; font-weight:600; display:block; color:var(--accent-ink); }
.stat span{ font-size:12px; color:var(--muted); }
.tile-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:14px 0; }
.tile{ background:var(--card); border:1px solid var(--line); border-radius:var(--radius-lg); padding:16px;
  box-shadow:none; display:flex; flex-direction:column; gap:6px; min-height:104px;
  transition:transform .1s ease, border-color .18s; }
.tile:active{ transform:scale(.985); }
.tile .ic{ font-size:24px; height:28px; display:flex; align-items:center; }
.tile b{ font-size:15.5px; letter-spacing:-.01em; }
.tile small{ color:var(--muted); font-size:12.5px; line-height:1.45; }
/* text row-link (e.g. "The mnemonic system") */
.rowlink{ display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:16px 2px; border-top:1px solid var(--line); border-bottom:1px solid var(--line); margin:4px 0 14px; }
.rowlink b{ font-size:15px; }
.rowlink .sub{ margin-top:2px; }
.rowlink .go{ flex:none; color:var(--accent-ink); font-size:20px; font-weight:700; }

/* ---- HSK level picker: an editorial index, ink + gold only ---- */
.levels{ display:flex; flex-direction:column; }
.level-btn{ display:flex; align-items:center; gap:16px; width:100%; text-align:left;
  padding:18px 4px; border:none; border-top:1px solid var(--line); background:transparent;
  border-radius:0; box-shadow:none; transition:background .15s ease; }
.levels .level-btn:last-child{ border-bottom:1px solid var(--line); }
a.level-btn:hover{ background:color-mix(in srgb, var(--card) 55%, transparent); }
a.level-btn:active{ background:var(--accent-soft); }
.level-badge{ flex:none; width:46px; height:46px; border-radius:9px; display:grid; place-items:center;
  font-family:var(--serif); font-weight:600; font-size:21px; color:var(--accent-ink);
  background:transparent; border:1px solid var(--tz); position:relative; }
.level-btn.locked .level-badge{ color:var(--muted); border-color:var(--line); }
/* per-level colour: the number carries a gradient in its HSK band's hue and the
   badge picks up a faint tint of the same colour (--lc is set inline per level). */
.level-badge{ background:color-mix(in srgb, var(--lc, transparent) 9%, transparent);
  border-color:color-mix(in srgb, var(--lc, var(--tz)) 42%, var(--line)); }
.level-btn.locked .level-badge{ background:transparent; border-color:var(--line); }
.lv-num{ font-weight:700; line-height:1;
  background:linear-gradient(155deg,
    color-mix(in srgb, var(--lc,#e0b24c) 52%, #fff) 0%,
    var(--lc,#e0b24c) 54%,
    color-mix(in srgb, var(--lc,#e0b24c) 72%, #000) 100%);
  -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; color:transparent; }
.level-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:3px; }
.level-main > b{ font-family:var(--serif); font-weight:600; font-size:18px; letter-spacing:-.01em; }
.level-main small{ color:var(--muted); font-size:12.5px; }
.level-main small b{ font-family:inherit; font-size:inherit; font-weight:700; }
.level-go{ flex:none; font-size:20px; font-weight:700; color:var(--accent-ink); padding-right:4px; }
.level-btn.locked{ opacity:.55; cursor:default; }
.level-soon{ flex:none; font-size:10.5px; font-weight:800; letter-spacing:.14em; text-transform:uppercase;
  color:var(--muted); background:transparent; border:1px solid var(--line); padding:5px 10px; border-radius:999px; white-space:nowrap; }
body.levels-mode{ padding-bottom:calc(16px + env(safe-area-inset-bottom)); }
body.levels-mode .tabbar{ display:none; }

/* ---- group headers / topic bars ---- */
.group-head{ display:flex; align-items:center; justify-content:space-between; gap:12px;
  margin:26px 2px 10px; padding-top:14px; border-top:1px solid var(--line); }
.group-head h3{ margin:0; font-size:15px; font-weight:700; letter-spacing:-.01em; }
.gbar{ height:3px; background:var(--line); border-radius:99px; overflow:hidden; flex:1; max-width:120px; }
.gbar i{ display:block; height:100%; background:var(--accent); }

/* ---- Learn grid: practice-square cells ---- */
.char-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(76px,1fr)); gap:9px; }
.char-cell{ background:var(--card); border:1px solid var(--line); border-radius:10px; padding:12px 6px 9px;
  text-align:center; box-shadow:none; position:relative; transition:transform .09s ease, border-color .15s; }
.char-cell:active{ transform:scale(.96); }
/* corner ticks, like a printed practice book */
.char-cell::after{ content:""; position:absolute; inset:4px; pointer-events:none; border-radius:6px; opacity:.7;
  background:
    linear-gradient(var(--tz),var(--tz)) 0 0/7px 1px no-repeat, linear-gradient(var(--tz),var(--tz)) 0 0/1px 7px no-repeat,
    linear-gradient(var(--tz),var(--tz)) 100% 0/7px 1px no-repeat, linear-gradient(var(--tz),var(--tz)) 100% 0/1px 7px no-repeat,
    linear-gradient(var(--tz),var(--tz)) 0 100%/7px 1px no-repeat, linear-gradient(var(--tz),var(--tz)) 0 100%/1px 7px no-repeat,
    linear-gradient(var(--tz),var(--tz)) 100% 100%/7px 1px no-repeat, linear-gradient(var(--tz),var(--tz)) 100% 100%/1px 7px no-repeat; }
.char-cell .hz{ font-size:31px; line-height:1.15; }
.char-cell .py{ font-size:11.5px; margin-top:3px; letter-spacing:.01em; }
.char-cell .dot{ position:absolute; top:8px; right:8px; width:7px; height:7px; border-radius:50%; background:var(--line-strong); }
.char-cell .dot.learning{ background:var(--warn); }
.char-cell .dot.known{ background:var(--seal); }
.char-cell .star{ position:absolute; top:2px; left:2px; width:27px; height:27px; padding:0; border:none; background:transparent;
  color:var(--stroke-outline); font-size:15px; line-height:1; display:grid; place-items:center; border-radius:50%; z-index:2;
  transition:transform .12s ease, color .15s; }
.char-cell .star.on{ color:var(--accent); }
.char-cell .star:active{ transform:scale(.8); }

/* tone colours */
.tone1{ color:var(--t1); } .tone2{ color:var(--t2); } .tone3{ color:var(--t3); }
.tone4{ color:var(--t4); } .tone5{ color:var(--t5); }

/* ---- character detail ---- */
.detail-nav{ display:flex; align-items:stretch; gap:8px; margin-bottom:16px; }
.detail-nav > .card, .detail-nav > .char-hero{ flex:1; min-width:0; margin-bottom:0; }
.char-arrow{ flex:none; width:40px; border-radius:10px; display:grid; place-items:center; align-self:stretch;
  font-size:24px; line-height:1; background:transparent; border:1px solid var(--line); color:var(--muted);
  box-shadow:none; user-select:none; transition:color .15s, border-color .15s, transform .1s; }
.char-arrow:hover{ color:var(--accent-ink); border-color:var(--line-strong); }
.char-arrow:active{ transform:scale(.95); }
@media (max-width:480px){ .detail-nav .char-arrow{ align-self:flex-start; height:150px; } }
@media (max-width:420px){ .detail-nav{ gap:6px; } .char-arrow{ width:34px; font-size:21px; } }
/* the hero: glyph in a real 田字格 frame, meta beside/below it */
.char-hero{ background:transparent; border:none; padding:2px 0 6px; }
.char-hero .detail-top{ display:flex; gap:18px; align-items:center; }
.char-tzg{ flex:none; width:132px; height:132px; display:grid; place-items:center; }
.char-tzg .bighz{ font-size:88px; line-height:1; font-weight:600; }
.detail-top{ display:flex; gap:16px; align-items:center; }
@media (max-width:480px){
  .char-hero .detail-top{ flex-direction:column; align-items:center; text-align:center; gap:12px; }
  .char-hero .detail-meta{ width:100%; }
  .char-hero .chips{ justify-content:center; }
  .char-tzg{ width:150px; height:150px; }
  .char-tzg .bighz{ font-size:100px; }
}
.bighz{ font-size:84px; line-height:1; font-weight:600; }
.detail-meta{ flex:1; min-width:0; }
.detail-meta .py{ font-size:25px; font-weight:700; letter-spacing:.01em; }
.detail-meta .mean{ font-size:16.5px; margin-top:3px; }
.detail-meta .sound-btn{ margin-top:10px; }

/* Flashcard flip (character hero) — front = character info, back = story image */
.char-hero.flipcard{ padding:0; cursor:pointer; -webkit-tap-highlight-color:transparent; outline:none; }
.flipcard{ perspective:1400px; }
.flipcard .flip-inner{ position:relative; transition:transform .55s cubic-bezier(.4,.12,.2,1); transform-style:preserve-3d; }
.flipcard.flipped .flip-inner{ transform:rotateY(180deg); }
.flip-face{ backface-visibility:hidden; -webkit-backface-visibility:hidden; border:1px solid var(--line); background:var(--card); border-radius:14px; }
.flipcard:focus-visible .flip-face{ border-color:var(--accent-ink); box-shadow:0 0 0 3px var(--card-2); }
.flip-front{ position:relative; aspect-ratio:3/2; min-height:200px; box-sizing:border-box; padding:16px 18px 30px; display:flex; align-items:center; }
.flip-back{ position:absolute; inset:0; transform:rotateY(180deg); overflow:hidden; display:grid; place-items:center; background:var(--card-2); }
.flip-back .flip-img{ position:absolute; inset:0; width:100%; height:100%; object-fit:contain; z-index:1; }
.flip-back-ph{ color:var(--muted); font-size:13.5px; font-weight:600; letter-spacing:.02em; z-index:0; }
.flip-hint{ position:absolute; left:0; right:0; bottom:9px; display:flex; justify-content:center; align-items:center; gap:5px; font-size:12px; color:var(--muted); font-weight:600; letter-spacing:.01em; pointer-events:none; }
.flip-hint.back{ left:50%; right:auto; bottom:9px; transform:translateX(-50%); z-index:2; background:rgba(20,18,14,.62); color:#fff; padding:3px 11px; border-radius:999px; -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); }
/* chips → quiet dotted meta line */
.chips{ display:flex; gap:4px 14px; flex-wrap:wrap; margin-top:9px; align-items:center; }
.chip{ font-size:11px; background:transparent; color:var(--muted); padding:0; border-radius:0;
  font-weight:700; letter-spacing:.1em; text-transform:uppercase; white-space:nowrap; position:relative; }
.chip + .chip::before{ content:"·"; position:absolute; left:-9px; color:var(--line-strong); }
.chip.g{ background:transparent; color:var(--seal); }
.chip.lvl{ border:none; color:var(--muted); }
.section-title{ font-size:11px; text-transform:uppercase; letter-spacing:.16em; color:var(--muted); font-weight:800; margin:2px 0 10px;
  display:flex; align-items:center; gap:8px; }
.section-title::before{ content:""; width:5px; height:5px; background:var(--accent); flex:none; }
.what-link{ text-transform:none; letter-spacing:0; font-weight:600; font-size:12px; color:var(--accent-ink);
  border:none; background:transparent; padding:0; cursor:pointer; font-family:inherit; }
.what-link:hover{ text-decoration:underline; }
.mnemonic{ background:transparent; border-left:2px solid var(--accent); padding:4px 0 4px 16px; border-radius:0;
  font-size:16px; line-height:1.85; }

/* ---- mnemonic role colours: coloured UNDERLINES, not highlighter pills ---- */
:root{ --mn-a:#2456c8; --mn-a-bg:rgba(59,130,246,.10); --mn-s:#0a7a5c; --mn-s-bg:rgba(16,185,129,.11);
  --mn-z:#a35b07; --mn-z-bg:rgba(245,158,11,.13); --mn-c:#6d3fc8; --mn-c-bg:rgba(139,92,246,.11);
  --mn-m:#b3123d; --mn-m-bg:rgba(244,63,94,.10); }
@media (prefers-color-scheme: dark){ :root{ --mn-a:#9dc2ff; --mn-a-bg:rgba(59,130,246,.16); --mn-s:#7fe0bb; --mn-s-bg:rgba(16,185,129,.15);
  --mn-z:#f3ca66; --mn-z-bg:rgba(245,158,11,.15); --mn-c:#c9b4ff; --mn-c-bg:rgba(139,92,246,.18); --mn-m:#ff9fb0; --mn-m-bg:rgba(244,63,94,.16); } }
html[data-theme="dark"]{ --mn-a:#9dc2ff; --mn-a-bg:rgba(59,130,246,.16); --mn-s:#7fe0bb; --mn-s-bg:rgba(16,185,129,.15);
  --mn-z:#f3ca66; --mn-z-bg:rgba(245,158,11,.15); --mn-c:#c9b4ff; --mn-c-bg:rgba(139,92,246,.18); --mn-m:#ff9fb0; --mn-m-bg:rgba(244,63,94,.16); }
html[data-theme="light"]{ --mn-a:#2456c8; --mn-a-bg:rgba(59,130,246,.10); --mn-s:#0a7a5c; --mn-s-bg:rgba(16,185,129,.11);
  --mn-z:#a35b07; --mn-z-bg:rgba(245,158,11,.13); --mn-c:#6d3fc8; --mn-c-bg:rgba(139,92,246,.11); --mn-m:#b3123d; --mn-m-bg:rgba(244,63,94,.10); }
.mn-a,.mn-s,.mn-z,.mn-c,.mn-m,.mn-r{ font-weight:650; border-radius:0; padding:0; background:transparent; cursor:help;
  text-decoration:underline; text-decoration-thickness:2px; text-underline-offset:4px;
  box-decoration-break:clone; -webkit-box-decoration-break:clone; }
.mn-a{ color:var(--mn-a); text-decoration-color:var(--mn-a); }
.mn-s{ color:var(--mn-s); text-decoration-color:var(--mn-s); }
.mn-z{ color:var(--mn-z); text-decoration-color:var(--mn-z); }
.mn-c{ color:var(--mn-c); text-decoration-color:var(--mn-c); }
.mn-m{ color:var(--mn-m); text-decoration-color:var(--mn-m); }
.mn-r{ color:var(--mn-m); text-decoration-color:var(--mn-m); }
.scene-img{ width:100%; max-height:300px; object-fit:cover; border-radius:10px; margin:8px 0 4px; display:block; background:var(--card-2); border:1px solid var(--line); }
/* per-character image + its placeholder */
.char-img-wrap{ margin:8px 0 4px; }
.char-img-wrap .char-img{ display:none; width:100%; height:auto; max-height:520px; object-fit:contain; border-radius:10px; background:var(--card-2); border:1px solid var(--line); }
.char-img-wrap.has-img .char-img{ display:block; }
.char-img-wrap.has-img .char-img-ph{ display:none; }
.char-img-ph{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; min-height:140px; margin:0;
  padding:24px; text-align:center; border:1px dashed var(--line-strong); border-radius:10px; background:transparent; color:var(--muted); }
.char-img-ph .ph-ic{ width:34px; height:34px; opacity:.8; display:grid; place-items:center; font-size:15px; color:var(--accent-ink); }
.char-img-ph .ph-txt{ font-size:12.5px; font-weight:600; }
.char-img-ph .ph-file{ font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:10.5px; opacity:.8; background:var(--card); border:1px solid var(--line); border-radius:6px; padding:3px 8px; }
/* role hover/tap tips */
.role-tip{ position:fixed; z-index:9999; left:0; top:0; pointer-events:none; opacity:0; transform:translateY(3px);
  transition:opacity .12s ease, transform .12s ease; min-width:90px; max-width:240px; padding:10px 15px 11px;
  background:var(--card); border:1px solid var(--line-strong); border-radius:10px; box-shadow:0 14px 34px rgba(0,0,0,.4);
  display:flex; flex-direction:column; align-items:center; gap:3px; text-align:center; }
.role-tip.on{ opacity:1; transform:translateY(0); }
.role-tip .rt-label{ font-size:9.5px; letter-spacing:.14em; text-transform:uppercase; font-weight:800; color:var(--muted); }
.role-tip .rt-value{ font-size:24px; font-weight:800; line-height:1.05; color:var(--rt,var(--ink)); }
.role-tip .rt-tone{ font-size:14px; font-weight:700; color:var(--rt,var(--ink)); }
.role-tip .rt-only{ font-size:14px; font-weight:800; color:var(--rt,var(--ink)); }
.role-tip .rt-contour{ display:block; line-height:0; margin:1px 0; }
.role-tip .rt-contour svg{ width:44px; height:24px; color:var(--rt,var(--ink)); display:block; }
.role-tip::after{ content:""; position:absolute; top:100%; left:var(--arrow-x,50%); transform:translateX(-50%);
  border:6px solid transparent; border-top-color:var(--card); }
.role-tip.below::after{ top:auto; bottom:100%; border-top-color:transparent; border-bottom-color:var(--card); }
/* ---- remix ---- */
.btn.sm{ min-height:38px; padding:0 14px; font-size:13px; border-radius:9px; }
.remix-tag{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:10px; font-size:11.5px; font-weight:800; letter-spacing:.05em; text-transform:uppercase; color:var(--accent-ink); }
.linkbtn{ border:none; background:none; padding:0; color:var(--accent-ink); font-weight:700; font-size:12px; text-decoration:underline; text-underline-offset:3px; }
.remix-text{ width:100%; resize:vertical; min-height:128px; background:var(--card-2); color:var(--ink); border:1px solid var(--line-strong); border-radius:10px; padding:13px 15px; font-family:inherit; font-size:15.5px; line-height:1.75; }
.remix-text:focus{ outline:none; border-color:var(--accent); }
.remix-edit-area{ min-height:128px; resize:none; }
.remix-edit-area .lockword{ cursor:default; user-select:none; -webkit-user-select:none; padding:0 2px; }
.remix-hint{ font-size:12.5px; color:var(--muted); margin-top:8px; line-height:1.55; }
.tip-card{ display:flex; gap:13px; align-items:flex-start; text-align:left; background:transparent; border-left:2px solid var(--accent); border-radius:0; }
.tip-ic{ font-size:20px; line-height:1.1; flex:none; margin-top:1px; }
.tip-body b{ display:block; font-size:11px; text-transform:uppercase; letter-spacing:.14em; color:var(--accent-ink); font-weight:800; margin-bottom:3px; }
.tip-body p{ margin:0; font-size:15px; line-height:1.65; color:var(--ink); }
/* decode: typography first, small emoji cue */
.decode{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; text-align:center; }
.decode .d{ background:transparent; border:1px solid var(--line); border-radius:10px; padding:12px 6px 11px; }
.decode .d .e{ font-size:19px; opacity:.9; margin-bottom:2px; }
.decode .d b{ display:block; font-size:13.5px; letter-spacing:-.01em; }
.decode .d small{ color:var(--muted); font-size:10.5px; display:block; margin-top:2px; }
.comp-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.py-toggle{ border:1px solid var(--line); background:transparent; color:var(--muted); font-size:11.5px; font-weight:600; padding:5px 12px; border-radius:999px; cursor:pointer; line-height:1; white-space:nowrap; }
.py-toggle.on{ background:var(--accent-soft); color:var(--accent-ink); border-color:transparent; }
.comp-list{ display:flex; flex-direction:column; }
.comp{ display:flex; align-items:flex-start; gap:14px; background:transparent; border:none; border-top:1px solid var(--line); border-radius:0; padding:12px 2px; }
.comp:first-child{ border-top:none; padding-top:4px; }
.comp .c{ font-size:30px; line-height:1.1; flex:none; min-width:38px; text-align:center; color:var(--accent-ink); }
.comp .comp-txt{ display:flex; flex-direction:column; gap:2px; line-height:1.35; }
.comp .comp-txt small{ color:var(--muted); }
.comp .comp-txt small.comp-en{ color:var(--ink); font-weight:700; font-size:15px; }
.comp .comp-txt small.comp-py{ color:var(--accent-ink); font-weight:400; font-size:13px; }
.comp .comp-txt small.comp-hsk{ font-size:10.5px; letter-spacing:.08em; text-transform:uppercase; opacity:.75; }
.comp .comp-txt small.comp-note{ font-size:11.5px; line-height:1.5; }
.comp-list.no-py .comp-py{ display:none; }
.comp-link{ text-decoration:none; color:inherit; transition:background .15s; }
.comp-link:active{ background:var(--accent-soft); }
.comp-link .comp-go{ margin-left:auto; align-self:center; color:var(--muted); font-size:20px; line-height:1; }
/* "View story" jump: only rendered for a component that IS a taught, unlocked
   character (see componentStory() in app.js). Pill styled to match .py-toggle. */
.comp .comp-story{ margin-left:auto; align-self:center; flex:none; display:inline-flex; align-items:center; gap:5px;
  white-space:nowrap; text-decoration:none; cursor:pointer; font-size:12px; font-weight:600; line-height:1;
  color:var(--accent-ink); background:transparent; border:1px solid var(--line); border-radius:999px; padding:7px 13px;
  transition:background .15s, border-color .15s, transform .05s; }
.comp .comp-story:hover{ background:var(--accent-soft); border-color:transparent; }
.comp .comp-story:active{ transform:translateY(1px); }
.comp .comp-story .cs-go{ font-size:15px; line-height:0; opacity:.85; }
.bighz.word-hz{ font-size:44px; letter-spacing:-1px; line-height:1.1; }
/* Learn: header + filters */
.learn-count{ color:var(--muted); font-weight:500; font-size:13.5px; margin:-8px 2px 14px; }
.learn-filterbar{ display:flex; align-items:center; gap:10px; margin:2px 0 10px; }
.filter-btn{ display:inline-flex; align-items:center; gap:7px; border:1px solid var(--line); background:transparent;
  color:var(--muted); border-radius:999px; padding:7px 13px; font-family:inherit; font-weight:700; font-size:12.5px; cursor:pointer; }
.filter-btn.on{ border-color:var(--accent); color:var(--accent-ink); background:var(--accent-soft); }
.filter-btn .fb-ic{ font-size:12px; }
.filter-btn .fb-sum{ font-weight:600; color:var(--accent-ink); }
.filter-btn .fb-caret{ font-size:9px; color:var(--muted); }
.fb-clear{ font-size:12px; }
.learn-filters{ display:none; margin:-2px 0 16px; padding:4px 2px 8px; border:none; border-bottom:1px solid var(--line); border-radius:0; background:transparent; }
.learn-filters.open{ display:block; }
.learn-filters .filter-label{ font-size:10px; text-transform:uppercase; letter-spacing:.16em; color:var(--muted); font-weight:800; margin:10px 2px 4px; }
.word-grid{ grid-template-columns:repeat(auto-fill,minmax(122px,1fr)); }
.char-cell.word .hz{ font-size:23px; letter-spacing:-.5px; }
.char-cell.word .cell-m{ font-size:11px; color:var(--muted); margin-top:4px; line-height:1.35; }
.ex-list .ex{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:11px 0; border-bottom:1px solid var(--line); }
.ex-list .ex:last-child{ border-bottom:none; }
.ex .w{ font-size:21px; } .ex .p{ font-size:13px; } .ex .m{ color:var(--muted); font-size:13px; }
.sound-btn{ border:1px solid var(--line-strong); background:transparent; color:var(--accent-ink); width:44px; height:44px; border-radius:50%; font-size:18px; flex:none; display:inline-grid; place-items:center; transition:background .15s, transform .1s; }
.sound-btn:active{ background:var(--accent-soft); transform:scale(.94); }
.sound-btn svg{ width:19px; height:19px; display:block; }
.btn .snd-ic{ width:18px; height:18px; flex:none; }
.writer-box{ width:210px; height:210px; margin:0 auto; background:var(--card-2); border-radius:10px; border:1px solid var(--tz); display:grid; place-items:center; }
.writer-box svg line{ stroke:var(--tz); }

/* ---- review / flashcard ---- */
.flash{ min-height:340px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; gap:10px; position:relative; overflow:hidden; }
.flash::before{ content:""; position:absolute; inset:12px; pointer-events:none; opacity:.5; border-radius:8px;
  background:
    repeating-linear-gradient(to bottom, var(--tz) 0 5px, transparent 5px 12px) calc(50% - .5px) 0/1px 100% no-repeat,
    repeating-linear-gradient(to right,  var(--tz) 0 5px, transparent 5px 12px) 0 calc(50% - .5px)/100% 1px no-repeat; }
.flash > *{ position:relative; }
.flash .bighz{ font-size:100px; }
.grade-row{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.grade-row .btn{ flex-direction:column; gap:2px; min-height:58px; padding:6px; font-size:14px; border-color:transparent; }
.grade-row .btn small{ font-weight:600; opacity:.8; font-size:11px; }
.g-again{ background:var(--bad-soft); color:var(--bad); }
.g-hard{ background:#f6ead8; color:#b06e10; }
.g-good{ background:var(--good-soft); color:var(--good); }
.g-easy{ background:var(--accent-soft); color:var(--accent-ink); }
html[data-theme="dark"] .g-hard{ background:#33270f; color:#e8b45a; }

/* ---- quiz ---- */
.opt{ width:100%; text-align:left; padding:15px 16px; margin-bottom:9px; border-radius:var(--radius); border:1px solid var(--line-strong);
  background:transparent; font-size:15.5px; font-weight:600; transition:.15s; }
.opt:active{ transform:scale(.995); }
.opt .han{ font-size:24px; }
.opt.correct{ background:var(--good-soft); border-color:var(--good); color:var(--good); }
.opt.wrong{ background:var(--bad-soft); border-color:var(--bad); color:var(--bad); }
.opt:disabled{ opacity:1; }
.qprompt{ text-align:center; padding:20px 0; position:relative; overflow:hidden; }
.qprompt::before{ content:""; position:absolute; inset:10px; pointer-events:none; opacity:.4; border-radius:8px;
  background:
    repeating-linear-gradient(to bottom, var(--tz) 0 5px, transparent 5px 12px) calc(50% - .5px) 0/1px 100% no-repeat,
    repeating-linear-gradient(to right,  var(--tz) 0 5px, transparent 5px 12px) 0 calc(50% - .5px)/100% 1px no-repeat; }
.qprompt > *{ position:relative; }
.qprompt .bighz{ font-size:80px; }
.qbar{ height:3px; background:var(--line); border-radius:99px; overflow:hidden; margin-bottom:14px; }
.qbar i{ display:block; height:100%; background:var(--accent); transition:width .3s; }
/* review start screen: big serif count, no emoji hero */
.start-count{ display:flex; flex-direction:column; align-items:center; gap:2px; padding:8px 0 2px; }
.start-count .sc-n{ font-family:var(--serif); font-size:54px; font-weight:600; line-height:1; color:var(--accent-ink); }
.start-count .sc-l{ font-size:13px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--muted); }

/* ---- system reference ---- */
.ref-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(124px,1fr)); gap:8px; }
.ref-cell{ background:transparent; border:1px solid var(--line); border-radius:10px; padding:10px; display:flex; align-items:center; gap:10px; }
.ref-cell .e{ font-size:21px; } .ref-cell b{ font-size:14px; } .ref-cell small{ color:var(--muted); display:block; font-size:11.5px; }

/* ---- mnemonic-system page ---- */
.sys-lede{ color:var(--muted); font-size:15.5px; line-height:1.65; margin:-6px 2px 4px; }
.sys-part{ margin-top:24px; padding-top:22px; border-top:1px solid var(--line); }
.sys-part:first-of-type{ border-top:none; padding-top:4px; margin-top:18px; }
.sys-head{ margin-bottom:14px; }
.sys-step{ display:inline-block; font-family:var(--serif); font-weight:600; font-size:14px; letter-spacing:.1em;
  width:auto; height:auto; border:none; background:transparent; color:var(--accent-ink); border-radius:0; margin-bottom:6px; }
.sys-step::after{ content:""; display:block; width:26px; height:2px; background:var(--accent); margin-top:6px; }
.sys-title{ font-family:var(--serif); font-size:24px; font-weight:600; letter-spacing:-.015em; margin:0 0 4px; }
.sys-cards{ display:grid; grid-template-columns:1fr 1fr; gap:9px; }
.sys-map{ grid-template-columns:1fr; }
.sys-cell{ background:transparent; border:1px solid var(--line); border-radius:var(--radius); padding:14px; box-shadow:none; display:flex; flex-direction:column; }
.sys-cell .sys-ic{ font-size:20px; line-height:1; margin-bottom:9px; }
.sys-cell .sys-ic.han{ color:var(--accent-ink); font-size:24px; }
.sys-cell b{ font-size:14.5px; margin-bottom:3px; font-weight:700; }
.sys-cell small{ color:var(--muted); font-size:13px; line-height:1.55; }
.sys-eg{ display:flex; align-items:center; gap:7px; margin-top:auto; padding-top:11px; border-top:1px solid var(--line); font-size:13px; font-weight:700; flex-wrap:wrap; }
.sys-eg .k{ display:inline-grid; place-items:center; min-width:30px; height:25px; padding:0 7px; border-radius:7px; background:var(--card-2); border:1px solid var(--line); font-weight:800; }
.sys-eg .ar{ color:var(--muted); }
.sys-example{ margin-top:12px; }
.sys-ex-head{ display:flex; align-items:center; gap:16px; padding-bottom:13px; margin-bottom:13px; border-bottom:1px solid var(--line); }
.sys-ex-han{ font-size:52px; line-height:1; color:var(--accent-ink); }
.sys-ex-py{ font-size:21px; font-weight:700; display:block; line-height:1.1; }
.sys-example .mnemonic{ font-size:15.5px; line-height:1.8; }
.sys-ex-foot{ margin-top:11px; }

/* carousel */
.sys-car{ margin-top:18px; }
.sys-slide{ display:none; min-height:42vh; animation:sysIn .34s cubic-bezier(.22,.61,.36,1); }
.sys-slide.active{ display:block; }
@keyframes sysIn{ from{ opacity:0; transform:translateX(18px); } to{ opacity:1; transform:translateX(0); } }
@media (prefers-reduced-motion:reduce){ .sys-slide{ animation:none; } }
.sys-car .sys-head{ margin-bottom:18px; }
.sys-car .sys-title{ font-size:27px; }
.sys-car .sys-head .sub{ font-size:15px; line-height:1.55; }
.sys-car .sys-lede{ font-size:16.5px; line-height:1.7; margin:12px 2px 20px; }
.sys-car .sys-cards{ gap:10px; }
.sys-car .sys-cell{ padding:16px; }
.sys-car .sys-cell .sys-ic{ font-size:24px; margin-bottom:11px; }
.sys-car .sys-cell b{ font-size:16px; }
.sys-car .sys-cell small{ font-size:13.5px; }
.sys-foot{ margin-top:24px; }
.sys-progress{ display:flex; justify-content:center; gap:9px; margin-bottom:16px; }
.sys-dot{ width:7px; height:7px; padding:0; border:none; border-radius:50%; background:var(--line-strong); cursor:pointer; transition:transform .2s, background .2s; }
.sys-dot.on{ background:var(--accent); transform:scale(1.35); }
.sys-cnav{ display:flex; align-items:center; justify-content:space-between; gap:14px; }
.sys-count{ color:var(--muted); font-size:12.5px; font-weight:700; letter-spacing:.06em; white-space:nowrap; }
.sys-back, .sys-fwd{ min-width:108px; }

/* ---------- onboarding ---------- */
/* Home "Start here" hero: the guided entry into the mnemonic-system intro. */
.onb-hero{ display:flex; align-items:center; gap:12px; margin:0 0 20px; padding:15px 16px 16px;
  text-decoration:none; color:inherit; border-radius:var(--radius-lg);
  background:var(--accent-soft); position:relative; overflow:hidden; transition:transform .12s, box-shadow .2s; }
.onb-hero::before{ content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--grad-gold); }
.onb-hero:hover{ transform:translateY(-1px); box-shadow:0 10px 28px rgba(0,0,0,.08); }
.onb-hero:active{ transform:translateY(0); box-shadow:none; }
.onb-hero-main{ flex:1; min-width:0; }
.onb-hero-badge{ display:inline-block; font-size:10px; font-weight:800; letter-spacing:.1em; text-transform:uppercase;
  color:#fff; background:var(--accent); border-radius:999px; padding:4px 9px; margin-bottom:8px; }
[data-theme="dark"] .onb-hero-badge{ color:#1a150a; }
.onb-hero-main b{ display:block; font-size:16.5px; line-height:1.3; color:var(--ink); }
.onb-hero-main small{ display:block; margin-top:4px; color:var(--muted); font-size:13px; line-height:1.5; }
.onb-hero-go{ flex:none; color:var(--accent-ink); font-size:24px; font-weight:700; }

/* "Try it yourself" active-recall drill inside the intro carousel. */
.onb-quiz{ display:flex; flex-direction:column; gap:14px; }
.onb-q{ border:1px solid var(--line); border-radius:var(--radius); padding:14px; transition:border-color .2s, background .2s; }
.onb-q.done{ border-color:var(--good); background:var(--good-soft); }
.onb-q-prompt{ font-size:15px; line-height:1.55; color:var(--ink); margin-bottom:12px; }
.onb-q-prompt .han{ font-size:20px; }
.onb-q-opts{ display:flex; flex-direction:column; gap:8px; }
.onb-opt{ display:flex; align-items:center; gap:11px; width:100%; text-align:left; cursor:pointer;
  min-height:var(--tap); padding:10px 13px; border:1px solid var(--line-strong); border-radius:10px;
  background:var(--card); color:var(--ink); font-size:15px; font-weight:600; font-family:inherit;
  transition:transform .08s, border-color .15s, background .15s, opacity .2s, color .15s; }
.onb-opt:hover:not(:disabled){ border-color:var(--accent); }
.onb-opt:active:not(:disabled){ transform:scale(.99); }
.onb-opt-e{ font-size:20px; line-height:1; flex:none; }
.onb-opt.correct{ border-color:var(--good); background:var(--good-soft); color:var(--good); }
.onb-opt.wrong{ border-color:var(--bad); background:var(--bad-soft); color:var(--bad); animation:onbShake .4s; }
.onb-opt.dim{ opacity:.45; }
.onb-opt:disabled{ cursor:default; }
.onb-q-fb{ font-size:13px; line-height:1.5; color:var(--bad); max-height:0; overflow:hidden; transition:max-height .25s, margin-top .25s; }
.onb-q-fb:not(:empty){ margin-top:10px; max-height:90px; }
.onb-q-fb.ok{ color:var(--good); font-weight:600; }
@keyframes onbShake{ 0%,100%{transform:translateX(0)} 20%{transform:translateX(-5px)} 40%{transform:translateX(5px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)} }
.onb-done{ text-align:center; padding:20px 14px 6px; opacity:0; transform:translateY(6px); transition:opacity .35s, transform .35s; }
.onb-done.show{ opacity:1; transform:none; }
.onb-done-scene{ margin-bottom:8px; }
.onb-done-han{ font-size:52px; line-height:1; }
.onb-done b{ font-size:17px; color:var(--ink); }

/* decoder diagram: character → its three colour-coded clues (intro slide 01) */
.dcd{ border:1px solid var(--line); border-radius:var(--radius-lg); padding:18px 14px 16px; background:var(--card); }
.dcd-top{ display:flex; align-items:center; justify-content:center; gap:15px; }
.dcd-han{ font-size:56px; line-height:1; }
.dcd-say{ display:flex; flex-direction:column; }
.dcd-py{ font-size:22px; font-weight:700; color:var(--ink); }
.dcd-mean{ color:var(--muted); font-size:14px; }
.dcd-link{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:11px 0 8px; }
.dcd-link i{ height:16px; width:2px; margin:0 auto; background:var(--line-strong); border-radius:2px; }
.dcd-clues{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.dcd-clue{ display:flex; flex-direction:column; align-items:center; text-align:center; gap:2px;
  border:1px solid var(--line); border-top-width:3px; border-radius:12px; padding:12px 6px 11px; }
.dcd-e{ font-size:26px; line-height:1; margin-bottom:4px; }
.dcd-role{ font-size:9.5px; font-weight:800; letter-spacing:.09em; text-transform:uppercase; color:var(--muted); }
.dcd-clue b{ font-size:13.5px; line-height:1.2; color:var(--ink); }
.dcd-clue small{ font-size:12px; color:var(--muted); }
.dcd-a{ border-top-color:var(--mn-a); } .dcd-a .dcd-role{ color:var(--mn-a); }
.dcd-s{ border-top-color:var(--mn-s); } .dcd-s .dcd-role{ color:var(--mn-s); }
.dcd-z{ border-top-color:var(--mn-z); } .dcd-z .dcd-role{ color:var(--mn-z); }
/* the same character woven into words, right under the diagram */
.sys-scene{ margin-top:14px; padding:13px 15px; border-radius:var(--radius); background:var(--card-2); }
.sys-scene-lab{ display:block; font-size:10px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; color:var(--muted); margin-bottom:6px; }
.sys-scene .mnemonic{ margin:0; font-size:15px; line-height:1.7; }

/* cast drill (repeatable sound → actor/place/room quiz) */
.cast-view{ max-width:520px; margin:0 auto; }
.cast-top{ display:flex; align-items:center; gap:12px; margin:2px 0 22px; }
.cast-x{ flex:none; width:34px; height:34px; display:grid; place-items:center; border-radius:50%; text-decoration:none;
  color:var(--muted); font-size:15px; border:1px solid var(--line); }
.cast-x:active{ background:var(--accent-soft); }
.cast-bar{ flex:1; height:6px; border-radius:99px; background:var(--line); overflow:hidden; }
.cast-bar i{ display:block; height:100%; background:var(--grad-gold); border-radius:99px; transition:width .3s ease; }
.cast-count{ flex:none; font-size:12.5px; font-weight:700; color:var(--muted); font-variant-numeric:tabular-nums; }
.cast-q{ text-align:center; margin-bottom:22px; }
.cast-cat{ display:inline-block; font-size:10.5px; font-weight:800; letter-spacing:.1em; text-transform:uppercase;
  color:var(--accent-ink); background:var(--accent-soft); border-radius:999px; padding:5px 12px; margin-bottom:14px; }
.cast-prompt{ font-size:22px; line-height:1.4; color:var(--ink); font-family:var(--serif); font-weight:600; }
.cast-prompt b{ font-family:var(--sans); }
.cast-opts{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.cast-opt{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; cursor:pointer;
  min-height:104px; padding:14px 10px; border:1px solid var(--line-strong); border-radius:14px;
  background:var(--card); color:var(--ink); font-size:15px; font-weight:600; font-family:inherit; text-align:center;
  transition:transform .08s, border-color .15s, background .15s, color .15s; }
.cast-opt:hover:not(:disabled){ border-color:var(--accent); }
.cast-opt:active:not(:disabled){ transform:scale(.98); }
.cast-opt-e{ font-size:34px; line-height:1; }
.cast-opt.correct{ border-color:var(--good); background:var(--good-soft); color:var(--good); }
.cast-opt.wrong{ border-color:var(--bad); background:var(--bad-soft); color:var(--bad); }
.cast-opt:disabled{ cursor:default; }
.cast-fb{ text-align:center; min-height:22px; margin-top:16px; font-size:14px; font-weight:600; }
.cast-fb.ok{ color:var(--good); } .cast-fb.no{ color:var(--bad); }
.cast-done{ text-align:center; padding-top:22px; }
.cast-ring{ width:118px; height:118px; margin:8px auto 6px; border-radius:50%; display:flex; flex-direction:column;
  align-items:center; justify-content:center; border:3px solid var(--accent); background:var(--accent-soft); }
.cast-ring b{ font-size:42px; font-weight:700; color:var(--accent-ink); line-height:1; }
.cast-ring small{ font-size:14px; color:var(--muted); margin-top:2px; }

@media (min-width:560px){
  .sys-cards{ grid-template-columns:repeat(4,1fr); }
  .sys-map{ grid-template-columns:repeat(3,1fr); }
}

/* ---- tab bar ---- */
.tabbar{ position:fixed; bottom:0; left:0; right:0; z-index:40;
  background:color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
  border-top:1px solid var(--line);
  display:grid; grid-template-columns:repeat(5,1fr); padding-bottom:env(safe-area-inset-bottom); }
@supports not (background:color-mix(in srgb, red 50%, blue)){ .tabbar{ background:var(--bg); } }
.tabbar a{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; height:60px; color:var(--muted); font-size:10.5px; font-weight:700; letter-spacing:.02em; position:relative; }
.tabbar a.active{ color:var(--accent-ink); }
.tabbar a.active::after{ content:""; position:absolute; bottom:6px; width:4px; height:4px; background:var(--accent); border-radius:1px; transform:rotate(45deg); }

/* ===== the painted UI icon set (masked PNG cut-outs; recolour by theme) ===== */
.uic{ display:inline-block; background-color:var(--ui-icon);
  -webkit-mask-position:center; mask-position:center;
  -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat;
  -webkit-mask-size:contain; mask-size:contain; }
.uic--streak { -webkit-mask-image:url(icons/ui/streak.png);     mask-image:url(icons/ui/streak.png); }
.uic--profile{ -webkit-mask-image:url(icons/ui/profile.png);    mask-image:url(icons/ui/profile.png); }
.uic--sun    { -webkit-mask-image:url(icons/ui/theme-sun.png);  mask-image:url(icons/ui/theme-sun.png); }
.uic--moon   { -webkit-mask-image:url(icons/ui/theme-moon.png); mask-image:url(icons/ui/theme-moon.png); }
.uic--home   { -webkit-mask-image:url(icons/ui/tab-home.png);   mask-image:url(icons/ui/tab-home.png); }
.uic--learn  { -webkit-mask-image:url(icons/ui/tab-learn.png);  mask-image:url(icons/ui/tab-learn.png); }
.uic--review { -webkit-mask-image:url(icons/ui/tab-review.png); mask-image:url(icons/ui/tab-review.png); }
.uic--quiz   { -webkit-mask-image:url(icons/ui/tab-quiz.png);   mask-image:url(icons/ui/tab-quiz.png); }
.uic--write  { -webkit-mask-image:url(icons/ui/tab-write.png);  mask-image:url(icons/ui/tab-write.png); }
.streak{ display:inline-flex; align-items:center; gap:6px; }
.streak .uic{ width:19px; height:19px; }
.icon-btn .uic{ width:23px; height:23px; }
.tile .ic.uic{ width:26px; height:26px; }
.btn .uic{ width:19px; height:19px; flex:none; background-color:currentColor; }
.tabbar a .ti{ width:24px; height:24px; opacity:.5; transition:opacity .15s, background-color .15s; }
.tabbar a.active .ti{ opacity:1; background-color:var(--accent); }

/* ---- theme switch: topbar light/dark toggle (fixed dark capsule = theme indicator) ---- */
.theme-switch{ position:relative; width:62px; height:32px; flex:none; padding:0;
  border-radius:999px; background:#17151c; border:1px solid #2c2820; box-shadow:inset 0 1px 3px rgba(0,0,0,.45); }
.theme-switch:active{ transform:scale(.96); }
.ts-thumb{ position:absolute; top:3px; left:3px; width:26px; height:26px; border-radius:50%;
  background:rgba(255,255,255,.10); border:1px solid rgba(255,255,255,.16); box-shadow:0 1px 3px rgba(0,0,0,.4);
  transition:transform .22s cubic-bezier(.4,.05,.2,1); z-index:0; }
.ts-ic{ position:absolute; top:50%; width:18px; height:18px; transform:translateY(-50%); z-index:1; transition:opacity .18s; }
.ts-sun { left:7px;  background-color:#cdd3dd; }
.ts-moon{ right:7px; background-color:#d8b873; }
html[data-theme="dark"]  .ts-thumb{ transform:translateX(30px); }
html[data-theme="dark"]  .ts-sun { opacity:.4; }
html[data-theme="light"] .ts-thumb{ transform:translateX(0); }
html[data-theme="light"] .ts-moon{ opacity:.4; }

@media (min-width:560px){
  .streak{ font-size:15px; gap:7px; }
  .streak .uic{ width:22px; height:22px; }
  .icon-btn{ width:42px; height:42px; }
  .icon-btn .uic{ width:26px; height:26px; }
  .theme-switch{ width:78px; height:40px; }
  .ts-thumb{ top:4px; left:4px; width:32px; height:32px; }
  html[data-theme="dark"] .ts-thumb{ transform:translateX(38px); }
  .ts-ic{ width:22px; height:22px; }
  .ts-sun{ left:9px; }
  .ts-moon{ right:9px; }
}
.due-badge{ position:absolute; top:6px; right:50%; transform:translateX(22px); background:var(--seal); color:#fff; font-style:normal; font-size:10px; min-width:16px; height:16px; border-radius:99px; padding:0 4px; display:none; align-items:center; justify-content:center; }
.due-badge.show{ display:inline-flex; }
.toast{ position:fixed; bottom:calc(76px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:var(--bg); padding:12px 18px; border-radius:10px; font-weight:700; font-size:13.5px;
  opacity:0; pointer-events:none; transition:.3s; z-index:60; max-width:90vw; }
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.empty{ text-align:center; padding:40px 16px; color:var(--muted); }
.empty .big{ font-size:44px; line-height:1.2; }
.empty .big.han{ color:var(--accent-ink); font-size:54px; }

/* ---- segmented controls → editorial underline tabs ---- */
.seg{ display:flex; background:transparent; border:none; border-bottom:1px solid var(--line); border-radius:0; padding:0; gap:2px;
  scrollbar-width:none; -ms-overflow-style:none; }
.seg::-webkit-scrollbar{ display:none; }
.seg button{ flex:1; border:none; background:transparent; color:var(--muted); padding:10px 10px 11px; border-radius:0;
  font-weight:700; font-size:13px; position:relative; transition:color .15s; }
.seg button.on{ background:transparent; color:var(--accent-ink); box-shadow:none; }
.seg button.on::after{ content:""; position:absolute; left:10%; right:10%; bottom:-1px; height:2px; background:var(--accent); }
/* topic selector row + chevrons */
.topic-seg-wrap{ display:flex; align-items:stretch; gap:2px; margin-bottom:12px; }
.topic-seg{ flex:1 1 auto; min-width:0; overflow-x:auto; margin:0; }
.topic-seg button{ flex:0 0 auto; white-space:nowrap; padding:10px 13px 11px; }
.seg-arrow{ flex:none; width:30px; align-self:stretch; border:none; border-bottom:1px solid var(--line); background:transparent;
  color:var(--muted); border-radius:0; font-size:18px; font-weight:700; line-height:1;
  display:grid; place-items:center; box-shadow:none; transition:opacity .15s, color .15s; }
.seg-arrow:active{ color:var(--accent-ink); }
.seg-arrow:disabled{ opacity:.25; pointer-events:none; }
.spinner{ width:26px; height:26px; border:3px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; margin:8px auto; }
@keyframes spin{ to{ transform:rotate(360deg);} }
@media (min-width:560px){ .grade-row .btn{ min-height:64px; } .bighz{ font-size:96px; } }

/* ===== review modes · story type-out · quiz timer · mock exam ===== */
.scroll-seg{ overflow-x:auto; }
.scroll-seg button{ white-space:nowrap; flex:1 0 auto; }
.wrap-seg{ flex-wrap:wrap; border-bottom:none; gap:6px; padding:2px 0; }
.wrap-seg button{ flex:0 0 auto; padding:8px 13px; border:1px solid var(--line); border-radius:999px; font-size:12.5px; }
.wrap-seg button.on{ border-color:var(--accent); background:var(--accent-soft); }
.wrap-seg button.on::after{ display:none; }
.seg-sub{ display:block; font-size:10px; font-weight:600; opacity:.65; line-height:1.3; }
.mode-seg{ margin-bottom:14px; }
.mode-seg button{ display:flex; flex-direction:column; align-items:center; gap:1px; padding:8px 4px 10px; }
.mode-seg button span{ font-size:15px; line-height:1.15; }
.mode-seg button small{ font-size:11px; font-weight:700; }

/* story cloze (bank variant) */
.cloze{ text-align:left; line-height:2.1; }
.cz{ display:inline-block; min-width:72px; border:none; border-bottom:2px dashed var(--line-strong); background:var(--card-2);
     border-radius:7px 7px 0 0; padding:1px 9px; margin:0 2px; font-weight:700; font-size:15px; font-family:inherit;
     color:var(--ink); vertical-align:baseline; line-height:1.7; }
.cz[data-role="a"]{ border-bottom-color:var(--mn-a); }
.cz[data-role="s"]{ border-bottom-color:var(--mn-s); }
.cz[data-role="z"]{ border-bottom-color:var(--mn-z); }
.cz[data-role="m"]{ border-bottom-color:var(--mn-m); }
.cz.ok{ border-bottom-style:solid; }
.cz.ok[data-role="a"]{ color:var(--mn-a); background:var(--mn-a-bg); }
.cz.ok[data-role="s"]{ color:var(--mn-s); background:var(--mn-s-bg); }
.cz.ok[data-role="z"]{ color:var(--mn-z); background:var(--mn-z-bg); }
.cz.ok[data-role="m"]{ color:var(--mn-m); background:var(--mn-m-bg); }
.cz.bad{ color:var(--bad); background:var(--bad-soft); border-bottom-color:var(--bad); animation:czshake .3s; }
@keyframes czshake{ 25%{ transform:translateX(-3px); } 75%{ transform:translateX(3px); } }
.bank{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:16px; }
.bank .wd{ border:1px solid var(--line-strong); background:transparent; color:var(--ink); border-radius:999px;
           padding:9px 15px; font-weight:700; font-size:14px; font-family:inherit; box-shadow:none; }
.bank .wd.used{ opacity:.22; pointer-events:none; }

/* story type-out boxes */
.cz-in{ display:inline-block; min-width:2.4em; max-width:14ch; border:none; border-bottom:2px dashed var(--line-strong);
        background:var(--card-2); border-radius:6px 6px 0 0; padding:1px 6px; margin:0 1px; font-weight:700; font-size:15px;
        font-family:inherit; color:var(--ink); vertical-align:baseline; line-height:1.7; text-align:center; }
.cz-in:focus{ outline:none; border-bottom-color:var(--accent); background:var(--accent-soft); }
.cz-in.ok{ border-bottom-style:solid; border-bottom-color:var(--good); color:var(--good); background:var(--good-soft); }
.cz-in.bad{ border-bottom-style:solid; border-bottom-color:var(--bad); color:var(--bad); background:var(--bad-soft); animation:czshake .3s; }
.cz-miss{ background:var(--bad-soft); color:var(--bad); border-radius:4px; padding:0 3px; box-decoration-break:clone; -webkit-box-decoration-break:clone; }
.cz-result{ font-size:14px; font-weight:700; margin:5px 0 2px; }
.cz-result.good{ color:var(--good); }
.cz-result.miss{ color:var(--bad); }
.sound-inline{ width:30px; height:30px; min-width:30px; font-size:13px; padding:0; vertical-align:middle; }
.sound-inline svg{ width:15px; height:15px; }

/* auto-starred notice */
.autostar{ border:1px solid var(--line-strong); }
.autostar .as-head{ font-weight:800; color:var(--accent-ink); }
.autostar .as-head .as-star{ color:var(--accent); margin-right:4px; }
.as-row{ display:flex; flex-wrap:wrap; gap:8px; }
.as-chip{ display:flex; flex-direction:column; align-items:center; gap:1px; text-decoration:none; border:1px solid var(--line);
          background:transparent; border-radius:10px; padding:8px 12px; min-width:58px; }
.as-chip .han{ font-size:24px; line-height:1.2; }
.as-chip small{ color:var(--muted); font-weight:600; font-size:10.5px; max-width:90px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* mock exam */
.exam-banner{ display:flex; align-items:center; gap:14px; text-decoration:none; color:inherit; margin-bottom:14px;
              border:1px solid var(--line-strong); background:var(--card); }
.exam-banner:active{ transform:scale(.995); }
.exam-banner .eb-ic{ font-size:26px; }
.exam-banner .eb-ic.tzg{ flex:none; width:52px; height:52px; display:grid; place-items:center;
  font-size:26px; color:var(--accent-ink); border-radius:8px; }
.exam-banner .eb-main{ flex:1; display:flex; flex-direction:column; gap:3px; }
.exam-banner .eb-main b{ font-size:15.5px; }
.exam-banner .eb-main small{ color:var(--muted); font-weight:500; line-height:1.5; font-size:12.5px; }
.exam-banner .eb-go{ font-size:20px; color:var(--accent-ink); font-weight:800; }
.exam-struct .es-row{ display:flex; justify-content:space-between; align-items:baseline; gap:10px; padding-top:10px; }
.exam-struct .es-row span{ color:var(--muted); font-size:13px; font-weight:600; white-space:nowrap; }
.exam-struct .es-row.total{ border-top:1px solid var(--line); margin-top:10px; }
.exam-struct .es-sub{ color:var(--muted); font-size:12px; line-height:1.5; margin-top:2px; }
.es-row{ display:flex; justify-content:space-between; align-items:baseline; gap:10px; width:100%; }
.es-row span{ color:var(--muted); font-size:13px; font-weight:600; }
.exam-sec-glyph{ width:76px; height:76px; margin:0 auto; display:grid; place-items:center; font-size:38px; color:var(--accent-ink); }
.tf-row{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.tf-row .opt{ text-align:center; font-size:17px; margin-bottom:0; padding:18px 10px; }
.opt .abc{ display:inline-flex; align-items:center; justify-content:center; width:23px; height:23px; border-radius:50%;
           border:1px solid var(--line-strong); background:transparent; color:var(--accent-ink); font-size:11px; font-weight:800; margin-right:10px; vertical-align:middle; }
#exam-clock.low{ color:var(--bad); font-weight:800; }
/* the result stamp: a proper seal */
.stamp{ display:inline-block; padding:10px 18px; border-radius:6px; font-weight:800; font-size:15px; letter-spacing:.1em; transform:rotate(-3deg); }
.stamp.pass{ border:2.5px solid var(--seal); color:var(--seal); background:var(--seal-soft); }
.stamp.fail{ border:2.5px solid var(--muted); color:var(--muted); background:transparent; }

/* mock exam prompts + options */
.qprompt.listen{ text-align:center; padding:24px 0 20px; }
.qprompt.read{ text-align:left; padding:16px; }
.qprompt.read::before{ display:none; }
.play-audio{ font-size:16px; }
.ex-sent{ line-height:1.5; }
.ex-py{ font-size:14px; font-weight:600; margin-bottom:3px; }
.ex-zh{ font-size:24px; font-weight:600; }
.ex-qline{ display:flex; gap:8px; align-items:flex-start; margin-top:12px; padding-top:12px; border-top:1px dashed var(--line-strong); }
.ex-star{ color:var(--seal); font-size:17px; line-height:1.4; }
.gap-q{ color:var(--muted); font-weight:700; }
.gap-blank{ display:inline-block; min-width:1.6em; border-bottom:2.5px solid var(--accent); margin:0 4px; color:transparent; }
.exopts.grid, .exopts.words{ display:grid; grid-template-columns:repeat(3,1fr); gap:9px; }
.exopt{ margin-bottom:0; }
.exopts.list .exopt{ width:100%; margin-bottom:9px; }
.exopt.emoji, .exopt.word{ display:flex; flex-direction:column; align-items:center; gap:6px; padding:14px 6px; text-align:center; }
.exopt.emoji .abc, .exopt.word .abc{ margin-right:0; }
.opt-emoji{ font-size:44px; line-height:1; }
.opt-emoji.sm{ font-size:22px; }
.opt-word .han{ font-size:24px; font-weight:700; }
.opt-word small{ display:block; font-size:12px; color:var(--muted); }
.opt-txt{ display:inline-flex; flex-direction:column; gap:2px; vertical-align:middle; }
.opt-txt .py{ font-size:13px; font-weight:600; }
.opt-txt .han{ font-size:18px; font-weight:700; }
.ex-review{ display:flex; flex-direction:column; }
.exr{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:10px 0; border-bottom:1px solid var(--line); }
.exr:last-child{ border-bottom:0; }
.exr-tag{ font-size:10.5px; font-weight:800; letter-spacing:.06em; color:var(--accent-ink); border:1px solid var(--line); background:transparent; border-radius:5px; padding:2px 7px; white-space:nowrap; }
.exr-zh{ font-size:16px; font-weight:600; flex:1; min-width:120px; }
.exr-ans{ font-size:15px; color:var(--muted); display:inline-flex; align-items:center; gap:4px; }

/* tone filter dot */
.tone-seg .tdot{ display:inline-block; width:9px; height:9px; border-radius:50%; background:currentColor; margin-right:6px; vertical-align:middle; }

/* hard mode: type the answer */
.diff-seg{ margin-top:-6px; }
.type-row{ display:flex; gap:8px; align-items:stretch; }
.type-input{ flex:1; min-width:0; background:var(--card-2); border:1px solid var(--line-strong); border-radius:var(--radius);
             padding:13px 14px; font:inherit; font-size:16px; font-weight:600; color:var(--ink); }
.type-input:focus{ outline:none; border-color:var(--accent); }
.type-input::placeholder{ color:var(--muted); opacity:.7; }
.type-ok{ width:100%; text-align:center; font-size:17px; font-weight:800; color:var(--good); padding:10px; }
.wrong-note{ background:var(--bad-soft); color:var(--bad); border-radius:10px; padding:9px 12px;
             font-weight:700; font-size:13.5px; margin-bottom:12px; text-align:left; }

/* ===== mastery bars ===== */
.level-bar{ display:block; height:3px; background:var(--line); border-radius:99px; overflow:hidden; margin-top:8px; }
.level-bar i{ display:block; height:100%; background:var(--accent); border-radius:99px; transition:width .5s ease; }
/* overall mastery: gold topics + seal-red exam quarter (ink · gold · cinnabar) */
.mbar{ position:relative; height:10px; background:var(--line); border-radius:99px; overflow:hidden; }
.mbar-fill{ position:absolute; top:0; height:100%; transition:width .5s ease; }
.mbar-fill.topics{ left:0; background:var(--accent); border-radius:99px 0 0 99px; }
.mbar-fill.exam{ background:var(--seal); }
.mbar-div{ position:absolute; top:0; height:100%; width:2px; background:var(--bg); }
.mbar-legend{ display:flex; gap:18px; margin-top:10px; font-size:12px; font-weight:700; color:var(--muted); }
.mbar-legend i.dot{ display:inline-block; width:8px; height:8px; border-radius:2px; margin-right:6px; vertical-align:middle; }
.mbar-legend i.dot.topics{ background:var(--accent); }
.mbar-legend i.dot.exam{ background:var(--seal); }
.ghead-prog{ display:flex; align-items:center; gap:9px; flex:1; max-width:190px; }
.ghead-prog .gbar{ max-width:none; }
.gbar-pct{ font-size:11.5px; font-weight:800; color:var(--muted); min-width:36px; text-align:right; font-variant-numeric:tabular-nums; }
.mode-score{ flex:none; font-size:12.5px; font-weight:800; color:var(--accent-ink);
             background:transparent; border:1px solid var(--line-strong); border-radius:999px; padding:3px 10px; font-variant-numeric:tabular-nums; }
/* topic picker chips: gold in progress, seal-stamped when complete */
.gpick{ display:flex; flex-wrap:wrap; gap:8px; }
.gpick-btn{ display:inline-flex; align-items:center; gap:8px; border:1px solid var(--line-strong); background:transparent;
            color:var(--ink); border-radius:9px; padding:8px 12px; font-weight:700; font-size:12.5px; line-height:1; }
.gpick-btn .gp-pct{ font-size:11px; font-weight:800; color:var(--muted); font-variant-numeric:tabular-nums; }
.gpick-btn.partial{ border-color:var(--warn); background:transparent; }
.gpick-btn.partial .gp-pct{ color:var(--warn); }
.gpick-btn.done{ border-color:var(--seal); background:var(--seal-soft); }
.gpick-btn.done .gp-pct{ color:var(--seal); }
.gpick-btn.on{ box-shadow:inset 0 0 0 1.5px var(--accent); color:var(--accent-ink); }
.newbest{ color:var(--seal); font-weight:800; margin:-4px 0 0; }

/* ===== streak flame ===== */
.streak{ border:none; cursor:pointer; font-family:inherit; -webkit-appearance:none; appearance:none; transition:transform .12s; }
.streak:active{ transform:scale(.94); }
.sk-flamewrap{ position:relative; display:inline-flex; align-items:center; }
.streak:not(.lit) .uic{ background-color:var(--muted); }
.streak:not(.lit) #streak-n{ color:var(--muted); }
.streak.lit .uic{ width:24px; height:24px; background-color:#ff6a16; animation:fireGlow 2.4s ease-in-out infinite; }
.streak.lit #streak-n{ color:#ff7e22; font-weight:800; }
.streak.justlit{ animation:skPop .5s ease; }
@keyframes skPop{ 0%{ transform:scale(.6); } 60%{ transform:scale(1.2); } 100%{ transform:scale(1); } }
@keyframes fireGlow{
  0%,100%{ filter:drop-shadow(0 0 2px rgba(255,110,0,.7)) drop-shadow(0 0 5px rgba(255,150,20,.4)); }
  50%    { filter:drop-shadow(0 0 4px rgba(255,95,0,.95)) drop-shadow(0 0 9px rgba(255,165,30,.6)); }
}
.streak.lit .sk-flamewrap::before, .streak.lit .sk-flamewrap::after,
.sk-flamewrap.on::before, .sk-flamewrap.on::after{
  content:""; position:absolute; left:46%; top:8%; width:3px; height:3px; border-radius:50%;
  background:radial-gradient(circle, #ffd27a 0%, #ff7a18 55%, rgba(255,90,0,0) 100%);
  pointer-events:none; opacity:0; animation:ember 2.3s ease-out infinite; }
.streak.lit .sk-flamewrap::after, .sk-flamewrap.on::after{ left:60%; animation-delay:1.15s; animation-duration:2.7s; }
@keyframes ember{
  0%  { transform:translate(-50%, 1px) scale(.7); opacity:0; }
  18% { opacity:.8; }
  100%{ transform:translate(-50%, calc(-1 * var(--rise, 10px))) scale(.15); opacity:0; }
}
.sk-flamewrap.on{ --rise:18px; }
.sk-flamewrap.on::before, .sk-flamewrap.on::after{ width:4px; height:4px; }
@media (min-width:560px){ .streak.lit .uic{ width:28px; height:28px; } }
@media (prefers-reduced-motion:reduce){
  .streak.lit .uic, .sk-flame.on{ animation:none; }
  .streak.lit .sk-flamewrap::before, .streak.lit .sk-flamewrap::after,
  .sk-flamewrap.on::before, .sk-flamewrap.on::after{ animation:none; opacity:0; }
}

.sk-ov{ position:fixed; inset:0; z-index:9998; display:flex; align-items:flex-start; justify-content:center;
  padding:62px 16px 24px; background:rgba(8,7,4,.66); backdrop-filter:blur(5px); opacity:0; transition:opacity .18s; overflow-y:auto; }
.sk-ov.on{ opacity:1; }
.sk-card{ width:100%; max-width:420px; background:var(--card); border:1px solid var(--line-strong); border-radius:var(--radius-lg);
  padding:18px 18px 20px; transform:translateY(10px); transition:transform .2s; }
.sk-ov.on .sk-card{ transform:none; }
.sk-top{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.sk-title{ font-size:11px; font-weight:800; color:var(--muted); letter-spacing:.16em; text-transform:uppercase; }
.sk-x{ border:none; background:none; color:var(--muted); font-size:17px; cursor:pointer; line-height:1; padding:4px; }
.sk-hero{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.sk-hero-l{ display:flex; align-items:center; gap:13px; }
.sk-flame{ width:48px; height:48px; flex:none; background-color:var(--muted); }
.sk-flame.cold{ background-color:var(--muted); opacity:.7; }
.sk-flame.on{ background-color:#ff6a16; animation:fireGlow 2.4s ease-in-out infinite; }
.sk-count{ font-family:var(--serif); font-size:46px; font-weight:600; line-height:1; color:var(--accent-ink); }
.sk-count.cold{ color:var(--muted); }
.sk-sub{ font-size:12px; color:var(--muted); margin-top:3px; }
.sk-best{ text-align:right; }
.sk-best b{ display:block; font-family:var(--serif); font-size:24px; font-weight:600; color:var(--ink); }

/* generic popup */
.modal-card{ text-align:left; }
.modal-body{ font-size:14.5px; line-height:1.65; }
.modal-body .decode{ margin-top:4px; }
.modal-body .btn.block{ margin-top:4px; }
.modal-body .han{ font-weight:700; }

/* inline sound icon (SVG) inherits currentColor */
.snd-ic{ display:inline-block; vertical-align:middle; }
