/* Layout: an exercise-book page. One ruled card holds the dictation, answers are marked like a teacher's red pen; navigation and tools stay quiet around it. */
:root {
  --bg: #edf1f5;
  --paper: #fbfcfd;
  --paper-2: #f2f5f8;
  --ink: #1b2531;
  --ink-2: #485664;
  --ink-3: #5b6672;
  --rule: #dbe3eb;
  --rule-strong: #c3cfdb;
  --line: #d3e1f0;
  --margin: #e4a49c;
  --accent: #2552a3;
  --accent-ink: #ffffff;
  --accent-soft: #e3ebf8;
  --ok: #16744b;
  --ok-soft: #e0f2e8;
  --bad: #b42e22;
  --bad-soft: #fbe5e2;
  --warn: #8f6210;
  --warn-soft: #fbefd6;
  --shadow: 0 1px 2px rgba(22, 40, 66, .06), 0 6px 18px rgba(22, 40, 66, .07);
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  --font-word: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --nav-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151b;
    --paper: #18202a;
    --paper-2: #1d2631;
    --ink: #e5ebf1;
    --ink-2: #b2becb;
    --ink-3: #8794a2;
    --rule: #29333f;
    --rule-strong: #3a4654;
    --line: #233243;
    --margin: #6b3a36;
    --accent: #8db4ff;
    --accent-ink: #0c1a33;
    --accent-soft: #1d2b44;
    --ok: #52c58e;
    --ok-soft: #16322a;
    --bad: #ff7b6f;
    --bad-soft: #3a1f1d;
    --warn: #e6b65c;
    --warn-soft: #33290f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10151b;
  --paper: #18202a;
  --paper-2: #1d2631;
  --ink: #e5ebf1;
  --ink-2: #b2becb;
  --ink-3: #8794a2;
  --rule: #29333f;
  --rule-strong: #3a4654;
  --line: #233243;
  --margin: #6b3a36;
  --accent: #8db4ff;
  --accent-ink: #0c1a33;
  --accent-soft: #1d2b44;
  --ok: #52c58e;
  --ok-soft: #16322a;
  --bad: #ff7b6f;
  --bad-soft: #3a1f1d;
  --warn: #e6b65c;
  --warn-soft: #33290f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--font-ui);
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--paper);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.3; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- top bar & navigation ---------- */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--nav-h);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.brand b { font-size: 1.05rem; letter-spacing: .02em; }
.brand span { font: italic 500 .9rem var(--font-word); color: var(--ink-3); }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.tabs a svg { width: 18px; height: 18px; flex: none; }
.tabs a:hover { background: var(--paper-2); color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.tabs .badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font: 600 11px/18px var(--font-mono);
  text-align: center;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.sync-dot[data-state="ok"] { background: var(--ok); }
.sync-dot[data-state="busy"] { background: var(--warn); }
.sync-dot[data-state="error"] { background: var(--bad); }

@media (max-width: 720px) {
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    margin: 0;
    gap: 0;
    justify-content: space-around;
    background: var(--paper);
    border-top: 1px solid var(--rule);
    padding: 4px max(16px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  }
  .tabs a { flex-direction: column; gap: 1px; padding: 6px 4px; font-size: 11px; flex: 1; justify-content: center; position: relative; }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs .badge { position: absolute; top: 2px; left: calc(50% + 6px); }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  body.practicing { padding-bottom: 0; }
}
body.practicing .tabs { display: none; }

/* ---------- page container ---------- */
.view {
  max-width: 920px;
  margin: 0 auto;
  padding-block: 24px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.view:focus { outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .sub { color: var(--ink-3); font-size: .9rem; }
.eyebrow { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.card.raised { box-shadow: var(--shadow); }
#summaryCard:focus { outline: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ---------- buttons & controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--paper-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-lg { min-height: 48px; padding: 10px 22px; font-size: 1.05rem; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-danger { color: var(--bad); border-color: var(--bad-soft); }
.btn-danger:hover { background: var(--bad-soft); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn.star[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.icon-btn.star[aria-pressed="true"] svg { fill: currentColor; }
.fb-head .icon-btn.star { margin-left: auto; }
.icon-btn svg { width: 18px; height: 18px; }

.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .seg { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.seg button {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.seg button b { font-size: .98rem; }
.seg button span { font-size: .8rem; color: var(--ink-3); }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg button[aria-pressed="true"] b { color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .8rem; color: var(--ink-3); }
select, input[type="text"], input[type="number"], textarea {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 8px 10px;
  min-height: 40px;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.switch input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.switch span { display: flex; flex-direction: column; }
.switch small { color: var(--ink-3); font-size: .8rem; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
@media (max-width: 640px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- home ---------- */
.hero-date { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 14px; }
.hero-date h1 { font-size: 1.6rem; }
.streak { color: var(--warn); font-weight: 600; font-size: .92rem; }
.plan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 14px 0 18px;
  border-bottom: 1px dashed var(--rule-strong);
  margin-bottom: 18px;
}
.plan-num { font: 600 2.6rem/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.plan-split { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; color: var(--ink-2); }
.plan-split b { font-family: var(--font-mono); }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--rule-strong); }
.stat .num { font: 600 1.5rem/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: .82rem; color: var(--ink-3); }
.book-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: .9rem; color: var(--ink-2); }
.progress { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.progress .p-ok { background: var(--ok); }
.progress .p-bad { background: var(--bad); }
.progress .p-acc { background: var(--accent); }
.keys { font-size: .82rem; color: var(--ink-3); }
kbd {
  font: 500 .78rem var(--font-mono);
  padding: 1px 6px;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-2);
}

/* ---------- practice (the notebook) ---------- */
.practice { max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.pbar { display: flex; align-items: center; gap: 12px; }
.pbar .round { font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.pbar .mode-pick { width: auto; min-height: 30px; padding: 2px 6px; font-weight: 600; }
.pbar .count { font: 500 .9rem var(--font-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pbar .progress { flex: 1; height: 8px; }
.tally { display: flex; gap: 12px; font: 600 .9rem var(--font-mono); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .pbar { flex-wrap: wrap; row-gap: 8px; column-gap: 10px; }
  .pbar .round { flex: 1 1 60%; min-width: 0; }
  .pbar .progress { flex: 1 1 40%; }
}
.tally .t-ok { color: var(--ok); }
.tally .t-bad { color: var(--bad); }
.notebook {
  position: relative;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 39px, var(--line) 39px, var(--line) 40px);
  background-position: 0 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px 56px;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.notebook::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 38px;
  width: 2px;
  background: var(--margin);
  opacity: .7;
}
@media (max-width: 560px) {
  .notebook { padding: 22px 16px 18px 34px; }
  .notebook::before { left: 22px; }
}
.prompt { display: flex; align-items: center; gap: 16px; min-height: 72px; }
.play-big {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.play-big svg { width: 32px; height: 32px; }
.play-big.playing { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.prompt-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prompt-text .zh { font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; }
.prompt-text .zh.big { font-size: 1.5rem; }
.prompt-text .help { font-size: .85rem; color: var(--ink-3); }
.letters { font: 500 1.1rem var(--font-mono); letter-spacing: .25em; color: var(--ink-3); overflow-wrap: anywhere; }
.notebook .answer {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--ink-2);
  border-radius: 0;
  background: transparent;
  font: 500 2rem/1.2 var(--font-mono);
  padding: 6px 2px;
  min-height: 56px;
  letter-spacing: .02em;
}
.notebook .answer:focus { outline: none; border-bottom-color: var(--accent); }
.notebook .answer::placeholder { color: var(--ink-3); opacity: .7; font-size: .7em; }
.notebook .answer.is-ok { color: var(--ok); border-bottom-color: var(--ok); }
.notebook .answer.is-bad { color: var(--bad); border-bottom-color: var(--bad); text-decoration: line-through; text-decoration-thickness: 2px; }
.notebook .answer.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (max-width: 560px) {
  .notebook .answer { font-size: 1.6rem; order: 2; }
  /* feedback sits between the prompt and the box, so the soft keyboard cannot cover it */
  .notebook #fb { order: 1; }
  .notebook .p-actions { order: 3; }
  .notebook .keys { order: 4; }
  .notebook .prev { order: 5; }
}
/* 16px keeps iOS Safari from zooming in when a field is focused */
@media (max-width: 760px) {
  select, input[type="text"], input[type="number"], textarea { font-size: 16px; }
}
.p-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.feedback { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: var(--radius-sm); }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback.warn { background: var(--warn-soft); }
.fb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-word { font: 600 1.7rem/1.2 var(--font-word); overflow-wrap: anywhere; }
.ipa { font-family: var(--font-word); color: var(--ink-2); }
.meaning { color: var(--ink-2); overflow-wrap: anywhere; }
.diff { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: baseline; }
.diff .lbl { font-size: .8rem; color: var(--ink-3); white-space: nowrap; }
.diff .letters-row { font: 500 1.35rem/1.4 var(--font-mono); overflow-wrap: anywhere; }
.l-miss { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.l-wrong { color: var(--bad); }
.l-extra { color: var(--bad); text-decoration: line-through; }
.mark { width: 28px; height: 28px; flex: none; }
.prev { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 12px; border: 1px dashed var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper); }
.prev .eyebrow { flex-basis: 100%; }
.prev .mark { width: 20px; height: 20px; }
.prev .prev-word { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.prev .prev-word b { font: 600 1.05rem var(--font-word); }
.prev .prev-word b.said { font: 500 1rem var(--font-mono); }
.prev .icon-btn { width: 32px; height: 32px; }
details.allwords summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
.mark-ok { color: var(--ok); }
.mark-bad { color: var(--bad); }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }

/* paper mode */
.paper-now { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.paper-index { font: 600 3rem/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.paper-index small { font-size: 1.1rem; color: var(--ink-3); }
.paper-timer { height: 4px; width: 100%; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.paper-timer i { display: block; height: 100%; background: var(--accent); width: 0; }

/* ---------- lists (summary, mistakes, history) ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--rule);
}
.item:last-child { border-bottom: none; }
.item.now { background: var(--accent-soft); border-radius: var(--radius-sm); }
.item .w { font: 600 1.2rem/1.3 var(--font-word); overflow-wrap: anywhere; }
.item .meta { font-size: .85rem; color: var(--ink-3); overflow-wrap: anywhere; }
.item .typed { font-family: var(--font-mono); color: var(--bad); text-decoration: line-through; }
.item .acts { display: flex; gap: 6px; align-items: center; }
.item.no-mark { grid-template-columns: minmax(0, 1fr) auto; }
/* on narrow phones the buttons go under the word, so long words never break mid-word */
@media (max-width: 560px) {
  .item { grid-template-columns: auto minmax(0, 1fr); }
  .item.no-mark, .word-grid .item { grid-template-columns: minmax(0, 1fr); }
  .item .acts { grid-column: 2 / -1; flex-wrap: wrap; }
  .item.no-mark .acts, .word-grid .item .acts { grid-column: 1 / -1; }
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  background: var(--paper-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { border: 1px solid var(--rule-strong); background: var(--paper); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: .88rem; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.empty { padding: 28px 8px; text-align: center; color: var(--ink-3); }
.big-score { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
.big-score .pct { font: 600 3rem/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.rounds-trail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font: 500 .85rem var(--font-mono); }
.rounds-trail .arrow { color: var(--ink-3); }
.note { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: .92rem; }
.note.ok { background: var(--ok-soft); }
.note.warn { background: var(--warn-soft); }

/* paper-mode answer sheet */
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.sheet button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  min-width: 0;
}
.sheet button .n { font: 500 .8rem var(--font-mono); color: var(--ink-3); width: 22px; flex: none; }
.sheet button .w { font: 600 1.05rem var(--font-word); overflow-wrap: anywhere; min-width: 0; flex: 1; }
.sheet button .w small { display: block; font: 400 .8rem/1.4 var(--font-ui); color: var(--ink-3); }
.sheet button[aria-pressed="true"] { border-color: var(--bad); background: var(--bad-soft); }
.sheet button[aria-pressed="true"] .w { color: var(--bad); text-decoration: line-through; }

/* ---------- books ---------- */
.book { display: flex; flex-direction: column; gap: 10px; }
.book.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.unit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  min-width: 0;
}
.unit label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.unit input { accent-color: var(--accent); width: 16px; height: 16px; margin-top: 3px; flex: none; }
.unit .u-name { font-weight: 600; }
.unit .u-en { font: italic .82rem var(--font-word); color: var(--ink-3); }
.unit .u-acts { display: flex; flex-wrap: wrap; gap: 4px; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 18px; }
.word-grid .item { grid-template-columns: minmax(0, 1fr) auto; }

/* ---------- topics ---------- */
.day-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-nav .d { font-weight: 600; min-width: 9em; text-align: center; }
.topic { display: flex; flex-direction: column; gap: 16px; }
.topic-head { display: flex; flex-direction: column; gap: 4px; }
.topic-head h2 { font: 600 1.55rem/1.25 var(--font-word); }
.topic-head .zh-title { font-size: 1rem; color: var(--ink-2); }
.chip { align-self: flex-start; font-size: .75rem; font-weight: 600; letter-spacing: .04em; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--rule-strong); color: var(--ink-2); }
.topic section { display: flex; flex-direction: column; gap: 8px; }
.topic section > h3 { font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.qs { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; }
.qs li::marker { font-family: var(--font-mono); color: var(--ink-3); }
.en { font-family: var(--font-word); font-size: 1.04rem; line-height: 1.55; }
.zh { color: var(--ink-2); font-size: .9rem; }
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; }
.vocab div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vocab div > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.vocab b { font: 600 1rem var(--font-word); }
.vocab span span { font-size: .85rem; color: var(--ink-3); }
.vocab .icon-btn { width: 28px; height: 28px; }
.vocab .icon-btn svg { width: 15px; height: 15px; }
details.sample { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; }
details.sample summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.sample[open] summary { margin-bottom: 8px; }
.topic textarea { min-height: 80px; }
.topic-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 16px; }
.topic-index a { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule); min-width: 0; }
.topic-index a span { font-size: .82rem; color: var(--ink-3); overflow-wrap: anywhere; }
.topic-index a.done b::after { content: " ✓"; color: var(--ok); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  font-size: .92rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 721px) { .toast { bottom: 28px; } }

.confirm-inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.footer-note { font-size: .8rem; color: var(--ink-3); text-align: center; padding: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
