/* Tingdong: wayfinding look borrowed from Taipei Metro signage.
   Tone colours follow MRT lines: 1 Red (Tamsui-Xinyi), 2 Orange (Zhonghe-Xinlu),
   3 Green (Songshan-Xindian), 4 Blue (Bannan), neutral grey. */
:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-2: #f5f7f6;
  --ink: #121716;
  --ink-2: #4a5552;
  --ink-3: #6f7a77;
  --rule: #d6dcd9;
  --accent: #0b6db5;
  --accent-soft: #e2eff9;
  --on-accent: #ffffff;
  --hl: #fff2bd;
  --t1: #d1002a;
  --t2: #b06400;
  --t3: #007f58;
  --t4: #0063ad;
  --t5: #7a8582;
  --good: #007f58;
  --warn: #a86000;
  --bad: #c0222f;
  --shadow: 0 1px 2px rgba(18, 23, 22, .06), 0 6px 18px rgba(18, 23, 22, .06);
  --f-ui: "Barlow", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-label: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --f-han: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --f-py: "Noto Sans", "Barlow", system-ui, sans-serif;
  --r: 10px;
  --tab-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1110;
    --surface: #151b1a;
    --surface-2: #1a2220;
    --ink: #e7edeb;
    --ink-2: #aab6b2;
    --ink-3: #82908c;
    --rule: #29332f;
    --accent: #4aa2ea;
    --accent-soft: #15293a;
    --on-accent: #06121c;
    --hl: #3b3313;
    --t1: #ff6f80;
    --t2: #f0ad45;
    --t3: #43d199;
    --t4: #68b4ff;
    --t5: #8d9a96;
    --good: #43d199;
    --warn: #f0ad45;
    --bad: #ff6f80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--f-ui); -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top, 0) 0 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.han { font-family: var(--f-han); }
.py { font-family: var(--f-py); }
.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); }
.t4 { color: var(--t4); } .t5 { color: var(--t5); }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
#app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom, 0)); min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding-block: 14px 10px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font: 700 26px/1 var(--f-han); letter-spacing: .02em; }
.brand span { font: 600 13px/1 var(--f-label); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.topbar .spacer { flex: 1; }
.chip-btn { white-space: nowrap; flex: none; border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: 600 14px/1 var(--f-label); letter-spacing: .02em; display: inline-flex; gap: 6px; align-items: center; }
.chip-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

body.watching .tabs { display: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom, 0); }
.tabs nav { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tab-h); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-3); font: 600 12px/1 var(--f-label); letter-spacing: .06em; text-transform: uppercase; position: relative; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--ink); }
.tabs a.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
.tabs .badge { position: absolute; top: 7px; left: calc(50% + 6px); background: var(--t1); color: #fff; border-radius: 999px; font: 700 10px/16px var(--f-ui); min-width: 16px; padding: 0 4px; text-align: center; }

.section-h { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.section-h h2 { margin: 0; font: 700 15px/1.2 var(--f-label); letter-spacing: .08em; text-transform: uppercase; }
.section-h .line { width: 22px; height: 6px; border-radius: 3px; background: var(--c, var(--accent)); flex: none; }
.section-h small { color: var(--ink-3); font-size: 13px; margin-left: auto; text-align: right; }
.banner { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; font-size: 14px; margin-top: 8px; }
.banner b { display: block; }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--rule)); }

/* ---------- buttons & inputs ---------- */
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font: 600 15px/1.1 var(--f-ui); background: var(--surface-2); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; border: 1px solid var(--rule); }
.btn.small { min-height: 34px; padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }
.field { display: flex; gap: 8px; }
.field input, .input { flex: 1; min-width: 0; border: 1px solid var(--rule); background: var(--surface); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
label.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
label.row:last-child { border-bottom: 0; }
label.row span small { display: block; color: var(--ink-3); font-size: 13px; }
.switch { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--rule); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- library ---------- */
.hero { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; display: grid; text-decoration: none; color: inherit; }
.hero .thumb { aspect-ratio: 16/9; }
.hero .body { padding: 14px 16px 16px; display: grid; gap: 8px; }
.hero .why { font: 600 13px/1.2 var(--f-label); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero h3 { margin: 0; font: 700 20px/1.3 var(--f-han); text-wrap: balance; }
.thumb { background: var(--surface-2) center/cover no-repeat; position: relative; }
.thumb.lesson { display: grid; place-items: center; background: linear-gradient(135deg, var(--c1, #0b6db5), var(--c2, #007f58)); color: #fff; }
.thumb.lesson b { font: 700 clamp(26px, 8vw, 40px)/1 var(--f-han); letter-spacing: .06em; text-shadow: 0 1px 8px rgba(0,0,0,.2); }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.72); color: #fff; font: 600 12px/1 var(--f-ui); padding: 3px 6px; border-radius: 5px; }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: min(72%, 260px); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.card { scroll-snap-align: start; background: var(--surface); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; display: grid; grid-template-rows: auto 1fr; box-shadow: var(--shadow); min-width: 0; }
.card .thumb { aspect-ratio: 16/9; }
.card .body { padding: 10px 12px 12px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.card h3 { margin: 0; font: 600 15px/1.3 var(--f-han); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fit { display: flex; align-items: center; gap: 8px; font: 600 13px/1 var(--f-label); letter-spacing: .02em; }
.fit .bar { flex: 1; height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.fit .bar i { display: block; height: 100%; background: var(--fc, var(--good)); border-radius: 3px; }
.fit.easy { --fc: var(--t4); } .fit.right { --fc: var(--good); } .fit.stretch { --fc: var(--warn); } .fit.hard { --fc: var(--bad); }
.stations { display: flex; align-items: center; gap: 0; }
.stations i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--ink-3); background: var(--surface); flex: none; }
.stations i.done { background: var(--accent); border-color: var(--accent); }
.stations b { width: 10px; height: 2px; background: var(--ink-3); flex: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.list { display: grid; gap: 10px; }
.row-card { display: grid; grid-template-columns: 120px 1fr; gap: 12px; background: var(--surface); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.row-card .thumb { width: 120px; height: 100%; min-height: 68px; aspect-ratio: auto; }
.row-card .body { padding: 10px 12px 10px 0; display: grid; gap: 5px; align-content: center; min-width: 0; }
.row-card h3 { margin: 0; font: 600 15px/1.3 var(--f-han); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.queue { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 10px; }
.queue .q { display: flex; gap: 10px; align-items: center; font-size: 14px; background: var(--surface); border-radius: 10px; padding: 8px 12px; }
.queue .q .st { font: 700 11px/1 var(--f-label); letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; border-radius: 5px; background: var(--surface-2); flex: none; }
.queue .q .st.done { color: var(--good); } .queue .q .st.failed, .queue .q .st.skipped { color: var(--bad); } .queue .q .st.working { color: var(--accent); }
.queue .q .txt { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); background: var(--surface); border-radius: 12px; border: 1px dashed var(--rule); }

/* ---------- watch ---------- */
.watch { padding-bottom: 110px; }
.watch-top { position: sticky; top: 0; z-index: 20; background: var(--bg); margin: 0 -16px; padding: 0 16px 8px; }
.watch-bar { display: flex; align-items: center; gap: 8px; padding-block: 8px; }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.watch-bar h1 { flex: 1; min-width: 0; margin: 0; font: 600 16px/1.25 var(--f-han); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; max-height: 34vh; margin-inline: auto; width: 100%; }
.player.vertical { aspect-ratio: 9/16; max-height: 42vh; width: auto; }
.player iframe, .player > div { width: 100%; height: 100%; border: 0; display: block; }
.player .offline { color: #ddd; display: grid; place-items: center; height: 100%; text-align: center; padding: 16px; font-size: 14px; }
.stage { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 6px; align-content: center; }
.stage .spk { font: 700 12px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.stage .big { font: 500 22px/1.8 var(--f-han); }
.stage .en { color: var(--ink-2); }

.passes { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 10px; position: relative; }
.passes::before { content: ""; position: absolute; left: 12.5%; right: 12.5%; top: 13px; height: 4px; background: var(--rule); border-radius: 2px; }
.pass { border: 0; background: none; display: grid; justify-items: center; gap: 4px; position: relative; padding: 4px 2px; }
.pass .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 4px solid var(--ink-3); display: grid; place-items: center; font: 700 10px/1 var(--f-label); }
.pass.done .dot { border-color: var(--accent); background: var(--accent); }
.pass.on .dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pass .code { font: 700 11px/1 var(--f-label); letter-spacing: .08em; color: var(--ink-3); }
.pass .name { font: 600 13px/1.1 var(--f-label); }
.pass.on .name { color: var(--accent); }
.progress-line { display: flex; justify-content: space-between; font: 600 12px/1 var(--f-label); color: var(--ink-3); letter-spacing: .04em; margin-top: 6px; }

.phrases { margin-top: 12px; background: var(--surface); border-radius: 12px; padding: 4px 12px; }
.phrases summary { padding: 10px 0; font: 700 13px/1 var(--f-label); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.phrases ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.phrases li { display: flex; gap: 10px; align-items: baseline; }
.phrases li .han { font-size: 18px; }
.phrases li button { margin-left: auto; }

.lines { display: grid; gap: 2px; margin-top: 12px; }
.ln { padding: 10px 12px; border-radius: 10px; display: grid; gap: 4px; position: relative; scroll-margin-top: 45vh; }
.ln.on { background: var(--hl); }
.ln .tm { font: 600 11px/1 var(--f-label); color: var(--ink-3); letter-spacing: .04em; display: flex; gap: 8px; align-items: center; }
.ln .tm .spk { text-transform: uppercase; letter-spacing: .1em; }
.ln .tm .spk.you { color: var(--accent); }
.ln .zh { font: 400 21px/1.9 var(--f-han); word-break: keep-all; overflow-wrap: anywhere; }
.ln .en { color: var(--ink-2); font-size: 15px; }
.ln .note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-left: 3px solid var(--t2); padding: 6px 10px; border-radius: 0 6px 6px 0; }
.ln.hide-en .en, .ln.hide-en .note { display: none; }
.ln.hide-py rt { visibility: hidden; }
.ln.ears .zh, .ln.ears .en, .ln.ears .note { filter: blur(7px); opacity: .5; }
.ln.ears.peek .zh, .ln.ears.peek .en, .ln.ears.peek .note { filter: none; opacity: 1; }
.ln .more { position: absolute; right: 4px; top: 4px; }
.w { cursor: pointer; border-radius: 4px; padding: 0 1px; margin-inline-end: .22em; }
ruby { padding-inline: .04em; }
.w:hover { background: var(--accent-soft); }
.w.st-l { box-shadow: inset 0 -2px 0 var(--accent); }
.w.st-u { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--t1) 60%, transparent); }
.w.st-new { box-shadow: inset 0 -1px 0 var(--ink-3); }
.w.sel { background: var(--accent-soft); }
.w.num rt { color: var(--ink-3); }
ruby { ruby-position: over; }
rt { font: 500 11px/1 var(--f-py); letter-spacing: 0; text-align: center; }
.no-tones rt { color: var(--ink-3) !important; }
.jump { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0)); z-index: 25; }

.controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--rule); padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0)); }
.controls .in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.controls .play { width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: var(--on-accent); border: 0; display: grid; place-items: center; }
.controls .play svg { width: 28px; height: 28px; }
.controls .speed { font: 700 14px/1 var(--f-label); min-width: 48px; }
.shadow-meter { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.shadow-meter i { display: block; height: 100%; width: 0; background: var(--t3); }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(8, 12, 11, .45); z-index: 50; animation: fade .15s ease-out; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 86vh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 18px 18px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0)); box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: rise .2s ease-out; max-width: 760px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; touch-action: none; background: var(--rule); border-radius: 3px; margin: 4px auto 12px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0 } }
@keyframes fade { from { opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .backdrop, .sheet { animation: none; } }
.word-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.word-head .hz { font: 500 44px/1.1 var(--f-han); }
.word-head .pys { font: 500 20px/1.2 var(--f-py); }
.status-pill { font: 700 11px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; padding: 5px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.status-pill.l { background: var(--accent-soft); color: var(--accent); }
.status-pill.k { color: var(--good); }
.status-pill.u { color: var(--t1); }
.gloss { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.gloss li::before { content: "·"; color: var(--ink-3); margin-right: 8px; }
.ctx { margin-top: 10px; padding: 10px 12px; background: var(--hl); border-radius: 10px; }
.ctx .han { font-size: 18px; }
.ctx b { font-weight: 700; }
.sheet .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.sheet h4 { margin: 18px 0 8px; font: 700 13px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.chars { display: grid; gap: 10px; }
.char { border: 1px solid var(--rule); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.char .top { display: flex; gap: 12px; align-items: center; }
.char .glyph { font: 500 40px/1 var(--f-han); width: 52px; text-align: center; }
.char .type { font: 700 11px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.part { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; }
.part .k { font: 700 11px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.part .v { font-size: 14px; }
.part .v .han { font-size: 20px; margin-right: 6px; }
.family { display: flex; flex-wrap: wrap; gap: 6px; }
.family span { display: inline-grid; justify-items: center; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; min-width: 44px; }
.family span .han { font-size: 20px; line-height: 1.1; }
.family span .py { font-size: 11px; }
.family span.known { outline: 2px solid color-mix(in srgb, var(--good) 55%, transparent); }
.match { font-size: 13px; color: var(--ink-2); }

/* ---------- review ---------- */
.review-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; min-height: 300px; align-content: start; }
.review-card .prompt { font: 700 12px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.review-card .front-hz { font: 500 56px/1.2 var(--f-han); text-align: center; padding: 24px 0; }
.review-card .listen { display: flex; gap: 10px; justify-content: center; padding: 18px 0; }
.review-card .mini { aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: #000; max-height: 26vh; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.grades button { border: 0; border-radius: 12px; padding: 10px 4px; display: grid; gap: 4px; justify-items: center; font: 700 15px/1 var(--f-ui); background: var(--surface-2); min-height: 58px; }
.grades button small { font: 600 12px/1 var(--f-label); color: var(--ink-3); }
.grades .g1 { color: var(--bad); } .grades .g2 { color: var(--warn); } .grades .g3 { color: var(--good); } .grades .g4 { color: var(--t4); }
.reveal { width: 100%; margin-top: 12px; }

/* ---------- stats / me ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border-radius: 12px; padding: 14px; display: grid; gap: 2px; }
.tile .v { font: 700 30px/1.1 var(--f-ui); font-variant-numeric: tabular-nums; }
.tile .k { font: 600 13px/1.2 var(--f-label); letter-spacing: .04em; color: var(--ink-3); }
.panel { background: var(--surface); border-radius: 12px; padding: 4px 14px; }
.panel.pad { padding: 14px; }
.week svg { width: 100%; height: 120px; display: block; }
.week text { fill: var(--ink-3); font: 600 11px var(--f-label); }
.countdown { display: flex; align-items: center; gap: 14px; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 14px 16px; }
.countdown .n { font: 700 40px/1 var(--f-ui); font-variant-numeric: tabular-nums; }
.countdown .t { font: 600 14px/1.3 var(--f-label); letter-spacing: .04em; }
.countdown .t b { display: block; font: 700 18px/1.2 var(--f-han); letter-spacing: 0; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; }
.word-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 10px; padding: 10px 12px; text-align: left; border: 0; width: 100%; }
.word-row .hz { font: 500 24px/1 var(--f-han); min-width: 56px; }
.word-row .g { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-row .pyl { font: 500 13px/1.2 var(--f-py); }
.word-row > div { min-width: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 90px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); animation: rise .2s ease-out; }
.gate { min-height: 80vh; display: grid; align-content: center; gap: 16px; max-width: 420px; margin: 0 auto; }
.gate h1 { font: 700 48px/1 var(--f-han); margin: 0; }
.gate p { margin: 0; color: var(--ink-2); }
.wrap-list { display: grid; gap: 6px; }
.wrap-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; border-bottom: 1px solid var(--rule); padding: 8px 0; }
.wrap-item .seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.wrap-item .seg button { border: 0; background: transparent; padding: 7px 10px; font: 600 13px/1 var(--f-label); }
.wrap-item .seg button.on { background: var(--ink); color: var(--bg); }
@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rail { grid-auto-columns: 240px; }
  .ln .zh { font-size: 23px; }
}

/* ---------- zhuyin & layers ---------- */
.zy { font-family: var(--f-han); letter-spacing: 0; }
rt.zy { font: 500 11px/1 var(--f-han); letter-spacing: -.02em; }
.cell { display: inline-flex; flex-direction: column; align-items: center; vertical-align: bottom; line-height: 1; }
.cell .a1 { font: 500 11px/1.1 var(--f-py); }
.cell .a2 { font: 500 10.5px/1.1 var(--f-han); margin-bottom: 2px; }
.cell .c { line-height: 1.3; }
.ln .zh:has(.cell) { line-height: 1.5; }
.ln.hide-py .cell .a1, .ln.hide-py .cell .a2 { visibility: hidden; }
.no-tones .cell .a1, .no-tones .cell .a2 { color: var(--ink-3) !important; }
.layers { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.layers .chip-btn { padding: 5px 10px; font-size: 13px; }
.src-badge { font: 700 11px/1 var(--f-label); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- explore ---------- */
.level-ladder { display: flex; align-items: center; }
.level-ladder b { flex: 1; height: 3px; background: var(--rule); margin: 0 4px 16px; }
.level-ladder .rung { display: grid; justify-items: center; gap: 4px; }
.level-ladder .rung i { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--ink-3); background: var(--surface); }
.level-ladder .rung.on i { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.level-ladder .rung small { font: 600 12px/1 var(--f-label); color: var(--ink-3); white-space: nowrap; }
.level-ladder .rung.on small { color: var(--accent); }
.src-card { background: var(--surface); border-radius: 12px; padding: 14px; display: grid; gap: 6px; box-shadow: var(--shadow); }
.src-card h3 { margin: 0; font: 700 16px/1.3 var(--f-han); }
.src-card p { margin: 0; color: var(--ink-2); font-size: 14px; }
.src-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.src-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.accent-pill { flex: none; font: 700 11px/1 var(--f-label); letter-spacing: .08em; text-transform: uppercase; padding: 5px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.accent-pill.tw { background: var(--accent-soft); color: var(--accent); }
.audio-src { font: 600 12px/1 var(--f-label); color: var(--ink-3); letter-spacing: .04em; }

/* ---------- other ways to say it, expressions, culture ---------- */
.nu-list { display: grid; gap: 8px; }
.nu-anchor { font-size: 13px; margin-top: 6px; }
.nu-alt { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; font-size: 15px; }
.nu-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nu-zh { font: 500 22px/1.6 var(--f-han); }
.nu-acts { margin-left: auto; display: flex; gap: 2px; }
.nu-acts .btn { padding-inline: 8px; }
.nu-ex { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 6px; padding: 6px 0 0; border-top: 1px dashed var(--rule); margin-top: 2px; }
.nu-ex .han { font-size: 17px; }
.nu-ex .muted { grid-column: 1 / -1; font-size: 14px; }
.nu-ex .icon-btn { width: 32px; height: 32px; }
.nu-ex .icon-btn svg, .cy-line .icon-btn svg { width: 16px; height: 16px; }
.nu-heard { display: inline-flex; gap: 6px; align-items: center; font: 600 14px/1 var(--f-label); color: var(--accent); text-decoration: none; padding-top: 4px; }
.nu-heard svg { width: 14px; height: 14px; }
.nu-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.nu-badges span, .xp-type { font: 700 11px/1 var(--f-label); letter-spacing: .06em; text-transform: uppercase; padding: 4px 6px; border-radius: 5px; --c: var(--t5);
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); white-space: nowrap; }
.reg.casual { --c: var(--t3); } .reg.polite, .reg.formal { --c: var(--t4); } .reg.slang { --c: var(--t1); }
.reg.internet { --c: var(--t2); } .reg.hokkien { --c: var(--accent); }
.rgn.tw { --c: var(--good); } .rgn.cn { --c: var(--warn); }
.xp-type { --c: var(--t2); }
.xp-marks { display: flex; gap: 6px; flex-wrap: wrap; }
.xp-mark { border: 1px solid color-mix(in srgb, var(--t2) 45%, transparent); background: transparent; color: var(--t2); border-radius: 999px;
  padding: 3px 9px; font: 600 12px/1.2 var(--f-label); letter-spacing: .02em; }
.xp-mark b { font: 500 14px/1 var(--f-han); color: var(--ink); }
.ln.ears .xp-marks { filter: blur(7px); opacity: .5; }
.ln.ears.peek .xp-marks { filter: none; opacity: 1; }
.ln.hide-en .xp-marks { display: none; }
.xp-row { cursor: pointer; }
.xp-row .hz { font-size: 20px; }
.cy-hz { font: 500 32px/1.7 var(--f-han); }
.cy-line { display: grid; grid-template-columns: 1fr auto; align-items: start; column-gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.cy-line .zh { font: 400 19px/1.9 var(--f-han); }
.cy-line .en { grid-column: 1 / -1; color: var(--ink-2); font-size: 14px; }
.cy-line .icon-btn { width: 32px; height: 32px; margin-top: 6px; }

/* ---------- today's plan ---------- */
.today { margin-top: 12px; background: var(--surface); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); display: grid; gap: 8px; }
.today-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.today-h h2 { margin: 0; font: 700 13px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; }
.today-len { margin-left: auto; display: flex; gap: 6px; }
.today-len .chip-btn { padding: 5px 10px; font-size: 13px; }
.today-focus p { margin: 0 0 4px; font-size: 14px; color: var(--ink-2); }
.today-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.today-steps a { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px;
  background: var(--surface-2); color: var(--ink); text-decoration: none; }
.today-steps .done a { opacity: .6; }
.today-ic { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.today-ic svg { width: 16px; height: 16px; }
.today-steps .done .today-ic { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.today-txt { display: grid; min-width: 0; }
.today-txt b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-txt small { color: var(--ink-3); font-size: 13px; }
.today-min { color: var(--ink-3); font-size: 13px; }

/* ---------- tones ---------- */
.tone-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 12px; }
.ts { display: grid; gap: 4px; font-size: 12px; }
.ts b { font: 700 12px/1 var(--f-label); letter-spacing: .06em; color: var(--c); }
.ts .bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.ts .bar i { display: block; height: 100%; background: var(--c); }
.ts small { color: var(--ink-3); }
.ts.t1 { --c: var(--t1); } .ts.t2 { --c: var(--t2); } .ts.t3 { --c: var(--t3); } .ts.t4 { --c: var(--t4); }
.tone-card { text-align: center; justify-items: center; gap: 8px; }
.tone-canvas { width: 100%; height: 150px; display: block; background: var(--surface-2); border-radius: 10px; }
.tone-level { width: 100%; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.tone-level i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .05s linear; }
.tone-verdict { min-height: 48px; display: grid; gap: 4px; }
.tone-verdict p { margin: 0; font-size: 15px; }
.tone-sylls { display: flex; gap: 10px; justify-content: center; font: 500 18px/1 var(--f-py); }
.tone-sylls span { display: inline-flex; gap: 4px; align-items: center; }
.tone-sylls svg { width: 16px; height: 16px; }
.tone-sylls .ok { color: var(--good); } .tone-sylls .off { color: var(--bad); }
.tone-actions .tone-mic { font-size: 17px; }
.rec-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--bad); display: inline-block; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.tone-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* level check */
.place-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.place-actions .btn { justify-content: center; min-height: 52px; }
.place-word { text-align: center; }
.place-word .front-hz { padding: 8px 0; }
.place-opts { display: grid; gap: 8px; }
.place-opts .btn { justify-content: center; min-height: 48px; white-space: normal; text-align: center; }
.place-opts .btn.ok { background: var(--good); color: var(--surface); }
.place-opts .btn.off { background: var(--bad); color: var(--surface); }

/* coach */
.coach-suggest { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 8px; }
.coach-suggest p { margin: 0; color: var(--ink); }
.coach-suggest small { display: block; margin-top: 4px; color: var(--ink-3); font-size: 13px; }
.coach-btns { display: flex; gap: 8px; }
.today-focus .linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
.coach-weekly p { line-height: 1.5; }

/* words tools + practice */
.word-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.word-tools:empty { display: none; }
.practice-back { display: grid; gap: 8px; }
.practice-back .front-hz { padding: 8px 0; }
.practice-grades { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.practice-grades .btn { justify-content: center; min-height: 52px; }

/* levels, progress, browse */
.lvl { flex: none; font: 700 11px/1 var(--f-label); letter-spacing: .04em; padding: 3px 6px; border-radius: 6px;
  color: var(--surface); background: var(--ink-3); }
.lvl.lv-a1, .lvl.lv-a2 { background: var(--t4); }
.lvl.lv-b1, .lvl.lv-b2 { background: var(--t3); }
.lvl.lv-c1, .lvl.lv-c2 { background: var(--t1); }
.vstatus { display: flex; gap: 10px; font: 600 12px/1.2 var(--f-label); color: var(--ink-3); margin-top: 4px; }
.vstatus .saved-mark { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); }
.vstatus .saved-mark svg { width: 12px; height: 12px; }
.vstatus .st-watching { color: var(--accent); }
.vstatus .st-done { color: var(--good); }
.browse-row { display: flex; justify-content: flex-end; margin-top: 10px; }
.browse-filters { display: grid; gap: 8px; margin-top: 10px; }
.fgroup { display: grid; gap: 4px; }
.fgroup .chips { margin: 0; }
.flabel { font: 700 11px/1 var(--f-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
