/* Hanzi-Trainer — "Qinghua" (blue-and-white porcelain) by day, ink by night.
   Layout: one centered column (max 44rem), sticky status bar on top, tab bar at the bottom. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eaeef6;
  --line: #d5dceb;
  --fg: #16203a;
  --fg-muted: #5b6784;
  --accent: #2547a6;        /* cobalt of qinghua porcelain */
  --accent-soft: #dde5fb;
  --accent-fg: #ffffff;
  --seal: #b8322a;          /* cinnabar seal ink */
  --ok: #1f7a4d;
  --ok-soft: #d9f1e4;
  --bad: #b23a2c;
  --bad-soft: #f8dcd7;
  --gold: #a87400;
  --gold-soft: #f6e7c1;
  --heat-0: #e3e8f2;
  --heat-1: #b9c8ee;
  --heat-2: #7f9be0;
  --heat-3: #4469c9;
  --heat-4: #1f3d94;
  --shadow: 0 1px 2px rgba(22, 32, 58, .06), 0 4px 16px rgba(22, 32, 58, .06);
  --radius: 14px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-han: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-kai: "KaiTi", "STKaiti", "Kaiti SC", "AR PL UKai CN", var(--font-han);
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b26; --surface-2: #1c2433; --line: #2a3446;
    --fg: #e6eaf3; --fg-muted: #94a0ba; --accent: #8fb0ff; --accent-soft: #22325a; --accent-fg: #0d1117;
    --seal: #e2574c; --ok: #4cc38a; --ok-soft: #133b2a; --bad: #f07c6c; --bad-soft: #43201c;
    --gold: #e9b949; --gold-soft: #3a2e10;
    --heat-0: #1c2433; --heat-1: #22396b; --heat-2: #2f56a8; --heat-3: #4f7be0; --heat-4: #9bb8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151b26; --surface-2: #1c2433; --line: #2a3446;
  --fg: #e6eaf3; --fg-muted: #94a0ba; --accent: #8fb0ff; --accent-soft: #22325a; --accent-fg: #0d1117;
  --seal: #e2574c; --ok: #4cc38a; --ok-soft: #133b2a; --bad: #f07c6c; --bad-soft: #43201c;
  --gold: #e9b949; --gold-soft: #3a2e10;
  --heat-0: #1c2433; --heat-1: #22396b; --heat-2: #2f56a8; --heat-3: #4f7be0; --heat-4: #9bb8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.han { font-family: var(--font-han); }
.kai { font-family: var(--font-kai); }
.muted { color: var(--fg-muted); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- frame ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  padding-top: max(8px, env(safe-area-inset-top));
}
.topbar-inner { max-width: 44rem; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .01em; }
.brand .logo { width: 28px; height: 28px; }
.topstats { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pill.flame { color: var(--seal); }
.pill.xp { color: var(--gold); }
main {
  flex: 1; width: 100%; max-width: 44rem; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 96px max(16px, env(safe-area-inset-left));
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.tabbar-inner { max-width: 44rem; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; border: 0; background: none;
  color: var(--fg-muted); font-size: .72rem; cursor: pointer; border-radius: 10px;
}
.tab .ico { font-family: var(--font-han); font-size: 1.25rem; line-height: 1.2; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:focus-visible, .btn:focus-visible, .opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.in-session .tabbar { display: none; }
body.in-session main { padding-bottom: 24px; }

/* ---------- generic ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2, .card h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 600; }
h1.view-title { font-size: 1.35rem; margin: 4px 0 2px; font-weight: 650; text-wrap: balance; }
.sub { color: var(--fg-muted); margin: 0; font-size: .92rem; }
.label { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550; min-height: 44px;
}
.btn { text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.big { width: 100%; padding: 16px; font-size: 1.1rem; border-radius: 16px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; font-size: 1.1rem; }
.icon-btn.playing { border-color: var(--accent); color: var(--accent); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.ring { width: 112px; height: 112px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-bg { stroke: var(--surface-2); }
.ring .ring-fg { stroke: var(--accent); transition: stroke-dashoffset .8s ease; stroke-linecap: round; }
.ring.done .ring-fg { stroke: var(--ok); }
.ring .ring-text { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .ring-text b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.ring .ring-text small { color: var(--fg-muted); font-size: .72rem; }
.streak-big { font-size: 2.1rem; font-weight: 700; color: var(--seal); font-variant-numeric: tabular-nums; line-height: 1; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.kpi b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .78rem; color: var(--fg-muted); }
.kpi.warn b { color: var(--bad); }
.kpi.good b { color: var(--ok); }

/* seal stamp for the rank */
.seal {
  display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 8px; background: var(--seal);
  color: #fff; font-family: var(--font-kai); font-size: 1.15rem; line-height: 1.05; writing-mode: vertical-rl;
  box-shadow: inset 0 0 0 3px color-mix(in srgb, #fff 25%, var(--seal)); letter-spacing: .05em; flex: none;
}
.levelbar { flex: 1; min-width: 0; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), color-mix(in srgb, var(--gold) 60%, var(--seal))); border-radius: inherit; transition: width .6s ease; }

/* ---------- quiz ---------- */
.session-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.session-head .bar { flex: 1; }
.session-head .bar > i { background: var(--accent); }
.combo { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.combo.hot { color: var(--seal); }
.prompt { text-align: center; padding: 20px 12px 16px; position: relative; }
.prompt .tag { position: absolute; left: 12px; top: 10px; font-size: .72rem; color: var(--fg-muted); letter-spacing: .05em; text-transform: uppercase; }
.prompt .tag.hard { color: var(--bad); }
.prompt .speak { position: absolute; right: 10px; top: 8px; }
.hanzi-big { font-family: var(--font-han); font-size: clamp(3rem, 14vw, 4.6rem); line-height: 1.15; margin: 10px 0 4px; word-break: keep-all; }
.hanzi-big.long { font-size: clamp(2.2rem, 10vw, 3.4rem); }
.prompt .py { font-size: 1.15rem; color: var(--fg-muted); min-height: 1.6em; }
.prompt .meaning-prompt { font-size: 1.2rem; margin: 18px 0 8px; text-wrap: balance; }
.cloze { font-family: var(--font-han); font-size: 1.55rem; line-height: 1.6; margin: 14px 0 6px; text-wrap: balance; }
.cloze .gap { display: inline-block; min-width: 2.4em; border-bottom: 3px solid var(--accent); color: var(--accent); }
.cloze .gap.filled-ok { color: var(--ok); border-color: var(--ok); }
.cloze .gap.filled-bad { color: var(--bad); border-color: var(--bad); }
.cloze-hint { color: var(--fg-muted); font-size: .95rem; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.options.hanzi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt {
  text-align: left; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; min-height: 64px; font-size: .9rem; line-height: 1.35; display: flex; gap: 8px; align-items: flex-start;
  transition: border-color .15s, background .15s, transform .1s; min-width: 0; overflow-wrap: anywhere;
}
.opt .k { font-size: .7rem; color: var(--fg-muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; flex: none; margin-top: 1px; }
.opt .t { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.options.hanzi .opt { justify-content: center; text-align: center; font-family: var(--font-han); font-size: 1.6rem; min-height: 72px; align-items: center; }
.options.hanzi .opt .k { display: none; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
.opt.dim { opacity: .55; }
.opt:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.reveal { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.verdict { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.verdict .xp-gain { margin-left: auto; color: var(--gold); font-variant-numeric: tabular-nums; }
.entry-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.entry-head .han { font-size: 2rem; line-height: 1.2; }
.entry-head .py { color: var(--accent); font-size: 1.1rem; }
.readings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.readings li { line-height: 1.45; }
.readings .rp { color: var(--accent); font-weight: 600; margin-right: 6px; }
.readings .de { color: var(--fg-muted); display: block; font-size: .92rem; }
.sentence { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: start; }
.sentence .zh { font-family: var(--font-han); font-size: 1.25rem; line-height: 1.55; }
.sentence .zh mark { background: none; color: var(--accent); font-weight: 700; }
.sentence .spy { color: var(--fg-muted); font-size: .9rem; grid-column: 1; }
.sentence .tr { font-size: .92rem; grid-column: 1; }
.sentence .icon-btn { grid-row: 1 / span 2; grid-column: 2; }
.next-row { display: flex; gap: 10px; }
.next-row .btn { flex: 1; }
.float-xp { position: fixed; left: 50%; top: 30%; transform: translateX(-50%); font-weight: 800; font-size: 1.6rem; color: var(--gold); pointer-events: none; animation: floatup 1s ease forwards; z-index: 50; }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -60px); } }

/* ---------- end of session ---------- */
.result-hero { text-align: center; padding: 22px 12px; }
.result-hero .big { font-size: 3rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.badge-new { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--gold-soft); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.badge-new .bi { font-size: 2rem; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- charts ---------- */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--fg-muted); font-size: 11px; font-family: var(--font-ui); }
.chart .grid line { stroke: var(--line); }
.heat-scroll { overflow-x: auto; padding-bottom: 4px; }
.heat-scroll svg { width: auto; }
.heat text { font-size: 10px; fill: var(--fg-muted); font-family: var(--font-ui); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--fg-muted); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; padding: 4px 8px; font-size: .78rem; white-space: nowrap; z-index: 5; }
.wordlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.wordlist li { display: grid; grid-template-columns: 4.5rem 1fr 4.5rem; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.wordlist li:last-child { border-bottom: 0; }
.wordlist .han { font-size: 1.25rem; }
.wordlist .gl { font-size: .85rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordlist .rb { height: 6px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.wordlist .rb i { display: block; height: 100%; background: var(--bad); }

/* ---------- badges ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); gap: 10px; }
.badge { text-align: center; padding: 14px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.badge .bi { font-size: 2rem; display: block; }
.badge b { display: block; font-size: .92rem; margin-top: 4px; }
.badge small { color: var(--fg-muted); font-size: .76rem; display: block; line-height: 1.3; margin-top: 2px; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.ranks { display: flex; gap: 8px; flex-wrap: wrap; }
.ranks .r { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); font-size: .85rem; }
.ranks .r.me { outline: 2px solid var(--seal); }

/* ---------- settings / forms ---------- */
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field label { flex: 1; min-width: 0; }
.field small { display: block; color: var(--fg-muted); font-size: .8rem; }
.field input[type="number"], .field select { width: 7rem; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg-muted); transition: transform .2s, background .2s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent-fg); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; color: var(--fg-muted); }
.dropzone.over { border-color: var(--accent); color: var(--accent); }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: .9rem; }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 70; max-width: calc(100% - 32px); animation: rise .2s ease; font-size: .92rem; }
.login { max-width: 22rem; margin: 12vh auto 0; }
.login input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); margin: 10px 0; }
.foot { text-align: center; font-size: .75rem; color: var(--fg-muted); margin-top: 24px; }

@media (max-width: 420px) {
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .options.hanzi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi { padding: 8px; }
  .kpi b { font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- writing ---------- */
.write-area { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 12px; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.slot { width: 44px; height: 44px; border-radius: 8px; border: 1.5px dashed var(--line); display: grid; place-items: center; font-family: var(--font-han); font-size: 1.6rem; color: var(--fg-muted); background: var(--surface); }
.slot.current { border-style: solid; border-color: var(--accent); }
.slot.done-ok { border-style: solid; border-color: var(--ok); color: var(--fg); }
.slot.done-bad { border-style: solid; border-color: var(--bad); color: var(--fg); }
.pad {
  --ink: var(--fg);
  position: relative; width: min(100%, 360px); aspect-ratio: 1; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); touch-action: none; user-select: none; -webkit-user-select: none;
}
.pad.complete { box-shadow: 0 0 0 3px var(--ok), var(--shadow); transition: box-shadow .2s; }
.pad-svg, .pad-ink { position: absolute; inset: 0; width: 100%; height: 100%; }
.pad-ink { touch-action: none; cursor: crosshair; border-radius: 18px; }

.pad-ink.fade { opacity: 0; transition: opacity .35s ease; }
.pad-ink.bad.fade { transition: opacity .45s ease; }
.pad-grid rect { fill: none; stroke: var(--line); stroke-width: 6; }
.pad-grid line { stroke: var(--line); stroke-width: 3; stroke-dasharray: 14 14; }
.pad-outline path { fill: var(--fg); opacity: 0; transition: opacity .2s; }
.pad.show-outline .pad-outline path { opacity: .1; }
.pad-done path { fill: var(--ink); }
.pad-done path.auto { fill: var(--bad); }
.pad-done path.appear { animation: ink-in .25s ease; }
@keyframes ink-in { from { opacity: .2; } to { opacity: 1; } }
.pad-anim .sweep { fill: none; stroke: var(--accent); stroke-width: 150; stroke-linecap: round; stroke-linejoin: round; }
.pad-anim .sweep.hint-fade { animation: hint-out 1.4s ease .3s forwards; }
@keyframes hint-out { to { opacity: 0; } }
.write-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.write-tools .btn { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
.write-tools .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.write-msg { min-height: 1.5em; font-size: .92rem; color: var(--fg-muted); text-align: center; }
.write-msg.bad { color: var(--bad); }
.demo-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.demo-svg { background: var(--surface-2); border-radius: 10px; cursor: pointer; }
.demo-svg .pad-outline path { fill: var(--fg); opacity: .12; }
.demo-svg .sweep { fill: none; stroke: var(--accent); stroke-width: 150; stroke-linecap: round; }
.demo-svg .demo-stroke { stroke: var(--fg); }
.pill.offline { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.brand span { white-space: nowrap; }
@media (max-width: 440px) { .brand span { display: none; } }

/* ---------- vocabulary list ---------- */
.tabbar-inner { grid-template-columns: repeat(5, 1fr); }
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: .85rem; cursor: pointer; min-height: 32px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.vfilters select { padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); flex: 1; min-width: 0; }
.vlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.vitem { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.vitem[open] { box-shadow: var(--shadow); }
.vitem summary { list-style: none; display: grid; grid-template-columns: minmax(3.2rem, auto) 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; min-height: 52px; }
.vitem summary::-webkit-details-marker { display: none; }
.vw { font-size: 1.5rem; line-height: 1.2; }
.vmid { min-width: 0; display: flex; flex-direction: column; }
.vpy { color: var(--accent); font-size: .9rem; }
.vmean { font-size: .85rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vside { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hsk { font-size: .7rem; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.vacc { font-size: .78rem; color: var(--fg-muted); }
.vbar { width: 3.2rem; height: 5px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.vbar i { display: block; height: 100%; }
.vdetail { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); }
.vstats { width: 100%; border-collapse: collapse; font-size: .85rem; }
.vstats th, .vstats td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.vstats th:first-child { text-align: left; }
.vstats thead th { color: var(--fg-muted); font-weight: 500; font-size: .75rem; }
.okc { color: var(--ok); } .badc { color: var(--bad); }
.vfacts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .88rem; }
.vfacts dt { color: var(--fg-muted); }
.vfacts dd { margin: 0; }
.today-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.today-grid > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.today-grid b { font-size: 1.25rem; }
.today-grid span { font-size: .75rem; color: var(--fg-muted); }
.today-grid .okc b { color: var(--ok); } .today-grid .badc b { color: var(--bad); }
.today-words summary { cursor: pointer; color: var(--accent); }
.winfo { display: flex; flex-wrap: wrap; gap: 6px; }
.wchip { font-size: .78rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); white-space: nowrap; }
.stimer { font-weight: 650; color: var(--fg-muted); min-width: 3.6em; text-align: center; font-size: .95rem; }
.stimer.paused { opacity: .5; }
.total-hours { color: var(--fg-muted); margin-top: 2px; }
.total-hours b { color: var(--fg); }
.today-grid b { white-space: nowrap; }
.today-grid b { font-size: clamp(1rem, 4.6vw, 1.25rem); }

/* characters of a word */
.chars { display: grid; gap: 8px; margin-top: 4px; }
.cx { display: grid; grid-template-columns: 3.2rem 1fr; gap: 10px; align-items: start; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.cx-han { font-size: 2.4rem; line-height: 1; text-align: center; padding-top: 2px; }
.cx-body { display: grid; gap: 3px; font-size: .95rem; min-width: 0; overflow-wrap: anywhere; }
.cx-body .rp { margin-right: 6px; }
.cx-et .zh, .cx-also .zh, .cx-body .zh { font-size: 1.1em; }
.cx-tag { display: inline-block; font-size: .78rem; padding: 1px 7px; margin-right: 6px; border-radius: 99px; background: var(--accent-soft); color: var(--fg); }
.cx-other, .cx-also { font-size: .88rem; }
.cx .muted { color: var(--fg-muted); }
.cx-han { font-family: var(--font-kai); }
.cx .zh { font-family: var(--font-han); }
.cx-body .rp { color: var(--accent); font-weight: 600; }

/* folded sections after an answer */
.folds { display: grid; gap: 8px; margin-top: 4px; }
.fold { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.fold > summary { cursor: pointer; list-style: none; padding: 11px 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: '›'; display: inline-block; width: 1em; color: var(--accent); font-size: 1.2em; transition: transform .15s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > :not(summary) { margin: 0 12px 12px; }
