/* HanyuMochi — design tokens
   Idea: a study desk with matcha and mochi. Warm paper, matcha green ink,
   a soft apricot accent, and the red practice grid kept as the signature. */
:root {
  --bg: #F6F5EF;
  --surface: #FFFFFF;
  --surface-2: #ECEDE2;
  --ink: #1E2A24;
  --ink-2: #5A6B61;
  --line: #DCDFD2;
  --primary: #2E7D5B;
  --primary-2: #245F46;
  --on-primary: #FFFFFF;
  --accent: #E08A54;
  --grid: #CF4B40;
  --grid-soft: rgba(207, 75, 64, .3);
  --ok: #2E7D5B;
  --warn: #B87333;
  --danger: #B3261E;
  --t1: #D2382B; --t2: #C97A00; --t3: #1E8A4C; --t4: #2458C6; --t5: #7A8599;
  --hz-font: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --ui-font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --shadow: 0 1px 0 rgba(30, 42, 36, .04), 0 8px 24px -16px rgba(30, 42, 36, .28);
  --side-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171A; --surface: #1A2124; --surface-2: #232B2E; --ink: #E8EDE7; --ink-2: #9DAAA2;
    --line: #2C3639; --primary: #6FCf9A; --primary-2: #9BE3BC; --on-primary: #12171A;
    --accent: #F0A876;
    --grid: #E57D72; --grid-soft: rgba(229, 125, 114, .32); --ok: #6FCF9A; --warn: #E7B471; --danger: #FF8A80;
    --t1: #FF7A6E; --t2: #F2B347; --t3: #5BCB85; --t4: #7EA6FF; --t5: #8C97AD;
    --shadow: 0 1px 0 rgba(0,0,0,.2), 0 10px 30px -18px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12171A; --surface: #1A2124; --surface-2: #232B2E; --ink: #E8EDE7; --ink-2: #9DAAA2;
  --line: #2C3639; --primary: #6FCF9A; --primary-2: #9BE3BC; --on-primary: #12171A;
  --accent: #F0A876;
  --grid: #E57D72; --grid-soft: rgba(229, 125, 114, .32); --ok: #6FCF9A; --warn: #E7B471; --danger: #FF8A80;
  --t1: #FF7A6E; --t2: #F2B347; --t3: #5BCB85; --t4: #7EA6FF; --t5: #8C97AD;
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 10px 30px -18px rgba(0,0,0,.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: hidden; background: var(--bg); color: var(--ink);
  font: 400 17px/1.55 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
.panel h3 { margin-top: 22px; }
.panel > h2:first-child { margin-top: 0; }
h1 { font-size: clamp(1.7rem, 2.6vw, 2.2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
a { color: var(--primary); }
.btn, .chip, .chip-btn, .back, .link, .rate, .sentence, .tabbar a, .side-nav a, .brand,
.book-meta h2 a, .path-step, .lesson-row, .unit-row, .pron-list a, .say { text-decoration: none; }
.link:hover, .back:hover, .pron-list a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-2); }
.small { font-size: .88rem; }
.lead { font-size: 1.1rem; max-width: 62ch; }
.strong { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px; }
.icon { width: 20px; height: 20px; flex: none; }
[lang="zh-CN"], .hz { font-family: var(--hz-font); }
.py { font-family: var(--ui-font); color: var(--ink-2); letter-spacing: .01em; }
html[data-pinyin="off"] .py { visibility: hidden; }
html[data-pinyin="off"] .rev-py.is-revealed { visibility: visible; }   /* tapped "Show pinyin" on this card */
html[data-tones="on"] .t1 { color: var(--t1); }
html[data-tones="on"] .t2 { color: var(--t2); }
html[data-tones="on"] .t3 { color: var(--t3); }
html[data-tones="on"] .t4 { color: var(--t4); }
html[data-tones="on"] .t5 { color: var(--t5); }
.tone-key { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: -6px 0 0; }
.tone-key span { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; }
.tone-key span { font-weight: 600; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 14px; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 4px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center; position: relative;
  border: 1.5px solid var(--grid); border-radius: 4px; font-size: 22px; color: var(--ink);
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid-soft), var(--grid-soft)), linear-gradient(var(--grid-soft), var(--grid-soft));
  background-size: 100% 1px, 1px 100%;
  background-position: center, center;
  background-repeat: no-repeat;
}
.brand-name { font-weight: 700; font-size: 1.1rem; }
.side-nav { display: grid; gap: 2px; }
.side-nav a, .link-btn {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md);
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .98rem;
}
.side-nav a:hover, .link-btn:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--surface-2); color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.side-foot { margin-top: auto; }
.link-btn { width: 100%; border: 0; background: none; cursor: pointer; font: inherit; font-weight: 600; }
.main { padding: 36px clamp(18px, 4vw, 56px) 80px; max-width: 1180px; width: 100%; min-width: 0; justify-self: center; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 22px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: .66rem; font-weight: 600; color: var(--ink-2); text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--primary); }
  .tabbar .icon { width: 24px; height: 24px; }
}

/* ---------- 田字格 practice grid (signature element) ---------- */
.tzg {
  --size: 56px; width: var(--size); height: var(--size); flex: none;
  position: relative; display: grid; place-items: center;
  border: 1.5px solid var(--grid); border-radius: 3px; background: var(--surface);
  font-family: var(--hz-font); color: var(--ink); line-height: 1;
}
.tzg::before, .tzg::after {
  content: ""; position: absolute; pointer-events: none;
  background-image: linear-gradient(90deg, var(--grid-soft) 50%, transparent 50%);
  background-size: 8px 1px;
}
.tzg::before { left: 0; right: 0; top: 50%; height: 1px; }
.tzg::after { top: 0; bottom: 0; left: 50%; width: 1px; background-image: linear-gradient(var(--grid-soft) 50%, transparent 50%); background-size: 1px 8px; }
.tzg > span, .tzg > svg { position: relative; z-index: 1; }
.tzg-num::before, .tzg-num::after { display: none; }   /* numbers get a plain box, characters keep the grid */
.tzg-sm { --size: 40px; font-family: var(--ui-font); font-weight: 700; font-size: .95rem; }
.tzg-md { --size: 52px; font-size: 28px; }
.tzg-lg { --size: 96px; font-size: 64px; margin: 0 auto 18px; }
.tzg-hero { --size: clamp(150px, 22vw, 210px); font-size: calc(var(--size) * .72); border-width: 2px; }
.tzg-sm.is-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.tzg-sm.is-done::before, .tzg-sm.is-done::after { opacity: .25; }
.tzg-sm.is-in_progress { border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }

/* ---------- Building blocks ---------- */
.page-head { margin-bottom: 26px; }
.page-head h1 { margin-bottom: .2em; }
.zh-title { font-family: var(--hz-font); font-weight: 700; letter-spacing: .02em; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .92rem; }
.back:hover { color: var(--primary); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 3vw, 28px); margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.link { font-weight: 600; text-decoration: none; }
.stack > * + * { margin-top: 18px; }
.stack > .row { margin-top: 22px; }
.stack > p + .field, .stack > .field + .field { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
.section-title { margin-top: 32px; }
.empty { background: var(--surface-2); border-radius: var(--r-md); padding: 14px 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1.5px solid var(--primary);
  background: var(--primary); color: var(--on-primary); font: 600 1rem var(--ui-font);
  text-decoration: none; cursor: pointer; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .92rem; }
.btn-block { width: 100%; }
.say {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--primary);
}
.say:hover, .say.is-playing { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 14px; border-radius: 999px; background: var(--surface-2); font-size: .88rem; font-weight: 600; color: var(--ink-2); border: 1px solid transparent; }
.chip-btn { cursor: pointer; font-family: inherit; color: var(--primary); }
.chip-btn:hover { border-color: var(--primary); }
.chip-btn .icon { width: 14px; height: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: .75rem; font-weight: 700; border: 1px solid var(--line); color: var(--ink-2); }
.badge-new { border-color: var(--primary); color: var(--primary); }
.tag { font-size: .78rem; color: var(--ink-2); }
.tag + .tag::before { content: "/ "; opacity: .5; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .92rem; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=email], input[type=tel], input[type=url],
input:not([type]), textarea, select {
  width: 100%; max-width: 460px; min-height: 44px; padding: 8px 12px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: 400 1rem var(--ui-font);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
input[type=number] { max-width: 220px; }
input[type=range] { width: 100%; max-width: 460px; accent-color: var(--primary); margin: 6px 0; }
.deck-filters input, .deck-filters select { max-width: 100%; }
.pin-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; font-weight: 600; font-size: .95rem; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg label > span { display: inline-block; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font-weight: 600; }
.seg input:checked + span { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.seg input:focus-visible + span { outline: 3px solid var(--primary); }

.toast { padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 20px; font-weight: 600; border-left: 4px solid var(--ok); background: var(--surface); box-shadow: var(--shadow); }
.toast-error { border-left-color: var(--danger); }
.alert { padding: 12px 16px; border-radius: var(--r-md); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); font-weight: 600; }
.alert p:last-child { margin: 0; }
.steps { padding-left: 1.3em; margin: 0 0 1em; }
.steps li { margin-bottom: .35em; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .82rem; color: var(--ink-2); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.deck-table td:first-child { white-space: normal; min-width: 230px; }
.deck-table td:first-child .muted { display: block; margin-top: 2px; }
.table td.hz { font-size: 1.4rem; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- Bare pages (login, install) ---------- */
.bare { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.bare-main { width: 100%; max-width: 560px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 36px 28px; text-align: center; max-width: 380px; margin: auto; box-shadow: var(--shadow); }
.install-head { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; }
.install-head .tzg { --size: 72px; font-size: 44px; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checks li { display: flex; gap: 8px; align-items: center; }
.checks .ok .icon { color: var(--ok); }
.checks .fail { color: var(--danger); font-weight: 600; }
.checks .x { width: 20px; text-align: center; }

/* ---------- Today ---------- */
.hero {
  display: flex; gap: clamp(20px, 4vw, 44px); align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: clamp(20px, 4vw, 36px); margin-bottom: 20px; box-shadow: var(--shadow);
}
.hero-kicker { font-weight: 700; color: var(--grid); margin-bottom: .3em; }
.hero h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.hero-word { font-size: 1.05rem; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.hero-word .hz { font-size: 1.6rem; }
.hero .btn { margin-top: 8px; }
.tzg-hero span { animation: ink-in .9s ease-out both; }
@keyframes ink-in { from { opacity: 0; filter: blur(6px); transform: scale(.96); } to { opacity: 1; filter: none; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tzg-hero span { animation: none; } * { transition: none !important; } }
@media (max-width: 620px) { .hero { flex-direction: column; text-align: center; } .hero-word { justify-content: center; } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; display: grid; }
.stat-num { font-size: 1.7rem; font-weight: 700; }
.stat-num small { font-size: .95rem; color: var(--ink-2); font-weight: 600; }
.stat-label { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-num { font-size: 1.35rem; } .stat { padding: 10px 12px; } }
.path { list-style: none; padding: 0; margin: 10px 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.path-step {
  width: 44px; height: 44px; display: grid; place-items: center; text-decoration: none; position: relative;
  border: 1.5px solid var(--grid); border-radius: 3px; color: var(--ink); font-weight: 700; background: var(--surface);
}
.path-step span { position: relative; }
.path-step.is-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.path-step.is-in_progress { border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.path-step:hover { transform: translateY(-1px); }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 2px; border: 1.5px solid var(--grid); display: inline-block; margin-left: 8px; }
.dot:first-child { margin-left: 0; }
.dot.is-done { background: var(--ok); border-color: var(--ok); }
.dot.is-in_progress { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }

/* ---------- Library & lists ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.book-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.book-card.is-active { border-color: var(--primary); }
.book-cover { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px; text-decoration: none; color: var(--ink); background: var(--surface-2); }
.book-zh { font-family: var(--hz-font); font-size: 1.5rem; font-weight: 700; }
.book-meta { padding: 16px 20px 20px; }
.book-meta h2 { font-size: 1.1rem; }
.book-meta h2 a { color: inherit; text-decoration: none; }
.ring { --p: 0; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0); }
.ring span { width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.import-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.file-drop { flex: 1 1 260px; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; border: 1.5px dashed var(--line); border-radius: var(--r-md); cursor: pointer; color: var(--ink-2); font-weight: 600; }
.file-drop:hover { border-color: var(--primary); color: var(--primary); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.lesson-list, .unit-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lesson-row, .unit-row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 16px; align-items: center;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  text-decoration: none; color: var(--ink);
}
.unit-row { grid-template-columns: auto 1fr auto; }
.lesson-row:hover, .unit-row:hover { border-color: var(--primary); }
.lesson-text { display: grid; gap: 2px; min-width: 0; }
.lesson-zh { font-family: var(--hz-font); font-size: 1.2rem; font-weight: 600; }
.lesson-facts { display: flex; gap: 4px 12px; flex-wrap: wrap; }
.lesson-facts .is-good, .lesson-facts .is-weak { font-weight: 700; }
.status { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.status-done { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.status-in_progress { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
@media (max-width: 700px) {
  .lesson-row { grid-template-columns: auto 1fr; }
  .lesson-facts { grid-column: 2; }
  .status { grid-column: 2; justify-self: start; }
}

/* ---------- Lesson ---------- */
.lesson-title { display: flex; gap: 16px; align-items: center; }
.lesson-title .tzg { font-family: var(--ui-font); font-weight: 700; font-size: 1.3rem; }
.lesson-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.lesson-bar .status-form { display: flex; }
.field select { max-width: 420px; }
.status-form select { min-height: 34px; padding: 4px 10px; width: auto; max-width: none; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; padding: 12px 14px; font: 600 1rem var(--ui-font); color: var(--ink-2);
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.count { font-size: .78rem; background: var(--surface-2); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.toolbar { display: flex; gap: 10px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .switch, .player-switches .switch { display: inline-flex; }
.word-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.word {
  display: grid; grid-template-columns: auto minmax(130px, 220px) 1fr; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px;
}
.word-main { display: grid; }
.word-hz { font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.word-info { display: grid; gap: 2px; min-width: 0; }
.word-en { font-weight: 600; }
.word-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.note { color: var(--warn); }
.panel-words-hide-meaning .word-en { filter: blur(6px); }
.hide-meaning .word-en, .hide-meaning .ex-en { filter: blur(6px); cursor: pointer; }
.word-ex { grid-column: 2 / -1; display: flex; gap: 10px; align-items: flex-start; padding-top: 10px; border-top: 1px dashed var(--line); }
.word-ex p { margin: 0; }
.word-ex .ex-zh { font-size: 1.15rem; }
.word-ex .py, .word-ex .ex-en { font-size: .92rem; }
.say-sm { width: 32px; height: 32px; }
.say-sm .icon { width: 16px; height: 16px; }
.hide-examples .word-ex { display: none; }
@media (max-width: 600px) { .word { grid-template-columns: auto 1fr; } .word-info { grid-column: 2; } .word-ex { grid-column: 1 / -1; } }

.grammar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 3vw, 26px); margin-bottom: 16px; }
.grammar h2 { display: flex; gap: 10px; align-items: center; }
.g-num { width: 28px; height: 28px; flex: none; display: inline-grid; place-items: center; border: 1.5px solid var(--grid); border-radius: 3px; font-size: .9rem; }
.pattern { font-family: var(--ui-font), var(--hz-font); background: var(--surface-2); padding: 10px 14px; border-radius: var(--r-sm); border-left: 3px solid var(--grid); font-weight: 600; }
.examples { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 12px; }
.examples li { display: flex; gap: 12px; align-items: flex-start; }
.examples p { margin: 0; }
.ex-zh { font-size: 1.3rem; }
.drills { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.drill { margin-bottom: 14px; }
.drill label { display: block; font-size: 1.15rem; margin-bottom: 6px; }
.drill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.drill-row input { flex: 1 1 140px; width: auto; }
.drill-result { margin: 6px 0 0; font-weight: 600; min-height: 1.4em; }
.drill-result.ok { color: var(--ok); }
.drill-result.no { color: var(--danger); }
.pager { display: flex; justify-content: space-between; margin-top: 28px; gap: 12px; }

.writer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.writer-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; justify-items: center; gap: 8px; }
.tzg-writer { --size: 160px; border-width: 2px; }
.tzg-writer svg { width: 100%; height: 100%; }
.tzg-small-writer { --size: 96px; }
.writer-actions { display: flex; gap: 6px; align-items: center; }
.writer-msg { min-height: 1.3em; margin: 0; text-align: center; }

/* ---------- Foundations ---------- */
.tone-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tone-card {
  display: grid; justify-items: center; gap: 2px; padding: 14px 10px; cursor: pointer; text-align: center;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r-md); color: var(--ink); font-family: var(--ui-font);
}
.tone-card:hover { border-color: currentColor; }
.tone-card svg { width: 140px; height: 84px; overflow: visible; margin-bottom: 4px; }
.tone-card .guide { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.tone-card .guide-label { fill: var(--ink-2); font: 600 7px var(--ui-font); }
.tone-card .contour { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.tone-card .dot { fill: currentColor; }
.tone-card .pitch { font-size: .8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tone-note { margin-top: 14px; }
.pitch-key { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tone-card.t1 { color: var(--t1); } .tone-card.t2 { color: var(--t2); } .tone-card.t3 { color: var(--t3); } .tone-card.t4 { color: var(--t4); } .tone-card.t5 { color: var(--t5); }
.tone-card .small, .tone-card .muted { color: var(--ink-2); }
.tone-card .tone-name { color: var(--ink); font-weight: 600; }
.tone-hz { font-size: 2.4rem; line-height: 1.1; }
.tone-py { font-size: 1.2rem; font-weight: 700; }
.trainer { display: grid; gap: 12px; justify-items: start; }
.trainer-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.trainer-choices .btn.is-right { background: var(--ok); border-color: var(--ok); color: #fff; }
.trainer-choices .btn.is-wrong { background: var(--danger); border-color: var(--danger); color: #fff; }
.trainer-msg { font-weight: 600; margin: 0; min-height: 1.5em; }
.sound-group h3 { margin-top: 12px; color: var(--ink-2); font-size: .9rem; }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.sound {
  display: grid; justify-items: center; gap: 0; padding: 10px 6px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink); font-family: var(--ui-font);
}
.sound:hover, .sound.is-playing { border-color: var(--primary); }
.sound strong { font-size: 1.25rem; color: var(--primary); }
.sound [lang] { font-size: 1.3rem; }
.sound .py { font-size: .82rem; }
.stroke-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stroke-card { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); }
.stroke-card p { margin: 0; }
.radical-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 20px; }
.radical { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.radical p { margin: 0 0 4px; }
.radical-ex { display: flex; gap: 6px; }
.radical-ex .chip { font-size: 1.1rem; }
.unit-foot { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.unit-foot p { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--ok); font-weight: 600; }
.credits { margin-top: 20px; }

/* ---------- Listen tab ---------- */
.player { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 3vw, 28px); margin-bottom: 18px; box-shadow: var(--shadow); }
.player-now {
  min-height: 190px; display: grid; align-content: center; justify-items: center; text-align: center; gap: 4px;
  padding: 18px 12px; border-radius: var(--r-md); position: relative;
  background:
    linear-gradient(var(--grid-soft), var(--grid-soft)) center / 100% 1px no-repeat,
    var(--bg);
  border: 1.5px solid var(--grid);
}
.player-now p { margin: 0; position: relative; }
.now-meta { display: flex; gap: 10px; color: var(--ink-2); font-weight: 600; background: var(--bg); padding: 0 8px; }
.now-tag { font-family: var(--hz-font); font-weight: 400; }
.now-zh { font-family: var(--hz-font); font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.3; background: var(--bg); padding: 0 10px; }
.now-py { font-size: 1.1rem; background: var(--bg); padding: 0 8px; }
.now-en { color: var(--ink-2); background: var(--bg); padding: 0 8px; }
.now-reveal { margin-top: 6px; }
.player[data-text="no-en"] .now-en,
.player[data-text="none"] .now-en,
.player[data-text="none"] .now-py,
.player[data-text="none"] .now-zh { filter: blur(10px); user-select: none; }
.player[data-text="none"] ~ .sentence-list .s-body,
.player[data-text="no-en"] ~ .sentence-list .s-en,
.player[data-text="none"] ~ .word-list .word-main,
.player[data-text="none"] ~ .word-list .word-en,
.player[data-text="none"] ~ .word-list .word-ex,
.player[data-text="no-en"] ~ .word-list .word-en,
.player[data-text="no-en"] ~ .word-list .ex-en { filter: blur(6px); }
.turn { width: min(360px, 90%); display: grid; gap: 6px; margin-top: 10px; }
.turn-label { font-weight: 700; color: var(--grid); }
.turn-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.turn-bar span { display: block; height: 100%; width: 0; background: var(--grid); }
.player-controls { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 18px 0 4px; }
.ctrl { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.ctrl:hover { border-color: var(--primary); color: var(--primary); }
.ctrl-main { width: 68px; height: 68px; background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ctrl-main:hover { background: var(--primary-2); color: var(--on-primary); }
.ctrl-main .icon { width: 28px; height: 28px; }
.ctrl .i-pause, .player.is-playing .ctrl .i-play { display: none; }
.player.is-playing .ctrl .i-pause { display: block; }
.player-keys { text-align: center; margin-bottom: 16px; }
.seg legend .muted { font-weight: 400; }
.player-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 24px; }
.seg-sm label > span { padding: 6px 10px; font-size: .9rem; }
.player-speed { align-self: start; }
.player-switches { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
@media (max-width: 820px) { .player-keys { display: none; } }

.sentence-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.sentence {
  width: 100%; display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center; text-align: left;
  padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; cursor: pointer;
}
.sentence:hover { border-color: var(--primary); }
.is-current .sentence { border-color: var(--grid); box-shadow: inset 3px 0 0 var(--grid); }
.s-num { font-weight: 700; color: var(--ink-2); font-size: .85rem; text-align: center; }
.s-body { display: grid; min-width: 0; }
.s-zh { font-size: 1.2rem; }
.s-py { font-size: .88rem; }
.s-en { font-size: .88rem; color: var(--ink-2); }
.s-tag { font-size: .8rem; color: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; white-space: nowrap; }
@media (max-width: 520px) { .s-tag { display: none; } .sentence { grid-template-columns: 24px 1fr; } }

/* ---------- Player: modes, quiz, speaking ---------- */
.player .opt-quiz, .player .opt-shadow { display: none; }
.player[data-mode="quiz"] .opt-quiz { display: flex; }
.player[data-mode="shadow"] .opt-shadow { display: grid; gap: 4px; align-content: start; }
.player[data-mode="quiz"] .opt-play { display: none; }
.ctrl:disabled { opacity: .35; cursor: not-allowed; }
.ctrl-mic { color: var(--grid); border-color: var(--grid); }
.ctrl-mic:hover { background: var(--grid); color: #fff; border-color: var(--grid); }
.player.is-listening .ctrl-mic { background: var(--grid); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--grid) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .player.is-listening .ctrl-mic { animation: none; } }
.speak-result { margin-top: 8px; display: grid; gap: 2px; justify-items: center; background: var(--bg); padding: 4px 10px; }
.speak-score { font-weight: 700; font-size: 1.15rem; }
.speak-score .is-good, .is-good { color: var(--ok); }
.is-weak { color: var(--danger); }
.speak-msg { color: var(--warn); font-weight: 600; font-size: .95rem; }
.speak-marks { font-family: var(--hz-font); font-size: 1.4rem; letter-spacing: .04em; }
.m-ok { color: var(--ok); }
.m-miss { color: var(--danger); text-decoration: underline wavy; text-underline-offset: 5px; }

.quiz { margin-top: 16px; }
.quiz-q { font-weight: 700; font-size: 1.1rem; margin-bottom: 10px; }
.quiz-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.choice {
  display: flex; gap: 10px; align-items: center; text-align: left; padding: 12px 14px; min-height: 52px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: 500 1rem var(--ui-font);
}
.choice[lang] { font-family: var(--hz-font); font-size: 1.15rem; }
.choice:hover:not(:disabled) { border-color: var(--primary); }
.choice:disabled { cursor: default; }
.choice-n { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 4px; background: var(--surface-2); font: 700 .8rem var(--ui-font); color: var(--ink-2); }
.choice.is-right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.choice.is-wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.quiz-feedback { font-weight: 700; min-height: 1.5em; margin: 10px 0 6px; }
.quiz-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.quiz-result { margin-top: 16px; padding: 18px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); text-align: center; }
.quiz-result .row { justify-content: center; }
.quiz-pct { font-size: 2rem; font-weight: 700; margin-bottom: 4px; }
.player-stats { display: flex; gap: 6px 18px; flex-wrap: wrap; margin: 0; }

.s-side { display: grid; justify-items: end; gap: 4px; }
.s-score { font-size: .75rem; font-weight: 700; white-space: pre; }
.s-score:empty { display: none; }
.word-tags .s-score { margin-left: 4px; }
.chip-score { color: var(--ink); }
.chip-needs { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.mastery { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px; margin: 0 0 16px; border-radius: var(--r-md); border: 1.5px solid var(--ok);
  background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.mastery p { margin: 0; }
.mastery-goal { margin: -4px 0 14px; }
@media (max-width: 520px) { .s-side { display: none; } }
.player[data-mode="quiz"] .ctrl .i-pause { display: none; }
.player[data-mode="quiz"] .ctrl .i-play { display: block; }

/* ---------- Microphone test ---------- */
.mic-step h2 { display: flex; gap: 10px; align-items: center; }
.meter { height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; margin: 14px 0 8px; max-width: 480px; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .06s linear; }
.mic-verdict { font-weight: 700; min-height: 1.5em; }
.mic-state { font-weight: 700; color: var(--grid); min-height: 1.5em; margin-top: 12px; }
.mic-log { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; font-size: .78rem; white-space: pre-wrap; max-height: 260px; overflow: auto; }
.checks li.fail span:first-child { color: var(--danger); }
.checks li.ok span:first-child { color: var(--ok); width: 20px; text-align: center; }
.speak-msg a { color: var(--primary); }
.btn, .chip, .chip-btn, .back, .link, .rate, .sentence, .tabbar a, .side-nav a, .brand,
.book-meta h2 a, .path-step, .lesson-row, .unit-row, .pron-list a, .say { text-decoration: none; }
.link:hover, .back:hover, .pron-list a:hover { text-decoration: underline; text-underline-offset: 3px; }
.player[data-mic="listening"] .turn-label, .player[data-mic="hearing"] .turn-label { color: var(--ok); }

.now-zh.is-prompt { font-family: var(--ui-font); font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 700; }
.ctrl-mic:disabled { opacity: .45; }

/* ---------- Setup ---------- */
.setup-banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 18px; border-radius: var(--r-md); border: 1.5px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface)); }
.setup-banner p { margin: 0; max-width: 70ch; }
.setup-progress { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: step; }
.setup-progress li { counter-increment: step; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1.5px solid var(--line); font-weight: 600; font-size: .9rem; display: flex; gap: 6px; align-items: center; }
.setup-progress li::before { content: counter(step); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .75rem; }
.setup-progress li.is-pass { border-color: var(--ok); color: var(--ok); }
.setup-progress li.is-pass::before { content: "✓"; background: var(--ok); color: #fff; }
.setup-progress li.is-fail { border-color: var(--danger); color: var(--danger); }
.setup-progress li.is-fail::before { content: "!"; background: var(--danger); color: #fff; }
.setup-step h2 { display: flex; gap: 10px; align-items: center; }
.setup-verdict { font-weight: 700; min-height: 1.5em; margin-top: 10px; }
.fix { margin-top: 10px; padding: 12px 16px; border-radius: var(--r-md); background: var(--bg); border-left: 3px solid var(--warn); }
.fix .steps { margin-bottom: 0; }
.fix code { user-select: all; }
kbd { font: 600 .8em var(--ui-font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); }
.checks li span:first-child { width: 20px; text-align: center; flex: none; }

.quiz-hint { font-weight: 600; color: var(--primary); min-height: 1.3em; margin: 0 0 8px; }
.player .turn:not([hidden]) + .speak-result { margin-top: 4px; }

/* ---------- 1.4.2: compact sticky player ---------- */
.player { position: sticky; top: 8px; z-index: 30; padding: 14px 16px 10px; margin-bottom: 16px; }
.player .player-now { min-height: 0; padding: 10px 12px; gap: 2px; }
.player .now-zh { font-size: clamp(1.6rem, 3.4vw, 2.2rem); line-height: 1.25; }
.player .now-py { font-size: 1rem; }
.player .now-en { font-size: .95rem; }
.player .turn { margin-top: 6px; }
.player .speak-result { margin-top: 4px; padding: 2px 10px; }
.player .speak-marks { font-size: 1.2rem; }
.player-controls { margin: 10px 0 2px; gap: 10px; }
.ctrl { width: 42px; height: 42px; }
.ctrl-main { width: 54px; height: 54px; }
.ctrl-main .icon { width: 24px; height: 24px; }
.ctrl-sm { width: 36px; height: 36px; font-size: .9rem; }
.ctrl-sep { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }
.ctrl-sm .i-grow, .player.is-mini .ctrl-sm .i-shrink { display: none; }
.player.is-mini .ctrl-sm .i-grow { display: block; }
.player-mode-line { text-align: center; color: var(--ink-2); margin: 0; min-height: 1.2em; }
.player .quiz { margin-top: 10px; }
.player .quiz-q { font-size: 1rem; margin-bottom: 6px; }
.player .quiz-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.player .choice { min-height: 40px; padding: 7px 10px; font-size: .95rem; }
.player .quiz-feedback { margin: 6px 0 2px; }
.player .quiz-actions { margin-bottom: 0; align-items: center; }
.player .quiz-count { margin: 4px 0 0; }
.player .quiz-result { margin-top: 10px; padding: 12px; }
.player .quiz-pct { font-size: 1.5rem; }
/* mini: just the item and the controls */
.player.is-mini { padding: 8px 12px 6px; }
.player.is-mini .player-now { padding: 6px 10px; background: var(--bg); }
.player.is-mini .now-zh { font-size: 1.35rem; }
.player.is-mini .now-py, .player.is-mini .now-en, .player.is-mini .now-meta .now-tag, .player.is-mini .player-mode-line,
.player.is-mini .quiz-q, .player.is-mini .quiz-count, .player.is-mini .speak-heard, .player.is-mini [data-speak-heard] { display: none; }
.player.is-mini .speak-marks { font-size: 1rem; }
.player.is-mini .player-controls { margin: 6px 0 0; }
.player.is-mini .ctrl { width: 36px; height: 36px; }
.player.is-mini .ctrl-main { width: 44px; height: 44px; }
.player.is-mini .choice { min-height: 34px; padding: 4px 8px; }
.player.is-mini .quiz-hint { display: none; }
@media (max-width: 820px) {
  .player { top: 4px; }
  .player .quiz-choices { grid-template-columns: 1fr 1fr; }
  .player .choice { font-size: .85rem; }
}
/* options drawer */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 22, .45); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 40px -20px rgba(0,0,0,.5);
  padding: 18px 20px 24px; display: grid; align-content: start; gap: 16px; outline: none;
  animation: drawer-in .18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.drawer-head h2 { margin: 0; font-size: 1.1rem; }
.drawer .player-options { grid-template-columns: 1fr; gap: 16px; }
.drawer-foot { display: flex; justify-content: flex-end; }
body.drawer-open { overflow: hidden; }
@media (max-width: 820px) {
  .drawer-panel { top: auto; left: 0; width: 100%; max-height: 82vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { .drawer-panel { animation: none; } }

/* microphone on each row */
.row-actions { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.word-ex .row-actions, .examples .row-actions { flex-direction: row; }
.row-mic { color: var(--grid); }
.row-mic:hover { background: var(--grid); border-color: var(--grid); color: #fff; }
.row-mic.is-listening { background: var(--grid); border-color: var(--grid); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .row-mic.is-listening { animation: none; } }
.row-result { display: block; margin-top: 4px; font-size: .9rem; }
.row-result[hidden] { display: none; }
.rr-state { font-weight: 700; color: var(--ok); }
.rr-msg { color: var(--warn); font-weight: 600; }
.rr-score { font-weight: 800; }
.rr-marks { font-family: var(--hz-font); font-size: 1.05rem; }
.rr-heard { color: var(--ink-2); }
.sentence-row { display: flex; gap: 8px; align-items: center; }
.sentence-row .sentence { flex: 1; min-width: 0; }
.sentence-row .row-mic { flex: none; }

/* score pop-up */
.score-toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 70; width: min(320px, calc(100vw - 36px));
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
  padding: 12px 14px 8px; cursor: pointer; animation: toast-in .18s ease-out;
}
.score-toast[hidden] { display: none; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
.score-toast.is-good { border-color: var(--ok); }
.score-toast.is-weak { border-color: var(--danger); }
.score-toast p { margin: 0; }
.score-toast .t-score { font-weight: 800; font-size: 1.1rem; }
.score-toast.is-good .t-score { color: var(--ok); }
.score-toast.is-weak .t-score { color: var(--danger); }
.score-toast .t-zh { font-family: var(--hz-font); font-size: 1.4rem; }
.score-toast .t-heard, .score-toast .score-toast-tip { font-size: .8rem; color: var(--ink-2); }
.score-toast .t-msg { color: var(--warn); font-weight: 600; font-size: .9rem; }
.score-toast.is-pinned .score-toast-tip { display: none; }
.score-toast-x { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: var(--ink-2); cursor: pointer; font-size: .9rem; }
@media (max-width: 820px) { .score-toast { bottom: calc(84px + env(safe-area-inset-bottom)); right: 10px; } }

/* 1.4.2: tighter quiz and results */
.player .speak-result { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 2px 10px; }
.player .speak-result p { margin: 0; }
.player .quiz-feedback, .player .quiz-hint { display: inline; margin: 0 8px 0 0; }
.player .quiz-feedback:empty, .player .quiz-hint:empty { display: none; }
.player .quiz-actions { margin-top: 6px; }
.player .quiz-count { display: inline-block; margin: 0 0 0 4px; }
.player .quiz-actions .btn { min-height: 34px; }
@media (min-width: 900px) {
  .player[data-mode="quiz"] { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); column-gap: 16px; align-items: start; }
  .player[data-mode="quiz"] > .player-now { grid-column: 1; grid-row: 1; align-self: stretch; }
  .player[data-mode="quiz"] > .quiz, .player[data-mode="quiz"] > .quiz-result { grid-column: 2; grid-row: 1; margin-top: 0; }
  .player[data-mode="quiz"] > .player-controls, .player[data-mode="quiz"] > .player-mode-line { grid-column: 1 / -1; }
  .player[data-mode="quiz"] .quiz-q { margin-top: 2px; }
}

.fail-list { padding-left: 1.2em; margin: 0 0 10px; }
.fail-list li { margin-bottom: 4px; }

.pron-panel { border-left: 3px solid var(--grid); }
.pron-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pron-list a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .92rem; }
.pron-list a:hover { border-color: var(--primary); }

/* ---------- Daily reviews ---------- */
.reviewer { display: grid; gap: 14px; max-width: 640px; margin: 0 auto 20px; }
.rev-top { display: grid; gap: 6px; text-align: center; }
.rev-progress { margin: 0; font-weight: 700; }
.rev-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.rev-bar span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .25s ease-out; }
.rev-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 18px;
  display: grid; justify-items: center; gap: 10px; text-align: center; box-shadow: var(--shadow); }
.rev-prompt { margin: 0; font-weight: 700; color: var(--ink-2); }
.rev-face {
  --size: clamp(140px, 30vw, 200px);
  display: grid; place-items: center; text-align: center;
  font-family: var(--hz-font); color: var(--ink); line-height: 1.25;
  max-width: 100%; padding: 6px;
}
.rev-face[data-len="1"] { width: var(--size); height: var(--size); padding: 0; font-size: calc(var(--size) * .58); }
.rev-face[data-len="3"] { min-height: calc(var(--size) * .8); width: auto; min-width: var(--size); font-size: calc(var(--size) * .34);
  border: 1.5px solid var(--grid); border-radius: 4px; padding: 10px 18px; }
.rev-face[data-len="6"] { min-height: calc(var(--size) * .7); width: auto; max-width: 100%; font-size: clamp(1.8rem, 5vw, 2.5rem);
  border: 1.5px solid var(--grid); border-radius: 4px; padding: 12px 18px; }
.rev-face[data-len="many"] { width: 100%; font-size: clamp(1.4rem, 4vw, 2rem);
  border: 1.5px solid var(--grid); border-radius: 4px; padding: 14px 16px; }
.rev-face span { line-height: 1.3; word-break: keep-all; }
.rev-face[data-len="1"] span { line-height: 1.1; }
.rev-hidden { color: var(--ink-2); opacity: .5; }
.rev-say { width: 46px; height: 46px; }
.rev-back { display: grid; gap: 4px; justify-items: center; }
.rev-pinyin-btn { font: 600 .85rem var(--ui-font); color: var(--primary); background: none; border: 0; cursor: pointer; padding: 2px 6px; }
.rev-pinyin-btn:hover { text-decoration: underline; }
.rev-back .py { font-size: 1.2rem; }
.rev-meaning { margin: 0; font-size: 1.25rem; font-weight: 600; }
.rev-speak { margin: 0; background: none; padding: 0; }            /* same card colour as the rest */
.rate.is-suggested { box-shadow: inset 0 0 0 2px currentColor; }
.rate.is-suggested .rate-name::after { content: " ·"; }
.rev-actions { display: grid; gap: 10px; }
.rev-ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate { display: grid; gap: 2px; padding: 10px 6px; cursor: pointer; border-radius: var(--r-md); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 .95rem var(--ui-font); }
.rate:hover { border-color: currentColor; }
.rate-key { font-size: .7rem; color: var(--ink-2); }
.rate-when { font-size: .78rem; color: var(--ink-2); font-weight: 600; }
.rate.r1 { color: var(--danger); } .rate.r2 { color: var(--warn); } .rate.r3 { color: var(--ok); } .rate.r4 { color: var(--primary); }
.rate.r1:hover { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.rate.r3:hover { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.rev-help { text-align: center; }
@media (max-width: 560px) { .rev-ratings { grid-template-columns: repeat(2, 1fr); } .rev-help { display: none; } }
.rev-done { max-width: 640px; margin: 0 auto; text-align: center; }
.rev-done .row { justify-content: center; }
.forecast { list-style: none; padding: 0; margin: 10px 0 18px; display: grid; grid-auto-flow: column; gap: 8px; align-items: end; height: 110px; }
.forecast li { display: grid; align-content: end; justify-items: center; gap: 4px; height: 100%; }
.fc-bar { width: 100%; min-height: 4px; height: var(--h); background: color-mix(in srgb, var(--primary) 35%, transparent);
  border: 1px solid var(--primary); border-radius: 4px 4px 0 0; display: grid; align-items: start; justify-items: center; }
.fc-n { font-size: .72rem; font-weight: 700; color: var(--ink-2); transform: translateY(-16px); }
.fc-day { font-size: .72rem; color: var(--ink-2); }
.add-list { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.add-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md); }
@media (max-width: 560px) { .add-list li { grid-template-columns: 1fr auto; } }

/* ---------- Deck and heatmap ---------- */
.rev-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.rev-foot .rev-help { margin: 0; }
.heatmap { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; margin: 10px 0 18px; }
.hm-day { width: 12px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--ok) calc(var(--v) * 100%), var(--surface-2)); border: 1px solid var(--line); }
.deck-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; align-items: end; }
.deck-filters .row { margin-top: 4px; }
.deck-filters .row { grid-column: 1 / -1; }
/* the table scrolls inside its own box, so the page never slides sideways */
.table-wrap { max-width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 6px 14px; -webkit-overflow-scrolling: touch; }
.table-wrap .table { min-width: 620px; }
.deck-table td { vertical-align: middle; }
.deck-zh { font-size: 1.3rem; margin-right: 8px; }
.deck-table tr.is-suspended { opacity: .55; }
.deck-actions { display: flex; gap: 6px; justify-content: flex-end; }
.deck-actions form { margin: 0; }

/* ---------- Study plan ---------- */
.plan-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 8px 0 10px; }
.plan-bar span { display: block; height: 100%; background: var(--ok); transition: width .25s ease-out; }
.plan-strip { list-style: none; padding: 0; margin: 16px 0 6px; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.plan-strip li { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; border-radius: var(--r-sm); }
.plan-strip li.is-today { background: color-mix(in srgb, var(--primary) 12%, transparent); font-weight: 600; }
.ps-date { color: var(--ink-2); font-size: .85rem; }
.ps-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-stats { grid-template-columns: repeat(4, 1fr); margin: 4px 0 18px; }
.plan-preview form { margin-top: 18px; }
.plan-current form { margin-top: 18px; }
.plan-warn { color: var(--warn); font-weight: 600; }
.plan-preview .stat-num { font-size: 1.5rem; }
.session .panel-head { align-items: baseline; }
.task-list { list-style: none; padding: 0; margin: 4px 0 14px; display: grid; gap: 6px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.task.is-done { opacity: .55; }
.task.is-done .task-label { text-decoration: line-through; }
.task-check input { position: absolute; opacity: 0; width: 24px; height: 24px; }
.task-check span { width: 24px; height: 24px; display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: 6px; cursor: pointer; }
.task-check input:checked + span { background: var(--ok); border-color: var(--ok); }
.task-check input:checked + span::after { content: "✓"; color: #fff; font-size: .9rem; font-weight: 700; }
.task-check input:focus-visible + span { outline: 3px solid var(--primary); }
.task-body { display: grid; gap: 2px; min-width: 0; }
.task-label { font-weight: 600; }

/* ---------- Homework ---------- */
textarea { width: 100%; max-width: 100%; min-height: 140px; padding: 10px 12px; border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--bg); color: var(--ink); font: 400 1.05rem var(--hz-font); }
textarea:focus { border-color: var(--primary); outline: none; }
.hw-points { margin: 0 0 12px; padding-left: 1.2em; }
.hw-points li { margin-bottom: 10px; }
.hw-pattern { display: block; color: var(--ink-2); font-size: .95rem; margin-top: 2px; }
.dict-result:empty { min-height: 0; margin: 0; }
.mastery-goal { margin: 0 0 18px; }
.now-meta:empty, .player-mode-line:empty { display: none; }
.dict-result { font-size: 1.1rem; min-height: 1.6em; margin: 16px 0 0; }
[data-dictation] .field { margin: 18px 0; }
[data-dictation] .row + .row { margin-top: 0; }
.dict-result .m-ok, .dict-result .m-miss { font-family: var(--hz-font); font-size: 1.3rem; }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.hw-audio, .hw-list audio { width: min(420px, 100%); margin-top: 8px; }
.hw-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.hw-list li { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); }
.hw-body { font-family: var(--hz-font); font-size: 1.1rem; margin: 6px 0 0; }

/* On a phone the cards table becomes a simple stacked list: no sideways scrolling. */
.table-wrap { contain: paint; }
@media (max-width: 700px) {
  .table-wrap { padding: 4px 12px; }
  .table-wrap .table { min-width: 0; }
  .deck-table thead { display: none; }
  .deck-table tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
    padding: 14px 0; border-bottom: 1px solid var(--line); }
  .deck-table tbody tr:last-child { border-bottom: 0; }
  .deck-table td { display: block; border: 0; padding: 0; white-space: normal; }
  .deck-table td:first-child { flex: 1 1 100%; }
  .deck-table td:nth-child(2), .deck-table td:nth-child(3), .deck-table td:nth-child(4),
  .deck-table td:nth-child(5), .deck-table td:nth-child(6) { flex: 0 0 auto; font-size: .82rem; color: var(--ink-2); }
  .deck-table td:nth-child(3)::before { content: "lesson "; }
  .deck-table td:nth-child(5)::before { content: "due "; }
  .deck-table td:nth-child(6)::before { content: "lapses "; }
  .deck-table .deck-actions { flex: 1 1 100%; flex-direction: row; justify-content: flex-start; margin-top: 8px; }
}

.kind-counts { list-style: none; padding: 0; margin: 0 0 12px; display: flex; gap: 18px; flex-wrap: wrap; color: var(--ink-2); }
.kind-counts strong { color: var(--ink); font-size: 1.1rem; }
.topup { padding: 14px 16px; border-radius: var(--r-md); border: 1.5px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent); margin-bottom: 16px; }
.topup p { margin: 0 0 10px; }
.link-inline { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.voice-help summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.voice-help .steps { margin-top: 10px; }
.voice-help li { margin-bottom: 8px; }

.task-group { font-weight: 700; color: var(--ink-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; margin-top: 8px; list-style: none; }
.unit-cards { margin-top: 14px; }

/* ---------- Practice drills ---------- */
.drill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.drill-card { display: grid; align-content: start; gap: 8px; }
.drill-card p { margin: 0; }
.drill-card .btn { justify-self: start; margin-top: 6px; }
.drill { display: grid; gap: 14px; max-width: 680px; margin: 0 auto 20px; }
.drill-card-main { gap: 12px; }
.drill-feedback { font-weight: 600; min-height: 1.6em; margin: 0; text-align: center; }
.drill-feedback .m-ok, .drill-feedback .m-miss { font-family: var(--hz-font); font-size: 1.25rem; }
.drill-actions { justify-content: center; }
.drill-input { width: 100%; }
.drill-input input { max-width: 100%; font-family: var(--hz-font); font-size: 1.2rem; }
.type-en { display: block; font-family: var(--ui-font); font-size: 1.4rem; font-weight: 700; }
.type-py { display: block; font-family: var(--ui-font); font-size: 1rem; color: var(--ink-2); margin-top: 6px; }
.tone-answer { display: grid; gap: 8px; width: 100%; }
.tone-row { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.tone-char { font-family: var(--hz-font); font-size: 1.6rem; width: 48px; text-align: center; }
.tone-pick { min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 .9rem var(--ui-font); cursor: pointer; }
.tone-pick:hover { border-color: var(--primary); }
.tone-pick.is-picked { background: var(--primary); border-color: var(--primary); color: #fff; }
.builder { display: grid; gap: 12px; width: 100%; }
.builder-line { min-height: 62px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center;
  padding: 10px; border: 1.5px dashed var(--line); border-radius: var(--r-md); background: var(--bg); }
.builder-pool { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chunk { font-family: var(--hz-font); font-size: 1.25rem; padding: 8px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chunk:hover { border-color: var(--primary); }
.builder-line .chunk { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border-color: var(--primary); }
.drill-done { max-width: 680px; margin: 0 auto; text-align: center; }
.drill-done .row { justify-content: center; }
.miss-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; text-align: left; }
.miss-list li { padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.miss-list span[lang] { font-family: var(--hz-font); font-size: 1.15rem; margin-right: 8px; }

/* ---------- Mock exam ---------- */
.exam { display: grid; gap: 12px; max-width: 720px; margin: 0 auto 20px; }
.exam-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.exam-part { font-weight: 700; color: var(--primary); }
.exam-clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.exam-clock.is-low { color: var(--danger); }
.exam-card { gap: 14px; }
.exam-audio { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.exam-zh { font-family: var(--hz-font); font-size: clamp(1.4rem, 4vw, 2rem); text-align: center; margin: 0; }
.exam-choices { width: 100%; grid-template-columns: 1fr; }
.exam-choices .choice.is-chosen { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.exam-nav { justify-content: center; }
.exam-map { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.map-dot { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font: 600 .72rem var(--ui-font); cursor: pointer; }
.map-dot.is-done { background: color-mix(in srgb, var(--ok) 22%, var(--surface)); border-color: var(--ok); color: var(--ink); }
.map-dot.is-here { outline: 2px solid var(--primary); }
.exam-score { text-align: center; }
.exam-score .stats { grid-template-columns: repeat(2, 1fr); max-width: 420px; margin: 12px auto; }
.exam-score .row { justify-content: center; }
.miss-q { font-weight: 600; margin: 4px 0; }

/* ---------- Progress ---------- */
.progress-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart { width: 100%; height: auto; margin: 8px 0; }
.ch-bar { fill: color-mix(in srgb, var(--primary) 45%, transparent); }
.ch-bar.is-hit { fill: var(--ok); }
.ch-target { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.ch-label { fill: var(--ink-2); font: 10px var(--ui-font); }
.ch-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
.ch-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.ch-dot.is-good { fill: var(--ok); stroke: var(--ok); }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; align-items: center; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
.bar span.is-good { background: var(--ok); }
.bar span.is-weak { background: var(--danger); }
.bar-label { font-weight: 600; }
.bar-num { font-weight: 700; font-variant-numeric: tabular-nums; }
.deck-split { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: var(--surface-2); margin: 10px 0; }
.ds-known { background: var(--ok); }
.ds-learning { background: var(--primary); }
.ds-fresh { background: var(--surface-2); border-left: 1px solid var(--line); }
.legend { list-style: none; padding: 0; margin: 0 0 8px; display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink-2); font-size: .9rem; }
.legend span { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
@media (max-width: 560px) { .bars li { grid-template-columns: 1fr auto; } .bars .bar { grid-column: 1 / -1; } }

/* ---------- AI sentence checking ---------- */
.ai-result { display: grid; gap: 10px; margin-top: 16px; }
.ai-item { padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); border-left-width: 4px; }
.ai-item.is-ok { border-left-color: var(--ok); }
.ai-item.is-fix { border-left-color: var(--warn); }
.ai-item p { margin: 0 0 4px; }
.ai-orig { font-family: var(--hz-font); font-size: 1.15rem; color: var(--ink-2); }
.ai-fix { font-family: var(--hz-font); font-size: 1.25rem; font-weight: 600; }
.ai-note { font-weight: 600; }

/* ---------- Book builder and exam countdown ---------- */
.col-map { display: flex; gap: 8px; flex-wrap: wrap; }
.col-map select { width: auto; min-width: 150px; }
.lesson-pills { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; align-items: center; }
.lesson-pills form { margin: 0; }
.chip-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); font-weight: 700; }
.word-edit { display: grid; grid-template-columns: 120px 140px 70px 1fr 130px auto auto; gap: 6px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--line); }
.word-edit input, .word-edit select { min-height: 38px; max-width: none; }
.word-edit .we-zh { font-family: var(--hz-font); font-size: 1.1rem; }
@media (max-width: 900px) { .word-edit { grid-template-columns: 1fr 1fr; } .word-edit .we-zh { grid-column: 1 / -1; } }
.exam-countdown { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; padding: 10px 14px; margin: 0 0 16px;
  border-radius: var(--r-md); border: 1.5px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }

/* Write tab: show the character itself until (or unless) stroke data loads */
.tzg-writer { position: relative; }
.writer-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(3rem, 12vw, 5rem); line-height: 1; color: var(--ink);
}
.tzg-writer.has-strokes .writer-fallback { display: none; }

/* --- accounts: sign in, register, reset ------------------------------- */
.auth-card {
  max-width: 420px; margin: 8vh auto; padding: 28px 26px 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.auth-title { margin: 0 0 4px; font-size: 1.5rem; }
.auth-sub { margin: 0 0 18px; }
.auth-card .stack { display: grid; gap: 14px; }
.auth-card label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.auth-card input { width: 100%; }
.auth-card small { font-weight: 400; }
.auth-card small.bad { color: var(--danger); }
.auth-links { margin: 16px 0 0; font-size: .9rem; text-align: center; color: var(--ink-2); }
.auth-links a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-links .sep { margin: 0 6px; }
.flash { padding: 9px 12px; border-radius: var(--r-sm); font-size: .92rem; margin: 0 0 14px; }
.flash.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.flash.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.row-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline { display: inline; }
.actions { white-space: nowrap; }
.btn-ghost.danger { color: var(--danger); }
.table select { min-width: 110px; padding: 4px 8px; }
.auth-card { text-align: left; }
.auth-title, .auth-sub { text-align: center; }
.edit-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.edit-row input { min-width: 150px; padding: 5px 8px; font-size: .9rem; }
.actions form.inline input[type="password"] { width: 130px; padding: 5px 8px; font-size: .85rem; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hw-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.hw-item:last-child { border-bottom: 0; }
.hw-body { font-family: var(--hz-font); font-size: 1.05rem; margin: 4px 0 0; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 12px 0 18px; }
ul.plain { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 4px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-ghost.danger { color: var(--danger); }
/* Study links at the top, running-the-place links pushed to the bottom. */
.side-nav-manage {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.side-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.section-title { margin: 28px 0 10px; font-size: 1.15rem; }
.empty { margin-top: 12px; }

/* Today is where the day starts, so it reads as the one action in the menu. */
.side-nav a.nav-primary {
  background: var(--primary);
  color: var(--on-primary);
  margin-bottom: 8px;
  font-weight: 700;
}
.side-nav a.nav-primary svg { color: currentColor; opacity: 1; }
.side-nav a.nav-primary:hover { background: var(--primary-2); color: var(--on-primary); }
.side-nav a.nav-primary[aria-current="page"] { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--on-primary) 35%, transparent); }
.bar { display: block; height: 5px; width: 120px; max-width: 100%; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 4px 0 2px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.attention { border-left: 3px solid var(--accent); }
.attention p { margin: 4px 0; font-size: .94rem; }
.pill { margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; }
.notice-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notice-list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.notice-list li.is-new { border-left: 3px solid var(--accent); }
.notice-title { margin: 0 0 2px; font-weight: 600; }
.hw-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feedback { margin-top: 8px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--r-sm); }
.badge-ok { color: var(--ok); border-color: var(--ok); }
.field-sm { max-width: 200px; }
.trial-bar { margin: 0 0 18px; padding: 9px 14px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); font-size: .93rem; font-weight: 600; }
.trial-bar.is-over { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.page-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.notice-list li { align-items: flex-start; }
.notice-list .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; background: var(--accent); }
.notice-list li.is-read { opacity: .72; }
.notice-list li.is-read .dot { background: var(--line); }
.notice-list li.is-read .notice-title { font-weight: 500; }
.notice-main { flex: 1 1 auto; min-width: 0; }
.notice-actions { display: flex; gap: 6px; align-items: center; }
.badge-new { background: var(--accent); color: #fff; border: 0; margin-left: 6px; }
.marked-item { padding: 0; }
.marked-item summary { cursor: pointer; padding: 12px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.marked-item summary::-webkit-details-marker { color: var(--ink-2); }
.marked-item[open] summary { border-bottom: 1px solid var(--line); }
.marked-item > *:not(summary) { margin: 10px 16px; }

/* Rows of controls line up on their bottom edge, whatever is in them. */
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.row-form .field { margin: 0; }
.row-form input[type=search] { max-width: 280px; }
.row-form .btn { min-height: 44px; }
textarea { min-height: 96px; max-width: 100%; line-height: 1.5; resize: vertical; }
.tabs .tab { padding: 10px 14px; text-decoration: none; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; display: inline-flex; gap: 7px; align-items: center; }
.tabs .tab.is-on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: .78rem; }
.tabs .tab.is-on .count { background: var(--primary); color: var(--on-primary); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 22px 0; }
.hw-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }

/* ---------- progress report ------------------------------------------
   The sheet follows the theme on screen and is forced back to paper colours
   when printing, so a dark screen never produces a dark PDF. */
.print-body { background: #E9E9E4; margin: 0; padding: 0 0 40px; }
:root[data-theme="dark"] .print-body { background: #0D1214; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .print-body { background: #0D1214; } }

.print-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.btn-ai { background: #6C4BD4; color: #fff; border-color: #6C4BD4; }
.btn-ai:hover { background: #5b3cbb; color: #fff; }

.sheet {
  width: 210mm; min-height: 297mm; margin: 22px auto; padding: 18mm 16mm;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 10px 40px -20px rgba(0,0,0,.5);
}
:root[data-theme="dark"] .sheet { box-shadow: 0 10px 40px -18px rgba(0,0,0,.9); }

.sheet-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid var(--primary); padding-bottom: 12px; }
.sheet-brand { margin: 0; color: var(--primary); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .78rem; }
.sheet-head h1 { margin: 4px 0 0; font-size: 1.7rem; }
.sheet-meta { text-align: right; }
.sheet-meta p { margin: 0 0 2px; }

.sheet-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.sheet-stats div { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; }
.sheet-stats .n { display: block; font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.sheet-stats .l { font-size: .8rem; color: var(--ink-2); }

.sheet-note { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 4px; }
.sheet-block { margin-top: 20px; break-inside: avoid; }
.sheet-block h2 { font-size: 1.05rem; margin: 0 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.sheet-analysis { line-height: 1.65; }

.sheet-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.sheet-table th { text-align: left; background: var(--surface-2); padding: 7px 9px; border-bottom: 1px solid var(--line); }
.sheet-table td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet-table .comment { color: var(--ink-2); }
.sheet-table .nowrap { white-space: nowrap; }
.sheet-foot { margin-top: 26px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }

@media print {
  @page { size: A4; margin: 14mm; }
  .no-print, .print-toolbar, .ai-overlay { display: none !important; }

  /* Paper is white whatever the screen was doing. */
  .print-body, .sheet { background: #fff !important; color: #1E2A24 !important; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .sheet-head { border-bottom-color: #2E7D5B !important; break-after: avoid; }
  .sheet-brand, .sheet-stats .n { color: #2E7D5B !important; }
  .sheet-stats div, .sheet-table th { background: #F3F5EF !important; }
  .sheet-stats .l, .sheet-table .comment, .muted { color: #5A6B61 !important; }
  .sheet-block h2, .sheet-table th, .sheet-table td, .sheet-foot { border-color: #DCDFD2 !important; }
  .sheet-note { background: #FBF1E8 !important; border-left-color: #E08A54 !important; }
  .sheet-block, .sheet-table tr { break-inside: avoid; }
}
}
.ai-help { max-width: 420px; font-size: .9rem; }
.ai-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.ai-help ol { margin: 8px 0 0 18px; display: grid; gap: 4px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.tag-ai { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: #EDE7FB; color: #6C4BD4; font-size: .72rem; font-weight: 700; vertical-align: middle; }
.toolbar-label { margin-right: auto; font-size: .95rem; color: var(--ink-2); }
.ai-error { border-left: 3px solid var(--danger); padding-left: 12px; }
.ai-note { background: #EDE7FB; color: #4B3491; padding: 8px 12px; border-radius: 6px; margin: 14px 0 0; }

/* Report page: follows the theme on screen, always white on paper. */
.print-body { background: #e9e9e4; }
:root[data-theme="dark"] .print-body { background: #0F1416; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .print-body { background: #0F1416; } }
:root[data-theme="dark"] .sheet { box-shadow: 0 10px 40px -20px rgba(0,0,0,.9); }

.ai-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(12, 16, 18, .72); z-index: 50; }
.ai-box { width: min(420px, 90vw); background: var(--surface); color: var(--ink); border-radius: var(--r-lg); padding: 22px 24px; box-shadow: var(--shadow); text-align: center; }
.ai-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
.ai-bar > span { display: block; height: 100%; width: 40%; border-radius: 999px; background: #6C4BD4; animation: ai-slide 1.4s ease-in-out infinite; }
@keyframes ai-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.ai-step { margin: 0 0 4px; font-weight: 600; }
@media print { .ai-overlay { display: none !important; } }
.analysis-edit { margin-top: 10px; }
.analysis-edit textarea { width: 100%; font-family: var(--ui-font); }
.hw-check { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; }
.hw-check li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-md); }
.hw-check .mark { width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--ink-2); font-weight: 700; }
.hw-check li.is-done .mark { background: var(--primary); color: var(--on-primary); }
.hw-check-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
.hand-in-row { align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.hw-part { padding: 8px 0; border-top: 1px solid var(--line); }
.hw-part:first-of-type { border-top: 0; }
.hw-part.is-missing { opacity: .6; }
.reopen-form { border-top: 1px dashed var(--line); padding-top: 10px; }
.check { display: flex; gap: 9px; align-items: center; font-size: .94rem; }
.check input { width: 17px; height: 17px; }
.choice { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin: 0; display: grid; gap: 8px; }
.choice legend { padding: 0 6px; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.choice small { font-size: .82rem; }

/* ---------- accounts screen ------------------------------------------- */
.waiting-list { border-left: 3px solid var(--accent); }
.waiting-row { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.waiting-row:first-of-type { border-top: 0; }
.waiting-who { display: grid; gap: 2px; min-width: 240px; }
.waiting-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.turn-down summary { cursor: pointer; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: .88rem; font-weight: 600; color: var(--danger); }
.turn-down[open] { width: 100%; margin-top: 8px; }
.turn-down .stack { margin-top: 8px; }

.accounts-table td { vertical-align: middle; }
.accounts-table .who { display: grid; gap: 1px; }
.accounts-table .right { text-align: right; }
.manage-row-tr td { background: var(--surface-2); }
.manage-body { padding: 14px 4px; display: grid; gap: 16px; text-align: left; }
.manage-body .grid-2 { gap: 12px; }
.manage-row { flex-wrap: wrap; gap: 8px; }

/* Space between a table card and the panel after it (Accounts, Students). */
.card + .panel { margin-top: 28px; }

/* ---------- Dictionary (v1.1.0) ---------- */
.side-nav .nav-dict {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; margin-top: 2px;
  border: 0; border-radius: var(--r-md); background: none; cursor: pointer;
  color: var(--ink-2); font: inherit; font-weight: 600; font-size: .98rem; text-align: left;
}
.side-nav .nav-dict .icon { color: #E57D72; }
.side-nav .nav-dict:hover { background: var(--surface-2); color: var(--ink); }
.side-nav .nav-dict kbd { margin-left: auto; opacity: .7; font-size: .75rem; }
.dict-fab { display: none; }
@media (max-width: 820px) {
  .dict-fab {
    display: grid; place-items: center; position: fixed; z-index: 21; right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom)); width: 52px; height: 52px; border-radius: 50%;
    border: 0; background: #E57D72; color: #fff; cursor: pointer;
    box-shadow: 0 10px 24px -10px rgba(229, 125, 114, .9);
  }
  .dict-fab .icon { width: 24px; height: 24px; }
}
html.dict-open { overflow: hidden; }
html.dict-open .dict-fab { display: none; }

.dict { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 8vh 16px 16px; }
.dict[hidden] { display: none; }
.dict-backdrop { position: absolute; inset: 0; background: rgba(12, 16, 18, .55); backdrop-filter: blur(4px); animation: dict-fade .15s ease; }
.dict-panel {
  position: relative; width: min(860px, 100%); height: min(640px, 84vh); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); overflow: hidden; animation: dict-rise .18s ease;
}
@keyframes dict-fade { from { opacity: 0; } }
@keyframes dict-rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.dict-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dict-bar > .icon { width: 20px; height: 20px; color: #E57D72; flex: 0 0 auto; }
.dict-bar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink);
  font: 500 1.2rem var(--ui-font); padding: 6px 0;
}
.dict-bar input, .dict-bar input:focus, .dict-bar input:focus-visible { flex: 1 1 auto; width: 100%; max-width: none; min-height: 0; padding: 6px 0; border: 0; box-shadow: none; outline: 0; background: none; }
.dict-bar input::-webkit-search-cancel-button { display: none; }
.dict-x { border: 0; background: none; color: var(--ink-2); width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.dict-x:hover { background: var(--surface-2); color: var(--ink); }
.dict.is-busy .dict-bar > .icon { animation: dict-pulse .8s ease-in-out infinite alternate; }
@keyframes dict-pulse { to { opacity: .35; } }

.dict-body { flex: 1; min-height: 0; overflow-y: auto; position: relative; overscroll-behavior: contain; }
.dict.is-word .dict-list, .dict.is-word .dict-state, .dict.is-word #dict-tips-slot { display: none; }
.dict-list { list-style: none; margin: 0; padding: 0; }
.dict-list > li {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; gap: 18px; align-items: center;
  padding: 12px 22px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.dict-list > li[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 #E57D72; }
@media (hover: hover) { .dict-list > li:hover { background: var(--surface-2); } }
.dict-head .hz { display: block; font-family: var(--hz-font); font-size: 1.55rem; line-height: 1.2; font-weight: 600; }
.dict-py { display: block; color: var(--ink-2); font-size: .95rem; margin-top: 2px; }
.dict-senses { list-style: none; margin: 0; padding: 0; counter-reset: sense; display: grid; gap: 4px; }
.dict-senses li { counter-increment: sense; display: flex; gap: 8px; align-items: baseline; line-height: 1.35; }
.dict-senses li::before {
  content: counter(sense); flex: 0 0 auto; min-width: 20px; height: 20px; border-radius: 4px; display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2); font-size: .72rem; font-weight: 700; transform: translateY(-1px);
}
.dict-list > li[aria-selected="true"] .dict-senses li::before { background: var(--surface); }
.dict-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dict-tag { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.dict-tag-book { border-color: color-mix(in srgb, var(--primary) 50%, transparent); color: var(--primary); }

.dict-state:empty { display: none; }
.dict-state, #dict-tips-slot { padding: 14px 22px; }
.dict-label { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.dict-empty { margin: 18px 0; color: var(--ink-2); }
.dict-tips p { margin: 0 0 8px; }
.dict-tries { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dict-try { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 3px 12px; cursor: pointer; font: inherit; font-size: .92rem; }
.dict-try:hover { border-color: #E57D72; }

.dict-foot {
  display: flex; gap: 22px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line);
  background: var(--surface-2); font-size: .82rem; color: var(--ink-2);
}
.dict-foot kbd { margin-right: 2px; }
.dict-count { margin-left: auto; }

/* one word */
.dict-word { padding: 18px 26px 28px; outline: 0; }
.dict-word[hidden] { display: none; }
.dict-back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 6px 4px 0; }
.dict-back:hover { color: var(--ink); }
.dict-back .icon { width: 18px; height: 18px; }
.dict-hero { display: flex; gap: 22px; align-items: center; margin: 10px 0 18px; flex-wrap: wrap; }
.dict-big .hz { font-family: var(--hz-font); font-size: clamp(3rem, 8vw, 4.4rem); line-height: 1; font-weight: 600; }
.dict-hero-py { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 600; margin-bottom: 8px; }
.dict-hero .dict-tags { justify-content: flex-start; }
.dict-say {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink); display: inline-grid; place-items: center; cursor: pointer;
}
.dict-say:hover, .dict-say.is-playing { border-color: #E57D72; color: #E57D72; }
.dict-say .icon { width: 18px; height: 18px; }
.dict-word section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; }
.dict-word h3 { margin: 0 0 10px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.dict-word h3 .hz { font-family: var(--hz-font); text-transform: none; font-size: 1rem; }
.dict-senses-full { font-size: 1.05rem; gap: 8px; }
.dict-note { margin: 12px 0 0; color: var(--ink-2); }
.dict-ex { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.dict-ex-zh { font-family: var(--hz-font); font-size: 1.2rem; }
.dict-ex-py { color: var(--ink-2); font-size: .92rem; }
.dict-ex-en { font-size: .95rem; }
.dict-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dict-chip {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; text-align: left;
}
.dict-chip:hover { border-color: #E57D72; }
.dict-chip .hz { font-family: var(--hz-font); font-size: 1.25rem; font-weight: 600; }
.dict-chip span { color: var(--ink-2); font-size: .9rem; }
.dict-chip small { color: var(--ink-2); font-size: .82rem; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dict-chip.is-plain { cursor: default; }
.dict-books { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dict-books a { color: var(--ink); font-weight: 600; text-decoration: none; }
.dict-books a span { color: var(--ink-2); font-weight: 400; }
.dict-books a:hover { color: var(--primary); }

@media (max-width: 820px) {
  .dict { padding: 0; }
  .dict-panel { height: 100%; width: 100%; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .dict-list > li { grid-template-columns: 1fr; gap: 6px; padding: 12px 16px; }
  .dict-tags { justify-content: flex-start; }
  .dict-head .hz { display: inline; margin-right: 10px; }
  .dict-py { display: inline; }
  .dict-foot { display: none; }
  .dict-word { padding: 14px 16px 28px; }
}
@media (prefers-reduced-motion: reduce) { .dict-backdrop, .dict-panel { animation: none; } }

/* Dictionary: shown as a search box so it reads as an action, not a page */
.side-nav .nav-dict {
  margin: 10px 0 6px; padding: 9px 10px 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--ink-2); font-weight: 500;
  transition: border-color .15s, background .15s;
}
.side-nav .nav-dict:hover { border-color: #E57D72; background: var(--surface); color: var(--ink); }
.side-nav .nav-dict:focus-visible { outline: 2px solid #E57D72; outline-offset: 2px; }
.side-nav .nav-dict kbd { margin-left: auto; opacity: 1; background: var(--surface); color: var(--ink-2); }

/* Dictionary credits and Sources page (v1.2.0) */
.dict-credit { margin: 22px 0 0; font-size: .78rem; color: var(--ink-2); }
.dict-credit a { color: inherit; }
.sources-page { max-width: 760px; }
.sources-page .panel h2 { margin: 0; }

/* Dialogues tab (v1.3.0, own courses) */
.dialogue + .dialogue { margin-top: 18px; }
.dlg-lines { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.dlg-lines li { display: grid; grid-template-columns: 64px 36px 1fr; gap: 10px; align-items: start; }
.dlg-who { font-family: var(--hz-font); font-weight: 600; color: var(--ink-2); padding-top: 6px; }
.dlg-say { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.dlg-say:hover, .dlg-say.is-playing { border-color: var(--primary); color: var(--primary); }
.dlg-say .icon { width: 17px; height: 17px; }
.dlg-body { display: grid; gap: 1px; }
.dlg-zh { font-family: var(--hz-font); font-size: 1.25rem; }
.dlg-py { font-size: .92rem; color: var(--ink-2); }
.dlg-en { font-size: .92rem; }
@media (max-width: 560px) { .dlg-lines li { grid-template-columns: 36px 1fr; } .dlg-who { grid-column: 1 / -1; padding: 0; } }

.word-pic { font-size: 1.6rem; line-height: 1; margin-right: 6px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.dlg-scene { font-size: 1.3rem; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }

/* Phone menu: More button and sheet (v1.3.1) */
.tab-more { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font: inherit; font-size: .66rem; font-weight: 600; color: var(--ink-2); background: none; border: 0; cursor: pointer; }
.tab-more .icon { width: 24px; height: 24px; }
.tab-more.is-current, .tab-more[aria-expanded="true"] { color: var(--primary); }
.tab-dot { position: absolute; top: 5px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: #E57D72; box-shadow: 0 0 0 2px var(--surface); }
.more-sheet { position: fixed; inset: 0; z-index: 60; }
.more-sheet[hidden] { display: none; }
.more-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.more-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 85vh; overflow-y: auto; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -10px 30px rgba(0,0,0,.25); animation: more-up .2s ease-out; }
@keyframes more-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.more-head { display: flex; justify-content: center; position: relative; padding: 4px 0 6px; }
.more-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin-top: 6px; }
.more-x { position: absolute; right: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.more-x .icon { width: 18px; height: 18px; }
.more-label { margin: 12px 4px 8px; font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.more-grid a, .more-grid button { position: relative; display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 78px; padding: 10px 4px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: .8rem; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer; }
.more-grid .icon { width: 24px; height: 24px; color: var(--ink-2); }
.more-grid [aria-current="page"] { border-color: var(--primary); color: var(--primary); }
.more-grid [aria-current="page"] .icon { color: var(--primary); }
.more-grid .pill { position: absolute; top: 6px; right: 8px; }
.more-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (min-width: 821px) { .more-sheet { display: none !important; } }

.nope { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
