:root {
  --bg: #07110f;
  --surface: #0c1815;
  --panel: #10201d;
  --ink: #effff8;
  --muted: #9eb7ae;
  --faint: #789a8d;
  --accent: #63f5ba;
  --accent-strong: #2cda98;
  --accent-ink: #062016;
  --amber: #ffca72;
  --danger: #ff7f7f;
  --line: rgba(194, 255, 224, 0.14);
  --line-strong: rgba(194, 255, 224, 0.26);
  --accent-tint: rgba(99, 245, 186, 0.12);
  --amber-tint: rgba(255, 202, 114, 0.14);
  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.28);
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -15%, var(--accent-tint), transparent 42%), var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

::selection { background: var(--accent-tint); color: var(--ink); }

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono, .mono-code { font-family: var(--font-mono); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: 16px; z-index: 60;
  background: var(--panel); color: var(--ink); padding: 10px 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  transform: translateY(-200%); transition: transform 0.15s;
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.page-wrap { padding: 28px 0 64px; }
.doc-wrap { max-width: 760px; padding: 48px 0 64px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.header-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 68px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--radius-sm); border: 1px solid var(--accent);
  background: var(--panel); color: var(--accent); font-family: var(--font-mono);
  font-size: 16px; line-height: 1;
}
.nav-desktop { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-link {
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 500; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.nav-link:hover, .nav-link[aria-current="page"] {
  background: var(--panel); color: var(--ink); text-decoration: none;
}
.nav-link[lang] {
  border: 1px solid var(--line); margin-left: 6px; font-family: var(--font-mono);
  font-size: 12px; padding: 6px 10px; color: var(--accent);
}
.nav-toggle {
  display: none; min-height: 44px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.nav-mobile { border-top: 1px solid var(--line); background: var(--surface); padding: 12px 16px; }
.nav-mobile-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-mobile-link {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 15px;
}
.nav-mobile-link[aria-current="page"], .nav-mobile-link:hover {
  background: var(--panel); color: var(--ink); text-decoration: none;
}

/* Breadcrumbs & Hero */
.breadcrumbs { margin-bottom: 16px; font-size: 14px; color: var(--faint); }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumbs a { color: var(--muted); }
.crumb-sep { margin-left: 6px; opacity: 0.6; }

.page-hero { margin-bottom: 24px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 10px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 13px; color: var(--accent); font-weight: 500;
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.page-h1 {
  margin: 0; font-size: clamp(28px, 4.2vw, 42px);
  line-height: 1.18; font-weight: 700; letter-spacing: -0.025em;
}
.page-lead {
  margin: 12px 0 0; font-size: 17px; color: var(--muted); max-width: 70ch;
}

/* Buttons */
.btn-primary, .btn-outline, .btn-amber {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; }
.btn-outline {
  background: transparent; color: var(--ink); border: 1px solid var(--line-strong);
}
.btn-outline:hover:not(:disabled) { background: var(--panel); border-color: var(--accent); color: var(--ink); text-decoration: none; }
.btn-outline[aria-pressed="true"], .btn-outline.is-active {
  background: var(--accent-tint); border-color: var(--accent); color: var(--accent);
}
.btn-amber {
  background: var(--amber); color: var(--accent-ink); border: 1px solid var(--amber);
}
.btn-amber:hover:not(:disabled) { filter: brightness(0.95); text-decoration: none; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
button:disabled { opacity: 0.42; cursor: not-allowed; }
.text-link { font-weight: 600; font-size: 14px; color: var(--accent); display: inline-block; margin-top: 8px; }

/* Sections & Prose */
.sec { margin-top: 48px; contain: layout style; }
.prose-sec, .faq-sec { content-visibility: auto; contain-intrinsic-size: auto 380px; }
.sec-h2 {
  margin: 0 0 12px; font-size: clamp(22px, 3vw, 28px);
  line-height: 1.25; font-weight: 700; letter-spacing: -0.02em;
}
.sub-h3 { margin: 28px 0 12px; font-size: 18px; font-weight: 700; }
.sec-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.prose-lead { margin: 0 0 20px; color: var(--muted); max-width: 70ch; }
.micro-note { margin: 0 0 16px; font-size: 13px; color: var(--faint); font-family: var(--font-mono); }

.prose-sec h2 { margin: 36px 0 12px; font-size: 24px; line-height: 1.25; }
.prose-sec h2:first-child { margin-top: 0; }
.prose-sec h3 { margin: 24px 0 8px; font-size: 18px; line-height: 1.3; }
.prose-sec p { margin: 0 0 14px; color: var(--muted); max-width: 70ch; }
.prose-sec ul, .prose-sec ol { margin: 0 0 18px; padding-left: 22px; color: var(--muted); max-width: 70ch; }
.prose-sec li { margin-bottom: 8px; }
.prose-sec strong { color: var(--ink); }
.prose-sec code {
  background: var(--panel); color: var(--accent); padding: 2px 6px;
  border-radius: 6px; font-size: 0.92em;
}
.prose-sec blockquote {
  margin: 18px 0; padding: 12px 16px; border-left: 3px solid var(--amber);
  background: var(--amber-tint); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink); max-width: 70ch;
}
.prose-sec blockquote p { margin: 0; color: var(--ink); }

.table-wrap { overflow-x: auto; margin: 16px 0 24px; }
.prose-sec table, .data-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  font-size: 15px;
}
.prose-sec th, .prose-sec td, .data-table th, .data-table td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.prose-sec th, .data-table th {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--faint); background: var(--panel);
}
.prose-sec tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.row-accent td { background: var(--accent-tint); color: var(--ink); }

/* Steps / Cards / Grids */
.steps-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.step-card, .info-card, .ratio-card, .related-card, .variation-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.step-num, .ratio-badge {
  display: inline-block; font-family: var(--font-mono); font-size: 12px;
  font-weight: 600; color: var(--accent); margin-bottom: 8px;
}
.step-title, .info-card h3, .ratio-card h3 { margin: 0 0 8px; font-size: 17px; color: var(--ink); }
.step-desc, .info-card p, .ratio-card p { margin: 0; font-size: 14px; color: var(--muted); }
.info-card-accent { border-color: var(--accent); background: var(--panel); }

.two-col-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ratio-grid { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* Quick Alphabet Strip */
.quick-alpha-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px;
}
.qa-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60px; padding: 8px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.qa-chip:hover, .qa-chip.is-playing { border-color: var(--accent); background: var(--panel); }
.qa-char { font-size: 18px; font-weight: 700; line-height: 1.1; }
.qa-code { font-family: var(--font-mono); font-size: 13px; color: var(--accent); margin-top: 4px; }

/* Translator Deck & Tool Panels */
.tool-stage { margin-top: 8px; }
.deck {
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden;
}
.deck-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.mode-group { display: flex; flex-wrap: wrap; gap: 6px; }
.mode-btn {
  min-height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
}
.mode-btn:hover { background: var(--panel); color: var(--ink); }
.mode-btn[aria-pressed="true"] { background: var(--accent-tint); color: var(--ink); border-color: var(--accent); }
.local-badge { margin: 0; font-size: 12px; color: var(--accent); font-family: var(--font-mono); }

.deck-panes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.deck-pane { display: flex; flex-direction: column; padding: 18px 20px; min-width: 0; }
.deck-pane-out { border-left: 1px solid var(--line); }
.pane-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); }
.pane-textarea {
  margin-top: 10px; min-height: 170px; max-height: 360px; overflow-y: auto; width: 100%; resize: vertical;
  border: 0; background: transparent; color: var(--ink);
  font-family: var(--font-sans); font-size: 22px; line-height: 1.5; outline: none;
}
.pane-textarea::placeholder { color: var(--faint); }
.pane-output {
  margin-top: 10px; min-height: 170px; max-height: 360px; overflow-y: auto; contain: content; flex: 1; overflow-wrap: anywhere; white-space: pre-wrap;
  font-family: var(--font-mono); font-size: 22px; line-height: 1.55; color: var(--ink);
}
.pane-placeholder { font-family: var(--font-sans); font-size: 16px; color: var(--faint); }
.pane-meta {
  margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px; font-size: 12px; color: var(--faint);
}
.meta-warn { color: var(--amber); font-weight: 500; }
.chip-row { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); }
.chip-btn {
  min-height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  font-family: var(--font-mono); font-size: 12px; cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); color: var(--ink); }

.deck-rail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid var(--line);
}
.rail-spacer { flex: 1; }

.flash-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line); background: var(--amber-tint); font-size: 14px;
}
.signal-lamp {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--amber); background: var(--bg); transition: background 0.04s, box-shadow 0.04s;
}
.signal-lamp.is-lit { background: var(--amber); box-shadow: 0 0 28px 6px var(--amber); }
.flash-msg { color: var(--amber); flex: 1; min-width: 200px; }

.deck-settings {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 20px;
  padding: 16px; border-top: 1px solid var(--line); background: var(--panel);
}
.slider-box { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slider-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.slider-head label { font-weight: 600; color: var(--ink); }
.slider-val { font-family: var(--font-mono); color: var(--accent); font-weight: 600; font-size: 13px; }
.slider-box input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.check-inline input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Alphabet Page */
.alpha-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); margin-bottom: 20px;
}
.alpha-search {
  flex: 1; min-width: 200px; min-height: 44px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font-size: 15px;
}
.alpha-wpm { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.alpha-wpm input[type="range"] { width: 120px; accent-color: var(--accent); }
.alpha-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.alpha-group { margin-bottom: 32px; }
.alpha-group h2 { margin: 0 0 14px; font-size: 22px; }
.alpha-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px;
}
.alpha-card {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  contain: layout style paint;
  transition: border-color 0.15s;
}
.alpha-card:hover, .alpha-card.is-playing { border-color: var(--accent); }
.alpha-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.alpha-char { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1; }
.alpha-code { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--accent); letter-spacing: 0.05em; }
.alpha-label { font-size: 12px; color: var(--faint); margin: -2px 0 0; }
.alpha-bars { display: flex; align-items: center; gap: 4px; height: 8px; }
.bar-dot { width: 8px; height: 6px; border-radius: 3px; background: var(--accent); }
.bar-dash { width: 22px; height: 6px; border-radius: 3px; background: var(--accent-strong); }
.alpha-actions { display: flex; gap: 6px; margin-top: auto; }
.alpha-btn {
  flex: 1; min-height: 32px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.alpha-btn:hover { border-color: var(--accent); color: var(--ink); }

/* Binary Tree */
.tree-box {
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  background: var(--surface); padding: 20px; margin-top: 12px;
}
.tree-readout {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line); margin-bottom: 14px;
  font-size: 14px; color: var(--muted);
}
.tree-readout strong { color: var(--accent); font-family: var(--font-mono); }
.tree-scroll { overflow-x: auto; }
.tree-svg { width: 100%; min-width: 720px; height: auto; display: block; }
.tree-edge { stroke: var(--line-strong); stroke-width: 1.5; fill: none; }
.tree-edge.is-dot { stroke: var(--accent); stroke-opacity: 0.45; }
.tree-edge.is-dash { stroke: var(--amber); stroke-opacity: 0.45; }
.tree-edge.is-path { stroke: var(--accent); stroke-opacity: 1; stroke-width: 3; }
.tree-node { cursor: pointer; }
.tree-node circle { fill: var(--panel); stroke: var(--line-strong); stroke-width: 1.5; transition: fill 0.15s, stroke 0.15s; }
.tree-node:hover circle, .tree-node.is-active circle { fill: var(--accent-tint); stroke: var(--accent); stroke-width: 2.2; }
.tree-node text { fill: var(--ink); font-family: var(--font-mono); font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.tree-legend { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--faint); }

.download-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.dl-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.dl-card h3 { margin: 0 0 6px; font-size: 17px; }
.dl-card p { margin: 0; font-size: 14px; color: var(--muted); }

/* Practice & Keyer */
.tab-bar {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.practice-body { padding: 20px; }
.practice-grid { display: grid; grid-template-columns: 1.35fr 0.85fr; gap: 20px; }
.sub-panel {
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg); padding: 18px;
}
.koch-active-chars { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.koch-char-pill {
  min-height: 36px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-family: var(--font-mono); font-size: 13px; cursor: pointer;
}
.koch-char-pill span { color: var(--accent); margin-left: 4px; }
.koch-char-pill:hover { border-color: var(--accent); }
.koch-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 5px; margin-top: 12px; }
.koch-lesson-btn {
  height: 34px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--faint); font-family: var(--font-mono);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.koch-lesson-btn.is-unlocked { color: var(--ink); border-color: var(--line-strong); }
.koch-lesson-btn.is-current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.drill-input {
  width: 100%; min-height: 92px; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-family: var(--font-mono); font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase;
  resize: vertical;
}
.score-box {
  margin-top: 14px; padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
}
.score-big { font-size: 26px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.diff-line { font-family: var(--font-mono); font-size: 15px; letter-spacing: 0.08em; margin-top: 8px; word-break: break-all; }
.diff-ok { color: var(--accent); }
.diff-miss { color: var(--danger); text-decoration: underline; }

/* Straight-Key Tapper */
.tapper-pad {
  width: 100%; min-height: 150px; border-radius: var(--radius-lg);
  border: 2px solid var(--accent); background: var(--panel);
  color: var(--ink); font-size: 20px; font-weight: 700; cursor: pointer;
  user-select: none; touch-action: none; transition: transform 0.04s, background 0.04s, box-shadow 0.04s;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.tapper-pad.is-down {
  background: var(--accent); color: var(--accent-ink);
  transform: scale(0.99); box-shadow: 0 0 28px var(--accent-tint);
}
.tapper-sub { font-size: 13px; font-weight: 500; opacity: 0.85; }
.rhythm-meter {
  margin-top: 14px; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
}
.rhythm-bar-track {
  position: relative; height: 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); margin: 8px 0; overflow: hidden;
}
.rhythm-bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.08s; }
.tapper-out {
  margin-top: 14px; padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
}
.tapper-morse { font-family: var(--font-mono); font-size: 20px; color: var(--accent); word-break: break-word; min-height: 28px; }
.tapper-text { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--ink); margin-top: 6px; min-height: 30px; }

/* Generator & Decoder Studios */
.studio-grid { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 16px; }
.studio-card {
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  background: var(--surface); padding: 20px; min-width: 0;
  contain: layout style;
}
.studio-card-full { grid-column: 1 / -1; }
.studio-h2 { margin: 0; font-size: 19px; font-weight: 700; }
.studio-sub { margin: 4px 0 0; font-size: 13px; color: var(--faint); }
.studio-textarea {
  margin-top: 14px; width: 100%; min-height: 120px; padding: 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-family: var(--font-mono);
  font-size: 17px; line-height: 1.5; resize: vertical;
}
.signal-preview-box {
  margin-top: 12px; padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg);
}
.signal-preview-code { margin: 6px 0 0; max-height: 180px; overflow-y: auto; contain: content; font-family: var(--font-mono); font-size: 14px; color: var(--accent); word-break: break-word; }
.metrics-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.metric-box { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); }
.metric-k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 0; }
.metric-v { font-size: 16px; font-weight: 700; font-family: var(--font-mono); color: var(--ink); margin: 4px 0 0; }

.timeline-scroll { margin-top: 14px; overflow-x: auto; padding: 12px 0; }
.timeline-track { display: flex; align-items: flex-end; gap: 4px; min-height: 84px; }
.t-bar { display: block; width: 9px; border-radius: 4px; flex-shrink: 0; }
.t-dot { height: 28px; background: var(--accent); }
.t-dash { height: 68px; background: var(--accent-strong); }

/* Decoder specific */
.dropzone {
  margin-top: 14px; padding: 26px 16px; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--bg); transition: border-color 0.15s, background 0.15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--panel); }
.preset-row { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.tuning-box {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
  display: grid; gap: 14px;
}
.env-canvas {
  width: 100%; height: 130px; display: block; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); margin-top: 12px;
}
.meter-bar {
  height: 10px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--line); overflow: hidden; margin-top: 10px;
}
.meter-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.06s; }
.warn-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.warn-pill {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--amber-tint); color: var(--amber); border: 1px solid var(--amber);
}

/* Phrase Pages */
.phrase-answer {
  margin-top: 18px; padding: 22px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); background: var(--surface);
}
.phrase-eq {
  margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  font-size: clamp(22px, 3.6vw, 34px); font-weight: 700;
}
.phrase-eq-sign { color: var(--faint); }
.phrase-morse { color: var(--accent); font-family: var(--font-mono); letter-spacing: 0.06em; word-break: break-word; }
.phrase-morse-sm { color: var(--accent); font-family: var(--font-mono); font-size: 20px; margin-left: 8px; }
.phrase-player { margin-top: 16px; }
.player-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.player-meta { margin: 12px 0 0; font-size: 13px; color: var(--faint); }
.dual-players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.dual-h2 { margin: 0 0 8px; font-size: 24px; }
.timing-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  margin-top: 14px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line); min-height: 40px;
}
.ts-dot { width: 10px; height: 10px; border-radius: 4px; background: var(--accent); }
.ts-dash { width: 30px; height: 10px; border-radius: 4px; background: var(--accent-strong); }
.ts-gap { width: 12px; height: 10px; }
.ts-word { width: 2px; height: 18px; background: var(--line-strong); margin: 0 8px; }

.variation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.variation-card { display: block; color: var(--ink); transition: border-color 0.15s; }
.variation-card:hover { border-color: var(--accent); text-decoration: none; }
.var-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.var-title { margin: 0; font-size: 16px; }
.var-code { font-size: 13px; color: var(--accent); }
.var-desc { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* Learn Page */
.jump-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.jump-pill {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600;
}
.jump-pill:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.jump-pill-accent { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.rhythm-demo-box {
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); margin: 16px 0;
}
.rhythm-demo-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.rhythm-demo-label { margin: 0; font-size: 14px; color: var(--ink); font-weight: 600; }
.contrast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.contrast-card {
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.contrast-head { margin-bottom: 12px; }
.contrast-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.contrast-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); cursor: pointer;
}
.contrast-btn:hover { border-color: var(--accent); }
.c-char { font-size: 22px; font-weight: 700; }
.c-code { font-family: var(--font-mono); color: var(--accent); font-size: 15px; }
.c-spoken { font-size: 12px; color: var(--faint); }
.contrast-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.radio-rhythm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.radio-card {
  text-align: left; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.radio-card:hover { border-color: var(--accent); }
.radio-top { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.radio-hear { font-size: 12px; color: var(--accent); font-weight: 600; }
.radio-card .mono-code { margin: 6px 0; color: var(--accent); font-size: 16px; }
.radio-desc { margin: 0; font-size: 13px; color: var(--muted); }

/* FAQ & Related */
.faq-list { display: grid; gap: 10px; }
.faq-item {
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); overflow: hidden;
}
.faq-q {
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 16px 18px; cursor: pointer; font-weight: 600; color: var(--ink);
}
.faq-q::-webkit-details-marker { display: none; }
.faq-plus { font-family: var(--font-mono); color: var(--accent); font-size: 18px; flex-shrink: 0; transition: transform 0.15s; }
.faq-item[open] .faq-plus { transform: rotate(45deg); }
.faq-a { margin: 0; padding: 0 18px 16px; color: var(--muted); font-size: 15px; max-width: 72ch; }

.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.related-card { display: block; color: var(--ink); transition: border-color 0.15s, background 0.15s; }
.related-card:hover { border-color: var(--accent); background: var(--panel); text-decoration: none; }
.related-title { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.related-desc { margin: 0; font-size: 14px; color: var(--muted); }
.related-desc.mono-code { color: var(--accent); font-size: 14px; }

/* Doc & 404 */
.doc-head { margin-bottom: 28px; }
.doc-updated { margin: 10px 0 0; font-size: 14px; color: var(--faint); }
.notfound-wrap { padding: 80px 0; text-align: center; }
.notfound-code { font-family: var(--font-mono); font-size: 28px; color: var(--accent); margin: 0 0 12px; letter-spacing: 0.12em; }
.notfound-wrap .page-lead { margin-left: auto; margin-right: auto; }
.notfound-actions { margin-top: 24px; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }

/* Footer */
.site-footer {
  margin-top: 64px; border-top: 1px solid var(--line);
  padding: 40px 0 36px; font-size: 14px; color: var(--faint);
  content-visibility: auto; contain-intrinsic-size: auto 280px;
}
.footer-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
.footer-heading {
  margin: 0 0 12px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint);
}
.footer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-link { color: var(--muted); }
.footer-link:hover { color: var(--ink); }
.footer-meta {
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px;
}
.footer-meta p { margin: 0; }

/* Responsive */
@media (max-width: 900px) {
  .nav-desktop { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; }
  .deck-panes, .studio-grid, .practice-grid, .dual-players, .two-col-cards { grid-template-columns: 1fr; }
  .deck-pane-out { border-left: 0; border-top: 1px solid var(--line); }
  .deck-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps-grid, .download-grid, .related-grid, .radio-rhythm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ratio-grid, .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .page-h1 { font-size: 28px; }
  .deck-settings, .steps-grid, .download-grid, .related-grid, .radio-rhythm-grid, .ratio-grid, .footer-grid {
    grid-template-columns: 1fr;
  }
  .deck-rail .btn-primary, .deck-rail .btn-outline, .player-actions .btn-primary {
    flex: 1 1 auto;
  }
  .rail-spacer { display: none; }
  .pane-textarea, .pane-output { font-size: 19px; min-height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Print stylesheet for Alphabet Chart */
@media print {
  html, body { background: #ffffff !important; color: var(--accent-ink) !important; }
  .prose-sec, .faq-sec, .site-footer { content-visibility: visible !important; contain-intrinsic-size: none !important; }
  body > header, body > footer, [data-print="hide"] { display: none !important; }
  .wrap { width: 100%; max-width: none; }
  .page-wrap { padding: 0; }
  h1, h2, h3, p, span, li, .alpha-char { color: var(--accent-ink) !important; }
  .alpha-grid { grid-template-columns: repeat(6, 1fr) !important; gap: 6px !important; }
  .alpha-card { background: #ffffff !important; border: 1px solid var(--faint) !important; padding: 6px 8px !important; break-inside: avoid; }
  .alpha-code { color: var(--accent-ink) !important; font-size: 12px !important; }
  .alpha-char { font-size: 16px !important; }
  .bar-dot, .bar-dash { background: var(--accent-ink) !important; }
  .alpha-actions, .alpha-toolbar, .alpha-jump { display: none !important; }
}
