/* typing.css: the typing area. Colors and fonts come from the shell tokens of the rebuild; the fallbacks
   below are only for the test harness. The integration step maps --tt-* onto the shell tokens (STAND.md). */
.tt { --tt-fg: var(--text, #1d2330); --tt-dim: var(--tt-dim-c, #6b7384); --tt-ok: var(--text, #1d2330); --tt-no: var(--danger, #c8372d); --tt-caret: var(--accent, #2457d6); --tt-bg: var(--surface, #fff); position: relative; max-width: 70ch; margin: 0 auto; }
.tt-text { position: relative; overflow: hidden; font-family: var(--font-mono, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace); font-size: calc(1.5rem * var(--tt-scale, 1)); line-height: 1.6em; color: var(--tt-dim); background: var(--tt-bg); contain: layout paint; user-select: none; -webkit-user-select: none; cursor: text; }
.tt-flow { position: relative; transition: transform .12s ease-out; will-change: transform; word-break: normal; overflow-wrap: anywhere; }
.tt-word { display: inline-block; white-space: pre; }
.tt-l { display: inline; }
.tt-ok { color: var(--tt-ok); }
.tt-no { color: var(--tt-no); }
.tt-extra { color: var(--tt-no); opacity: .75; }
.tt-miss { text-decoration: underline; text-decoration-color: var(--tt-no); }
.tt-bad { text-decoration: underline; text-decoration-color: var(--tt-no); text-decoration-thickness: 2px; }
.tt-caret { position: absolute; left: 0; top: 0; width: 2px; background: var(--tt-caret); pointer-events: none; animation: tt-blink 1s step-end infinite; }
.tt-text[data-caret="block"] .tt-caret { opacity: .35; animation: none; }
.tt-text[data-caret="underline"] .tt-caret { height: 2px !important; width: 1ch; margin-top: 1.9rem; }
.tt-running .tt-caret { animation: none; }
@keyframes tt-blink { 50% { opacity: 0; } }
/* visually hidden, still focusable and labelled; font-size 16px stops iOS from zooming on focus */
.tt-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); opacity: 0; font-size: 16px; }
.tt-dim .tt-text { opacity: .45; }
.tt-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 1rem; font: 1rem/1.4 var(--font-ui, system-ui, sans-serif); color: var(--tt-fg); background: transparent; pointer-events: none; opacity: 0; }
.tt-dim .tt-note { opacity: 1; }
.tt-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 480px) { .tt-text { font-size: calc(1.25rem * var(--tt-scale, 1)); } }
:root[data-tt-size="1"] { --tt-scale: .875; } :root[data-tt-size="2"] { --tt-scale: 1; } :root[data-tt-size="3"] { --tt-scale: 1.25; } :root[data-tt-size="4"] { --tt-scale: 1.5; }
@media (prefers-reduced-motion: reduce) { .tt-flow, .tt-caret { transition: none; } .tt-caret { animation: none; } }
:root[data-tt-motion="reduce"] .tt-flow, :root[data-tt-motion="reduce"] .tt-caret { transition: none; animation: none; }

/* timed test page and results screen (B7, B4) */
.tt-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; max-width: 70ch; margin: 8px auto 0; min-height: 44px; }
.tt-clock { font: 600 1.25rem/1 var(--font-mono, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace); font-variant-numeric: tabular-nums; color: var(--text, #1d2330); }
.tt-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 16px; font: inherit; color: var(--text, #1d2330); background: var(--surface, #fff); border: 1px solid var(--muted, #8a92a3); border-radius: 8px; cursor: pointer; text-decoration: none; }
.tt-btn:hover { border-color: var(--text, #1d2330); }
.tt-btn:focus-visible, .tt-input:focus-visible ~ .tt-text { outline: 3px solid var(--accent, #2457d6); outline-offset: 2px; }
.tt-btn-quiet { border-color: transparent; text-decoration: underline; }
.tt-results { max-width: 70ch; margin: 0 auto; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.tt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tt-score { display: flex; align-items: baseline; gap: 8px; }
.tt-wpm { font-size: 4rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-wpm-label { font-size: 1.25rem; color: var(--muted, #5b6474); }
.tt-notsaved { margin: 4px 0; font-weight: 600; }
.tt-compare { margin: 4px 0; }
.tt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: 8px 16px; margin: 16px 0; padding: 0; }
.tt-stat { margin: 0; }
.tt-stat dt { font-size: .875rem; color: var(--muted, #5b6474); }
.tt-stat dd { margin: 0; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tt-chartbox { margin: 16px 0; }
.tt-chart { display: block; width: 100%; height: auto; max-height: 180px; }
.tt-chart-axis { stroke: var(--muted, #8a92a3); stroke-width: 1; }
.tt-chart-line { fill: none; stroke: var(--accent, #2457d6); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.tt-chart-dot { fill: var(--accent, #2457d6); }
.tt-chartbox figcaption { font-size: .875rem; color: var(--muted, #5b6474); }
.tt-errors h3 { font-size: 1rem; margin: 0 0 4px; }
.tt-errors ul { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0; padding: 0; }
.tt-errors li { font-variant-numeric: tabular-nums; }
.tt-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 8px; }
.tt-share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tt-sharetext { font-size: .9375rem; }
.tt-bar[hidden] { display: none; }

/* 10-key test (B10) */
.tk-lengths { display: flex; gap: 8px; max-width: 70ch; margin: 0 auto 8px; }
.tk-lengths .tt-btn[aria-pressed="true"] { border-color: var(--accent, #2457d6); box-shadow: inset 0 0 0 1px var(--accent, #2457d6); font-weight: 600; }
.tk { min-height: 11rem; padding: 1rem; box-sizing: border-box; background: var(--tt-bg); border: 1px solid var(--ln, #8a92a3); border-radius: 8px; cursor: text; }
.tk-current { font-family: var(--font-mono, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace); font-size: 2.25rem; line-height: 3rem; min-height: 6rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tk-pending { color: var(--tt-dim); }
.tk-enter { margin-left: .75rem; font: 600 .875rem/1 var(--font-ui, system-ui, sans-serif); color: var(--tt-dim); border: 1px solid var(--tt-dim); border-radius: 4px; padding: .2rem .4rem; vertical-align: middle; }
.tk-next { font-family: var(--font-mono, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace); font-size: 1.125rem; line-height: 1.6rem; min-height: 3.2rem; color: var(--tt-dim); white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-warn { position: absolute; left: 0; right: 0; bottom: 0; padding: .5rem 1rem; font: .9375rem/1.4 var(--font-ui, system-ui, sans-serif); color: var(--tt-fg); background: var(--tt-bg); border-top: 2px solid var(--tt-no); border-radius: 0 0 8px 8px; }
.tk-warn:empty { display: none; }
@media (max-width: 480px) { .tk-current { font-size: 1.75rem; line-height: 2.5rem; min-height: 5rem; } .tk { min-height: 10rem; padding: .75rem; } .tk-next { font-size: 1rem; } }

/* certificate (B11): form on screen, sheet on screen and on paper */
.cert { max-width: 70ch; margin: 0 auto; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.cert-form label { display: block; font-weight: 600; margin-bottom: 4px; }
.cert-input { box-sizing: border-box; width: 100%; min-height: 44px; padding: 0 12px; font: inherit; color: inherit; background: var(--surface, #fff); border: 1px solid var(--ln, #8a92a3); border-radius: 8px; }
.cert-input:focus-visible { outline: 3px solid var(--accent, #2457d6); outline-offset: 2px; }
.cert-notice { min-height: 1.5em; margin: 4px 0 0; font-size: .9375rem; }
.cert-btn:disabled, .cert .tt-btn:disabled { opacity: .55; cursor: not-allowed; }
.cert-sheetbox { margin-top: 16px; }
.cert-sheet { box-sizing: border-box; padding: 28px 24px; text-align: center; color: #1d2330; background: #fff; border: 3px double #1d2330; break-inside: avoid; page-break-inside: avoid; }
.cert-kicker { margin: 0; font-size: .875rem; letter-spacing: .18em; text-transform: uppercase; }
.cert-title { margin: 8px 0 20px; font-size: 1.75rem; line-height: 1.2; }
.cert-line { margin: 0; }
.cert-name { margin: 8px 0; font-size: 1.75rem; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; word-break: break-word; unicode-bidi: plaintext; }
.cert-score { margin: 4px 0 16px; }
.cert-wpm { font-size: 3.5rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.cert-unit { font-size: 1.125rem; }
.cert-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 32px; margin: 0 0 20px; padding: 0; }
.cert-fact { margin: 0; }
.cert-fact dt { font-size: .875rem; color: #4a5263; }
.cert-fact dd { margin: 0; font-weight: 600; }
.cert-disclaimer { margin: 0; padding-top: 12px; border-top: 1px solid #8a92a3; font-size: .9375rem; }
@page { margin: 15mm; }
@media print {
  /* Everything except the sheet leaves the page (display:none, not visibility, so no blank extra pages). The page shell marks
     its header, footer and other chrome with .no-print; the certificate page adds the body class below. */
  body.cert-page > *:not(main), body.cert-page main > *:not(#cert-root), .no-print, .cert-form { display: none !important; }
  body.cert-page { margin: 0; padding: 0; background: #fff; }
  body.cert-page #cert-root, .cert { max-width: none; margin: 0; }
  .cert-sheetbox { margin: 0; }
  .cert-sheet { padding: 12mm 10mm; border-width: 2pt; }
}

/* live readout, storage notes, settings panel (B6) and progress page (B5) */
.tt-readout { font: 600 1rem/1 var(--font-ui, system-ui, sans-serif); font-variant-numeric: tabular-nums; color: var(--text, #1d2330); }
.tt-readout[hidden] { display: none; }
.tt-storage-note { max-width: 70ch; margin: 8px auto; font: .9375rem/1.4 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.tt-storage-note[hidden] { display: none; }
.tt-settings { max-width: 70ch; margin: 16px auto 0; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.tt-settings > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.tt-settings > summary:focus-visible { outline: 3px solid var(--accent, #2457d6); outline-offset: 2px; }
.tt-set { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 12px 24px; padding: 8px 0 16px; }
.tt-set-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.tt-set-group legend { padding: 0; font-weight: 600; }
.tt-set-opt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 44px; }
.tt-set-opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent, #2457d6); }
.tt-set-opt small { flex-basis: 100%; padding-left: 28px; color: var(--muted, #4b5565); }
.tt-set-opt input:focus-visible { outline: 3px solid var(--accent, #2457d6); outline-offset: 2px; }
.tt-progress { max-width: 70ch; margin: 0 auto; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.tt-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-variant-numeric: tabular-nums; }
.tt-table caption { text-align: left; font-weight: 600; padding-bottom: 4px; }
.tt-table th, .tt-table td { padding: 6px 8px 6px 0; text-align: left; border-bottom: 1px solid var(--ln, #4b5565); }
.tt-filter { display: block; margin: 16px 0 0; }
.tt-filter select { min-height: 44px; font: inherit; color: var(--text, #1d2330); background: var(--surface, #fff); border: 1px solid var(--muted, #4b5565); border-radius: 8px; padding: 0 8px; }
.tt-confirm { margin: 8px 0; padding: 12px; border: 2px solid var(--text, #1d2330); border-radius: 8px; }
.tt-confirm .tt-btn { margin-right: 12px; }
.tt-status { min-height: 1.5em; margin: 8px 0 0; }
.tt-fine { color: var(--muted, #4b5565); font-size: .875rem; }
.tt-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- practice (B8) and lessons (B9) ---- */
.pr-kinds { display: flex; flex-wrap: wrap; gap: 8px; max-width: 70ch; margin: 0 auto 8px; }
.pr-kind[aria-pressed="true"] { border-color: var(--accent, #2457d6); box-shadow: inset 0 0 0 1px var(--accent, #2457d6); font-weight: 600; }
.pr-options { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; max-width: 70ch; margin: 0 auto 8px; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); }
.pr-opt { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.pr-opt select { min-height: 44px; font: inherit; color: var(--text, #1d2330); background: var(--surface, #fff); border: 1px solid var(--muted, #8a92a3); border-radius: 8px; padding: 0 8px; }
.pr-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent, #2457d6); }
.pr-opt select:focus-visible, .pr-check input:focus-visible, .pr-ta:focus-visible { outline: 3px solid var(--accent, #2457d6); outline-offset: 2px; }
.pr-own { max-width: 70ch; margin: 0 auto 8px; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); }
.pr-own[hidden], .pr-opt[hidden] { display: none; }
.pr-own label { display: block; font-weight: 600; margin-bottom: 4px; }
.pr-own .pr-check { display: flex; font-weight: 400; margin: 0; }
.pr-ta { box-sizing: border-box; width: 100%; min-height: 8rem; padding: 8px 12px; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); background: var(--surface, #fff); border: 1px solid var(--muted, #8a92a3); border-radius: 8px; resize: vertical; }
.pr-count { margin: 4px 0; font-size: .9375rem; color: var(--muted, #4b5565); }
.pr-msg { max-width: 70ch; margin: 4px auto; min-height: 1.5em; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.pr-msg:empty { display: none; }
.pr-ownbtns { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.pr-progress { font: .9375rem/1 var(--font-ui, system-ui, sans-serif); color: var(--muted, #4b5565); font-variant-numeric: tabular-nums; }
.pr-skip { max-width: 70ch; margin: 4px auto 0; }
.pr-skip[hidden] { display: none; }

.ls-intro, .ls-run, .ls-drillres { max-width: 70ch; margin: 0 auto; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); color: var(--text, #1d2330); }
.ls-intro[hidden], .ls-run[hidden], .ls-drillres[hidden] { display: none; }
.ls-tip { padding: 8px 12px; border-left: 4px solid var(--accent, #2457d6); background: var(--tt-bg, var(--surface, #fff)); }
.ls-drillhead { margin: 0 0 8px; font-size: 1.125rem; }
.ls-drillhead:focus-visible { outline: 3px solid var(--accent, #2457d6); outline-offset: 2px; }
.ls-hint { min-height: 1.5em; margin: 8px 0; font-weight: 600; }
.ls-toggles { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 8px; }
.ls-kb[hidden] { display: none; }
.ls-summary { max-width: 70ch; margin: 0 auto 8px; font: 600 1.125rem/1.5 var(--font-ui, system-ui, sans-serif); }
.ls-list { max-width: 70ch; margin: 0 auto; padding: 0; list-style: none; font: 1rem/1.5 var(--font-ui, system-ui, sans-serif); }
.ls-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; min-height: 44px; padding: 6px 0 6px 12px; border-left: 4px solid var(--muted, #8a92a3); border-bottom: 1px solid color-mix(in srgb, var(--muted, #8a92a3) 40%, transparent); }
.ls-item .ls-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent, #2457d6); font-weight: 600; }
.ls-status { color: var(--muted, #4b5565); font-size: .9375rem; }
.ls-done { border-left-color: var(--accent, #2457d6); }
.ls-next { border-left-color: var(--text, #1d2330); border-left-width: 8px; }
.ls-locked .ls-link { font-weight: 400; }

/* On-screen keyboard: 15 key widths per row, so it scales from 320 px up. It is aria-hidden and takes no input. */
.kb { --kb-gap: 3px; user-select: none; max-width: 44rem; margin: 0 auto; font: 600 clamp(.5625rem, 2.4vw, .875rem)/1 var(--font-ui, system-ui, sans-serif); }
.kb-row { display: flex; gap: var(--kb-gap); margin: 0 0 var(--kb-gap) calc(var(--kb-off, 0) * 100% / 15); margin-right: calc(var(--kb-end, 0) * 100% / 15); }
.kb-key { display: flex; align-items: center; justify-content: center; flex: 1 1 0; min-width: 0; height: clamp(1.75rem, 8vw, 2.75rem); box-sizing: border-box; color: var(--text, #1d2330); background: var(--surface, #fff); border: 1px solid var(--ln, #8a92a3); border-radius: 6px; overflow: hidden; }
.kb-back { flex: 2 1 0; } .kb-shift[data-key="shift-l"] { flex: 2.25 1 0; } .kb-shift[data-key="shift-r"] { flex: 2.75 1 0; }
.kb-row-space { margin-left: calc(3.5 * 100% / 15); margin-right: calc(3.5 * 100% / 15); }
.kb-space { flex: 1 1 0; }
.kb-bump { border-bottom-width: 4px; }
.kb-fingers .kb-key[data-finger="lp"] { background: color-mix(in srgb, #d9534f 30%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="lr"] { background: color-mix(in srgb, #e69f00 32%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="lm"] { background: color-mix(in srgb, #009e73 30%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="li"] { background: color-mix(in srgb, #0072b2 30%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="ri"] { background: color-mix(in srgb, #56b4e9 34%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="rm"] { background: color-mix(in srgb, #20b486 30%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="rr"] { background: color-mix(in srgb, #f0b429 34%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="rp"] { background: color-mix(in srgb, #e5736f 30%, var(--surface, #fff)); }
.kb-fingers .kb-key[data-finger="th"] { background: color-mix(in srgb, #8a92a3 24%, var(--surface, #fff)); }
.kb .kb-key.kb-next[data-key] { color: var(--surface, #fff); background: var(--accent, #2457d6); border-color: var(--text, #1d2330); border-width: 2px; box-shadow: 0 0 0 2px var(--surface, #fff), 0 0 0 4px var(--accent, #2457d6); position: relative; z-index: 1; }
@media (prefers-reduced-motion: no-preference) { .kb .kb-key.kb-next { transition: background-color .08s; } }

/* Dyslexia-friendly font option (T9): OpenDyslexic, SIL OFL 1.1, self-hosted, file unchanged (fonts/OpenDyslexic-OFL.txt).
   The browser fetches the file only when the setting is on, because only then a rule uses the family. */
@font-face { font-family: "OpenDyslexic"; font-style: normal; font-weight: 400; font-display: swap; src: url("/typing-assets/fonts/opendyslexic-latin-400-normal.woff2") format("woff2"); }
:root[data-tt-font="dyslexic"] .tt-text { font-family: "OpenDyslexic", var(--font-mono, ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace); }
/* OpenDyslexic's glyph box is taller than the standard 1.6 line: give it room so the caret and the line box line up. */
:root[data-tt-font="dyslexic"] .tt-text { line-height: 2em; }
.al-result { max-width: 70ch; margin: 16px auto 0; }
.al-best { max-width: 70ch; margin: 8px auto 0; }
