Certainly! Here is the complete, updated `letter-board.css` code with the CSS Grid removal and absolute positioning fix applied so it scales perfectly.

```css
/* Letter Board — hi-fi AAC prototype styles
 * Direction A · Circular wells · bottom-strip always-on
 *
 * Design tokens:
 * bg          — outer chrome (the "room" the tablet sits in)
 * paper       — tablet surface (calm warm off-white)
 * ink         — primary text/stroke
 * muted       — secondary text
 * accent      — primary action color
 * line        — hairline strokes (≈ 10% ink)
 * surface     — keyboard plate (slightly cooler than paper)
 */

:root {
  --bg: #e3ddcb;
  --paper: #f5f1e6;
  --ink: #1a1814;
  --muted: #807a6b;
  --accent: #d96b3a;
  --accent-soft: #f4ddd0;
  --warn: #c4452f;        /* low-battery / alert — distinct red against the warm accent */
  --line: rgba(26,24,20,0.10);
  --line-strong: rgba(26,24,20,0.18);
  --surface: #ecebe4;
  --surface-strong: #e2e0d5;
  --card: #fff;          /* button/card face — inverts in dark themes */
  --card-hover: #fffaee;

  --font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* spring-feel cubic (single soft overshoot, ≈ damping 0.8) */
  --spring: cubic-bezier(0.34, 1.42, 0.64, 1);
  --spring-snap: cubic-bezier(0.4, 1.6, 0.55, 1);
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  --tablet-w: 768px;
  --tablet-h: 1024px;
  --stage-scale: 1;
  --text-scale: 1;
}

* { box-sizing: border-box; }

/* ── themes ─────────────────────────────────────────────────────────────────
   :root above is the default "warm" theme. Each block below re-points tokens;
   data-theme="warm" needs no block (it falls through to :root). The two
   high-contrast themes additionally drop decorative shadows and thicken borders
   so edges stay crisp for low vision. */
[data-theme="cool"] {
  --bg: #d8dcdb; --paper: #eef0ef; --surface: #e6e9e8; --surface-strong: #dadedd;
  --ink: #17191a; --muted: #6e7577;
  --accent-soft: #efdcd1;
  --card: #ffffff; --card-hover: #f6faf9;
  --line: rgba(20,28,30,0.10); --line-strong: rgba(20,28,30,0.18);
}
[data-theme="neutral"] {
  --bg: #dcd9d2; --paper: #f0eeea; --surface: #e8e6e0; --surface-strong: #ddd9d1;
  --ink: #1b1916; --muted: #79746a;
  --accent-soft: #f1ddd0;
  --card: #ffffff; --card-hover: #fbf9f4;
  --line: rgba(26,24,20,0.10); --line-strong: rgba(26,24,20,0.18);
}
[data-theme="dark"] {
  --bg: #0c0b09; --paper: #1c1a16; --surface: #252220; --surface-strong: #2f2b27;
  --ink: #f5efe0; --muted: #a59f8e;
  --accent: #e07a44; --accent-soft: #3a2a20; --warn: #e2613f;
  --card: #2a2723; --card-hover: #332f2a;
  --line: rgba(245,239,224,0.12); --line-strong: rgba(245,239,224,0.22);
}
[data-theme="high-contrast"] {
  --bg: #ffffff; --paper: #ffffff; --surface: #ffffff; --surface-strong: #f0f0f0;
  --ink: #000000; --muted: #000000;
  --accent: #0a52cc; --accent-soft: #d3e2ff; --warn: #b3000f;
  --card: #ffffff; --card-hover: #eef4ff;
  --line: #000000; --line-strong: #000000;
}
[data-theme="high-contrast-dark"] {
  --bg: #000000; --paper: #000000; --surface: #000000; --surface-strong: #0e0e0e;
  --ink: #ffffff; --muted: #ffffff;
  --accent: #ffd23f; --accent-soft: #4a3c00; --warn: #ff5a3c;
  --card: #000000; --card-hover: #1a1a1a;
  --line: #ffffff; --line-strong: #ffffff;
}
/* High-contrast structural pass: crisp edges, no soft shadows that blur them. */
[data-theme="high-contrast"] .well,
[data-theme="high-contrast"] .num-key,
[data-theme="high-contrast"] .chip,
[data-theme="high-contrast"] .ao,
[data-theme="high-contrast"] .letter,
[data-theme="high-contrast"] .pred,
[data-theme="high-contrast"] .sym-key,
[data-theme="high-contrast"] .action-btn,
[data-theme="high-contrast-dark"] .well,
[data-theme="high-contrast-dark"] .num-key,
[data-theme="high-contrast-dark"] .chip,
[data-theme="high-contrast-dark"] .ao,
[data-theme="high-contrast-dark"] .letter,
[data-theme="high-contrast-dark"] .pred,
[data-theme="high-contrast-dark"] .sym-key,
[data-theme="high-contrast-dark"] .action-btn {
  box-shadow: none !important;
  border-width: 3px;
}
[data-theme="high-contrast"] .action-btn:disabled,
[data-theme="high-contrast-dark"] .action-btn:disabled {
  opacity: 0.55;
}

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-family);
  color: var(--ink);
  background-color: var(--bg);
  overflow: hidden;
  height: 100%;
}
/* ── accessible font choices ───────────────────────────────────────────────
   Each option just re-points the single --font-family token, which every text
   element inherits. Adding a font = one block here + one picker entry. */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('fonts/opendyslexic-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'OpenDyslexic';
  src: url('fonts/opendyslexic-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
/* Lexend — designed for fluent reading; favoured in the dyslexia community. */
[data-font="lexend"]       { --font-family: 'Lexend', system-ui, sans-serif; }
/* OpenDyslexic — weighted letter bottoms reduce flipping/swapping. */
[data-font="opendyslexic"] { --font-family: 'OpenDyslexic', 'Comic Sans MS', system-ui, sans-serif; }
/* Atkinson Hyperlegible — maximally distinguishes similar glyphs (l/I/1, O/0). */
[data-font="atkinson"]     { --font-family: 'Atkinson Hyperlegible', system-ui, sans-serif; }

/* ── stage / tablet shell ───────────────────────────────────────────────── */
.stage {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, #ece6d4 0%, var(--bg) 60%),
    var(--bg);
}

.tablet {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--tablet-w);
  height: var(--tablet-h);
  background-color: var(--paper);
  border-radius: 44px;
  box-shadow:
    0 0 0 10px #2b2722,
    0 30px 60px -20px rgba(0,0,0,0.4),
    0 80px 120px -40px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%) scale(var(--stage-scale));
  display: grid;
  /* status | sentence(absorbs slack) | quick chips | prediction | numbers | keyboard | always-on */
  grid-template-rows: 36px 1fr 80px 96px 76px 244px 116px;
  padding: 4px 4px 24px;
  overflow: hidden;
}

/* iPad-style home indicator */
.tablet::after {
  content: '';
  position: absolute;
  left: 50%; bottom: 10px;
  width: 134px; height: 5px;
  background: rgba(26,24,20,0.45);
  border-radius: 3px;
  transform: translateX(-50%);
}

/* ── status bar ─────────────────────────────────────────────────────────── */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: nowrap;
  padding: 0 30px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
  white-space: nowrap;
  /* Sits above the scan switch layer so the gear stays reachable to leave
     scanning mode (the layer captures taps everywhere else). */
  position: relative;
  z-index: 41;
}
.status-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.status-pill.is-low {
  border-color: var(--warn);
  color: var(--warn);
}
.battery-icon { display: block; }
.status-pct { line-height: 1; }
.status-meta {
  display: flex; align-items: center; gap: 10px;
}
.status-gear {
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 50%;
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.status-gear:hover {
  background: rgba(26,24,20,0.06);
  border-color: var(--line-strong);
  color: var(--ink);
}

/* ── zone : quick-response chips ────────────────────────────────────────── */
.quick-chips {
  display: grid;
  grid-template-columns: repeat(6, 1fr) auto;
  gap: 8px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.chip.is-dim { opacity: 0.4; pointer-events: none; }

/* Pencil affordance — its own slim grid track so it never wraps the strip. */
.chip-editbtn {
  display: flex; align-items: center; justify-content: center;
  width: 44px;
  background-color: var(--card);
  border: 2px solid var(--line-strong, var(--ink));
  border-radius: 16px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s var(--ease-out);
  box-shadow: 0 2px 0 rgba(26,24,20,0.06);
}
.chip-editbtn:hover { color: var(--accent); border-color: var(--ink); }
.chip-editbtn:active { transform: scale(0.94); }
.chip-editbtn.is-active { color: var(--accent); border-color: var(--accent); }
.chip {
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: calc(18px * var(--text-scale));
  letter-spacing: -0.005em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  gap: 6px;
  transition: transform 0.12s var(--ease-out), background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 2px 0 rgba(26,24,20,0.06);
  text-align: center;
  line-height: 1.12;
  position: relative;
  overflow: hidden;
}
/* Comfortable chip size — larger, easier-to-hit quick-phrase buttons.
   Compact (above) is the original default. */
body.chips-comfortable .tablet {
  grid-template-rows: 36px 1fr 112px 96px 76px 244px 116px;
}
body.chips-comfortable .chip {
  border-radius: 18px;
  font-size: calc(21px * var(--text-scale));
  padding: 10px 14px;
}
.chip:hover {
  background-color: var(--accent);
  color: #fff;
  border-color: var(--ink);
}
.chip:active { transform: scale(0.96); }
.chip-text { flex: 0 1 auto; text-wrap: balance; }
.chip-mark {
  position: absolute;
  top: 7px; right: 9px;
  opacity: 0.4;
  display: flex;
  align-items: center;
}
.chip:hover .chip-mark { opacity: 0.9; }

/* ── quick-phrase editor overlay ────────────────────────────────────────── */
.quick-edit-scrim {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: rgba(26,24,20,0.34);
  z-index: 60;
  animation: sym-scrim-in 0.2s var(--ease-out);
}
.quick-edit-card {
  width: min(560px, 90%);
  max-height: 86%;
  display: flex; flex-direction: column;
  background-color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 8px 0 rgba(26,24,20,0.06), 0 30px 60px -20px rgba(0,0,0,0.4);
  animation: sym-pop-in 0.3s var(--spring);
  overflow: hidden;
}
.quick-edit-head {
  padding: 22px 24px 14px;
  border-bottom: 1.5px solid var(--line);
}
.quick-edit-head h2 {
  margin: 0;
  font-family: var(--font-family);
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.01em; color: var(--ink);
}
.quick-edit-head p {
  margin: 4px 0 0;
  font-family: var(--font-family);
  font-size: 14px; color: var(--muted);
}
.quick-edit-list {
  padding: 16px 24px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.quick-edit-row {
  display: flex; align-items: center; gap: 10px;
}
.quick-edit-arrows {
  display: flex; flex-direction: column; gap: 2px;
}
.quick-edit-arrows button {
  width: 26px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted); font-size: 9px;
  cursor: pointer; transition: color 0.12s, border-color 0.12s;
}
.quick-edit-arrows button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.quick-edit-arrows button:disabled { opacity: 0.3; cursor: not-allowed; }
.quick-edit-input {
  flex: 1;
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-family: var(--font-family);
  font-size: 17px; font-weight: 600;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.quick-edit-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(217,107,58,0.14);
}
.quick-edit-del {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  color: var(--muted); font-size: 24px; line-height: 1;
  cursor: pointer; transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.quick-edit-del:hover { color: #b94a2a; border-color: #b94a2a; background: #fdf1ec; }
.quick-edit-add {
  margin-top: 2px;
  padding: 13px;
  background: transparent;
  border: 2px dashed var(--line-strong);
  border-radius: 12px;
  font: inherit;
  font-family: var(--font-family);
  font-size: 16px; font-weight: 700;
  color: var(--muted);
  cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.quick-edit-add:hover { color: var(--accent); border-color: var(--accent); }
.quick-edit-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-top: 1.5px solid var(--line);
}
.quick-edit-reset {
  background: none; border: none;
  font: inherit; font-family: var(--font-family);
  font-size: 14px; font-weight: 700;
  color: var(--muted); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.quick-edit-reset:hover { color: #b94a2a; }
.quick-edit-done {
  background-color: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 30px;
  font: inherit; font-family: var(--font-family);
  font-size: 16px; font-weight: 800;
  color: #fff; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 3px 0 rgba(26,24,20,0.12);
  transition: transform 0.12s var(--ease-out), background 0.15s;
}
.quick-edit-done:hover { background: color-mix(in srgb, var(--accent) 90%, #000 10%); }
.quick-edit-done:active { transform: scale(0.97); }

/* ── zone : sentence ────────────────────────────────────────────────────── */
.zone { padding: 0 28px; }

.sentence-zone {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 14px;
  padding-top: 4px;
}

.sentence-card {
  position: relative;
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 22px;
  padding: 22px 28px;
  overflow: hidden;
  display: flex; align-items: flex-start;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 2px 0 rgba(26,24,20,0.08);
}
.sentence-text {
  font-family: var(--font-family);
  font-size: calc(40px * var(--text-scale));
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  word-break: break-word;
  width: 100%;
  padding-right: 56px;
}
.sentence-placeholder {
  position: absolute; inset: 22px 28px;
  font-size: 22px; color: var(--muted);
  font-weight: 400; letter-spacing: 0.01em;
  pointer-events: none;
  display: flex; align-items: flex-start;
}
.cursor {
  display: inline-block;
  width: 3px; height: 36px;
  background-color: var(--accent);
  margin-left: 4px;
  vertical-align: -4px;
  animation: blink 1s steps(2) infinite;
  border-radius: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Karaoke highlight — the word currently being spoken aloud. */
.speak-hl {
  background-color: var(--accent-soft);
  color: var(--ink);
  border-radius: 6px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0 0.06em;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Speak-again button inside the sentence card — one-tap re-speak. */
.sentence-repeat-btn {
  position: absolute;
  top: 14px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 2px 0 rgba(26,24,20,0.12);
  transition: background 0.15s, transform 0.12s var(--ease-out);
}
.sentence-repeat-btn:hover { background: color-mix(in srgb, var(--accent) 90%, #000 10%); }
.sentence-repeat-btn:active { transform: scale(0.93); }

/* History button inside the sentence card (top-right) */
.sentence-history-btn {
  position: absolute;
  top: 14px; right: 14px;
  width: 44px; height: 44px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background-color: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center; justify-content: center;
  gap: 4px;
  transition: background 0.15s, transform 0.12s var(--ease-out);
}
.sentence-history-btn:hover { background-color: var(--accent-soft); border-color: var(--accent); }
.sentence-history-btn:active { transform: scale(0.93); }
.sentence-history-count {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background-color: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

/* Show-to-listener button (sits next to the history icon) */
.sentence-show-btn {
  position: absolute;
  top: 14px;
  width: 44px; height: 44px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background-color: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.12s var(--ease-out);
}
.sentence-show-btn:hover { background-color: var(--accent-soft); border-color: var(--accent); }
.sentence-show-btn:active { transform: scale(0.93); }

/* ── speaker view (fullscreen sentence for the listener) ────────────────── */
.speaker-view {
  position: absolute;
  inset: 0;
  background-color: var(--paper);
  z-index: 70;
  display: flex; flex-direction: column;
  padding: 28px 32px 40px;
  animation: speaker-in 0.32s var(--spring);
}
@keyframes speaker-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.speaker-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.speaker-close, .speaker-speak {
  display: inline-flex; align-items: center; gap: 10px;
  background-color: var(--card);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  font: inherit;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 14px 22px;
  transition: transform 0.12s var(--ease-out), background 0.15s;
}
.speaker-close:hover { background: rgba(26,24,20,0.06); }
.speaker-close:active, .speaker-speak:active { transform: scale(0.97); }
.speaker-speak {
  background-color: var(--accent); color: #fff; border-color: var(--ink);
}
.speaker-speak:hover {
  background: color-mix(in srgb, var(--accent) 92%, #000 8%);
}
.speaker-text-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  padding: 32px 44px;
  overflow: auto;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 4px 0 rgba(26,24,20,0.06);
}
.speaker-text {
  font-family: var(--font-family);
  font-size: calc(120px * var(--text-scale));
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: center;
  text-wrap: balance;
  word-break: break-word;
}
.speaker-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.sentence-actions {
  display: flex; flex-direction: column; gap: 8px;
}
.action-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background-color: var(--card);
  color: var(--ink);
  font: inherit; font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px;
  flex: 1;
  transition: transform 0.12s var(--ease-out), background 0.15s;
}
.action-btn:hover:not(:disabled) { background: #faf6ec; }
.action-btn:active:not(:disabled) { transform: scale(0.96); }
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.action-btn.primary {
  background-color: var(--accent);
  color: #fff;
  border-color: var(--ink);
  flex: 1.6;
  font-size: 13px;
  letter-spacing: 0.16em;
  /* Raised hero: a colored elevation lifts the primary action above the field
     of equal-weight keys so it reads as THE thing to do. */
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 4px 0 color-mix(in srgb, var(--accent) 60%, #000 40%),
    0 10px 20px -8px rgba(217,107,58,0.55);
}
.action-btn.primary svg { width: 34px; height: 34px; }
.action-btn.primary:active:not(:disabled) {
  transform: translateY(2px) scale(0.99);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 2px 0 color-mix(in srgb, var(--accent) 60%, #000 40%),
    0 6px 12px -8px rgba(217,107,58,0.5);
}
.action-btn.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 90%, #000 10%);
}

/* Mini action row — SAVE / CLEAR sit under the SPEAK button. */
.action-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.action-btn-mini {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background-color: var(--card);
  color: var(--ink);
  font: inherit; font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 2px;
  transition: transform 0.12s var(--ease-out), background 0.15s;
  min-height: 64px;
}
.action-btn-mini:hover:not(:disabled) { background: #faf6ec; border-color: var(--accent); color: var(--accent); }
.action-btn-mini:active:not(:disabled) { transform: scale(0.93); }
.action-btn-mini:disabled { opacity: 0.3; cursor: not-allowed; }
.action-btn-mini svg { width: 22px; height: 22px; stroke-width: 2; }
.action-btn-mini.subtle:hover:not(:disabled) {
  background-color: var(--card);
  border-color: #b94a2a;
  color: #b94a2a;
}
/* ── Clear-undo toast ───────────────────────────────────────────────────────
   One tap clears; this 5s toast is the recovery for the only genuine panic
   (an accidental Clear). Centered over the now-empty sentence card so it's
   impossible to miss; the Undo target is a full 44px+ button. */
.clear-toast {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 66;
  display: flex; align-items: center; gap: 16px;
  background-color: var(--ink);
  color: var(--paper);
  padding: 10px 12px 10px 24px;
  border-radius: 999px;
  box-shadow: 0 12px 28px -10px rgba(0,0,0,0.55);
  overflow: hidden;
  animation: clear-toast-in 0.22s var(--spring) both;
}
@keyframes clear-toast-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
.clear-toast-label {
  font-family: var(--font-family);
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.02em;
}
.clear-toast-undo {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px;
  padding: 9px 24px;
  background-color: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font: inherit; font-family: var(--font-family);
  font-size: 16px; font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), filter 0.15s;
}
.clear-toast-undo svg { width: 20px; height: 20px; }
.clear-toast-undo:hover { filter: brightness(1.06); }
.clear-toast-undo:active { transform: scale(0.95); }
/* thin progress line that runs out over the 5s window */
.clear-toast-bar {
  position: absolute;
  left: 0; bottom: 0; height: 3px;
  width: 100%;
  background-color: var(--accent);
  transform-origin: left center;
  animation: clear-toast-countdown 5s linear both;
}
@keyframes clear-toast-countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── zone : prediction ──────────────────────────────────────────────────── */
.prediction-zone {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 4px;
}
.pred {
  border: 2px dashed var(--ink);
  border-radius: 16px;
  background: rgba(255,255,255,0.5);
  color: var(--ink);
  font: inherit;
  font-size: calc(26px * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  padding: 8px 10px;
  text-align: center;
  transition: transform 0.12s var(--ease-out), background 0.15s, border-color 0.15s;
}
.pred:hover {
  background-color: var(--card);
  border-style: solid;
  border-color: var(--accent);
}
.pred:active { transform: scale(0.97); }
.pred-match {
  color: var(--accent);
  font-weight: 700;
}
/* Learned-word marker — a small accent dot in the corner signals the board
   has surfaced this word from the user's own vocabulary, not just the dict. */
.pred { position: relative; }
.pred-learned-dot {
  position: absolute;
  top: 8px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  opacity: 0.8;
}
.pred.is-learned { border-style: solid; border-color: var(--line-strong); }
.pred-empty {
  grid-column: 1 / -1;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  align-self: center;
  font-style: italic;
}

/* ── zone : number row (always-visible 0–9) ─────────────────────────────── */
.number-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  align-items: stretch;
  padding-top: 4px;
  padding-bottom: 4px;
}
.num-key {
  background-color: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font: inherit;
  font-family: var(--font-family);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.12s var(--ease-out), background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.num-key:hover {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}
.num-key:active { transform: scale(0.92); }
.num-key.flash {
  animation: num-flash 0.4s var(--ease-out);
}
@keyframes num-flash {
  0%   { background-color: var(--accent); color: #fff; transform: scale(1.08); }
  100% { background-color: var(--card); color: var(--ink); transform: scale(1); }
}

/* ── zone : keyboard (Level 1 / Level 2) ────────────────────────────────── */
.keyboard-zone {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 12px 22px 0;
  gap: 24px;
  background:
    linear-gradient(180deg, transparent, rgba(26,24,20,0.03) 40%, transparent),
    var(--paper);
}

/* the 5 group wells row */
.well-row {
  display: flex; gap: 24px;
  align-items: center; justify-content: center;
  width: 100%;
  transition: transform 0.42s var(--spring);
}
.mode-l2 .well-row {
  transform: translateY(40px) scale(0.5);
}
.well {
  width: 124px; height: 124px;
  border-radius: 50%;
  background-color: var(--card);
  border: 2.5px solid var(--ink);
  color: var(--ink);
  font: inherit;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0;
  flex: 0 0 auto;
  transition:
    transform 0.42s var(--spring),
    background 0.2s,
    box-shadow 0.2s;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 2px 0 rgba(26,24,20,0.06);
  position: relative;
}
.well:hover {
  background-color: var(--card-hover);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 4px 0 rgba(26,24,20,0.08),
    0 0 0 6px rgba(217,107,58,0.10);
}
.well:active { transform: scale(0.95); }
.well.is-open {
  background-color: var(--accent);
  color: #fff;
  border-color: var(--ink);
  box-shadow:
    0 0 0 6px rgba(217,107,58,0.22),
    0 2px 0 rgba(26,24,20,0.06);
}
.well.recede {
  opacity: 0.3;
  transform: scale(0.72);
}
.well-label {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 800;
}
/* Arc-on-top — the actual letters of each group, curving above the well.
   Always visible at Level 1 so users never have to guess what's inside a
   chunk; fades out at Level 2 where the full-size letter buttons take over. */
.well-arc {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.arc-letter {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  /* Rotate around the well center, then push outward by the arc radius. */
  transform: rotate(var(--arc-angle)) translateY(-86px);
}
.arc-letter-glyph {
  display: inline-block;
  position: absolute;
  /* Counter-rotate so the glyph stays upright, then center on the anchor. */
  transform: rotate(calc(-1 * var(--arc-angle))) translate(-50%, -50%);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0.72;
  white-space: nowrap;
  line-height: 1;
  /* Subtle hover-affinity: when the well is hovered, brighten its arc letters. */
  transition: color 0.15s, transform 0.25s var(--ease-out);
}
.well:hover .arc-letter-glyph { color: var(--ink); }
.well.is-open .arc-letter-glyph { color: var(--accent); }
.mode-l2 .well-arc { opacity: 0; }
/* Hide the faint A–E letter previews when the user turns them off in Settings. */
body.hide-arc .well-arc { display: none; }
/* At Level 2 the full-size letter buttons take over; drop the receded wells to
   near-invisible so their ghosted labels don't bleed through between letters. */
.mode-l2 .well.recede { opacity: 0.06; }
.mode-l2 .well.is-open { opacity: 0.14; }

/* Level 2 — letter row, floated as an absolute overlay so it reserves NO
   space at Level 1 (otherwise its height pushes the wells down and leaves a
   dead band above them). Wells therefore center naturally in the zone. */
.letter-row {
  position: absolute;
  inset: 0;
  display: flex; gap: 18px;
  align-items: center; justify-content: center;
  width: 100%;
  pointer-events: none;
  z-index: 2;
}
.letter {
  flex: 1 1 0; min-width: 0; max-width: 134px; height: 180px;
  border-radius: 36px;
  background-color: var(--card);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  font: inherit;
  font-family: var(--font-family);
  font-size: 96px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  /* default: hidden / collapsed into the active well's x-position */
  opacity: 0;
  transform: translate(var(--origin-x, 0), 60px) scale(0.3);
  transition:
    transform 0.5s var(--spring),
    opacity 0.32s var(--ease-out),
    background 0.2s;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 4px 0 rgba(26,24,20,0.08);
}
.mode-l2 .letter {
  opacity: 1;
  transform: translate(0, 0) scale(1);
  pointer-events: auto;
}
.letter:hover {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}
.letter:active { transform: scale(0.95); }
.letter.flash {
  animation: letter-flash 0.5s var(--ease-out);
}
@keyframes letter-flash {
  0%   { background-color: var(--accent); color: #fff; transform: scale(1.05); }
  100% { background-color: var(--card); color: var(--ink); transform: scale(1); }
}

/* A–Z return glyph */
.return-glyph {
  position: absolute;
  top: 12px; left: 28px;
  display: flex; align-items: center; gap: 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.25em;
  padding: 8px 12px;
  border-radius: 999px;
  transition: opacity 0.3s var(--ease-out), color 0.15s;
}
.return-glyph:hover { color: var(--ink); background: rgba(26,24,20,0.04); }
.return-dots {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  width: 16px; height: 16px;
}
.return-dots i {
  display: block;
  background: currentColor;
  border-radius: 50%;
  width: 100%; height: 100%;
}

/* ── zone : always-on bottom strip ──────────────────────────────────────── */
.alwayson-zone {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 2.4fr 1.4fr 1.4fr;
  gap: 10px;
  padding-bottom: 0;
}
.ao {
  background-color: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  padding: 6px;
  transition: transform 0.12s var(--ease-out), background 0.15s;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 2px 0 rgba(26,24,20,0.06);
}
.ao:hover { background-color: var(--card-hover); }
.ao:active { transform: scale(0.96); }
.ao-glyph {
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.ao-sub {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.ao-enter { background-color: var(--accent); color: #fff; }
.ao-enter .ao-sub { color: rgba(255,255,255,0.85); }
.ao-enter:hover { background: color-mix(in srgb, var(--accent) 92%, #000 8%); }
.ao-back .ao-glyph svg { width: 36px; height: 36px; }
.ao-enter .ao-glyph svg { width: 36px; height: 36px; }
.ao-space .ao-space-glyph {
  font-size: 28px;
  letter-spacing: 0;
  position: relative;
  top: -8px;
}
.ao-space .ao-sub {
  font-size: 13px;
  letter-spacing: 0.28em;
}
.ao-more {
  /* "…" symbols-opener — visually distinct from punctuation */
  background-color: var(--surface-strong, #e2e0d5);
}
.ao-more.is-open {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}
.ao-more .ao-glyph {
  font-size: 36px;
  letter-spacing: 0;
  /* center the ellipsis vertically */
  line-height: 0.5;
  margin-top: 4px;
}

/* ── symbols popover ────────────────────────────────────────────────────── */
.sym-scrim {
  position: absolute;
  inset: 0;
  background: rgba(26,24,20,0.18);
  z-index: 50;
  animation: sym-scrim-in 0.18s var(--ease-out);
}
@keyframes sym-scrim-in { from { opacity: 0; } to { opacity: 1; } }
.sym-popover {
  position: absolute;
  /* anchor above the "…" key in the always-on row */
  right: 250px;
  bottom: 134px;
  width: 360px;
  background-color: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  padding: 18px;
  box-shadow:
    0 8px 0 rgba(26,24,20,0.06),
    0 24px 40px -12px rgba(0,0,0,0.30);
  z-index: 51;
  animation: sym-pop-in 0.28s var(--spring);
  transform-origin: 50% 100%;
}
@keyframes sym-pop-in {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* speech-bubble tail pointing down at the "…" key */
.sym-popover::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -14px;
  width: 22px; height: 22px;
  background-color: var(--paper);
  border-right: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
.sym-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.sym-key {
  height: 70px;
  background-color: var(--card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 14px;
  font: inherit;
  font-family: var(--font-family);
  font-size: 32px;
  font-weight: 600;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.12s var(--ease-out), background 0.15s, color 0.15s;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 2px 0 rgba(26,24,20,0.06);
}
.sym-key:hover {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}
.sym-key:active { transform: scale(0.95); }
.sym-foot {
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

/* ── history popover (anchored over the sentence card) ──────────────────── */
.hist-popover {
  position: absolute;
  top: 120px; right: 32px;
  width: 440px;
  max-height: 540px;
  background-color: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  padding: 16px 18px 14px;
  display: flex; flex-direction: column;
  box-shadow:
    0 8px 0 rgba(26,24,20,0.06),
    0 24px 40px -12px rgba(0,0,0,0.30);
  z-index: 51;
  animation: hist-pop-in 0.28s var(--spring);
  transform-origin: 100% 0%;
}
@keyframes hist-pop-in {
  from { opacity: 0; transform: translateY(-20px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hist-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 4px 12px;
  border-bottom: 1.5px dashed var(--line-strong);
}
.hist-close {
  background: transparent; border: 0;
  font-size: 18px; color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.hist-close:hover { color: var(--ink); background: rgba(26,24,20,0.06); }
.hist-empty {
  padding: 36px 12px;
  text-align: center;
  font-style: italic;
  color: var(--muted);
}
.hist-list {
  list-style: none;
  margin: 0; padding: 8px 0 0;
  display: flex; flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.hist-row {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.12s var(--ease-out);
}
.hist-row:hover { background-color: var(--accent-soft); border-color: var(--accent); }
.hist-row:active { transform: scale(0.98); }
.hist-text {
  flex: 1;
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
  word-break: break-word;
}
.hist-play {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  background-color: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}

/* ── settings panel ─────────────────────────────────────────────────────── */
.settings-panel {
  position: absolute;
  top: 70px; right: 20px;
  width: 460px;
  max-height: 740px;
  background-color: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  padding: 16px 20px 18px;
  display: flex; flex-direction: column;
  box-shadow:
    0 8px 0 rgba(26,24,20,0.06),
    0 24px 40px -12px rgba(0,0,0,0.30);
  z-index: 51;
  animation: hist-pop-in 0.28s var(--spring);
  transform-origin: 100% 0%;
}
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-family);
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  padding: 4px 4px 14px;
  border-bottom: 1.5px dashed var(--line-strong);
  letter-spacing: -0.005em;
}
.settings-body {
  display: flex; flex-direction: column;
  gap: 20px;
  padding-top: 16px;
  overflow-y: auto;
}
.settings-section {
  display: flex; flex-direction: column;
  gap: 12px;
}
.settings-section-title {
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-row {
  display: flex; flex-direction: column;
  gap: 8px;
}
.settings-row.is-disabled { opacity: 0.4; pointer-events: none; }
.settings-row.settings-toggle {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.settings-label {
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  display: flex; flex-direction: column;
  gap: 4px;
}
.settings-label em {
  font-style: normal;
  font-weight: 500;
  font-size: 14px;
  color: var(--muted);
}
.settings-hint {
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--muted) !important;
}
.settings-select {
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%231a1814' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background-color: var(--line-strong);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px; height: 26px;
  background-color: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}
.settings-slider::-moz-range-thumb {
  width: 26px; height: 26px;
  background-color: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}
.settings-test {
  align-self: flex-start;
  display: inline-flex;
  align-items: center; gap: 8px;
  background-color: var(--accent);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 4px;
}
.settings-test:hover {
  background: color-mix(in srgb, var(--accent) 90%, #000 10%);
}

/* Forget-learned-words button — neutral until usable, then a quiet reset. */
.settings-forget {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  width: 100%;
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.settings-forget em {
  font-style: normal;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.settings-forget:hover:not(:disabled) { border-color: #b94a2a; color: #b94a2a; }
.settings-forget:hover:not(:disabled) em { color: #b94a2a; }
.settings-forget:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── quick-setup presets ────────────────────────────────────────────────── */
.preset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.preset-btn {
  display: flex; flex-direction: column; gap: 4px;
  text-align: left;
  background-color: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: transform 0.12s var(--ease-out), background 0.15s, border-color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 0 rgba(26,24,20,0.06);
}
.preset-btn:hover { background: #faf6ec; border-color: var(--accent); }
.preset-btn:active { transform: scale(0.97); }
.preset-btn.enhanced { background-color: var(--accent-soft); }
.preset-btn.enhanced:hover { background: color-mix(in srgb, var(--accent-soft) 70%, #fff 30%); }
.preset-name {
  font-family: var(--font-family);
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.005em;
}
.preset-desc {
  font-size: 13px; font-weight: 500;
  line-height: 1.25;
  color: var(--muted);
}
.preset-note {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  text-wrap: pretty;
}

/* ── segmented control (chip size) ──────────────────────────────────────── */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
}
.seg-btn {
  background-color: var(--card);
  border: 0;
  font: inherit;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  padding: 11px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn + .seg-btn { border-left: 2px solid var(--ink); }
.seg-btn.on { background-color: var(--accent); color: #fff; }
.seg-btn:not(.on):hover { background-color: var(--accent-soft); }

/* ── theme swatch picker ──────────────────────────────────────────────────── */
.settings-row.settings-stack { gap: 10px; }
.settings-note {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.35;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.theme-swatch {
  position: relative;
  border: 2px solid;
  border-radius: 12px;
  height: 60px;
  padding: 8px 9px;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: 5px;
  overflow: hidden;
  transition: transform 0.12s var(--ease-out), box-shadow 0.15s;
}
.theme-swatch:active { transform: scale(0.97); }
.theme-swatch-bar {
  height: 4px; width: 60%; border-radius: 2px;
}
.theme-swatch-dot {
  position: absolute; top: 8px; right: 8px;
  width: 14px; height: 14px; border-radius: 50%;
}
.theme-swatch-name {
  font-family: var(--font-family);
  font-size: 12px; font-weight: 700;
  letter-spacing: -0.01em;
}
.theme-swatch.on {
  box-shadow: 0 0 0 3px var(--accent);
}

/* ── font preview picker ──────────────────────────────────────────────────── */
.font-list { display: flex; flex-direction: column; gap: 8px; }
.font-opt {
  position: relative;
  text-align: left;
  background-color: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.font-opt:hover { background-color: var(--accent-soft); }
.font-opt.on { border-color: var(--accent); background-color: var(--accent-soft); }
.font-opt-name { font-size: 17px; font-weight: 700; }
.font-opt-sample { font-size: 14px; opacity: 0.7; }
.font-opt-check {
  position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
  color: var(--accent); font-weight: 800; font-size: 18px;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 56px; height: 32px;
  background-color: var(--line-strong);
  border: 2px solid var(--ink);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s var(--ease-out);
  flex: 0 0 auto;
}
.toggle.on { background-color: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 24px; height: 24px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.25s var(--spring-snap);
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.toggle.on .toggle-thumb {
  transform: translateX(24px);
}

/* ── dwell-to-activate visual feedback ──────────────────────────────────── */
button.is-dwelling {
  position: relative;
  z-index: 1;
}
button.is-dwelling::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  pointer-events: none;
  /* Conic gradient grows clockwise from the top as --dwell-progress fills 0 → 1. */
  background: conic-gradient(
    from -90deg,
    var(--accent) calc(var(--dwell-progress, 0) * 360deg),
    transparent calc(var(--dwell-progress, 0) * 360deg)
  );
  /* Mask the conic into a thin ring so the button face stays clean. */
  -webkit-mask:
    radial-gradient(circle at center, transparent 0, transparent calc(100% - 8px), #000 calc(100% - 6px));
          mask:
    radial-gradient(circle at center, transparent 0, transparent calc(100% - 8px), #000 calc(100% - 6px));
  opacity: 0.85;
}
/* For non-circular buttons the radial mask doesn't fit, so we use a simpler
   outline-style halo instead — still grows visually with the progress. */
button.is-dwelling:not(.well):not(.letter):not(.num-key):not(.sym-key) {
  box-shadow: 0 0 0 calc(var(--dwell-progress, 0) * 6px) var(--accent);
}
button.is-dwelling:not(.well):not(.letter):not(.num-key):not(.sym-key)::after {
  display: none;
}
.ao.flash { animation: ao-flash 0.4s var(--ease-out); }
@keyframes ao-flash {
  0% { background-color: var(--accent-soft); transform: scale(1.05); }
  100% { transform: scale(1); }
}
.ao-enter.flash { animation: ao-enter-flash 0.4s var(--ease-out); }
@keyframes ao-enter-flash {
  0% { background-color: var(--card); color: var(--ink); }
  100% { background-color: var(--accent); color: #fff; }
}

/* ── reduce motion ──────────────────────────────────────────────────────────
   Near-instant transitions/animations so a user with timing-sensitive motor
   planning never taps into a key that's still mid-flight. Dwell + scanning
   feedback are inline/box-shadow based, so they keep working. */
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  transition-delay: 0ms !important;
}

/* ── single-switch scanning ─────────────────────────────────────────────────
   The switch layer covers the whole tablet (tap anywhere = the switch); it
   sits below the status bar (gear stays reachable) and below all popovers. */
.scan-switch-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

/* Item cursor — a box-shadow ring so it follows each key's border-radius
   (round wells, pill keys, rounded letters) without shifting layout. */
.scan-cursor {
  position: relative;
  z-index: 42;
  box-shadow:
    0 0 0 4px var(--paper),
    0 0 0 9px var(--accent),
    0 0 0 14px rgba(217,107,58,0.28) !important;
}
/* Region cursor — a dashed frame around the whole zone being offered. */
.scan-cursor-region {
  position: relative;
  z-index: 42;
  outline: 3px dashed var(--accent);
  outline-offset: 6px;
  border-radius: 18px;
}

.scan-indicator {
  position: absolute;
  top: 44px; left: 50%;
  transform: translateX(-50%);
  z-index: 65;
  pointer-events: none;
  background-color: var(--ink);
  color: var(--paper);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 20px -8px rgba(0,0,0,0.5);
  white-space: nowrap;
  transition: opacity 0.2s var(--ease-out);
}

/* ── first-run input-method prompt ──────────────────────────────────────── */
.firstrun {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: rgba(26,24,20,0.34);
  animation: sym-scrim-in 0.2s var(--ease-out);
}
.firstrun-card {
  width: 560px; max-width: 100%;
  background-color: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  padding: 34px 34px 30px;
  box-shadow: 0 8px 0 rgba(26,24,20,0.06), 0 30px 60px -20px rgba(0,0,0,0.4);
  animation: sym-pop-in 0.3s var(--spring);
}
.firstrun-title {
  font-family: var(--font-family);
  font-size: 32px; font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.firstrun-sub {
  margin-top: 8px;
  font-size: 17px; font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  text-wrap: pretty;
}
.firstrun-opts {
  margin-top: 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.firstrun-opt {
  display: flex; flex-direction: column; gap: 5px;
  text-align: left;
  background-color: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  padding: 16px 20px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: transform 0.12s var(--ease-out), background 0.15s, border-color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 0 rgba(26,24,20,0.06);
}
.firstrun-opt:hover { background-color: var(--accent-soft); border-color: var(--accent); }
.firstrun-opt:active { transform: scale(0.98); }
.firstrun-opt-title {
  font-family: var(--font-family);
  font-size: 21px; font-weight: 700;
  letter-spacing: -0.005em;
}
.firstrun-opt-desc {
  font-size: 15px; font-weight: 500;
  line-height: 1.3;
  color: var(--muted);
}

/* ── status-bar help button ──────────────────────────────────────────────── */
/* Sits left of the gear. The (?) is more discoverable than burying help in
   Settings, but visually quieter than the gear so it never competes. */
.status-help { color: var(--muted); }
.status-help:hover { color: var(--ink); }

/* ── first-launch nudge ──────────────────────────────────────────────────────
   Soft pulse on the group wells + a small caption. Never blocks the board;
   vanishes the instant the user taps anything. Gated by settings.firstLaunchHint. */
.well-row.is-nudging { position: relative; }
.well-row.is-nudging .well {
  animation: nudge-pulse 2.1s var(--ease-out) infinite;
}
.well-row.is-nudging .well:nth-child(2) { animation-delay: 0.12s; }
.well-row.is-nudging .well:nth-child(3) { animation-delay: 0.24s; }
.well-row.is-nudging .well:nth-child(4) { animation-delay: 0.36s; }
.well-row.is-nudging .well:nth-child(5) { animation-delay: 0.48s; }
.well-row.is-nudging .well:nth-child(6) { animation-delay: 0.60s; }
@keyframes nudge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  18%      { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.nudge-caption {
  position: absolute;
  top: -20px; left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-family: var(--font-family);
  font-size: 15px; font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
  background-color: var(--paper);
  padding: 4px 16px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  white-space: nowrap;
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.4);
  animation: nudge-cap-in 0.4s var(--spring) both;
  pointer-events: none;
}
@keyframes nudge-cap-in {
  from { transform: translate(-50%, 8px) scale(0.9); }
  to   { transform: translate(-50%, 0) scale(1); }
}
/* Motion-sensitive users: hold a steady ring + caption, no pulsing. */
.reduce-motion .well-row.is-nudging .well { animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.reduce-motion .nudge-caption { animation: none; }

/* ── "How it works" — settings entry ─────────────────────────────────────── */
.help-open-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  text-align: left;
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.12s var(--ease-out), background 0.15s, border-color 0.15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 0 rgba(26,24,20,0.06);
  margin-bottom: 14px;
}
.help-open-btn:hover { background-color: var(--accent-soft); border-color: var(--accent); }
.help-open-btn:active { transform: scale(0.99); }
.help-open-btn > svg { flex: 0 0 auto; color: var(--accent); }
.help-open-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.help-open-title { font-family: var(--font-family); font-size: 16px; font-weight: 700; }
.help-open-sub { font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.help-open-chevron { font-size: 26px; color: var(--muted); line-height: 1; }

/* ── How-it-works overlay ─────────────────────────────────────────────────── */
.help-overlay {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex; flex-direction: column;
  background-color: var(--paper);
  animation: speaker-in 0.32s var(--spring);
}
.help-head {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px 18px;
  border-bottom: 2px solid var(--line-strong);
}
.help-title {
  font-family: var(--font-family);
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.help-modeseg {
  display: flex;
  margin-left: auto;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
}
.help-modeseg button {
  background-color: var(--card);
  border: 0;
  font-family: var(--font-family);
  font-size: 15px; font-weight: 700;
  color: var(--ink);
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.help-modeseg button + button { border-left: 2px solid var(--ink); }
.help-modeseg button.on { background-color: var(--accent); color: #fff; }
.help-modeseg button:not(.on):hover { background-color: var(--accent-soft); }
.help-body {
  flex: 1;
  display: flex; flex-direction: column;
  padding: 24px;
  overflow-y: auto;
  min-height: 0;
}
.help-loop, .help-steps { display: flex; flex-direction: column; flex: 1; gap: 18px; }

/* the schematic stage */
.help-stage {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 20px;
  padding: 22px;
}

/* ── MiniBoard schematic ──────────────────────────────────────────────────── */
.miniboard {
  width: 480px; max-width: 100%;
  display: flex; flex-direction: column;
  gap: 10px;
  font-family: var(--font-family);
}
.mb-dim { opacity: 0.34; filter: saturate(0.7); transition: opacity 0.25s; }
.mb-lit { transition: opacity 0.25s; }
.mb-sentence {
  display: flex; align-items: center; gap: 12px;
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 12px 12px 16px;
}
.mb-sentence-text {
  flex: 1;
  font-size: 22px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; min-height: 28px;
}
.mb-placeholder { color: var(--muted); font-weight: 500; font-size: 16px; }
.mb-caret {
  display: inline-block; width: 2px; height: 22px;
  background-color: var(--accent); margin-left: 3px;
  animation: mb-blink 1s step-end infinite;
}
@keyframes mb-blink { 50% { opacity: 0; } }
.mb-speak {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  background-color: var(--accent); color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px; font-weight: 800;
}
.mb-phrases { display: flex; gap: 8px; flex-wrap: wrap; }
.mb-chip {
  position: relative;
  background-color: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.mb-keyboard {
  background-color: var(--surface-strong);
  border: 2px solid var(--line-strong);
  border-radius: 16px;
  padding: 14px 12px 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.mb-wellrow { display: flex; gap: 8px; justify-content: center; }
.mb-well {
  position: relative;
  flex: 1;
  aspect-ratio: 1 / 1;
  max-width: 76px;
  border-radius: 50%;
  background-color: var(--card);
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: var(--ink);
}
.mb-letterrow { display: flex; gap: 8px; justify-content: center; }
.mb-letter {
  position: relative;
  flex: 1; max-width: 76px;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  background-color: var(--accent-soft);
  border: 2px solid var(--accent);
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800; color: var(--ink);
}
.mb-utilrow { display: flex; gap: 8px; justify-content: center; }
.mb-util {
  position: relative;
  background-color: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  padding: 6px 16px;
  font-size: 14px; font-weight: 700; color: var(--muted);
}
.mb-space { flex: 1; text-align: center; max-width: 180px; }
.mb-well.is-target, .mb-letter.is-target, .mb-chip.is-target, .mb-util.is-target,
.mb-speak.is-target { z-index: 2; }

/* the tap-ring shown on the current target */
.mb-ring {
  position: absolute; inset: -7px;
  border: 3px solid var(--accent);
  border-radius: inherit;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  animation: mb-ring-pulse 1.5s var(--ease-out) infinite;
  pointer-events: none;
}
.mb-speak .mb-ring, .mb-chip .mb-ring, .mb-util .mb-ring { border-radius: 999px; }
@keyframes mb-ring-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.04); opacity: 0.75; }
}
[data-reduce-motion] .mb-ring, .reduce-motion .mb-ring, .reduce-motion .mb-caret { animation: none; }

/* ── step-through ─────────────────────────────────────────────────────────── */
.help-stepbody { flex: 1; }
.help-step-title {
  font-family: var(--font-family);
  font-size: 24px; font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 8px;
}
.help-caption {
  font-family: var(--font-family);
  font-size: 18px; font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  margin: 0;
  text-wrap: pretty;
}
.help-aside {
  display: block;
  margin: 14px 0 0;
  font-size: 14.5px; font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
  background-color: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 11px 14px;
  text-wrap: pretty;
}
.help-aside-tag {
  display: inline-block;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
  margin-right: 8px;
}
.help-nav {
  display: flex; align-items: center; gap: 16px;
  padding-top: 6px;
}
.help-navbtn {
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 16px; font-weight: 700;
  color: var(--ink);
  padding: 11px 24px;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), background 0.15s, opacity 0.15s;
}
.help-navbtn:hover:not(:disabled) { background-color: var(--accent-soft); }
.help-navbtn:active:not(:disabled) { transform: scale(0.97); }
.help-navbtn:disabled { opacity: 0.32; cursor: default; }
.help-navbtn.primary { background-color: var(--accent); color: #fff; border-color: var(--accent); }
.help-navbtn.primary:hover { filter: brightness(1.06); background-color: var(--accent); }
.help-dots { display: flex; gap: 9px; margin: 0 auto; }
.help-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background-color: transparent;
  border: 2px solid var(--line-strong);
  padding: 0; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s var(--spring);
}
.help-dot:hover { border-color: var(--accent); }
.help-dot.on { background-color: var(--accent); border-color: var(--accent); transform: scale(1.15); }

/* ── full loop ────────────────────────────────────────────────────────────── */
.help-loopbar { display: flex; flex-direction: column; gap: 16px; }
.help-loop .help-caption { min-height: 52px; }
.help-loopctl { display: flex; align-items: center; gap: 18px; }
.help-ghostbtn {
  background-color: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 15px; font-weight: 700;
  color: var(--ink);
  padding: 10px 20px;
  min-height: 44px;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), background 0.15s;
}
.help-ghostbtn:hover { background-color: var(--accent-soft); }
.help-ghostbtn:active { transform: scale(0.97); }
.help-progress { display: flex; gap: 7px; }
.help-pdot {
  width: 8px; height: 8px; border-radius: 50%;
  background-color: var(--line-strong);
  transition: background 0.2s, transform 0.2s var(--spring);
}
.help-pdot.on { background-color: var(--accent); transform: scale(1.3); }

/* ── settings still (last step) ───────────────────────────────────────────── */
.help-settings-still {
  width: 480px; max-width: 100%;
  display: flex; flex-direction: column; gap: 10px;
  font-family: var(--font-family);
}
.help-srow {
  display: flex; align-items: baseline; gap: 14px;
  background-color: var(--card);
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 16px;
}
.help-skey {
  flex: 0 0 116px;
  font-size: 16px; font-weight: 800; color: var(--accent);
}
.help-sval { font-size: 15px; font-weight: 500; color: var(--ink); line-height: 1.35; }