/* Independent appearance themes. Keep the teaching palette in readability.css. */
:root {
  color-scheme: light;
  --ui-bg: #f4f6fb;
  --ui-surface: #ffffff;
  --ui-soft: #edf0f8;
  --ui-softest: #f8f9fd;
  --ui-sidebar: #fafbff;
  --ui-ink: #253047;
  --ui-muted: #5c687c;
  --ui-subtle: #626e83;
  --ui-border: #dce2ed;
  --ui-strong-border: #bac5d9;
  --ui-accent: #5360bc;
  --ui-accent-hover: #414d9d;
  --ui-accent-soft: #e9edff;
  --ui-accent-ink: #3e4b9c;
  --ui-on-accent: #ffffff;
  --ui-secondary: #8470b5;
  --ui-success: #267157;
  --ui-success-soft: #e8f5ee;
  --ui-warning: #8b601c;
  --ui-warning-soft: #fbf0d8;
  --ui-error: #ae3c47;
  --ui-error-soft: #fce8e9;
  --ui-text: #556178;
  --ui-keyboard: #e5eaf2;
  --ui-key-plain: #f7f9fd;
  --ui-key-shadow: #b6c0d1;
  --ui-focus-cover: #ffffffed;
  --ui-backdrop: #15203970;
  --ui-shadow: 0 8px 24px #20335807, 0 1px 3px #20335805;
  --ui-shadow-raised: 0 12px 32px #20335810, 0 2px 6px #20335807;
  --ui-shadow-dialog: 0 24px 90px #12203f30;
  --ui-ease: cubic-bezier(.2,.7,.2,1);
}

:root[data-theme="paper"] {
  --ui-bg: #f3f5fb;
  --ui-sidebar: #fafbff;
  --ui-accent: #5261bd;
  --ui-secondary: #8a77b6;
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --ui-bg: #131b2b;
  --ui-surface: #1c273c;
  --ui-soft: #26334b;
  --ui-softest: #202d43;
  --ui-sidebar: #182235;
  --ui-ink: #edf2ff;
  --ui-muted: #bbc7dd;
  --ui-subtle: #a9b8d1;
  --ui-border: #35445e;
  --ui-strong-border: #5b6d8c;
  --ui-accent: #a7b4ff;
  --ui-accent-hover: #c0caff;
  --ui-accent-soft: #33416b;
  --ui-accent-ink: #d1d9ff;
  --ui-on-accent: #1a2547;
  --ui-secondary: #c2abe9;
  --ui-success: #8edbbc;
  --ui-success-soft: #233e3b;
  --ui-warning: #f3ce8e;
  --ui-warning-soft: #433b2c;
  --ui-error: #ffabb3;
  --ui-error-soft: #4c2e40;
  --ui-text: #becbe1;
  --ui-keyboard: #202d43;
  --ui-key-plain: #3a4964;
  --ui-key-shadow: #0f1727;
  --ui-focus-cover: #1c273cf5;
  --ui-backdrop: #060c19ba;
  --ui-shadow: 0 8px 24px #05091415, 0 1px 3px #05091418;
  --ui-shadow-raised: 0 12px 32px #05091430, 0 2px 6px #05091425;
  --ui-shadow-dialog: 0 28px 90px #03081280;
}

:root[data-theme="forest"] {
  --ui-bg: #edf5f0;
  --ui-surface: #fcfffc;
  --ui-soft: #e4efe7;
  --ui-softest: #f3f9f4;
  --ui-sidebar: #f6fbf6;
  --ui-ink: #293d35;
  --ui-muted: #546c60;
  --ui-subtle: #5b7265;
  --ui-border: #d1e2d7;
  --ui-strong-border: #a7c3b1;
  --ui-accent: #34745c;
  --ui-accent-hover: #275a47;
  --ui-accent-soft: #dcefe2;
  --ui-accent-ink: #2b654f;
  --ui-secondary: #7a8d61;
  --ui-success: #2c6c42;
  --ui-success-soft: #e1f0e2;
  --ui-text: #50685b;
  --ui-keyboard: #dce9df;
  --ui-key-plain: #f7fbf7;
  --ui-key-shadow: #afc3b6;
  --ui-focus-cover: #fcfffcf2;
  --ui-shadow: 0 8px 24px #21452e08, 0 1px 3px #21452e05;
  --ui-shadow-raised: 0 12px 32px #21452e12, 0 2px 6px #21452e07;
}

:root[data-theme="sunset"] {
  --ui-bg: #fbf0ea;
  --ui-surface: #fffcf9;
  --ui-soft: #f6e5de;
  --ui-softest: #fff5ef;
  --ui-sidebar: #fff7f0;
  --ui-ink: #503741;
  --ui-muted: #785e65;
  --ui-subtle: #81686f;
  --ui-border: #ebd5cd;
  --ui-strong-border: #d1aba0;
  --ui-accent: #a34f51;
  --ui-accent-hover: #843c40;
  --ui-accent-soft: #f9dfd8;
  --ui-accent-ink: #8a4448;
  --ui-secondary: #a17c9b;
  --ui-success: #477053;
  --ui-success-soft: #eaf1e3;
  --ui-text: #745c65;
  --ui-keyboard: #efded8;
  --ui-key-plain: #fff8f2;
  --ui-key-shadow: #ceb6ae;
  --ui-focus-cover: #fffcf9f2;
  --ui-shadow: 0 8px 24px #77432b08, 0 1px 3px #77432b05;
  --ui-shadow-raised: 0 12px 32px #77432b12, 0 2px 6px #77432b07;
}

/* Base tokens also cover existing components that already use CSS variables. */
:root body {
  --bg: var(--ui-bg);
  --white: var(--ui-surface);
  --ink: var(--ui-ink);
  --muted: var(--ui-muted);
  --border: var(--ui-border);
  --coral: var(--ui-accent);
  --coral-soft: var(--ui-accent-soft);
  --purple: var(--ui-secondary);
  background: var(--ui-bg);
  color: var(--ui-ink);
  line-height: 1.5;
  transition: background-color 180ms var(--ui-ease), color 180ms var(--ui-ease);
}
:root body ::selection { background: var(--ui-accent-soft); color: var(--ui-accent-ink); }
:root body :is(button,a,select,input,textarea) {
  transition: background-color 160ms var(--ui-ease), color 160ms var(--ui-ease), border-color 160ms var(--ui-ease), box-shadow 160ms var(--ui-ease);
}
:root body button:hover:not(:disabled) { filter: none; }
:root body button:active:not(:disabled) { transform: none; }
:root body :is(button,a,input,select,textarea):focus-visible {
  outline: 3px solid var(--ui-accent);
  outline-offset: 3px;
}
:root body button:disabled { opacity: .5; }
:root body :is(h1,h2,h3,strong) { text-wrap: pretty; }
:root body :is(.workspace,main,#trainer,#learnControls,#speedControls,#libraryPanel,#progressPanel) { min-width: 0; }
:root body main { max-width: 1340px; padding: 26px 36px 20px; }

/* Shell and navigation */
:root body .sidebar {
  background: var(--ui-sidebar);
  border-color: var(--ui-border);
  box-shadow: none;
  padding-top: 30px;
}
:root body .brand { color: var(--ui-ink); }
:root body .brand-symbol i {
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  box-shadow: 0 3px 0 color-mix(in srgb,var(--ui-accent) 72%,#152039);
}
:root body .brand-symbol i + i {
  background: var(--ui-secondary);
  color: #fff;
  box-shadow: 0 3px 0 color-mix(in srgb,var(--ui-secondary) 72%,#152039);
}
:root body :is(.brand-dot,.breadcrumb > span,h1 span,.page-footer .coral) { color: var(--ui-accent); }
:root body .nav-caption { color: var(--ui-subtle); font-size: 10px; letter-spacing: 1.45px; margin-top: 42px; }
:root body .nav-item {
  border: 1px solid transparent;
  padding: 12px 11px;
  border-radius: 12px;
  color: var(--ui-muted);
  font-size: 15px;
  gap: 10px;
}
:root body .nav-item[data-view] .icon { color: currentColor; }
:root body .nav-item:hover:not(:disabled) { background: var(--ui-soft); color: var(--ui-ink); }
:root body .nav-item[data-view].active {
  background: var(--ui-accent-soft);
  border-color: color-mix(in srgb,var(--ui-accent) 17%,var(--ui-accent-soft));
  color: var(--ui-accent-ink);
  box-shadow: none;
}
:root body .nav-arrow { font-size: 19px; font-weight: 400; }
:root body .daily-card {
  background: var(--ui-soft);
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  box-shadow: none;
  padding: 16px 13px;
}
:root body .little-star { color: var(--ui-secondary); }
:root body .daily-card strong { color: var(--ui-ink); }
:root body :is(.daily-card p,.daily-card small,.profile small) { color: var(--ui-muted); }
:root body .daily-track { height: 5px; background: var(--ui-border); }
:root body .daily-track span { background: var(--ui-accent); }
:root body .profile { color: var(--ui-ink); border-radius: 12px; }
:root body .profile strong { max-width: 112px; }
:root body .avatar { background: var(--ui-accent-soft); color: var(--ui-accent-ink); border: 1px solid var(--ui-border); }
:root body .topbar {
  min-height: 76px;
  height: auto;
  padding: 13px 36px;
  gap: 20px;
  background: var(--ui-sidebar);
  border-color: var(--ui-border);
}
:root body .breadcrumb { color: var(--ui-subtle); font-size: 10px; letter-spacing: 1.2px; line-height: 1.6; }
:root body .top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-width: 0; }
:root body :is(.presentation-switch,.language-switch,.segmented) {
  background: var(--ui-soft);
  border: 1px solid var(--ui-border);
  border-radius: 11px;
  gap: 3px;
  padding: 3px;
}
:root body .presentation-switch button { font-size: 13px; padding: 7px 13px; border-radius: 8px; font-weight: 650; color: var(--ui-muted); }
:root body .presentation-switch span { color: var(--ui-secondary); margin-left: 4px; }
:root body .language-switch button { font-size: 12px; padding: 6px 9px; color: var(--ui-muted); border-radius: 7px; }
:root body :is(.presentation-switch,.language-switch,.segmented) button.selected {
  background: var(--ui-surface);
  color: var(--ui-accent-ink);
  box-shadow: 0 1px 4px #15203912;
}
:root body :is(.presentation-switch,.language-switch,.segmented) button:not(.selected):hover { background: var(--ui-surface); color: var(--ui-ink); }
:root body .icon-button { width: 36px; height: 36px; border-radius: 10px; color: var(--ui-muted); flex: none; }
:root body .icon-button:hover { background: var(--ui-soft); color: var(--ui-accent-ink); }
:root body .icon-button[aria-pressed="true"] { background: var(--ui-accent-soft); color: var(--ui-accent-ink); }
:root body .appearance-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 12px;
  color: var(--ui-muted);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
:root body .appearance-button .icon { width: 17px; height: 17px; color: var(--ui-accent); }
:root body .appearance-button:hover { border-color: var(--ui-strong-border); background: var(--ui-accent-soft); color: var(--ui-accent-ink); }
:root body .page-heading { margin-bottom: 25px; align-items: center; }
:root body .eyebrow { color: var(--ui-subtle); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 8px; }
:root body h1 { color: var(--ui-ink); font-size: clamp(27px,2.65vw,38px); line-height: 1.15; letter-spacing: -1.2px; }
:root body .page-heading p { color: var(--ui-muted); margin-top: 10px; font-size: 15px; }
:root body .heading-label { color: var(--ui-muted); font-size: 12px; padding: 7px 10px; background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: 20px; }
:root body .status-dot { background: var(--ui-success); }
:root body .status-dot.violet { background: var(--ui-secondary); }
:root body .section-line h2 { color: var(--ui-ink); font-size: 16px; font-weight: 650; }
:root body .section-line > span { color: var(--ui-muted); font-size: 13px; }

/* Controls, course, and the six-step path */
:root body :is(select,input[type="text"],.custom-area) {
  color: var(--ui-ink);
  background: var(--ui-surface);
  border: 1px solid var(--ui-strong-border);
  border-radius: 10px;
  padding: 10px 12px;
  accent-color: var(--ui-accent);
}
:root body :is(input,.custom-area)::placeholder { color: var(--ui-subtle); opacity: 1; }
:root body select:hover { border-color: var(--ui-accent); }
:root body :is(.primary,.small-primary) {
  border: 1px solid transparent;
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  box-shadow: 0 2px 3px #16213b10;
  border-radius: 10px;
  font-weight: 650;
}
:root body :is(.primary,.small-primary):hover:not(:disabled) { background: var(--ui-accent-hover); box-shadow: 0 3px 8px #16213b18; }
:root body .primary { padding: 11px 20px; font-size: 14px; }
:root body .small-primary { padding: 7px 14px; font-size: 13px; }
:root body .secondary {
  background: var(--ui-accent-soft);
  color: var(--ui-accent-ink);
  border: 1px solid transparent;
  border-radius: 10px;
  box-shadow: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}
:root body .secondary:hover:not(:disabled) { border-color: var(--ui-strong-border); background: var(--ui-soft); }
:root body .text-button { color: var(--ui-accent-ink); font-size: 13px; }
:root body .text-button:hover { color: var(--ui-accent); text-decoration: underline; text-underline-offset: 4px; }
:root body .reset-button { color: var(--ui-muted); border-radius: 8px; min-width: 30px; }
:root body .reset-button:hover { color: var(--ui-accent); background: var(--ui-soft); }
:root body .course-toolbar { gap: 12px; margin: 13px 0; }
:root body .course-toolbar label { color: var(--ui-muted); font-size: 13px; gap: 9px; }
:root body .course-toolbar select { font-size: 14px; min-width: 260px; }
:root body .course-toolbar .course-actions { gap: 7px; flex-wrap: wrap; }
:root body .block-progress { color: var(--ui-muted); font-size: 12px; gap: 10px; margin: 11px 0 15px; }
:root body .block-progress strong { color: var(--ui-success); font-variant-numeric: tabular-nums; }
:root body .block-progress-track { height: 5px; background: var(--ui-border); }
:root body .block-progress-track span { background: var(--ui-success); transition: width 240ms var(--ui-ease); }
:root body .lesson-path { gap: 8px; margin-bottom: 12px; }
:root body .pair-button {
  min-width: 88px;
  padding: 10px 13px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 2px 3px #16213b03;
}
:root body .pair-button strong { color: var(--ui-ink); font-size: 21px; }
:root body .pair-button small { color: var(--ui-muted); font-size: 12px; }
:root body .pair-button:hover { border-color: var(--ui-strong-border); background: var(--ui-softest); box-shadow: var(--ui-shadow); }
:root body .pair-button.complete { background: var(--ui-success-soft); border-color: color-mix(in srgb,var(--ui-success) 25%,var(--ui-border)); }
:root body .pair-button.complete small { color: var(--ui-success); }
:root body .pair-button.current {
  background: var(--ui-accent-soft);
  border-color: var(--ui-accent);
  box-shadow: inset 0 0 0 1px var(--ui-accent);
}
:root body .pair-button.current strong { color: var(--ui-accent-ink); }
:root body .lesson-stages { gap: 7px; margin-bottom: 20px; }
:root body .stage-button {
  padding: 8px 11px;
  gap: 7px;
  color: var(--ui-muted);
  background: var(--ui-surface);
  border-color: var(--ui-border);
  border-radius: 10px;
  font-size: 13px;
}
:root body .stage-button > span { background: var(--ui-soft); color: var(--ui-muted); width: 24px; height: 24px; font-size: 12px; flex: none; }
:root body .stage-button:hover { border-color: var(--ui-strong-border); color: var(--ui-ink); }
:root body .stage-button.current { background: var(--ui-accent-soft); color: var(--ui-accent-ink); border-color: var(--ui-strong-border); }
:root body .stage-button.current > span { background: var(--ui-accent); color: var(--ui-on-accent); }
:root body .stage-button.complete > span { background: var(--ui-success-soft); color: var(--ui-success); }
:root body .control-label { color: var(--ui-muted); font-size: 13px; }
:root body .segmented button { color: var(--ui-muted); font-size: 14px; border-radius: 8px; padding: 8px 16px; }
:root body .mode-controls { gap: 22px; }
:root body .mode-controls select { color: var(--ui-ink); font-size: 14px; }

/* Practice: calm text surface, strong state colours, quiet feedback. */
:root body .presentation-bar { gap: 10px; align-items: center; margin-bottom: 12px; }
:root body .avatar-picker { color: var(--ui-muted); font-size: 13px; }
:root body .avatar-picker select { padding: 7px 10px; color: var(--ui-ink); background: var(--ui-surface); border-color: var(--ui-strong-border); }
:root body .animation-toggle { color: var(--ui-muted); font-size: 13px; }
:root body .animation-toggle input { accent-color: var(--ui-accent); }
:root body .game-hud {
  margin-left: auto;
  gap: 15px;
  padding: 5px 11px;
  background: var(--ui-success-soft);
  border: 1px solid color-mix(in srgb,var(--ui-success) 23%,var(--ui-success-soft));
  border-radius: 10px;
  color: var(--ui-success);
  box-shadow: none;
  font-size: 12px;
}
:root body .game-hud strong { color: var(--ui-success); font-size: 16px; }
:root body .game-hud > span:last-child > span { color: var(--ui-warning); }
:root body .scene-note { color: var(--ui-muted); font-size: 12px; line-height: 1.5; margin: -3px 0 14px; }
:root body .lesson-info { gap: 10px; margin-bottom: 12px; }
:root body .lesson-icon { background: var(--ui-accent-soft); color: var(--ui-accent); box-shadow: none; border-radius: 11px; }
:root body .lesson-info strong { font-size: 16px; color: var(--ui-ink); }
:root body .lesson-info p { color: var(--ui-muted); font-size: 13px; line-height: 1.55; }
:root body .typing-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  box-shadow: var(--ui-shadow);
}
:root body .stats-bar { padding: 15px 23px; background: var(--ui-softest); border-color: var(--ui-border); gap: 4px; }
:root body .stat { border-color: var(--ui-border); padding-left: 22px; gap: 4px; }
:root body .stat strong { font-size: 28px; font-weight: 650; letter-spacing: -.7px; color: var(--ui-ink); }
:root body .stat:nth-child(3) strong { color: var(--ui-ink); }
:root body .stat:nth-child(4) strong { color: var(--ui-success); }
:root body .stat small { font-size: 12px; color: var(--ui-muted); }
:root body .timer-stat { padding: 0; color: var(--ui-accent); }
:root body .timer-stat strong { color: var(--ui-accent-ink); }
:root body .timer-stat.urgent strong { color: var(--ui-error); }
:root body .error-stat strong { color: var(--ui-muted); }
:root body .text-overview { padding: 10px 24px 4px; color: var(--ui-muted); font-size: 12px; background: var(--ui-surface); }
:root body .text-overview strong { color: var(--ui-success); }
:root body .exercise-area:focus-within { background: var(--ui-surface); }
:root body #targetText { color: var(--ui-text); }
:root body .char.correct { color: var(--ui-success); }
:root body.game-mode .char.correct { color: transparent; opacity: 0; }
:root body .char.current { color: var(--ui-accent-ink); background: var(--ui-accent-soft); border-radius: 4px; }
:root body .char.current::after { background: var(--ui-accent); }
:root body .char.wrong { color: var(--ui-error); background: var(--ui-error-soft); }
:root body #targetText .text-end-marker { background: var(--ui-success-soft); color: var(--ui-success); border-radius: 6px; font-size: 12px; }
:root body .typing-footer { background: var(--ui-surface); padding: 10px 23px 12px; min-height: 52px; gap: 12px; }
:root body .typing-footer > span { font-size: 12px; color: var(--ui-muted); }
:root body .typing-footer > div { gap: 12px; }
:root body .caps-warning { color: var(--ui-warning); background: var(--ui-warning-soft); border: 1px solid color-mix(in srgb,var(--ui-warning) 25%,var(--ui-warning-soft)); border-radius: 6px; padding: 3px 7px; font-size: 11px; font-weight: 600; }
:root body .exercise-progress { background: var(--ui-soft); height: 4px; }
:root body .exercise-progress > span { background: var(--ui-accent); }
:root body .focus-cover { background: var(--ui-focus-cover); backdrop-filter: none; }
:root body .focus-cover > span { color: var(--ui-muted); }
:root body .keyboard-heading { color: var(--ui-muted); font-size: 12px; margin-top: 17px; margin-bottom: 10px; }
:root body .toggle { color: var(--ui-muted); font-size: 12px; }
:root body .toggle > span { background: var(--ui-strong-border); }
:root body .toggle input:checked + span { background: var(--ui-accent); }
:root body .keyboard { background: var(--ui-keyboard); border-color: var(--ui-strong-border); border-radius: 14px; box-shadow: 0 3px 0 var(--ui-key-shadow); padding: 10px; }
:root body .key { background: var(--ui-key-plain); color: var(--ui-ink); box-shadow: 0 2px 0 var(--ui-key-shadow); border-radius: 6px; }
:root body .key[data-finger]:not([data-finger=""]) { background: var(--finger); color: #202837; }
:root body .key.special { color: var(--ui-muted); }
:root body .key.special[data-finger]:not([data-finger=""]) { color: #202837; }
:root body #keyboardGuide:not(.no-hints) .key[data-code="Space"] { color: #17202b; }
:root body .key.next { box-shadow: 0 2px 0 var(--ui-key-shadow),0 0 0 2px var(--ui-surface),0 0 0 4px var(--ui-accent); }
:root body .key.pressed { box-shadow: none; }
:root body .no-hints .key,
:root body .no-hints .key[data-finger],
:root body .no-hints .key.special,
:root body .no-hints .key.special[data-finger] { background: var(--ui-key-plain)!important; color: var(--ui-ink); }
:root body .no-hints .key.next { box-shadow: 0 2px 0 var(--ui-key-shadow); }
:root body :is(.hand-caption,.hand-caption span,.finger-legend) { color: var(--ui-muted); }
:root body .hand-caption { font-size: 12px; }
:root body .hand-caption span { font-size: 13px; }
:root body .finger-legend { font-size: 12px; }
:root body .finger-legend i { border-color: var(--ui-strong-border); }
:root[data-theme="midnight"] .hand-sketch .hand-outline { stroke: #c4cfe0; }

/* Library and progress share the same surfaces as the practice area. */
:root body :is(.library-intro p,.library-note,.book-meta,.book-author,.book-preview) { color: var(--ui-muted); }
:root body .book-grid { gap: 18px; }
:root body .book-card { background: var(--ui-surface); border-color: var(--ui-border); border-radius: 16px; box-shadow: var(--ui-shadow); transition: border-color 160ms var(--ui-ease),box-shadow 160ms var(--ui-ease); }
:root body .book-card:hover { border-color: var(--ui-strong-border); box-shadow: var(--ui-shadow-raised); }
:root body .book-cover { background: #e0e8f9; color: #435d89; padding: 22px; height: 160px; }
:root body .book-cover.coral { background: #f5dfd3; color: #88533f; }
:root body .book-cover.green { background: #deeddf; color: #3c6a4c; }
:root body .book-cover.violet { background: #e8dff5; color: #695184; }
:root body .book-cover.sand { background: #f3e6c6; color: #78602f; }
:root body .book-cover > span { position: relative; z-index: 1; font-size: 11px; letter-spacing: .75px; }
:root body .book-cover > strong { position: relative; z-index: 1; max-width: 80%; font-size: 26px; line-height: 1.18; }
:root body .book-cover::after { opacity: .18; }
:root body .book-body { padding: 19px; }
:root body .book-body h3 { color: var(--ui-ink); font-size: 18px; }
:root body .book-meta { font-size: 12px; }
:root body .book-body button { color: var(--ui-accent-ink); background: var(--ui-accent-soft); border-color: transparent; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; }
:root body .book-body button:hover { border-color: var(--ui-strong-border); background: var(--ui-soft); }
:root body :is(.summary-card,.history-card,.empty-state) { background: var(--ui-surface); border-color: var(--ui-border); border-radius: 16px; box-shadow: var(--ui-shadow); }
:root body .summary-card:is(:first-child,:nth-child(2),:nth-child(3)) { background: var(--ui-surface); }
:root body .summary-card { padding: 21px; }
:root body .summary-card strong { color: var(--ui-accent-ink); }
:root body .summary-card:nth-child(2) strong { color: var(--ui-success); }
:root body .summary-card:nth-child(3) strong { color: var(--ui-accent-ink); }
:root body .summary-card span { color: var(--ui-muted); font-size: 13px; }
:root body .history-card h2 { color: var(--ui-ink); }
:root body .history-card th { color: var(--ui-muted); }
:root body .history-card :is(th,td) { border-color: var(--ui-border); }
:root body .history-card td small { color: var(--ui-muted); }
:root body .history-card tbody tr:hover { background: var(--ui-softest); }
:root body .chart-column span { color: var(--ui-muted); }
:root body .chart-column i { background: var(--ui-secondary); }
:root body .chart-column:last-child i { background: var(--ui-accent); }
:root body .lifetime-banner { color: var(--ui-muted); background: var(--ui-soft); border: 1px solid var(--ui-border); border-radius: 12px; line-height: 1.7; }
:root body .trophy-card { background: var(--ui-surface); border-color: var(--ui-border); border-radius: 14px; box-shadow: var(--ui-shadow); padding: 17px; }
:root body .trophy-card:nth-child(3n+2):not(.locked),
:root body .trophy-card:nth-child(3n):not(.locked) { background: var(--ui-surface); border-color: var(--ui-border); }
:root body .trophy-icon { background: var(--ui-warning-soft); border-radius: 14px; }
:root body .trophy-card h3 { color: var(--ui-ink); font-size: 15px; }
:root body .trophy-card p { color: var(--ui-muted); font-size: 13px; }
:root body .trophy-card small { color: var(--ui-success); font-size: 12px; }
:root body .trophy-card.locked { background: var(--ui-softest); color: var(--ui-muted); border-color: var(--ui-border); box-shadow: none; }
:root body .trophy-card.locked :is(h3,p) { color: var(--ui-muted); }
:root body .trophy-card.locked .trophy-icon { background: var(--ui-soft); opacity: .6; }
:root body .trophy-card .trophy-meter { background: var(--ui-border); }
:root body .trophy-meter > span { background: var(--ui-accent); }
:root body :is(.progress-filters,.training-presets) button { color: var(--ui-muted); background: var(--ui-surface); border-color: var(--ui-border); border-radius: 9px; font-size: 13px; }
:root body :is(.progress-filters,.training-presets) button:hover { border-color: var(--ui-strong-border); color: var(--ui-ink); }
:root body .progress-filters button.selected { color: var(--ui-accent-ink); background: var(--ui-accent-soft); border-color: var(--ui-strong-border); }
:root body .badge { color: var(--ui-muted); background: var(--ui-soft); }
:root body .badge.earned { color: var(--ui-warning); background: var(--ui-warning-soft); }
:root body .badge small { color: inherit; }
:root body .page-footer { color: var(--ui-muted); border-color: var(--ui-border); font-size: 12px; margin-top: 24px; padding-top: 18px; }

/* Dialogs, profiles, results and live notifications */
:root body dialog { color: var(--ui-ink); background: var(--ui-surface); border: 1px solid var(--ui-strong-border); border-radius: 22px; box-shadow: var(--ui-shadow-dialog); padding: 32px; width: min(730px,calc(100vw - 32px)); max-height: min(90dvh,850px); }
:root body dialog::backdrop { background: var(--ui-backdrop); backdrop-filter: none; }
:root body dialog.customization-dialog { width: min(790px,calc(100vw - 32px)); padding: 29px 30px 25px; }
:root body .customization-dialog .modal-actions { margin-top: 14px; }
:root body .customization-dialog .customization-status { color: var(--ui-accent-ink); font-size: 12px; line-height: 1.5; margin-top: 14px; }
:root body .customization-dialog .choice-check { display: none; }
:root body dialog h2 { color: var(--ui-ink); padding-right: 25px; line-height: 1.25; }
:root body dialog h3 { color: var(--ui-ink); }
:root body dialog :is(p,.help-steps li,.result-detail) { color: var(--ui-muted); }
:root body .help-steps li::before { color: var(--ui-accent-ink); background: var(--ui-accent-soft); }
:root body .help-steps strong { color: var(--ui-ink); }
:root body .modal-close { right: 12px; top: 12px; background: var(--ui-softest); }
:root body .modal-actions { gap: 10px; }
:root body .result-symbol { color: var(--ui-accent-ink); background: var(--ui-accent-soft); box-shadow: none; }
:root body .result-stats > div { background: var(--ui-soft); }
:root body .result-stats > div:first-child { background: var(--ui-accent-soft); }
:root body .result-stats > div:nth-child(2) { background: var(--ui-success-soft); }
:root body .result-stats strong { color: var(--ui-ink); }
:root body .result-stats > div:first-child strong { color: var(--ui-accent-ink); }
:root body .result-stats > div:nth-child(2) strong { color: var(--ui-success); }
:root body .result-stats small { color: var(--ui-muted); font-size: 12px; }
:root body .result-tip { background: var(--ui-success-soft); color: var(--ui-success)!important; }
:root body .stars { color: var(--ui-warning); }
:root body .profile-choice { color: var(--ui-ink); background: var(--ui-soft); border: 1px solid transparent; border-radius: 10px; }
:root body .profile-choice.selected { color: var(--ui-accent-ink); background: var(--ui-accent-soft); border-color: var(--ui-strong-border); }
:root body .profile-choice:hover { border-color: var(--ui-strong-border); }
:root body .preview-excerpt { color: var(--ui-ink); background: var(--ui-softest); border: 1px solid var(--ui-border); max-height: 210px; }
:root body .form-error { color: var(--ui-error); }
:root body .developer-contact { border-color: var(--ui-border); }
:root body .developer-contact a { color: var(--ui-accent-ink); }
:root body :is(.earned-strip,.achievement-notice) { color: var(--ui-warning); background: var(--ui-warning-soft); border-color: color-mix(in srgb,var(--ui-warning) 30%,var(--ui-warning-soft)); }
:root body :is(.earned-strip,.achievement-notice) strong { color: var(--ui-warning); }
:root body .achievement-notice small { color: var(--ui-warning); }
:root body .achievement-notice { box-shadow: var(--ui-shadow-raised); }
:root body .toast { color: var(--ui-on-accent); background: var(--ui-accent); border: 1px solid var(--ui-accent); box-shadow: var(--ui-shadow-raised); }

/* Appearance cards are small, recognisable previews of the actual shell. */
:root body .appearance-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; margin: 18px 0 10px; }
:root body .theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 9px 9px 13px;
  background: var(--ui-surface);
  color: var(--ui-ink);
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  min-width: 0;
}
:root body .theme-card:hover { border-color: var(--ui-strong-border); box-shadow: var(--ui-shadow); }
:root body .theme-card:is(.selected,[aria-pressed="true"]) { border-color: var(--ui-accent); box-shadow: inset 0 0 0 1px var(--ui-accent); background: var(--ui-softest); }
:root body .theme-card:is(.selected,[aria-pressed="true"])::after {
  content: '✓';
  position: absolute;
  right: 15px;
  top: 15px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ui-accent);
  color: var(--ui-on-accent);
  border: 2px solid var(--ui-surface);
  font-size: 12px;
  font-weight: 750;
}
:root body .theme-card > strong { display: block; font-size: 14px; font-weight: 650; margin: 10px 5px 2px; color: var(--ui-ink); }
:root body .theme-card > small { display: block; color: var(--ui-muted); font-size: 11px; line-height: 1.45; margin: 0 5px; }
:root body .theme-preview {
  --preview-bg: #f2f4fb;
  --preview-side: #ffffff;
  --preview-accent: #7381cf;
  --preview-card: #ffffff;
  --preview-line: #c6cede;
  height: 78px;
  display: flex;
  position: relative;
  overflow: hidden;
  gap: 10px;
  background: var(--preview-bg);
  border: 1px solid #5c687c1a;
  border-radius: 8px;
}
:root body [data-theme-choice="auto"] .theme-preview { --preview-bg: linear-gradient(115deg,#f2f4fb 48%,#131b2b 48%); --preview-accent: #5360bc; }
:root body [data-theme-choice="midnight"] .theme-preview { --preview-bg: #131b2b; --preview-side: #202d43; --preview-accent: #a7b4ff; --preview-card: #293750; --preview-line: #637694; }
:root body [data-theme-choice="forest"] .theme-preview { --preview-bg: #e6f0e8; --preview-side: #f6fbf6; --preview-accent: #568c6c; --preview-card: #fcfffc; --preview-line: #b8d0bf; }
:root body [data-theme-choice="sunset"] .theme-preview { --preview-bg: #f6e4dc; --preview-side: #fff5ed; --preview-accent: #bd7074; --preview-card: #fffcf9; --preview-line: #d7b5af; }
:root body .theme-preview-sidebar { width: 28%; flex: none; background: var(--preview-side); border-right: 1px solid #5c687c14; position: relative; }
:root body .theme-preview-sidebar::before { content: ''; position: absolute; left: 7px; top: 12px; width: 12px; height: 12px; border-radius: 4px; background: var(--preview-accent); }
:root body .theme-preview-sidebar::after { content: ''; position: absolute; top: 37px; left: 7px; right: 7px; height: 5px; border-radius: 3px; background: var(--preview-line); box-shadow: 0 12px 0 var(--preview-line),0 24px 0 var(--preview-line); }
:root body .theme-preview-lines { align-self: center; flex: 1; height: 43px; margin-right: 10px; background: var(--preview-card); border-radius: 5px; position: relative; }
:root body .theme-preview-lines::before { content: ''; position: absolute; height: 4px; width: 62%; left: 9px; top: 11px; background: var(--preview-line); border-radius: 2px; box-shadow: 0 9px 0 var(--preview-line); }
:root body .theme-preview-lines::after { content: ''; position: absolute; width: 25%; height: 5px; bottom: 8px; left: 9px; border-radius: 2px; background: var(--preview-accent); }

/* Each scene preview is supplied by the same renderer as its live character. */
:root body .scene-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 22px 0 10px; }
:root body .scene-card { position: relative; display: flex; flex-direction: column; padding: 0; text-align: left; border: 1px solid var(--ui-border); border-radius: 15px; overflow: hidden; background: var(--ui-surface); color: var(--ui-ink); min-width: 0; }
:root body .scene-card:hover { border-color: var(--ui-strong-border); box-shadow: var(--ui-shadow-raised); }
:root body .scene-card:is(.selected,[aria-pressed="true"]) { border-color: var(--ui-accent); box-shadow: 0 0 0 1px var(--ui-accent); }
:root body .scene-card:is(.selected,[aria-pressed="true"])::after { content: '✓'; position: absolute; right: 10px; top: 10px; display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--ui-surface); border-radius: 50%; background: var(--ui-accent); color: var(--ui-on-accent); font-size: 13px; font-weight: 750; }
:root body .scene-card-art { display: grid; place-items: center; width: 100%; height: 132px; overflow: hidden; background: var(--ui-softest); border-bottom: 1px solid var(--ui-border); }
:root body .scene-preview .monster-sprite { max-width: 100%; }
:root body .scene-card[data-scene-choice="munch"] .scene-card-art { background: color-mix(in srgb,var(--ui-success-soft) 70%,var(--ui-surface)); }
:root body .scene-card[data-scene-choice="cube"] .scene-card-art { background: var(--ui-accent-soft); }
:root body .scene-card[data-scene-choice="comet"] .scene-card-art { background: color-mix(in srgb,var(--ui-secondary) 12%,var(--ui-surface)); }
:root body .scene-card[data-scene-choice="cruiser"] .scene-card-art { background: color-mix(in srgb,#779fca 16%,var(--ui-surface)); }
:root body .scene-card[data-scene-choice="mage"] .scene-card-art { background: var(--ui-warning-soft); }
:root body .scene-card[data-scene-choice="cat"] .scene-card-art { background: color-mix(in srgb,#efb879 22%,var(--ui-surface)); }
:root body .scene-card-copy { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 14px; }
:root body .scene-card-copy strong { color: var(--ui-ink); font-size: 14px; }
:root body .scene-card-copy :is(p,.scene-description) { color: var(--ui-muted); font-size: 12px; line-height: 1.55; }
:root body .scene-card :is(.scene-badge,.scene-card-badge,.badge) { display: inline-flex; align-self: flex-start; margin-top: 6px; padding: 3px 7px; border-radius: 6px; background: var(--ui-accent-soft); color: var(--ui-accent-ink); font-size: 10px; font-weight: 650; line-height: 1.4; }
:root body .scene-card:is(.selected,[aria-pressed="true"]) .scene-card-copy { background: var(--ui-softest); }

/* Keep the complete exercise text. Compact only the surrounding chrome. */
@media (min-width: 951px) {
  :root body.practice-active .topbar { min-height: 49px; height: auto; padding-top: 5px; padding-bottom: 5px; }
  :root body.practice-active main { padding: 10px 30px 12px; }
  :root body.practice-active .presentation-switch button { padding-top: 5px; padding-bottom: 5px; }
  :root body.practice-active .scene-note { display: none; }
  :root body.practice-active .presentation-bar { margin-bottom: 6px; }
  :root body.practice-active .avatar-picker select { padding-top: 5px; padding-bottom: 5px; }
  :root body.practice-active .scene-gallery-button { padding-top: 6px; padding-bottom: 6px; }
  :root body.practice-active .game-hud { padding-top: 3px; padding-bottom: 3px; }
  :root body.practice-active .lesson-info { margin-bottom: 7px; align-items: center; }
  :root body.practice-active .lesson-icon { width: 31px; height: 31px; margin-top: 0; }
  :root body.practice-active .lesson-info > div:not(.lesson-icon) { line-height: 1.4; }
  :root body.practice-active .lesson-info strong { display: inline; font-size: 15px; }
  :root body.practice-active .lesson-info p { display: inline; margin: 0 0 0 9px; line-height: 1.45; }
  :root body.practice-active .stats-bar { padding-top: 8px; padding-bottom: 8px; }
  :root body.practice-active .stat { display: flex; flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; }
  :root body.practice-active .stat strong { font-size: 26px; }
  :root body.practice-active .stat small { margin-top: 0; }
  :root body.practice-active .timer-stat { flex-wrap: nowrap; align-items: center; }
  :root body.practice-active .timer-stat > div { display: flex; align-items: baseline; gap: 8px; }
  :root body.practice-active .timer-stat small { display: inline; }
  :root body.practice-active .text-overview { padding-top: 6px; padding-bottom: 3px; }
  :root body.practice-active .typing-footer { min-height: 42px; padding-top: 5px; padding-bottom: 6px; }
  :root body.practice-active .typing-footer .small-primary { padding-top: 5px; padding-bottom: 5px; }
  :root body.practice-active .keyboard-heading { margin-top: 10px; margin-bottom: 7px; }
  :root body.practice-active .keyboard { padding: 7px; }
  :root body.practice-active .key { height: 26px; }
  :root body.practice-active .hands-section { margin-top: 7px; }
  :root body.practice-active .hand { width: 106px; height: 108px; }
  :root body.practice-active .finger-legend { margin-top: 4px; }
}
@media (max-width: 1220px) {
  :root body .topbar { padding-left: 24px; padding-right: 24px; gap: 12px; }
  :root body main { padding-left: 24px; padding-right: 24px; }
  :root body .breadcrumb { display: none; }
  :root body .nav-item { font-size: 14px; gap: 8px; padding-left: 8px; padding-right: 8px; }
  :root body .stat { padding-left: 16px; }
  :root body .timer-stat { padding-left: 0; }
  :root body .course-toolbar { align-items: flex-start; }
  :root body .course-toolbar select { min-width: 245px; }
}
@media (max-width: 950px) {
  :root body .sidebar { padding: 24px 10px; }
  :root body .nav-item { font-size: 0; padding: 14px; gap: 0; }
  :root body .topbar { min-height: 70px; padding: 13px 22px; }
  :root body main { padding: 23px 22px 18px; }
  :root body .page-heading { margin-bottom: 22px; }
  :root body .stat { padding-left: 12px; }
  :root body .timer-stat { padding-left: 0; }
  :root body .stat strong { font-size: 26px; }
  :root body .stat small { font-size: 11px; }
  :root body .book-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  :root body .hand-caption { font-size: 11px; }
  :root body .hand-caption span { font-size: 12px; }
  :root body.practice-active .scene-note { display: none; }
}
@media (max-width: 650px) {
  :root body .sidebar { padding: 10px 16px; }
  :root body .sidebar nav { gap: 4px; }
  :root body .nav-item { padding: 10px; border-radius: 10px; }
  :root body .topbar { min-height: 58px; padding: 10px 16px; }
  :root body .top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; width: 100%; gap: 7px; }
  :root body .topbar .presentation-switch { grid-column: auto; justify-self: auto; }
  :root body .presentation-switch button { font-size: 12px; padding: 6px 10px; }
  :root body .appearance-button { font-size: 12px; min-height: 35px; padding: 6px 10px; }
  :root body .language-switch button { font-size: 11px; padding: 5px 8px; }
  :root body .icon-button { width: 34px; height: 34px; }
  :root body main { padding: 21px 16px 18px; }
  :root body h1 { font-size: 29px; letter-spacing: -.9px; }
  :root body .eyebrow { font-size: 9px; letter-spacing: 1.2px; }
  :root body .page-heading p { font-size: 14px; }
  :root body .section-line h2 { font-size: 15px; }
  :root body .section-line > span { font-size: 12px; }
  :root body .course-toolbar label { width: 100%; }
  :root body .course-toolbar select { min-width: 0; width: 100%; }
  :root body .course-toolbar .course-actions { gap: 7px; }
  :root body .course-actions .secondary { padding: 9px 11px; font-size: 12px; }
  :root body .block-progress { font-size: 11px; gap: 7px; }
  :root body .block-progress-track { min-width: 65px; }
  :root body .lesson-path { gap: 7px; }
  :root body .pair-button { min-width: 78px; padding: 9px 11px; }
  :root body .pair-button strong { font-size: 20px; }
  :root body .pair-button small { font-size: 11px; }
  :root body .stage-button { font-size: 12px; padding: 7px 9px; gap: 6px; }
  :root body .stage-button > span { width: 22px; height: 22px; }
  :root body .mode-controls { gap: 16px; align-items: stretch; }
  :root body .segmented button { padding: 8px 13px; }
  :root body .lesson-info strong { font-size: 15px; }
  :root body .lesson-info p { font-size: 13px; }
  :root body .presentation-bar { gap: 8px; }
  :root body .scene-gallery-button { font-size: 12px; padding: 7px 10px; }
  :root body .game-hud { width: auto; margin-left: auto; gap: 12px; }
  :root body .typing-card { border-radius: 15px; }
  :root body .stats-bar { padding: 12px 10px; gap: 0; }
  :root body .stat { padding-left: 9px; }
  :root body .timer-stat { padding-left: 0; }
  :root body .stat strong { font-size: 25px; }
  :root body .stat small { font-size: 11px; }
  :root body .text-overview { padding: 10px 14px 4px; font-size: 11px; }
  :root body .typing-footer { padding: 9px 12px 12px; }
  :root body .typing-footer > span { font-size: 12px; min-width: 160px; }
  :root body .typing-footer > div { gap: 9px; }
  :root body .typing-footer > div:has(.caps-warning:not([hidden])) { flex-wrap: wrap; justify-content: flex-end; flex-shrink: 1; }
  :root body .keyboard-heading { font-size: 12px; }
  :root body .keyboard { padding: 8px; border-radius: 11px; }
  :root body .finger-legend { font-size: 11px; gap: 9px 13px; }
  :root body .book-grid { grid-template-columns: 1fr; }
  :root body .book-cover { height: 150px; }
  :root body .book-cover > strong { max-width: 80%; }
  :root body .summary-card { padding: 16px 12px; }
  :root body .summary-card strong { font-size: 27px; }
  :root body .summary-card span { font-size: 12px; }
  :root body .history-card { padding: 16px 13px; }
  :root body .trophy-grid { grid-template-columns: 1fr; }
  :root body .page-footer { font-size: 11px; gap: 6px; }
  :root body dialog { padding: 28px 20px 24px; width: calc(100vw - 24px); border-radius: 18px; }
  :root body dialog.customization-dialog { padding: 28px 20px 24px; width: calc(100vw - 24px); }
  :root body dialog h2 { font-size: 23px; }
  :root body .appearance-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  :root body .theme-preview { height: 82px; }
  :root body .scene-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  :root body .scene-card-art { height: 115px; }
  :root body .scene-card-copy { padding: 12px; }
}
@media (max-width: 480px) {
  :root body .top-actions { display: grid; grid-template-columns: minmax(0,1fr) auto 34px 34px; gap: 7px; }
  :root body .topbar .presentation-switch { grid-column: 1 / 3; justify-self: stretch; }
  :root body .presentation-switch button { flex: 1; }
  :root body .appearance-button { grid-column: 3 / 5; justify-self: stretch; padding-left: 7px; padding-right: 7px; gap: 5px; }
  :root body .appearance-button .icon { width: 15px; height: 15px; }
  :root body .language-switch { grid-column: 2; justify-self: end; }
  :root body #soundBtn { grid-column: 3; }
  :root body #helpBtn { grid-column: 4; }
  :root body .progress-summary { grid-template-columns: 1fr; gap: 9px; }
  :root body .summary-card { display: flex; align-items: center; gap: 15px; padding: 15px 17px; }
  :root body .summary-card strong { min-width: 72px; font-size: 29px; flex: none; }
  :root body .summary-card span { font-size: 13px; }
  :root body .stats-bar { padding-left: 8px; padding-right: 8px; }
  :root body .stat { padding-left: 7px; }
  :root body .timer-stat { padding-left: 0; }
  :root body .stat small { font-size: 10px; }
  :root body .stat strong { font-size: 23px; }
  :root body .profile-form { flex-wrap: wrap; }
  :root body .profile-form input { flex: 1 1 100%; }
  :root body .profile-form button { margin-left: auto; }
  :root body .result-stats { gap: 7px; }
  :root body .result-stats strong { font-size: 25px; }
  :root body .result-stats small { font-size: 10px; }
}
@media (max-width: 350px) {
  :root body main { padding-left: 12px; padding-right: 12px; }
  :root body .sidebar { padding-left: 12px; padding-right: 12px; }
  :root body .topbar { padding-left: 12px; padding-right: 12px; }
  :root body .presentation-switch button { padding-left: 7px; padding-right: 7px; font-size: 11px; }
  :root body .appearance-button { font-size: 11px; }
  :root body .section-line h2 { font-size: 14px; }
  :root body .section-line > span { font-size: 11px; }
  :root body .stat small { font-size: 9px; }
  :root body .stat strong { font-size: 22px; }
  :root body .scene-grid { grid-template-columns: 1fr; }
  :root body .scene-card { display: grid; grid-template-columns: 94px minmax(0,1fr); }
  :root body .scene-card-art { height: 100%; min-height: 115px; border-bottom: 0; border-right: 1px solid var(--ui-border); }
  :root body .theme-card > strong { font-size: 13px; }
  :root body .theme-card > small { font-size: 10px; }
  :root body .segmented button { padding-left: 10px; padding-right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  :root body,:root body *, :root body *::before, :root body *::after { transition: none!important; scroll-behavior: auto!important; }
}

/* Flight and spell artwork uses a stable dark stage in every appearance theme.
   The focused state has the same surface so cursor focus cannot alter contrast. */
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .exercise-area,
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .exercise-area:focus-within {
  background: radial-gradient(ellipse at 82% 22%,#45618b25,transparent 60%),var(--scene-stage);
}
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) #targetText { color: var(--scene-ink); }
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .char.current { color: #ffffff; background: #abc9ed20; }
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .char.current::after { background: var(--scene-accent); }
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .char.wrong { color: #ffdbde; background: #703d51; }
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) #targetText .text-end-marker { color: #c2eddd; background: #2a4b46; }
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .focus-cover { background: color-mix(in srgb,var(--scene-stage) 96%,transparent); }
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .focus-cover > span { color: var(--scene-ink); }

/* Keyboard navigation and a plain-text equivalent of the animated exercise. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  z-index: 50;
  top: 10px;
  left: 10px;
  transform: translateY(calc(-100% - 18px));
  background: var(--ui-surface);
  color: var(--ui-ink);
  padding: 9px 15px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
}
.skip-link:focus { transform: none; }
:root body .toggle input:focus-visible + span {
  outline: 3px solid var(--ui-accent);
  outline-offset: 3px;
}

/* The page can be thousands of pixels tall when a pupil supplies the text. */
:root body #trainer .focus-cover { padding: 5px 12px; }
:root body .pause-controls {
  position: sticky;
  top: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-block: 0;
  text-align: center;
  color: var(--ui-ink);
}
:root body.game-mode:is([data-scene="cruiser"],[data-scene="mage"]) .pause-controls { color: var(--scene-ink); }

@media (min-width: 951px) {
  :root body :is(#exerciseTip,#inputHint,.stat small,.keyboard-heading,.hand-caption,.toggle) { font-size: 14px; }
}

/* On short desktop screens both illuminated guides share the same row. */
@media (min-width: 951px) and (max-height: 850px) {
  :root body.practice-active #keyboardGuide {
    display: grid;
    grid-template-columns: minmax(0,1fr) clamp(172px,17vw,228px);
    align-items: center;
    gap: 5px 16px;
    max-width: 1160px;
    margin-inline: auto;
  }
  :root body.practice-active .keyboard-heading { max-width: 1160px; }
  :root body.practice-active .keyboard { width: 100%; max-width: none; }
  :root body.practice-active .hands-section {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 4px;
    width: 100%;
    margin: 0;
  }
  :root body.practice-active .hands {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    justify-items: center;
    gap: inherit;
  }
  :root body.practice-active .hand { width: 100%; max-width: 106px; height: auto; }
  :root body.practice-active .hand-caption { grid-row: 2; text-align: center; }
  :root body.practice-active .hand-caption span { margin-top: 2px; letter-spacing: 1px; }
  :root body.practice-active .finger-legend { grid-column: 1 / -1; margin: 3px 0 0; }
  :root body.practice-active .back-library { margin-bottom: 4px; }
}

@media (max-width: 950px) {
  :root body .sidebar-bottom { display: flex; justify-content: center; }
  :root body .sidebar-bottom .daily-card,
  :root body .profile > span:not(.avatar) { display: none; }
  :root body .profile {
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 650px) {
  :root body .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    gap: 8px;
  }
  :root body .sidebar-bottom { margin: 0; padding: 0; }
  :root body .sidebar nav {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 1px;
  }
  :root body .sidebar .nav-item {
    font-size: 10px;
    line-height: 1.2;
    min-height: 44px;
    padding: 4px 0;
    flex-direction: column;
    gap: 3px;
    white-space: nowrap;
  }
  :root body .stats-bar { grid-template-columns: repeat(5,minmax(0,1fr)); }
  :root body .error-stat { display: flex; }
  :root body .stat { min-width: 0; }
  :root body .stat small { font-size: 11px; line-height: 1.2; }
  :root body .typing-footer { flex-wrap: wrap; }
  :root body .typing-footer > span { flex: 1 1 160px; }
  :root body .typing-footer > div { margin-inline-start: auto; }
}


@media (min-width: 951px) and (max-height: 850px) {
  :root body.practice-active.game-mode #libraryPanel:has(.back-library) {
    float: left;
    margin-inline-end: 14px;
  }
  :root body.practice-active.game-mode .back-library { margin-bottom: 0; }
}

/* Give the exercise the full line measure on a small school laptop. */
@media (min-width: 951px) and (max-width: 1179px) and (max-height: 850px) {
  :root body.practice-active .sidebar { width: 78px; padding-inline: 8px; }
  :root body.practice-active .workspace { margin-inline-start: 78px; }
  :root body.practice-active .sidebar :is(.brand > span:last-child,.nav-caption,.daily-card,.nav-arrow,.profile > span:not(.avatar)) { display: none; }
  :root body.practice-active .sidebar .brand { justify-content: center; padding: 0; }
  :root body.practice-active .sidebar nav { margin-top: 32px; }
  :root body.practice-active .sidebar .nav-item { justify-content: center; gap: 0; padding: 12px 5px; font-size: 0; }
  :root body.practice-active .sidebar .profile { justify-content: center; gap: 0; padding: 8px; }
  :root body.practice-active main { padding-inline: 20px; }
  :root body.practice-active .key { height: 24px; }
  :root body.practice-active .key-row:not(:last-child) { margin-bottom: 4px; }
}

