:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #5d6673;
  --line: #dfe3e8;
  --accent: #1f6f5c;
  --accent-soft: #d8efe8;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --bot: #7c3aed;
  --l0: #cbd2da;
  --l1: #f59e0b;
  --l2: #eab308;
  --l3: #22c55e;
  --l4: #15803d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color-scheme: light dark;
}
/* Dark: the device's setting (Auto), or chosen with the header button (data-mode). */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #111418;
    --panel: #1a1f25;
    --text: #e6e9ed;
    --muted: #9aa4b1;
    --line: #2c333c;
    --accent: #5fc4a8;
    --accent-soft: #173a31;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --bot: #c4a1ff;
    --l0: #3a434e;
  }
}
:root[data-mode="dark"] {
    --bg: #111418;
    --panel: #1a1f25;
    --text: #e6e9ed;
    --muted: #9aa4b1;
    --line: #2c333c;
    --accent: #5fc4a8;
    --accent-soft: #173a31;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --bot: #c4a1ff;
    --l0: #3a434e;
  }
:root[data-mode="dark"] { color-scheme: dark; }
:root[data-mode="light"] { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; background-color: var(--bg); background-image: var(--pattern, none); color: var(--text); min-height: 100vh; }
h1, h2, header .brand, .stat .v, .drill .zh { font-family: var(--font-head, inherit); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 10px 0 6px; }
button, select, input, textarea, a.button {
  font: inherit; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
}
textarea { width: 100%; }
button, a.button { cursor: pointer; display: inline-block; }
a.button:hover { text-decoration: none; }
a.button.disabled { opacity: 0.5; pointer-events: none; }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
button.link { border: none; background: none; color: var(--accent); padding: 0 4px; }
button.danger, .danger { color: var(--bad); }
button.good { border-color: var(--good); color: var(--good); }
button.bad { border-color: var(--bad); color: var(--bad); }
button.small { font-size: 13px; padding: 4px 8px; }
button:disabled { opacity: 0.5; cursor: default; }

header { background: var(--header-bg, var(--panel)); color: var(--header-text, var(--text)); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
header .bar1, header .bar2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 16px; max-width: 1200px; margin: 0 auto; }
header .bar2 { padding-top: 0; }
header .brand { font-weight: 700; font-size: 18px; color: var(--header-text, var(--text)); }
header nav { display: flex; flex-wrap: wrap; gap: 2px; }
header nav a { padding: 6px 10px; border-radius: 8px; color: var(--header-text, var(--text)); }
header nav a.active { background: var(--nav-active-bg, var(--accent-soft)); color: var(--nav-active, var(--accent)); text-decoration: none; }
header .spacer { flex: 1; }
header .picker { font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-top: var(--panel-top, 1px solid var(--line)); border-radius: var(--radius, 12px); box-shadow: var(--shadow, none); padding: 14px 16px; margin-bottom: 14px; overflow-x: auto; }
.panel > h2 { font-size: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 14px; align-items: start; }
.grid > .panel { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.spread { justify-content: space-between; }
.row.center { justify-content: center; }
.nowrap { flex-wrap: nowrap; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.pre { white-space: pre-wrap; }
.note { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; }
code.token { word-break: break-all; user-select: all; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.bot { background: color-mix(in srgb, var(--bot) 18%, transparent); color: var(--bot); }
.badge.status-assigned { background: var(--line); color: var(--text); }
.badge.status-in_progress { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.status-turned_in { background: color-mix(in srgb, var(--bot) 18%, transparent); color: var(--bot); }
.badge.status-checked, .badge.status-graded { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge.status-excused { background: var(--line); color: var(--muted); }
.badge.level-0 { background: var(--line); color: var(--muted); }
.badge.level-1 { background: color-mix(in srgb, var(--l1) 25%, transparent); color: var(--text); }
.badge.level-2 { background: color-mix(in srgb, var(--l2) 25%, transparent); color: var(--text); }
.badge.level-3 { background: color-mix(in srgb, var(--l3) 25%, transparent); color: var(--text); }
.badge.level-4 { background: color-mix(in srgb, var(--l4) 30%, transparent); color: var(--text); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.stats { display: flex; flex-wrap: wrap; gap: 22px; margin: 6px 0 14px; }
.stat .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat.warn .v { color: var(--warn); }
.stat.accent .v { color: var(--accent); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 4px 0 6px; }
.bar > div { height: 100%; background: var(--accent); }
.bar > div.done { background: var(--good); }

.daynav { margin-bottom: 8px; }
.daynav h2 { margin: 0 6px; }
.item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item.done .item-title { color: var(--muted); text-decoration: line-through; }
.item-title { font-weight: 600; font-size: 16px; }
.item-side { justify-content: flex-end; }
.score { font-weight: 650; font-variant-numeric: tabular-nums; }
.score.big { font-size: 20px; }
.practice { padding: 6px 0; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
a.launch { display: inline-block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-weight: 600; }
a.launch::after { content: " ↗"; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.week .day { margin: 0; }
.week .day.today { border-color: var(--accent); }
.week .mini { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.week .mini.done a { color: var(--muted); text-decoration: line-through; }

.feedback, .submission { border-left: 3px solid var(--accent); padding: 4px 10px; margin: 8px 0; }
.media img { max-width: 100%; max-height: 420px; border-radius: 8px; }
.turnin { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.turnin textarea { margin-bottom: 8px; }
.choices { display: flex; flex-direction: column; gap: 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.quiz .panel input:not([type=radio]):not([type=checkbox]) { width: min(320px, 100%); }
.cloze { font-size: 18px; line-height: 2.2; margin: 0; }
.cloze input.blank, .quiz .panel .cloze input.blank { width: 4.5em; padding: 2px 4px; margin: 0 3px; font-size: 18px; text-align: center; }
.grade-q { border-bottom: 1px solid var(--line); padding: 8px 0; }

.levels { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.levels .seg.level-0 { background: var(--l0); }
.levels .seg.level-1 { background: var(--l1); }
.levels .seg.level-2 { background: var(--l2); }
.levels .seg.level-3 { background: var(--l3); }
.levels .seg.level-4 { background: var(--l4); }
details summary { cursor: pointer; margin: 8px 0; color: var(--accent); }

nav.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
nav.tabs a { padding: 8px 12px; color: var(--text); border-bottom: 2px solid transparent; }
nav.tabs a.active { border-bottom-color: var(--accent); color: var(--accent); text-decoration: none; }

form.record { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
form.record label, form.inline label, .form-grid label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
form.record label.wide { flex-basis: 100%; }
form.record label.check, form.inline label.check { flex-direction: row; font-size: 15px; color: var(--text); }
form.record fieldset { display: flex; flex-wrap: wrap; gap: 4px 12px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px 8px; margin: 0; }
form.record fieldset legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
form.record fieldset.question { flex-basis: 100%; flex-direction: column; gap: 8px; }
form.record .questions { flex-basis: 100%; display: flex; flex-direction: column; gap: 10px; }
form.record .buttons, form.record > .row { flex-basis: 100%; }
form.record > .error { flex-basis: 100%; margin: 0; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 8px 0; }
form.inline textarea { min-width: min(320px, 100%); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 10px; }
.editor:empty { display: none; }

.drill { text-align: center; }
.drill .card { min-height: 180px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 14px; background: var(--bg); }
.drill .zh { font-size: 40px; line-height: 1.3; }
.drill .en { font-size: 22px; }
.drill .reading { font-size: 20px; color: var(--accent); }
.drill .answer.hidden { visibility: hidden; }
.drill .options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.drill .option { padding: 14px; font-size: 20px; }
.drill .option.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 18%, var(--panel)); }
.drill .option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, var(--panel)); }

.login { max-width: 360px; margin: 12vh auto; }
.login input { width: 100%; margin-bottom: 10px; }
.login button { width: 100%; }
.login .google-signin { display: flex; justify-content: center; min-height: 44px; margin-bottom: 12px; }

@media (max-width: 600px) {
  main { padding: 10px; }
  th, td { padding: 5px; }
  header .bar1, header .bar2 { padding: 6px 10px; }
  .drill .zh { font-size: 32px; }
}

/* ---- Music: notation, staff input, keyboard (staff.js, keyboard.js) ---- */
/* The width limit sits on .music, not the score: abcjs sizes the score's height as a share of its parent's width. */
.music { margin: 8px 0; max-width: 640px; }
.music.small { max-width: 320px; }
.music-score { color: var(--text); }
.music-score svg { display: block; }
.music-score .playing, .music-score .playing path { fill: var(--accent); }
.music-score [class*="abcjs-note"] { cursor: pointer; }
.music .play { display: block; margin-top: 6px; }
.staff-input-wrap { max-width: 320px; }
.staff-input { cursor: crosshair; touch-action: none; border: 1px dashed var(--line); border-radius: 8px; }
.acc-row { display: flex; gap: 6px; margin-top: 6px; }
.acc-row .acc { min-width: 44px; font-size: 20px; padding: 2px 10px; }
.acc-row .acc[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.staff-status { margin: 4px 0 0; min-height: 1.4em; }
.keyboard { display: block; width: 100%; max-width: 760px; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.keyboard .key { cursor: pointer; }
.keyboard .white rect { fill: #fdfdfb; stroke: #8b939c; stroke-width: 1; }
.keyboard .black rect { fill: #23272c; stroke: #111; stroke-width: 1; }
.keyboard .key-label { fill: #5d6673; font-size: 9px; pointer-events: none; }
.keyboard .white.marked rect { fill: #bfe6da; }
.keyboard .black.marked rect { fill: #1f6f5c; }
.keyboard .picked rect { fill: #fde68a; }
.keyboard .black.picked rect { fill: #b45309; }
.keyboard .right rect { fill: #bbf7d0; }
.keyboard .wrong rect { fill: #fecaca; }
.keyboard .down rect { fill: #9fd8c8; }
.keyboard .black.down rect { fill: #3f8f7a; }

/* ---- Lessons (lesson.js) ---- */
.lesson { display: grid; gap: 14px; max-width: 760px; }
.lesson h3 { margin: 4px 0 6px; font-size: 18px; }
.lesson-text p, .lesson-text ul, .lesson-text ol { margin: 0 0 10px; line-height: 1.55; max-width: 65ch; }
.lesson-text .table-wrap { overflow-x: auto; margin: 0 0 10px; max-width: 65ch; }
.lesson-text h3, .lesson-text h4 { margin: 12px 0 6px; }
.lesson figure { margin: 0; }
.lesson figcaption { margin-top: 4px; }
.lesson-try, .lesson-practice, .lesson-check { border: 1px solid var(--line); border-radius: var(--radius, 10px); padding: 12px 14px; background: color-mix(in srgb, var(--accent-soft) 35%, var(--panel)); }
.question { display: grid; gap: 8px; }
.q-prompt { margin: 0; font-weight: 600; font-size: 17px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.letters { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 420px; }
.choices .choice { min-height: 44px; min-width: 44px; font-size: 17px; }
.choices .choice:disabled { opacity: 1; cursor: default; }
.choices .choice.right, .choices .choice.right:disabled { border-color: var(--good); background: color-mix(in srgb, var(--good) 18%, var(--panel)); color: var(--text); }
.choices .choice.wrong, .choices .choice.wrong:disabled { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, var(--panel)); color: var(--text); }
.staff-q { display: grid; gap: 8px; justify-items: start; }
.keys-q { display: grid; gap: 8px; justify-items: start; }
.keys-q .keyboard { max-width: 440px; }
.q-feedback p { margin: 0; }
.q-feedback .right { color: var(--good); font-weight: 650; }
.q-feedback .wrong { color: var(--bad); font-weight: 650; }
.question .next { justify-self: start; }
.streak { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.streak .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.streak .dot.on { background: var(--good); border-color: var(--good); }
.streak .dot.miss { border-color: var(--bad); }
.streak .muted { margin-left: 6px; }
.done-line { color: var(--good); font-weight: 650; margin: 0 0 6px; }
.hint summary { cursor: pointer; color: var(--accent); }
.lesson-end { display: flex; justify-content: flex-end; }
.rhythm-q { display: grid; gap: 6px; }
.rhythm-q .row { flex-wrap: wrap; gap: 6px; }
.prompt .music { margin: 4px 0 8px; }
.table-wrap { overflow-x: auto; }

/* ---- Reading: her books ---- */
.book { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.book:last-child { border-bottom: 0; }
.book-line { padding: 6px 0; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.stars { color: var(--accent); letter-spacing: 1px; white-space: nowrap; }

/* ---- Writing: the editor page ---- */
.writer { display: grid; gap: 10px; overflow: visible; }
.writer-meta { gap: 8px; }
.writer-title { flex: 1 1 260px; min-width: 0; font-size: 20px; font-weight: 650; font-family: var(--font-head, inherit); }
.writer-target { width: 6em; }
.writer-tools { display: flex; flex-wrap: wrap; gap: 4px; position: sticky; top: var(--header-h, 0); z-index: 1; background: var(--panel); padding: 4px 0; border-bottom: 1px solid var(--line); }
.writer-tools button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.writer-tools .tb-bold { font-weight: 800; }
.writer-tools .tb-italic { font-style: italic; }
.writer-tools .tb-underline { text-decoration: underline; }
.writer-tools .tb-strike { text-decoration: line-through; }
.writer-page { background: var(--panel); }
.writer-text { min-height: 50vh; padding: 12px 4px; outline: none; font-size: 18px; line-height: 1.7; max-width: 70ch; margin: 0 auto; font-family: var(--font-body, Georgia, "Iowan Old Style", "Times New Roman", serif); }
.writer-page.readonly .writer-text { min-height: 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.writer-text p { margin: 0 0 0.9em; }
.writer-text h2, .writer-text h3 { margin: 1em 0 0.4em; line-height: 1.3; }
.writer-text blockquote { margin: 0 0 0.9em; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.writer-text ul, .writer-text ol { padding-left: 1.5em; margin: 0 0 0.9em; }
.writer-text p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--muted); float: left; height: 0; pointer-events: none; }
.writer-foot { border-top: 1px solid var(--line); padding-top: 6px; }
.writer-goal { display: flex; align-items: center; gap: 8px; }
.writer-goal .bar { width: 120px; }
.diff { line-height: 1.7; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; max-height: 60vh; overflow-y: auto; }
.diff ins { background: color-mix(in srgb, var(--good) 18%, transparent); text-decoration: underline; }
.diff del { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--muted); }

/* ProseMirror's base styles (Tiptap's injectCSS is off: the CSP allows no inline styles). */
.ProseMirror { position: relative; word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; font-variant-ligatures: none; font-feature-settings: "liga" 0; }
.ProseMirror [contenteditable="false"] { white-space: normal; }
.ProseMirror pre { white-space: pre-wrap; }
img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; }
.ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; }
.ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid var(--text); animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; }
@keyframes ProseMirror-cursor-blink { to { visibility: hidden; } }
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection * { caret-color: transparent; }
.ProseMirror-focused .ProseMirror-gapcursor { display: block; }

/* ---- Writing: nanny's notes beside the text ---- */
.writer-layout { display: grid; gap: 14px; align-items: start; }
.writer-layout > .panel { margin-bottom: 0; min-width: 0; }
@media (min-width: 1000px) {
  .writer-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .nanny-notes { position: sticky; top: calc(var(--header-h, 0px) + 8px); max-height: calc(100vh - var(--header-h, 0px) - 24px); overflow-y: auto; }
}
.writer-layout { margin-bottom: 14px; }
.nanny-notes { display: grid; gap: 10px; align-content: start; }
.nanny-notes h2, .nanny-notes p { margin: 0; }
.nanny-ask { display: grid; gap: 6px; }
.nanny-ask p { margin: 0; }
.nanny-waiting { color: var(--bot); font-weight: 600; margin: 0; }
.nanny-summary { margin: 0; line-height: 1.5; }
.nanny-note { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: grid; gap: 4px; }
.nanny-note p { margin: 0; line-height: 1.45; }
.nanny-note blockquote { margin: 0; color: var(--muted); font-style: italic; font-size: 14px; overflow-wrap: anywhere; }
.nanny-note.picked { box-shadow: 0 0 0 2px var(--accent); }
.nanny-note.lost { opacity: 0.65; cursor: default; }
.nanny-note.kind-praise { border-left-color: var(--good); }
.nanny-note.kind-suggestion { border-left-color: var(--accent); }
.nanny-note.kind-question { border-left-color: var(--bot); }
.nanny-note.kind-correction { border-left-color: var(--warn); }
.badge.note-praise { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge.note-question { background: color-mix(in srgb, var(--bot) 18%, transparent); color: var(--bot); }
.badge.note-correction { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.fb-mark { border-radius: 2px; cursor: pointer; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.fb-mark.fb-praise { text-decoration-color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
.fb-mark.fb-suggestion { text-decoration-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.fb-mark.fb-question { text-decoration-color: var(--bot); background: color-mix(in srgb, var(--bot) 10%, transparent); }
.fb-mark.fb-correction { text-decoration-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.fb-mark.picked { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* Words (vocabulary) */
.levels-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.levels-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.levels-dots span.on { background: var(--good); }
.vocab-test, .vocab-card { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.vocab-test h3 { margin: 0; }
.vocab-word { font-size: 28px; font-weight: 650; overflow-wrap: anywhere; }
.vocab-def { font-size: 17px; margin: 0; }
.vocab-example { font-style: italic; color: var(--muted); margin: 0; }
.vocab-answer { font-size: 18px; letter-spacing: 0.02em; }
.spell-input { font-size: 22px; padding: 8px 12px; max-width: 360px; width: 100%; letter-spacing: 0.04em; }
.vocab-choices { flex-direction: column; flex-wrap: nowrap; }
.vocab-choices .choice { text-align: left; font-size: 16px; padding: 10px 12px; white-space: normal; }
.word-form { display: flex; flex-direction: column; gap: 8px; }
.word-form:empty { display: none; }
.senses { display: flex; flex-direction: column; gap: 6px; }
.senses:empty { display: none; }
.sense { text-align: left; white-space: normal; font-weight: 400; }
.sense.on { border-color: var(--accent); background: var(--accent-soft); }

/* Lessons: number answers and key terms */
.number-q { align-items: center; }
.number-input { font-size: 18px; padding: 6px 10px; width: 12em; max-width: 100%; }
.number-q .unit { font-weight: 600; }
.lesson-terms dl { display: grid; grid-template-columns: minmax(8em, max-content) 1fr; gap: 6px 16px; margin: 0 0 8px; }
.lesson-terms dt { margin: 0; }
.lesson-terms dd { margin: 0; }
@media (max-width: 560px) { .lesson-terms dl { grid-template-columns: 1fr; } .lesson-terms dd { margin-bottom: 8px; } }

/* ---- Typing page (web/typing.js) ---- */
.tiny { font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip { border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.typing-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.typing-options .chips { margin: 0; }
.typing-player { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.typing-player .stats { margin: 0; }
.typing-level { display: flex; align-items: center; gap: 12px; }
.typing-level-n { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; font-weight: 700; background: var(--accent); color: var(--on-accent, #fff); box-shadow: 0 0 0 4px var(--accent-soft); font-family: var(--font-head, inherit); }
.typing-title { font-weight: 650; font-size: 17px; font-family: var(--font-head, inherit); }
.typing-xp { flex: 1 1 220px; min-width: 200px; }
.typing-xp .bar { height: 12px; border-radius: 6px; }

.typing-track { margin: 6px 0 10px; display: grid; gap: 4px; }
.typing-lane { display: grid; grid-template-columns: minmax(80px, 150px) 1fr; align-items: center; gap: 8px; }
.typing-lane-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.typing-lane-track { position: relative; height: 30px; background: var(--accent-soft); border-radius: 15px; border: 1px dashed var(--line); }
.typing-finish { position: absolute; right: 4px; top: 3px; bottom: 3px; width: 6px; border-radius: 2px; background: repeating-linear-gradient(0deg, var(--text) 0 4px, var(--panel) 4px 8px); opacity: 0.6; }
.typing-runner { position: absolute; top: 1px; left: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; transition: left 0.2s linear; color: #fff; }
.typing-runner.me { background: var(--accent); color: var(--on-accent, #fff); box-shadow: 0 0 0 3px var(--panel); z-index: 1; }
.typing-runner.ghost { opacity: 0.75; }
.typing-runner.c0 { background: #c2410c; } .typing-runner.c1 { background: #7c3aed; } .typing-runner.c2 { background: #0369a1; }
.typing-runner.c3 { background: #be185d; } .typing-runner.c4 { background: #4d7c0f; } .typing-runner.c5 { background: #a16207; }

.typing-live { margin: 4px 0 8px; }
.typing-box { position: relative; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 14px 16px; cursor: text; }
.typing-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.typing-text { position: relative; font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 22px; line-height: 1.6; height: calc(22px * 1.6 * 3); overflow: hidden; color: var(--muted); }
.typing-text .w { white-space: nowrap; }
.typing-text span.ok { color: var(--text); }
.typing-text span.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, transparent); border-radius: 2px; }
.typing-text span.sp.bad { text-decoration: underline wavy var(--bad); }
.typing-text span.cur { box-shadow: inset 2px 0 0 var(--accent); animation: typing-blink 1s steps(1) infinite; }
@keyframes typing-blink { 50% { box-shadow: inset 2px 0 0 transparent; } }
.typing-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; resize: none; border: none; cursor: text; font-size: 16px; }
.typing-hint { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; pointer-events: none; }
.typing-actions { margin: 10px 0; }

.typing-kb { margin: 10px auto 0; max-width: 640px; display: grid; gap: 4px; user-select: none; }
.typing-kb-row { display: flex; gap: 4px; justify-content: center; }
.typing-kb-row.r1 { padding-left: 2%; } .typing-kb-row.r2 { padding-left: 4%; }
.typing-key { flex: 0 1 40px; min-width: 0; height: 36px; border-radius: 6px; border: 1px solid var(--line); display: grid; place-items: center; font-family: ui-monospace, Consolas, monospace; font-size: 14px; position: relative; transition: transform 0.08s; }
.typing-key.wide { flex-basis: 70px; font-size: 12px; }
.typing-key.space { flex-basis: 260px; font-size: 12px; }
.typing-key.bump::after { content: ""; position: absolute; bottom: 5px; width: 10px; height: 2px; border-radius: 1px; background: currentColor; }
.typing-key.lp, .typing-key.rp { background: color-mix(in srgb, #e11d48 16%, var(--panel)); }
.typing-key.lr, .typing-key.rr { background: color-mix(in srgb, #f59e0b 18%, var(--panel)); }
.typing-key.lm, .typing-key.rm { background: color-mix(in srgb, #22c55e 16%, var(--panel)); }
.typing-key.li, .typing-key.ri { background: color-mix(in srgb, #3b82f6 16%, var(--panel)); }
.typing-key.th { background: color-mix(in srgb, #a855f7 12%, var(--panel)); }
.typing-key.next { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); transform: translateY(-2px); box-shadow: 0 3px 0 var(--accent-soft); }
.typing-kb-legend { text-align: center; margin-top: 4px; }
@media (max-width: 600px) { .typing-lane { grid-template-columns: 76px 1fr; } .typing-kb { display: none; } .typing-kb-toggle { display: none; } .typing-text { font-size: 18px; height: calc(18px * 1.6 * 3); } }

.typing-result { position: relative; margin-top: 8px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--accent-soft); overflow: hidden; }
.typing-result.best { border-color: var(--accent); }
.typing-result h3 { margin-top: 0; font-family: var(--font-head, inherit); font-size: 18px; }
.typing-levelup { color: var(--accent); font-weight: 650; }
.typing-burst { position: absolute; inset: 0; pointer-events: none; }
.typing-burst span { position: absolute; bottom: -20px; font-size: 22px; animation: typing-rise 1.6s ease-out forwards; }
.typing-burst span:nth-child(1) { left: 8%; } .typing-burst span:nth-child(2) { left: 24%; animation-delay: 0.15s; } .typing-burst span:nth-child(3) { left: 42%; animation-delay: 0.3s; }
.typing-burst span:nth-child(4) { left: 60%; animation-delay: 0.1s; } .typing-burst span:nth-child(5) { left: 76%; animation-delay: 0.25s; } .typing-burst span:nth-child(6) { left: 90%; animation-delay: 0.05s; }
@keyframes typing-rise { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-140px) scale(1.2); opacity: 0; } }

.typing-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; }
.typing-badges.new { margin: 8px 0; }
.typing-badge { border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; text-align: center; opacity: 0.55; }
.typing-badge.earned { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.typing-badge-icon { font-size: 26px; line-height: 1.2; }
.typing-board tr.me td { background: var(--accent-soft); font-weight: 650; }

.rain-sky { position: relative; height: 380px; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 22%, var(--panel)), var(--panel) 75%); }
.rain-sky::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: color-mix(in srgb, var(--accent) 35%, var(--panel)); border-top: 2px solid var(--accent); }
.rain-sky.rain-newwave { animation: rain-flash 0.8s; }
@keyframes rain-flash { 30% { box-shadow: inset 0 0 0 4px var(--accent); } }
.rain-drop { position: absolute; top: 0; padding: 3px 10px; border-radius: 12px 12px 14px 14px; background: var(--panel); border: 1px solid var(--line); font-family: ui-monospace, Consolas, monospace; font-size: 18px; white-space: nowrap; z-index: 1; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.rain-drop.match { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.rain-drop.pop { animation: rain-pop 0.3s forwards; }
.rain-drop.splash { animation: rain-splash 0.4s forwards; border-color: var(--bad); color: var(--bad); }
@keyframes rain-pop { to { opacity: 0; scale: 1.8; } }
@keyframes rain-splash { to { opacity: 0; scale: 1.4 0.4; } }
.rain-intro { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; gap: 6px; z-index: 2; background: color-mix(in srgb, var(--panel) 70%, transparent); }
.rain-intro p { max-width: 460px; margin: 0 auto 6px; }
.rain-input { display: block; width: 100%; margin-top: 8px; font-size: 20px; font-family: ui-monospace, Consolas, monospace; text-align: center; }
.rain-input.shake { animation: rain-shake 0.3s; border-color: var(--bad); }
@keyframes rain-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.rain-lives { color: var(--bad); letter-spacing: 2px; }
@media (prefers-reduced-motion: reduce) { .typing-runner, .typing-key { transition: none; } .typing-burst { display: none; } .typing-text span.cur { animation: none; } }
