/*
  Light theme by default; the dark theme (warm black + orange) is applied via
  [data-theme="dark"] on <html>, set before first paint by the inline script in base.html.

  Spacing: one scale (--space-*). Between the blocks of a page, spacing comes only from the
  `gap` of `.page` / `.stack` containers, never from margins on the blocks themselves; this
  keeps every page on the same rhythm when blocks are added or removed.
*/
:root {
  color-scheme: light;
  --bg: #f9f8f6;
  --surface: #ffffff;
  --surface-2: #f1eee9;
  --line: #e7e3dd;
  --text: #1c1a17;
  --text-muted: #6d6860;
  --text-dim: #a29c94;
  --accent: #c74f0b;
  --accent-soft: rgba(199, 79, 11, 0.32);
  --accent-hover: #a33f06;
  --on-accent: #ffffff;
  --active-bg: #1c1a17;
  --active-fg: #ffffff;
  --hover: rgba(28, 26, 23, 0.07);
  --ok: #2b8a57;
  --error: #d1264d;
  --cool: #4b63d8;
  --grid: rgba(28, 26, 23, 0.07);
  --key: #ffffff;
  --key-edge: #dcd7cf;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.04), 0 6px 24px rgba(28, 26, 23, 0.04);
  --radius: 14px;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Text to type: a proportional face reads like real text (a monospace font spreads narrow
     letters such as i and l apart). */
  --type-font: var(--sans);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  /* between the blocks of a page */
  --page-gap: var(--space-5);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12100e;
  --surface: #1a1714;
  --surface-2: #25211d;
  --line: #2e2924;
  --text: #f3ede6;
  --text-muted: #a0968b;
  --text-dim: #655c53;
  --accent: #ff7b29;
  --accent-soft: rgba(255, 123, 41, 0.38);
  --accent-hover: #ff9a5c;
  --on-accent: #1a0d04;
  --active-bg: #ff7b29;
  --active-fg: #1a0d04;
  --hover: rgba(255, 240, 225, 0.08);
  --ok: #57d08e;
  --error: #ff5277;
  --cool: #8094ff;
  --grid: rgba(255, 240, 225, 0.06);
  --key: #1e1a17;
  --key-edge: #0a0908;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: var(--space-6) 20px 80px; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }
.center { text-align: center; }
.lead { max-width: 640px; font-size: 1.02rem; }
[hidden] { display: none !important; }

/* ---------- layout primitives: the only source of vertical spacing between blocks ---------- */

.page, .stack, .stack-sm {
  display: flex;
  flex-direction: column;
  gap: var(--page-gap);
}
.stack { gap: var(--space-4); }
.stack-sm { gap: var(--space-2); }
.page > *, .stack > *, .stack-sm > * { margin-block: 0; }
/* Buttons keep their natural width inside column layouts. */
.page > .btn, .stack > .btn, .results > .btn { align-self: flex-start; }

.page-head { display: flex; flex-direction: column; gap: var(--space-2); }
.page-head p { margin: 0; }

/* Paragraphs inside cards and blocks: no stray outer margin. */
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
:where(.card) p { margin: var(--space-2) 0; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 20px 0;
}
.logo { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-1); font-size: 0.95rem; }
.nav-link {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { color: var(--text); font-weight: 600; }
.topbar .btn-small { margin-left: var(--space-1); }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--text-muted); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: var(--text); }
.danger { color: var(--error) !important; }

.theme-toggle, .icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.theme-toggle { margin-left: var(--space-2); }

.lang-menu { position: relative; margin-left: var(--space-2); }
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  list-style: none;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.lang-toggle::-webkit-details-marker { display: none; }
.lang-toggle:hover, .lang-menu[open] .lang-toggle { color: var(--text); border-color: var(--text-dim); background: var(--hover); }
.lang-toggle svg { width: 16px; height: 16px; }
.lang-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  margin: 0;
  padding: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.lang-options form { display: contents; }
.lang-options button {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.lang-options button:hover { background: var(--hover); }
.lang-options button[aria-current="true"] { color: var(--accent); font-weight: 600; }
.theme-toggle:hover, .icon-btn:hover { color: var(--text); border-color: var(--text-dim); background: var(--hover); }
.theme-toggle svg, .icon-btn svg { width: 16px; height: 16px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---------- buttons, groups, form controls ---------- */

.btn, .btn-small {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent) !important;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 22px;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.05s;
}
.btn-small { padding: 5px 14px; }
.btn:hover, .btn-small:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active, .btn-small:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--text) !important;
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-ghost:hover { background: transparent; box-shadow: inset 0 0 0 1px var(--accent); }

.group {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.group button, .group a {
  background: none;
  border: 0;
  color: var(--text-muted);
  padding: 4px 13px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  transition: background-color 0.15s, color 0.15s;
}
.group button:hover:not(:disabled):not(.active), .group a:hover:not(.active) { color: var(--text); background: var(--hover); text-decoration: none; }
.group .active { background: var(--active-bg); color: var(--active-fg); }
.group button:disabled { opacity: 0.4; cursor: not-allowed; }

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
input[type="checkbox"] { accent-color: var(--accent); }
label { color: var(--text-muted); font-size: 0.9rem; }

kbd {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.notice {
  background: var(--surface-2);
  border-radius: 10px;
  padding: var(--space-3) var(--space-4);
  color: var(--text);
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) 18px; }
.small-link { font-size: 0.8rem; }

/* ---------- typing test ---------- */

.test { --page-gap: var(--space-4); }
.test .settings { margin-bottom: var(--space-5); }
.test .kb-panel { margin-top: var(--space-5); }

.settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.focus { text-align: center; color: var(--text-muted); font-family: var(--mono); }

.live {
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
  min-height: 2.4rem;
}
.live .icon-btn { margin-left: auto; }
#live-wpm { color: var(--text-muted); font-size: 1.1rem; font-weight: 400; }

.words-box {
  position: relative;
  height: calc(3 * 3rem);
  overflow: hidden;
  cursor: text;
  outline: none;
}
.words {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  font-family: var(--type-font);
  font-size: 1.8rem;
  line-height: 3rem;
  letter-spacing: normal;
  font-variant-ligatures: none;
  color: var(--text-dim);
  transition: transform 0.12s ease-out;
  user-select: none;
}
.word { margin-right: 0.42em; position: relative; }
.word.current { color: var(--text-muted); }
.word .ok { color: var(--text); }
.word .bad { color: var(--error); }
.word .extra { color: color-mix(in srgb, var(--error) 60%, var(--bg)); }
.word.wrong { text-decoration: underline wavy var(--error); text-underline-offset: 8px; text-decoration-thickness: 1px; }
.word .caret { box-shadow: -2px 0 0 var(--accent); }
.word.caret-end span:last-child { box-shadow: 2px 0 0 var(--accent); }
/* Focus lost: the text stays sharp, only the caret blinks to invite typing. */
.words-box.idle .caret, .words-box.idle .caret-end span:last-child { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { box-shadow: none; } }

.hidden-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
  left: -1000px;
}

.hint { text-align: center; color: var(--text-dim); font-size: 0.85rem; }

/* ---------- results ---------- */

.results { display: flex; flex-direction: column; gap: var(--space-5); }
.results > * { margin-block: 0; }
.result-main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-7); }
.big { font-family: var(--mono); font-size: 4.5rem; font-weight: 700; letter-spacing: -0.03em; color: var(--accent); line-height: 1; }
.big small { font-size: 1rem; font-weight: 400; letter-spacing: 0; color: var(--text-muted); margin-left: 8px; }
.kpis { display: flex; flex-wrap: wrap; gap: var(--space-6); }
.kpis div { display: flex; flex-direction: column; }
.kpis span { font-family: var(--mono); font-size: 1.5rem; }
.kpis small, .kpi small { color: var(--text-muted); font-size: 0.8rem; }

.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 300px; }

.result-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-5); }
.result-details h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 0 0 10px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-family: var(--mono); font-size: 0.9rem; }
.chips li.muted { background: none; border: 0; padding: 0; font-family: var(--sans); }

.results .big { font-size: 3rem; }

.diagnosis { display: flex; flex-direction: column; gap: var(--space-4); }
.diagnosis > * { margin: 0; }
.diagnosis-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.diagnosis-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.diagnosis-list .label { color: var(--text-muted); min-width: 11rem; }
.diagnosis-list .unit {
  font-family: var(--mono);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0 8px;
}
.diagnosis-list .unit small { color: var(--text-muted); margin-left: 6px; }
.diagnosis-list .note { color: var(--text-muted); font-size: 0.9rem; }
.diagnosis-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.focus .link { margin-left: var(--space-3); color: var(--accent); font-family: var(--sans); }

.intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-top: calc(2 * var(--space-7));
  padding-top: var(--space-7);
  border-top: 1px solid var(--line);
}
.intro > * { margin: 0; }
.intro-title {
  font-family: var(--type-font);
  font-size: clamp(2.2rem, 6.5vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  min-height: 1.1em;
  color: var(--text);
  font-variant-ligatures: none;
}
.intro-typed:lang(zh), .intro-typed:lang(ja), .intro-typed:lang(ko) { letter-spacing: 0.02em; }
.intro-typed .bad { color: var(--error); }
.intro-typed::after {
  content: '';
  display: inline-block;
  width: 3px;
  height: 0.85em;
  margin-left: 0.04em;
  vertical-align: -0.08em;
  background: var(--accent);
}
.intro-typed.idle::after { animation: caret-blink 1s step-end infinite; }
.intro-typed.still::after { display: none; }
@keyframes caret-blink { 50% { opacity: 0; } }
.intro-lead { max-width: 62ch; font-size: 1.1rem; color: var(--text-muted); }
.intro-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.intro-features {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6) var(--space-7);
  margin-top: var(--space-4);
}
.intro-feature { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.intro-feature > * { margin: 0; }
.intro-feature p { max-width: 52ch; color: var(--text-muted); }
.intro-sample { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.intro-sample .unit {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0 8px;
}
.intro-sample .unit small { color: var(--text-muted); margin-left: 6px; }

.pb { font-size: 1rem; }
.pb.new { color: var(--accent); font-weight: 600; }

/* ---------- cards / auth ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card > h3 { margin-bottom: var(--space-2); }
.card.stack > h3, .card .stack > h3 { margin-bottom: 0; }
.card h2 + p { margin-top: var(--space-1); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }

.auth { width: 100%; max-width: 380px; margin: var(--space-7) auto; padding: 28px; }
.auth h1 { font-size: 1.4rem; margin-bottom: var(--space-4); }
.auth form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth label { display: flex; flex-direction: column; gap: 6px; }
.auth label small { font-size: 0.8rem; }
.auth label.checkbox, .stacked-form label.checkbox { flex-direction: row; align-items: flex-start; gap: var(--space-2); }
.auth label.checkbox input { margin-top: 3px; }
textarea { resize: vertical; line-height: 1.5; }
.contact { width: 100%; max-width: 720px; margin-inline: auto; }
.stacked-form.contact-form { max-width: none; }
.contact-form label small { font-size: 0.8rem; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.intro-support { font-size: 0.95rem; }
.forgot-form { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.account { width: 100%; max-width: 720px; margin-inline: auto; }
.account .card h2 { font-size: 1.1rem; }
.account p { margin: 0; }
.stacked-form { display: flex; flex-direction: column; gap: var(--space-3); max-width: 360px; }
.stacked-form label { display: flex; flex-direction: column; gap: 6px; }
.stacked-form .btn { align-self: flex-start; margin-top: var(--space-1); }
.account-delete { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5) 0 0; border-top: 1px solid var(--line); }
.account-delete > * { margin: 0; }
.account-delete h2 { font-size: 1.1rem; }
.btn-danger { background: transparent; color: var(--error) !important; box-shadow: inset 0 0 0 1px var(--line); }
.btn-danger:hover { background: var(--error); color: #fff !important; box-shadow: none; }

/* ---------- stats ---------- */

.stats-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }
.kpi { display: flex; flex-direction: column; }
.kpi span { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); align-items: start; }

.records { display: flex; flex-wrap: wrap; align-items: baseline; gap: 20px; }
.record b { font-family: var(--mono); font-size: 1.2rem; color: var(--accent); }
.record small { color: var(--text-muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: right; color: var(--text-muted); font-weight: 500; font-size: 0.8rem; padding: 4px 6px 8px; }
th:first-child, td:first-child { text-align: left; }
td { text-align: right; padding: 6px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
td.unit { text-align: left; font-family: var(--mono); font-size: 1rem; }
.history td.strong { color: var(--accent); font-weight: 600; }
.history td.ts { text-align: left; color: var(--text-muted); }

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.pager button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: 0.35; cursor: default; }

.cta { text-align: center; }
.empty { text-align: center; padding: var(--space-7); }

/* ---------- misc ---------- */

.caps-warning {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 12px;
}

.show-results .live, .show-results .hint, .show-results .kb-panel { display: none; }

/* ---------- on-screen keyboard ---------- */

/* Room for the case (plate) of themed keyboards, drawn outside the keys with a shadow. */
.kb-wrap { container-type: inline-size; padding-block: 12px; }
.kb {
  --u: min(40px, calc(100cqw / var(--kw)));
  --gap: calc(var(--u) * 0.1);
  /* keycap theme, see "keycap themes" below */
  --kb-key: var(--key);
  --kb-text: var(--text-muted);
  --kb-mod: var(--key);
  --kb-mod-text: var(--text-dim);
  --kb-accent: var(--key);
  --kb-accent-text: var(--text-muted);
  --kb-line: var(--line);
  --kb-edge: var(--key-edge);
  --kb-plate: transparent;
  position: relative;
  width: calc(var(--kw) * var(--u));
  height: calc(var(--kh) * var(--u));
  margin: 0 auto;
  border-radius: calc(var(--u) * 0.3);
  background: var(--kb-plate);
  box-shadow: 0 0 0 calc(var(--u) * 0.3) var(--kb-plate);
}
.kb .k {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u) - var(--gap));
  height: calc(var(--h) * var(--u) - var(--gap));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 0.04);
  padding-bottom: calc(var(--u) * 0.06);
  background: var(--kb-key);
  border-radius: calc(var(--u) * 0.16);
  box-shadow: inset 0 0 0 1px var(--kb-line), inset 0 calc(var(--u) * -0.06) 0 var(--kb-edge);
  color: var(--kb-text);
  font: 500 calc(var(--u) * 0.32) / 1 var(--mono);
  transition: background-color 0.18s, color 0.18s, transform 0.05s;
  user-select: none;
}
.kb .k .lg { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.02); }
.kb .k .sh { font-size: 0.72em; opacity: 0.55; min-height: 0.72em; }
.kb .k .ag {
  position: absolute;
  right: 12%;
  bottom: 12%;
  font-size: 0.6em;
  opacity: 0.45;
}
.kb .k.mod { background: var(--kb-mod); color: var(--kb-mod-text); font-size: calc(var(--u) * 0.22); }
.kb .k.accent { background: var(--kb-accent); color: var(--kb-accent-text); }
.kb .k.bump::after {
  content: '';
  position: absolute;
  bottom: 18%;
  width: 24%;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.6;
}
/* ISO Enter: two joined parts drawing an inverted L */
.kb .k.iso-top { border-bottom-right-radius: 0; box-shadow: inset 0 0 0 1px var(--kb-line); }
.kb .k.iso-bottom {
  top: calc(var(--y) * var(--u) - var(--gap));
  height: var(--u);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.kb .k.pressed { transform: translateY(1px); filter: brightness(0.9); box-shadow: inset 0 0 0 1px var(--kb-line); transition: none; }
.kb .k.new-key { box-shadow: inset 0 calc(var(--u) * -0.07) 0 var(--accent); }
.kb .k.next { color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.kb .k.hit-ok { background: color-mix(in srgb, var(--ok) 40%, var(--kb-key)); transition: none; }
.kb .k.hit-bad { background: color-mix(in srgb, var(--error) 50%, var(--kb-key)); transition: none; }
.kb.editing .k { cursor: pointer; }
.kb.editing .k.mod { cursor: default; }
.kb .k.selected-key { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }

.kb-panel { display: flex; flex-direction: column; gap: var(--space-4); }
.kb-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.kb-toolbar:hover, .kb-toolbar:focus-within, .card .kb-toolbar { opacity: 1; }
.kb-toolbar .group button { font-size: 0.78rem; padding: 3px 10px; }
.card .kb-wrap + .kb-toolbar { margin-top: var(--space-4); }

@media (max-width: 640px) { .kb-panel { display: none; } }

/* ---------- finger zones ---------- */

.kb.show-fingers .k { border-bottom: 3px solid var(--finger, transparent); }
.kb .f-lp, .kb .f-rp { --finger: #b06ad8; }
.kb .f-lr, .kb .f-rr { --finger: #4a96e0; }
.kb .f-lm, .kb .f-rm { --finger: #2ea8a0; }
.kb .f-li, .kb .f-ri { --finger: #6cae48; }
.kb .f-th { --finger: #e0a020; }

/* ---------- statistics heatmap: legend and value stacked in the middle of the key ---------- */

.kb.heatmap { --u: min(48px, calc(100cqw / var(--kw))); }
.kb.heatmap .k .hv { font-size: 0.5em; line-height: 1; opacity: 0.85; }
.kb.heatmap .k .sh, .kb.heatmap .k .ag, .kb.heatmap .k.bump::after { display: none; }
.kb.heat-err .k:not(.nodata):not(.mod) { background: color-mix(in srgb, var(--error) calc(var(--err) * 85%), var(--kb-key)); }
.kb.heat-speed .k:not(.nodata):not(.mod) { background: color-mix(in srgb, var(--cool) calc(var(--speed) * 85%), var(--kb-key)); }
.kb.heatmap .k.nodata:not(.mod) { opacity: 0.45; }

/* ---------- keycap themes ---------- */

.kb.theme-carbon {
  --kb-plate: #19191b; --kb-key: #2c2c30; --kb-text: #e8e6e3; --kb-mod: #3b3b41; --kb-mod-text: #bdb9b3;
  --kb-accent: #ff7b29; --kb-accent-text: #1a0d04; --kb-line: rgba(255, 255, 255, 0.05); --kb-edge: #121214;
}
.kb.theme-retro {
  --kb-plate: #c9c1b0; --kb-key: #ece6d8; --kb-text: #3b372f; --kb-mod: #b6ad9a; --kb-mod-text: #35312a;
  --kb-accent: #c8553d; --kb-accent-text: #fff; --kb-line: rgba(0, 0, 0, 0.08); --kb-edge: #a39a87;
}
.kb.theme-olivia {
  --kb-plate: #1d1a1b; --kb-key: #2b2627; --kb-text: #e9c3bb; --kb-mod: #e9c3bb; --kb-mod-text: #2b2627;
  --kb-accent: #d98c80; --kb-accent-text: #2b2627; --kb-line: rgba(255, 255, 255, 0.05); --kb-edge: #151213;
}
.kb.theme-botanical {
  --kb-plate: #dfe6da; --kb-key: #f7f8f3; --kb-text: #4b6847; --kb-mod: #a9bfa0; --kb-mod-text: #24401f;
  --kb-accent: #6f9a62; --kb-accent-text: #fff; --kb-line: rgba(0, 0, 0, 0.06); --kb-edge: #c9d4c2;
}
.kb.theme-laser {
  --kb-plate: #150c2b; --kb-key: #261848; --kb-text: #3fe3ff; --kb-mod: #ff3fa4; --kb-mod-text: #1a0f33;
  --kb-accent: #3fe3ff; --kb-accent-text: #1a0f33; --kb-line: rgba(255, 255, 255, 0.05); --kb-edge: #0f0820;
}
.kb.theme-ink {
  --kb-plate: #1b2433; --kb-key: #24304a; --kb-text: #ece4d0; --kb-mod: #3a4a6b; --kb-mod-text: #d9d1bd;
  --kb-accent: #c9a35a; --kb-accent-text: #1b2433; --kb-line: rgba(255, 255, 255, 0.05); --kb-edge: #121925;
}
.kb.theme-slate {
  --kb-plate: #3b4148; --kb-key: #575f69; --kb-text: #f1efe9; --kb-mod: #2e3338; --kb-mod-text: #c9ccd0;
  --kb-accent: #e3b23c; --kb-accent-text: #2e3338; --kb-line: rgba(255, 255, 255, 0.06); --kb-edge: #2a2f34;
}
.kb.theme-sand {
  --kb-plate: #d8cbb3; --kb-key: #efe6d4; --kb-text: #5a4a35; --kb-mod: #c4b393; --kb-mod-text: #3f3324;
  --kb-accent: #8a6a43; --kb-accent-text: #fbf6ec; --kb-line: rgba(0, 0, 0, 0.07); --kb-edge: #b9aa8c;
}
.kb.theme-forest {
  --kb-plate: #1f2b24; --kb-key: #2d3d33; --kb-text: #e3dcc8; --kb-mod: #4f6b57; --kb-mod-text: #eae4d2;
  --kb-accent: #b5583b; --kb-accent-text: #fbf3ea; --kb-line: rgba(255, 255, 255, 0.05); --kb-edge: #16201a;
}
.kb.theme-lavender {
  --kb-plate: #e3dfee; --kb-key: #f6f4fa; --kb-text: #4e4670; --kb-mod: #b9b0d6; --kb-mod-text: #2f2850;
  --kb-accent: #7a6bb0; --kb-accent-text: #fff; --kb-line: rgba(0, 0, 0, 0.06); --kb-edge: #cbc4e0;
}
.kb.theme-outline {
  --kb-key: transparent; --kb-mod: transparent; --kb-accent: transparent; --kb-accent-text: var(--accent);
  --kb-line: var(--text-dim); --kb-edge: transparent; --kb-text: var(--text-muted);
}

/* Custom themes: the 7 colours are set inline by keyboard.js, the outline and edge derive from them. */
.kb.theme-custom {
  --kb-line: color-mix(in srgb, var(--kb-text) 14%, transparent);
  --kb-edge: color-mix(in srgb, var(--kb-key) 70%, #000);
}

/* ---------- course overview ---------- */

.course-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-5);
}
.course-head h1 { font-size: 2rem; margin-bottom: var(--space-2); }
.course-head .lead { margin: 0; }
.course-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; text-align: right; }
.daily { margin: 0; font-size: 0.88rem; }
.daily b { font-family: var(--mono); font-size: 1.1rem; color: var(--accent); }

.course-kb { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-3) 0; }
.course-kb .kb-toolbar { opacity: 1; }
.course-kb .small { margin: 0; }

.module { display: flex; flex-direction: column; gap: 14px; }
.module-head { display: flex; align-items: flex-start; gap: var(--space-4); }
.module-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
}
.module-text { flex: 1; min-width: 0; }
.module-text h2 { margin: 4px 0; }
.module-text p { margin: 0; font-size: 0.92rem; max-width: 760px; }
.module-progress { flex: none; margin-top: 8px; font-family: var(--mono); font-size: 0.85rem; color: var(--text-muted); }
.module-progress.complete { color: var(--ok); }

.lessons {
  list-style: none;
  padding: 0;
  margin: 0 0 0 54px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.lesson-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "num title title" "keys keys status";
  align-items: baseline;
  column-gap: 10px;
  row-gap: 6px;
  height: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.lesson-card:hover { text-decoration: none; border-color: var(--text-dim); }
.lesson-card .l-num { grid-area: num; font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); }
.lesson-card .l-title { grid-area: title; font-weight: 600; font-size: 0.95rem; }
.lesson-card .l-keys { grid-area: keys; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.lesson-card .l-status { grid-area: status; justify-self: end; font-size: 0.8rem; color: var(--text-muted); }
.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  vertical-align: 1px;
}
.lesson-card.passed .l-status { color: var(--accent); letter-spacing: 0.05em; }
.lesson-card.skipped .l-status { font-style: italic; }
.lesson-card.locked { opacity: 0.5; cursor: not-allowed; }
.lesson-card.locked:hover { border-color: var(--line); }
.lesson-card.unavailable { opacity: 0.55; }
.lesson-card.next { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- lesson player ---------- */

.crumbs { display: flex; gap: var(--space-2); font-size: 0.85rem; }
.crumbs a { color: var(--text-muted); }
.crumbs span { color: var(--text-dim); }

.lesson-head { display: flex; flex-direction: column; gap: 10px; }
.lesson-head > * { margin: 0; }
.lesson-head h1 { display: flex; align-items: baseline; gap: var(--space-3); }
.lesson-head h1 .l-num { font-family: var(--mono); font-size: 1rem; color: var(--accent); }
.lesson-intro { max-width: 760px; font-size: 1.02rem; }
.lesson-keys { color: var(--text-muted); }
.lesson-keys kbd { font-size: 1rem; padding: 1px 9px; color: var(--text); }
.lesson-goal { font-size: 0.85rem; }

.theory { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); }
.theory p { font-size: 0.92rem; color: var(--text-muted); }

.lesson-play { display: flex; flex-direction: column; gap: var(--space-4); }
.lesson-play > * { margin: 0; }
.lesson-live { display: flex; align-items: center; gap: var(--space-4); font-family: var(--mono); }
.lesson-live #l-acc { color: var(--accent); font-size: 1.2rem; font-weight: 600; min-width: 4.5em; }
.lprogress { flex: 1; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
#lprogress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.12s ease-out; }

.words .fixed { color: var(--text); text-decoration: underline var(--error); text-underline-offset: 6px; text-decoration-thickness: 2px; }
.words .flash, .words .word.flash { animation: flash 0.25s ease-out; }
@keyframes flash {
  from { background: color-mix(in srgb, var(--error) 45%, transparent); }
  to { background: transparent; }
}

.stars { font-size: 2.6rem; letter-spacing: 0.08em; color: var(--text-dim); line-height: 1; }
.stars.earned { color: var(--accent); }
.lesson-results h2 { font-size: 1.5rem; }
.lesson-results #r-title + #r-msg { margin-top: calc(-1 * var(--space-4)); }

/* "How to type them" card of special-character lessons */
.howto-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-2) var(--space-4);
  font-size: 0.92rem;
  color: var(--text-muted);
}
.howto-list kbd { font-size: 1rem; color: var(--text); margin-right: 6px; }
.howto .btn { align-self: flex-start; }

/* ---------- keyboard customisation ---------- */

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.theme-option {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.theme-option:hover { border-color: var(--text-dim); }
.theme-option.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-option .kb-wrap { width: 100%; }
.theme-item { position: relative; }
.theme-option { position: relative; }
.theme-option.locked .kb-wrap, .theme-option.locked > span:not(.lock-badge) { opacity: 0.55; }
.theme-option.locked:hover { border-color: var(--line); }
.lock-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}
.supporter-badge { color: var(--accent); font-size: 0.85em; margin-left: 2px; }
.support { width: 100%; max-width: 720px; margin-inline: auto; }
.support .card h2 { font-size: 1.1rem; }
.support-perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.support-perks li { display: flex; flex-direction: column; gap: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--accent); }
.theme-item .theme-option { width: 100%; height: 100%; }
.theme-edit { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; background: var(--surface); font-size: 0.85rem; }
.theme-new {
  align-items: center;
  justify-content: center;
  min-height: 150px;
  border-style: dashed;
  color: var(--text-muted);
}
.theme-new .plus { font-size: 2.6rem; line-height: 1; font-weight: 300; color: var(--accent); }
.theme-new:hover { color: var(--text); }

.theme-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-3); }
.theme-colors label { display: inline-flex; align-items: center; gap: var(--space-3); }
input[type="color"] {
  flex: none;
  width: 42px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.theme-preview { padding: var(--space-4) 0; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }

.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }
.slots label, .editor-head label, .ed-key label { display: flex; flex-direction: column; gap: 6px; }

.custom-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.custom-list li { display: flex; align-items: baseline; gap: var(--space-3); }
.custom-list li span { font-weight: 600; }

.editor { border-top: 1px solid var(--line); padding-top: var(--space-4); }
.editor-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); }
.editor .small { margin: 0; }
.ed-key { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); }
.ed-key input { width: 4.5em; text-align: center; font-family: var(--mono); font-size: 1.1rem; }
.ed-code { font-family: var(--mono); font-size: 1.4rem; font-weight: 600; color: var(--accent); min-width: 3em; }

.format-options { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); }
.format-options label { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .words { font-size: 1.3rem; line-height: 2.4rem; }
  .words-box { height: calc(3 * 2.4rem); }
  .big { font-size: 3rem; }
  .topbar { flex-wrap: wrap; }
  .lessons { margin-left: 0; }
  .course-side { align-items: flex-start; text-align: left; }
  .intro-title { min-height: 2.2em; }
  .intro-features { grid-template-columns: 1fr; }
}

/* ---------- statistics glossary (modal) ---------- */

.help-toggle { font-family: var(--mono); font-size: 0.95rem; font-weight: 700; margin-left: var(--space-2); }

.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: min(82vh, 780px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(10, 8, 6, 0.28);
  overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(10, 8, 6, 0.45); }

/* Opening: slides down from the top of the screen to the centre while fading in. */
.modal[open] { animation: modal-in 0.34s cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal[open]::backdrop { animation: backdrop-in 0.34s ease-out; }
/* Closing: the same way back up. */
.modal.closing { animation: modal-out 0.26s ease-in forwards; }
.modal.closing::backdrop { animation: backdrop-out 0.26s ease-in forwards; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-45vh); } to { opacity: 1; transform: none; } }
@keyframes modal-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-45vh); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .modal[open], .modal.closing, .modal[open]::backdrop, .modal.closing::backdrop { animation: none; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}
.modal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
}
.modal-nav a {
  padding: 3px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.modal-nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-body > * { margin: 0; }
.modal-body h3 { margin-bottom: var(--space-3); color: var(--accent); }

.glossary { margin: 0; display: grid; gap: var(--space-4); }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 4px 0 0; color: var(--text-muted); font-size: 0.93rem; }
.glossary code {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}

/* ---------- footer & consent banner ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-5) 20px var(--space-7);
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--text-dim);
}
.footer a { color: var(--text-muted); }
.footer .kofi { display: inline-flex; align-self: center; opacity: 0.55; filter: grayscale(1); transition: opacity 0.2s ease, filter 0.2s ease, transform 0.2s ease; }
.footer .kofi:hover, .footer .kofi:focus-visible { opacity: 1; filter: none; transform: scale(1.18); }
.kofi img { display: block; width: 28px; height: 23px; }

.consent {
  position: fixed;
  left: 50%;
  bottom: var(--space-4);
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  width: min(880px, calc(100vw - 32px));
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(10, 8, 6, 0.18);
  transform: translateX(-50%);
  animation: consent-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.consent p { flex: 1 1 380px; margin: 0; font-size: 0.88rem; color: var(--text-muted); }
.consent-actions { display: flex; gap: var(--space-2); }
.consent.leaving { animation: consent-out 0.25s ease-in forwards; }
@keyframes consent-in { from { opacity: 0; transform: translate(-50%, 120%); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes consent-out { to { opacity: 0; transform: translate(-50%, 120%); } }
@media (prefers-reduced-motion: reduce) { .consent, .consent.leaving { animation-duration: 0.01s; } }

.plain-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: var(--space-2); color: var(--text-muted); }
.plain-list b { color: var(--text); }

/* ---------- leaderboard ---------- */

.ranking td.rank { text-align: left; width: 3em; font-family: var(--mono); font-weight: 700; color: var(--text-muted); }
.ranking td.rank-1 { color: #d4a017; }
.ranking td.rank-2 { color: #9aa3ad; }
.ranking td.rank-3 { color: #b8733a; }
.ranking td.player, .ranking th:nth-child(2) { text-align: left; }
.ranking td.player { font-weight: 600; }
.ranking td.strong { color: var(--accent); font-weight: 700; font-family: var(--mono); }
.ranking tr.me td { background: var(--surface-2); }
.ranking tr.gap td { text-align: center; color: var(--text-dim); border-top: 0; }
.ranking td.ts { color: var(--text-muted); }

.positions { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.position {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
}
.position:hover { border-color: var(--text-dim); text-decoration: none; }
.position.current { border-color: var(--accent); }
.pos-rank { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.pos-rank small { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }
.pos-cat { font-size: 0.88rem; font-weight: 600; }

/* ---------- admin ---------- */

.admin h2 { margin-top: var(--space-4); }
.kpi.alert span { color: var(--error); }
.tag.warn { color: var(--error); margin: 2px 4px 2px 0; }
.flagged td { vertical-align: top; }
.flagged td:nth-child(2), .flagged td.flags { text-align: left; }
.flagged .row-actions { white-space: nowrap; display: flex; gap: var(--space-3); justify-content: flex-end; }
.flagged tr.done { opacity: 0.45; }
tr.dim td { color: var(--text-dim); }
td.lesson-name { text-align: left; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bars li {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 4px 8px;
  font-size: 0.88rem;
  border-radius: 6px;
  isolation: isolate;
}
.bars li::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  z-index: -1;
  width: var(--pct, 0%);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.bars .bar-value { font-family: var(--mono); color: var(--text-muted); }
.bars .empty-bar::before { display: none; }

/* ---------- password reset ---------- */

.forgot summary { cursor: pointer; color: var(--text-muted); font-size: 0.9rem; }
.forgot summary:hover { color: var(--text); }
.forgot p { margin: var(--space-2) 0 0; font-size: 0.88rem; }
.auth .notice { margin: 0 0 var(--space-4); }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.reset-result { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: 0.88rem; }
.reset-result input { flex: 1 1 320px; font-family: var(--mono); font-size: 0.8rem; }
