/* ============================================================
   Morse Dojo — one stylesheet, no dependencies, light and dark.

   The look borrows from radio equipment rather than from software:
   a dark instrument face, one warm accent for anything keyed or live,
   a cool accent for anything measured. Monospace wherever a number
   changes, so it never jitters.
   ============================================================ */

/*
 * Dark is the default, and it is the default in the CSS rather than being
 * swapped in by JavaScript. Two reasons: this is a site people use in the
 * evening with headphones on, where a white page is an assault; and doing
 * it this way round means there is no flash of white before the script
 * runs, which there would be if the stylesheet said light and the theme
 * were applied afterwards.
 *
 * Light is an explicit choice. "Auto" follows the system.
 */
:root,
:root[data-theme="dark"],
:root[data-theme="auto"] {
  color-scheme: dark;
  --bg: #080b14;
  --bg-glow: rgba(60, 130, 255, .13);
  --surface: #101725;
  --surface-2: #161f31;
  --surface-3: #1e2941;
  --text: #e6ecf7;
  --muted: #9aa8c2;
  --faint: #6b7a95;
  --border: #23304a;
  --border-strong: #33415f;
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, .14);
  --key: #ffab45;
  --key-soft: rgba(255, 171, 69, .15);
  --ring: rgba(91, 157, 255, .38);
  --ok: #4bd693;
  --ok-soft: rgba(75, 214, 147, .13);
  --warn: #f2b45c;
  --warn-soft: rgba(242, 180, 92, .14);
  --bad: #ff7d86;
  --bad-soft: rgba(255, 125, 134, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 38px -20px rgba(0, 0, 0, .85);
  --shadow-pop: 0 14px 40px -12px rgba(0, 0, 0, .9);

  --radius: 14px;
  --radius-sm: 9px;
  --gap: .75rem;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --rail-w: 300px;
}

/* Chosen light. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-glow: rgba(56, 132, 255, .10);
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef2f9;
  --text: #101828;
  --muted: #5b6780;
  --faint: #94a0b5;
  --border: #e2e8f2;
  --border-strong: #cfd8e6;
  --accent: #1f6feb;
  --accent-soft: rgba(31, 111, 235, .10);
  --key: #e07b16;
  --key-soft: rgba(224, 123, 22, .12);
  --ring: rgba(31, 111, 235, .30);
  --ok: #147a4a;
  --ok-soft: rgba(20, 122, 74, .12);
  --warn: #9a6100;
  --warn-soft: rgba(154, 97, 0, .12);
  --bad: #c02b39;
  --bad-soft: rgba(192, 43, 57, .10);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 30px -16px rgba(16, 24, 40, .25);
  --shadow-pop: 0 10px 34px -10px rgba(16, 24, 40, .32);
}

/* Auto, on a system set to light. */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
  --bg: #f5f7fb;
  --bg-glow: rgba(56, 132, 255, .10);
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef2f9;
  --text: #101828;
  --muted: #5b6780;
  --faint: #94a0b5;
  --border: #e2e8f2;
  --border-strong: #cfd8e6;
  --accent: #1f6feb;
  --accent-soft: rgba(31, 111, 235, .10);
  --key: #e07b16;
  --key-soft: rgba(224, 123, 22, .12);
  --ring: rgba(31, 111, 235, .30);
  --ok: #147a4a;
  --ok-soft: rgba(20, 122, 74, .12);
  --warn: #9a6100;
  --warn-soft: rgba(154, 97, 0, .12);
  --bad: #c02b39;
  --bad-soft: rgba(192, 43, 57, .10);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 30px -16px rgba(16, 24, 40, .25);
  --shadow-pop: 0 10px 34px -10px rgba(16, 24, 40, .32);
  }
}

/* ------------------------------------------------------------------ *
   base
 * ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

/* Any rule that sets `display` beats the browser's default styling of the
   hidden attribute, and several below do. Say it once, loudly, here. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 50% -220px, var(--bg-glow), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0 0 .35rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .92rem; }
p { margin: 0 0 .6rem; }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

.mono { font-family: var(--mono); }
.muted-cell { color: var(--muted); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------------ *
   topbar
 * ------------------------------------------------------------------ */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1560px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem;
}

.brand {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.02rem; letter-spacing: -.02em;
  text-decoration: none; color: var(--text); flex: none;
}
.brand-mark {
  font-family: var(--mono); font-size: 1.15rem; letter-spacing: .05em;
  color: var(--key);
  background: var(--key-soft);
  border-radius: 8px; padding: .1rem .45rem;
}
.brand-accent { color: var(--accent); }

.tabs { display: flex; gap: .1rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  text-decoration: none;
  display: flex; align-items: center; gap: .4rem;
  padding: .48rem .7rem; border-radius: var(--radius-sm);
  color: var(--muted); font: inherit; font-size: .87rem; font-weight: 550;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); }
.tab-icon { font-size: .95rem; }

.topbar-actions { display: flex; gap: .25rem; flex: none; }

.icon-btn {
  appearance: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); font-size: .95rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ------------------------------------------------------------------ *
   the speed strip — always visible, because it is always wanted
 * ------------------------------------------------------------------ */

.strip-wrap {
  position: sticky; top: 47px; z-index: 30;
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.speed-strip {
  max-width: 1560px; margin: 0 auto;
  padding: .45rem 1rem;
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
}

.slider { display: flex; align-items: center; gap: .45rem; min-width: 190px; }
.slider-label { font-size: .74rem; color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; }
.slider-value {
  font-family: var(--mono); font-size: .78rem; color: var(--text);
  min-width: 62px; text-align: right;
}
.slider.is-off { opacity: .45; }

input[type=range] {
  appearance: none; -webkit-appearance: none;
  height: 4px; border-radius: 4px; flex: 1; min-width: 70px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%));
  background: var(--surface-3);
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}

.strip-presets { display: flex; gap: .25rem; flex-wrap: wrap; }
.strip-test { margin-left: auto; }

.chip {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .76rem;
  padding: .22rem .55rem; border-radius: 100px;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ *
   layout
 * ------------------------------------------------------------------ */

.shell {
  max-width: 1560px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w);
  gap: 1.4rem; padding: 1.2rem 1rem 0;
}
body:not(.has-ads) .shell,
.shell:has(.rail > [hidden]) { grid-template-columns: minmax(0, 1fr); }
body:not(.has-ads) .rail { display: none; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
}

main { min-width: 0; }

.panel { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.panel-head { margin-bottom: 1rem; }
.lede { color: var(--muted); max-width: 78ch; margin: 0; }

.rule { border: 0; border-top: 1px solid var(--border); margin: 2rem 0 1.2rem; }

.split {
  display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 1.2rem; align-items: start;
}
@media (max-width: 940px) { .split { grid-template-columns: minmax(0, 1fr); } }

.pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem;
  box-shadow: var(--shadow);
}
.pane-library { max-height: calc(100vh - 190px); overflow-y: auto; position: sticky; top: 106px; }
@media (max-width: 940px) { .pane-library { position: static; max-height: none; } }

.pane-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.pane-tools { display: flex; gap: .3rem; }

/* ------------------------------------------------------------------ *
   buttons, fields
 * ------------------------------------------------------------------ */

.btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: .86rem; font-weight: 550;
  padding: .42rem .8rem; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: .35rem;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-big { font-size: 1rem; padding: .65rem 1.3rem; }
.btn-wide { width: 100%; justify-content: center; margin-top: .5rem; }

.linkish {
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--accent); text-decoration: underline;
  text-underline-offset: 2px;
}

.row { display: flex; gap: .5rem; align-items: center; margin: .6rem 0; }
.row-wrap { flex-wrap: wrap; }

.input, .textarea, select.input {
  font: inherit; font-size: .88rem;
  padding: .45rem .6rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); width: 100%; min-width: 0;
}
.input-big { font-size: 1.05rem; padding: .6rem .8rem; }
.textarea { resize: vertical; line-height: 1.5; }
.textarea.mono { font-family: var(--mono); font-size: .85rem; letter-spacing: .05em; word-spacing: .7em; }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .7rem; }
.field-inline { margin-bottom: 0; }
.field-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.field-hint { font-size: .8rem; color: var(--muted); margin: .25rem 0 0; max-width: 74ch; }

.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 2px; gap: 2px; flex-wrap: wrap;
}
.seg-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: .8rem; color: var(--muted);
  padding: .28rem .6rem; border-radius: 6px; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.switch { display: flex; gap: .55rem; align-items: flex-start; cursor: pointer; margin-bottom: .6rem; }
.switch input {
  margin-top: .25rem; flex: none;
  width: 16px; height: 16px;
  accent-color: var(--accent);
  /* Left to itself an unchecked box renders as a dark block in some
     engines, which reads as "on". Draw it as an outline instead. */
  appearance: none; -webkit-appearance: none;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  background: var(--surface); cursor: pointer;
  display: inline-grid; place-content: center;
}
.switch input::before {
  content: ''; width: 8px; height: 8px; border-radius: 2px;
  transform: scale(0); transition: transform .1s;
  box-shadow: inset 1em 1em var(--accent);
}
.switch input:checked { border-color: var(--accent); }
.switch input:checked::before { transform: scale(1); }
.switch-body { display: flex; flex-direction: column; }
.switch-label { font-size: .87rem; font-weight: 550; }
.switch-hint { font-size: .78rem; color: var(--muted); }
.switch-inline { margin: 0; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.warning {
  background: var(--warn-soft); border-left: 3px solid var(--warn);
  padding: .5rem .7rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .84rem; color: var(--text);
}

.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: .3rem; }
.empty-hint { font-size: .85rem; max-width: 46ch; margin: 0 auto; }

.note-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1rem 0;
}
.note-card h3 { margin-bottom: .5rem; }
.note-card p { color: var(--muted); max-width: 80ch; }

.section-title { margin-top: 1.6rem; margin-bottom: .5rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 480px; }
.table th, .table td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

.tag {
  font-size: .66rem; font-family: var(--mono);
  background: var(--surface-3); color: var(--muted);
  padding: .05rem .3rem; border-radius: 4px;
}

/* ------------------------------------------------------------------ *
   the exercise library
 * ------------------------------------------------------------------ */

.library-filters { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .6rem; }
.library-count { font-size: .78rem; color: var(--faint); margin: 0 0 .4rem; font-family: var(--mono); }
.library-list { display: flex; flex-direction: column; gap: 2px; }

.list-heading {
  display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap;
  font-size: .82rem; font-weight: 650; color: var(--text);
  margin: .9rem 0 .3rem; padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.list-heading:first-child { margin-top: 0; }
.list-heading-icon { font-size: .95rem; }
.list-heading-blurb { font-size: .72rem; font-weight: 400; color: var(--faint); flex-basis: 100%; }

.item { display: flex; align-items: stretch; gap: 2px; border-radius: var(--radius-sm); }
.item:hover { background: var(--surface-2); }
.item.is-open { background: var(--accent-soft); }

.item-main {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; color: inherit;
  flex: 1; min-width: 0; padding: .35rem .5rem;
  display: flex; flex-direction: column; gap: .05rem;
}
.item-text { font-size: .87rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-note { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: flex; gap: .45rem; align-items: center; font-size: .7rem; color: var(--faint); font-family: var(--mono); }
.item-code { word-spacing: .5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .08em; }
.item-play { width: 30px; height: 30px; align-self: center; flex: none; }

/* ------------------------------------------------------------------ *
   the trainer
 * ------------------------------------------------------------------ */

.trainer-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .7rem; }
.trainer-title { font-size: 1.1rem; }
.trainer-sub { font-size: .8rem; color: var(--muted); margin: 0; }
.trainer-controls { display: flex; gap: .4rem; flex-wrap: wrap; margin: .8rem 0 .3rem; }
.trainer-hint { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; }

.scoreboard {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: .7rem;
}
.score-cell { background: var(--surface-2); padding: .45rem .5rem; text-align: center; }
.score-value { display: block; font-family: var(--mono); font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
.score-label { display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }

.copysheet {
  position: relative;
  min-height: 130px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: .9rem;
  cursor: text;
}
.copysheet:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

.play-rail { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--surface-3); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.play-rail-fill { display: block; height: 100%; width: 0; background: var(--key); transition: width .1s linear; }

.sheet-line { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin-top: .4rem; }

.tile {
  font-family: var(--mono); font-size: 1.05rem; font-weight: 600;
  width: 1.5em; height: 1.9em;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; background: var(--surface-3); color: var(--text);
}
.tile.is-ok { background: var(--ok-soft); color: var(--ok); }
.tile.is-bad { background: var(--bad-soft); color: var(--bad); }
.tile-space { width: .7em; background: transparent; }
.tile-caret {
  width: 3px; background: var(--accent); border-radius: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: .2; } }

.lag {
  font-size: .7rem; color: var(--faint); margin-left: .6rem;
  font-family: var(--mono); white-space: nowrap;
}
.lag.is-far { color: var(--warn); }
.lag.is-ahead { color: var(--accent); }

.sheet-placeholder { color: var(--faint); font-size: .87rem; margin: .5rem 0 0; }
.sheet-code {
  font-family: var(--mono); font-size: 1.3rem; letter-spacing: .18em;
  color: var(--key); margin: .5rem 0 0;
}
.sheet-answer { font-family: var(--mono); font-size: .85rem; color: var(--faint); margin: .4rem 0 0; letter-spacing: .04em; }

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

/* results */

.result {
  margin-top: .9rem; padding: .9rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.result-head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; margin-bottom: .6rem; }
.result-score { font-family: var(--mono); font-size: 1.9rem; font-weight: 700; color: var(--key); }
.result-score.is-good { color: var(--ok); }
.result-verdict { font-size: .9rem; color: var(--muted); }
.result-note { font-size: .84rem; color: var(--muted); }
.result-chars { font-family: var(--mono); font-weight: 700; color: var(--bad); letter-spacing: .12em; }

.diff { display: flex; flex-wrap: wrap; gap: 2px; margin: .5rem 0 .8rem; font-family: var(--mono); }
.dchar {
  min-width: 1.4em; padding: .1rem .15rem; border-radius: 4px;
  text-align: center; font-size: .95rem;
  display: inline-flex; flex-direction: column; line-height: 1.1;
}
.dchar.is-ok { background: var(--ok-soft); color: var(--ok); }
.dchar.is-wrong { background: var(--bad-soft); color: var(--bad); }
.dchar.is-missed { background: var(--warn-soft); color: var(--warn); text-decoration: line-through; }
.dchar.is-extra { background: var(--surface-3); color: var(--faint); }
.dchar-sent { font-size: .95rem; }
.dchar-got { font-size: .62rem; opacity: .75; }

/* per-character bars */

.charbars { display: flex; flex-direction: column; gap: 3px; margin: .6rem 0; }
.charbar { display: grid; grid-template-columns: 1.4rem 4.5rem 1fr 2.6rem; gap: .5rem; align-items: center; font-size: .8rem; }
.charbar-char { font-family: var(--mono); font-weight: 700; }
.charbar-code { font-family: var(--mono); color: var(--faint); font-size: .74rem; letter-spacing: .1em; }
.charbar-pct { font-family: var(--mono); text-align: right; color: var(--muted); font-size: .75rem; }

.bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-ok .bar-fill { background: var(--ok); }
.bar-warn .bar-fill { background: var(--warn); }
.bar-bad .bar-fill { background: var(--bad); }

/* ------------------------------------------------------------------ *
   the course
 * ------------------------------------------------------------------ */

.lesson-map {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: .35rem; margin-bottom: 1.2rem;
}
.lesson-tile {
  appearance: none; cursor: pointer; position: relative;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: .35rem .2rem;
  display: flex; flex-direction: column; align-items: center; gap: .05rem;
  font: inherit; color: var(--text);
}
.lesson-tile:hover { border-color: var(--accent); }
.lesson-tile.is-locked { opacity: .38; cursor: not-allowed; }
.lesson-tile.is-current { border-color: var(--accent); background: var(--accent-soft); }
.lesson-tile.is-passed { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.lesson-num { font-size: .62rem; color: var(--faint); font-family: var(--mono); }
.lesson-char { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.lesson-tick { position: absolute; top: 2px; right: 4px; font-size: .6rem; color: var(--ok); }

.lesson-head { display: flex; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: .9rem; }
.newchar { display: flex; align-items: center; gap: .7rem; }
.newchar-glyph {
  appearance: none; cursor: pointer;
  width: 62px; height: 62px; border-radius: var(--radius);
  border: 2px solid var(--key); background: var(--key-soft); color: var(--key);
  font-family: var(--mono); font-size: 2rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.newchar-glyph:hover { background: var(--key); color: #fff; }
.newchar-code { display: block; font-family: var(--mono); font-size: 1.15rem; letter-spacing: .18em; color: var(--key); }
.newchar-mnemonic { display: block; font-size: .8rem; color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------------ *
   the tuner
 * ------------------------------------------------------------------ */

.band-row { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .4rem; }

.wf-wrap {
  position: relative; margin: .9rem 0 .2rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  overflow: hidden; background: #05070d; cursor: crosshair;
}
#waterfall { display: block; width: 100%; height: 220px; }
.wf-overlay {
  position: absolute; top: 0; bottom: 18px;
  border-left: 1px solid rgba(255, 171, 69, .9);
  border-right: 1px solid rgba(255, 171, 69, .9);
  background: rgba(255, 171, 69, .10);
  pointer-events: none;
}
.wf-scale {
  position: absolute; left: 0; right: 0; bottom: 0; height: 18px;
  background: rgba(0, 0, 0, .55); pointer-events: none;
}
.wf-tick {
  position: absolute; bottom: 2px; transform: translateX(-50%);
  padding: 0 .15rem;
  font-family: var(--mono); font-size: .6rem; color: rgba(200, 225, 255, .8);
}

.dial-row { display: flex; align-items: center; gap: .4rem; margin: .4rem 0; }
.dial { flex: 1; }

.rx-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.readout {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 700;
  color: var(--key); background: var(--key-soft);
  padding: .1rem .6rem; border-radius: var(--radius-sm);
  letter-spacing: .02em;
}
.s-meter { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 200px; }
.s-meter-track { flex: 1; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.s-meter-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--key)); transition: width .08s linear; }
.s-meter-label { font-family: var(--mono); font-size: .74rem; color: var(--muted); white-space: nowrap; }

.rx-controls { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }

.log-panel { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.log-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .4rem; margin-top: .7rem; }
.log-cell {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: .4rem .55rem; display: flex; flex-direction: column; gap: .05rem;
}
.log-cell.is-known { border-style: solid; border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-soft); }
.log-call { font-family: var(--mono); font-weight: 700; font-size: .92rem; letter-spacing: .06em; }
.log-meta { font-size: .7rem; color: var(--muted); }
.log-done { margin-top: .7rem; color: var(--ok); font-weight: 550; }

/* real signals + decoder */

.rx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .6rem; }
.rx-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem .85rem; text-decoration: none; color: inherit;
  background: var(--surface); display: flex; flex-direction: column; gap: .25rem;
}
.rx-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.rx-name { font-weight: 600; font-size: .9rem; }
.rx-note { font-size: .78rem; color: var(--muted); }
.rx-go { font-size: .75rem; color: var(--accent); }

.decode-status { font-size: .8rem; color: var(--muted); margin: .5rem 0; }
.decode-status.is-live { color: var(--ok); font-weight: 600; }
.decode-status.is-live::before {
  content: '●'; margin-right: .35rem; color: var(--bad);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

.scope {
  display: block; width: 100%; height: 60px;
  background: #05070d; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
}
.decode-out {
  font-family: var(--mono); font-size: .95rem; letter-spacing: .12em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .7rem;
  min-height: 5.5rem; max-height: 14rem; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; margin: .5rem 0 .2rem;
}

/* ------------------------------------------------------------------ *
   sending
 * ------------------------------------------------------------------ */

.target-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem; margin: .8rem 0;
}
.target-text { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; letter-spacing: .08em; margin: .2rem 0; }
.target-code { font-family: var(--mono); font-size: .82rem; color: var(--faint); letter-spacing: .06em; word-spacing: .6em; margin: 0; }

.paddle-row { display: flex; gap: .6rem; align-items: stretch; margin: 1rem 0; }

.key-pad {
  appearance: none; cursor: pointer; flex: 1;
  min-height: 130px; border-radius: var(--radius);
  border: 2px solid var(--border-strong);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  color: var(--muted); font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  user-select: none; -webkit-user-select: none; touch-action: none;
  transition: transform .04s, background .04s;
}
.key-pad.is-down {
  background: var(--key); border-color: var(--key); color: #1a1206;
  transform: translateY(2px);
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, .25);
}
.key-label { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; letter-spacing: .2em; }
.key-hint { font-size: .76rem; }

.paddle {
  appearance: none; cursor: pointer; width: 90px;
  border-radius: var(--radius); border: 2px solid var(--border-strong);
  background: var(--surface-2); color: var(--muted);
  font-family: var(--mono); font-size: .9rem; font-weight: 600;
}
.paddle:active { background: var(--key); color: #1a1206; border-color: var(--key); }

.sent-out {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem .85rem; margin-top: .6rem;
}
.sent-text { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; letter-spacing: .1em; margin: .1rem 0; min-height: 1.6em; }
.sent-code { font-family: var(--mono); font-size: .78rem; color: var(--faint); letter-spacing: .05em; word-spacing: .6em; margin: 0; word-break: break-word; }
/* The character still being keyed: shown, but visibly not committed. */
.sent-open { color: var(--key); opacity: .8; }
.sent-waiting { color: var(--faint); animation: blink 1s steps(2) infinite; }

.fist { margin-top: 1rem; }
.fist-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .5rem; }
.fist-score { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; color: var(--accent); }
.fist-label { font-size: .82rem; color: var(--muted); }
.fist-grid { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.fist-row {
  background: var(--surface); padding: .45rem .6rem;
  display: grid; grid-template-columns: 12rem 5.5rem 5rem 1fr; gap: .6rem; align-items: baseline;
  font-size: .82rem;
}
@media (max-width: 760px) { .fist-row { grid-template-columns: 1fr 5rem; } .fist-hint, .fist-ideal { display: none; } }
.fist-name { font-weight: 550; }
.fist-value { font-family: var(--mono); font-weight: 700; }
.fist-value.is-ok { color: var(--ok); }
.fist-value.is-warn { color: var(--warn); }
.fist-value.is-bad { color: var(--bad); }
.fist-ideal { font-family: var(--mono); font-size: .74rem; color: var(--faint); }
.fist-hint { font-size: .76rem; color: var(--muted); }

/* ------------------------------------------------------------------ *
   games
 * ------------------------------------------------------------------ */

.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; }
.game-card {
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 1rem;
  display: flex; flex-direction: column; gap: .3rem;
  font: inherit; color: inherit; box-shadow: var(--shadow);
}
.game-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.game-icon { font-size: 1.8rem; }
.game-name { font-weight: 650; font-size: 1rem; }
.game-blurb { font-size: .82rem; color: var(--muted); }
.game-best { font-size: .74rem; color: var(--faint); font-family: var(--mono); margin-top: .3rem; }

.game-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .8rem; flex-wrap: wrap; }

.blitz-target {
  font-family: var(--mono); font-size: 4.5rem; font-weight: 700;
  text-align: center; padding: 1.4rem 0; color: var(--faint);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  line-height: 1;
}
.blitz-target.is-ok { color: var(--ok); background: var(--ok-soft); }
.blitz-target.is-bad { color: var(--bad); background: var(--bad-soft); }

.rush-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: 1rem 0; }
.rush-option {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 1rem .6rem;
  font-family: var(--mono); font-size: 1.15rem; font-weight: 600; letter-spacing: .06em;
  color: var(--text);
}
.rush-option:hover { border-color: var(--accent); background: var(--accent-soft); }

.pileup-slots { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.pileup-slot {
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700; letter-spacing: .1em;
  padding: .4rem .7rem; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--faint);
}
.pileup-slot.is-found { background: var(--ok-soft); color: var(--ok); }

/* ------------------------------------------------------------------ *
   translate
 * ------------------------------------------------------------------ */

.tr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 780px) { .tr-grid { grid-template-columns: 1fr; } }
.tr-pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem;
}
.tr-controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .9rem 0 .5rem; }

.lamp {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-3); border: 2px solid var(--border-strong);
  flex: none; transition: background .04s, box-shadow .04s;
}
.lamp.is-on {
  background: var(--key); border-color: var(--key);
  box-shadow: 0 0 18px 3px color-mix(in srgb, var(--key) 60%, transparent);
}

.strip {
  display: flex; height: 34px; margin: .7rem 0 .2rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.strip-el { display: block; height: 100%; }
.strip-el.is-on { background: var(--key); }
.strip-el.strip-gap-char { background: color-mix(in srgb, var(--border-strong) 60%, transparent); }
.strip-el.strip-gap-word { background: var(--surface-3); }

.breakdown { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .8rem; }
.bd-cell {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: .25rem .45rem;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  font: inherit; color: inherit; min-width: 2.4rem;
}
.bd-cell:hover { border-color: var(--accent); }
.bd-cell.is-live { background: var(--key); border-color: var(--key); color: #1a1206; }
.bd-char { font-family: var(--mono); font-weight: 700; font-size: .95rem; }
.bd-code { font-family: var(--mono); font-size: .68rem; color: var(--faint); letter-spacing: .08em; }
.bd-cell.is-live .bd-code { color: #1a1206; }
.bd-space { align-self: center; color: var(--faint); font-family: var(--mono); padding: 0 .3rem; }

/* ------------------------------------------------------------------ *
   the chart
 * ------------------------------------------------------------------ */

.chart-body { margin-top: 1rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .4rem; }
.chart-cell {
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: .45rem .55rem;
  display: flex; flex-direction: column; gap: .05rem;
  font: inherit; color: inherit;
}
.chart-cell:hover { border-color: var(--key); background: var(--key-soft); }
.chart-char { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; }
.chart-code { font-family: var(--mono); font-size: .9rem; letter-spacing: .14em; color: var(--key); }
.chart-mnemonic { font-size: .7rem; color: var(--muted); font-style: italic; }
.chart-meaning { font-size: .7rem; color: var(--muted); }

.tree { overflow-x: auto; padding: 1rem 0; }
.tree-node { display: flex; flex-direction: column; align-items: center; }
.tree-kids { display: flex; gap: .35rem; align-items: flex-start; margin-top: .35rem; position: relative; }
.tree-kids::before {
  content: ''; position: absolute; top: -.35rem; left: 25%; right: 25%;
  border-top: 1px solid var(--border-strong);
}
.tree-char {
  appearance: none; cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  font-family: var(--mono); font-weight: 700; font-size: .82rem; color: var(--text);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.tree-char:hover { background: var(--key); border-color: var(--key); color: #1a1206; }
.tree-root { color: var(--faint); font-size: 1.2rem; }
.tree-pass {
  color: var(--faint); font-family: var(--mono); font-size: .9rem;
  width: 26px; height: 26px; flex: none; opacity: .5;
  display: flex; align-items: center; justify-content: center;
}

/* the printable sheet */

.print-sheet { background: #fff; color: #000; padding: 1.4rem; border-radius: var(--radius); margin: 1rem 0; }
.print-sheet h2 { color: #000; }
.print-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.4rem; }
.print-col h4 { border-bottom: 1px solid #000; padding-bottom: .2rem; margin-bottom: .3rem; }
.print-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .88rem; padding: .04rem 0; }
.print-char { font-family: var(--mono); font-weight: 700; }
.print-code { font-family: var(--mono); letter-spacing: .16em; word-spacing: .5em; }
.print-foot { margin-top: 1rem; font-size: .8rem; font-style: italic; }

/* ------------------------------------------------------------------ *
   progress
 * ------------------------------------------------------------------ */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1.4rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow);
}
.stat-value { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat-hint { font-size: .74rem; color: var(--faint); margin-top: .2rem; }

.activity { display: flex; align-items: flex-end; gap: 3px; height: 74px; margin: .6rem 0; }
.activity-bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.activity-bar.is-empty { background: var(--surface-3); }

.heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: .3rem; margin: .7rem 0; }
.heat {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .3rem .1rem; background: var(--surface);
  display: flex; flex-direction: column; align-items: center;
  font: inherit; color: inherit;
}
.heat.is-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.heat.is-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.heat.is-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.heat-char { font-family: var(--mono); font-weight: 700; font-size: 1rem; }
.heat-pct { font-family: var(--mono); font-size: .64rem; color: var(--muted); }

.confusions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.confusion {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: 100px;
  background: var(--surface); padding: .25rem .7rem;
  display: inline-flex; align-items: center; gap: .35rem;
  font: inherit; font-family: var(--mono); font-size: .85rem; color: inherit;
}
.confusion:hover { border-color: var(--bad); }
.cf-from { font-weight: 700; }
.cf-arrow { color: var(--faint); }
.cf-to { font-weight: 700; color: var(--bad); }
.cf-count { font-size: .7rem; color: var(--faint); }

.spark { width: 100%; height: 90px; margin: .5rem 0; }
.spark polyline { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; margin: .7rem 0; }
.badge {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .55rem .7rem; background: var(--surface-2); opacity: .5;
  display: flex; flex-direction: column; gap: .1rem;
}
.badge.is-earned { opacity: 1; background: var(--surface); border-color: color-mix(in srgb, var(--key) 40%, var(--border)); }
.badge-mark { font-size: 1.1rem; }
.badge-name { font-weight: 600; font-size: .87rem; }
.badge-hint { font-size: .74rem; color: var(--muted); }

/* ------------------------------------------------------------------ *
   sheets, toast, flash
 * ------------------------------------------------------------------ */

.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 11, 20, .55); backdrop-filter: blur(3px);
  display: flex; justify-content: flex-end;
}
.sheet-panel {
  width: min(520px, 100%); height: 100%; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head {
  position: sticky; top: 0; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); z-index: 1;
}
.sheet-body { padding: 1.1rem; }
.sheet-section { margin-bottom: 1.8rem; }
.sheet-section h3 { margin-bottom: .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
body.sheet-open { overflow: hidden; }

.condition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .4rem; }
.condition {
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: .5rem .6rem;
  display: flex; flex-direction: column; gap: .1rem;
  font: inherit; color: inherit;
}
.condition.is-active { border-color: var(--accent); background: var(--accent-soft); }
.condition-name { font-weight: 600; font-size: .85rem; }
.condition-hint { font-size: .74rem; color: var(--muted); }

.advice { margin-bottom: .9rem; }
.advice h4 { color: var(--accent); margin-bottom: .15rem; }
.advice p { font-size: .85rem; color: var(--muted); margin: 0; }

.keys { display: flex; flex-direction: column; gap: .35rem; }
.key-row { display: grid; grid-template-columns: 6.5rem 1fr; gap: .6rem; align-items: baseline; font-size: .84rem; }
kbd {
  font-family: var(--mono); font-size: .74rem;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 5px; padding: .1rem .35rem; white-space: nowrap;
}

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: .6rem 1rem; border-radius: 100px; font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow-pop); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s;
  max-width: min(560px, 92vw); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--bad); color: #fff; }
.toast.is-ok { background: var(--ok); color: #fff; }

/* the visual key: a full-screen flash in time with the tone */
.flash-layer {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: var(--key); opacity: 0; transition: opacity .02s;
}
body.flashing .flash-layer { opacity: .30; }

/* ------------------------------------------------------------------ *
   advert slots — space reserved, so nothing moves when they fill
 * ------------------------------------------------------------------ */

.ad-slot { margin: 1rem 0; }
.rail { position: sticky; top: 106px; align-self: start; }
.ad-rail { min-height: 600px; margin: 0; }
.ad-banner { min-height: 90px; max-width: 1560px; margin: 1.4rem auto; padding: 0 1rem; }
.ad-slot-native { min-height: 250px; }

.ad-placeholder {
  display: flex; flex-direction: column; gap: .18rem; justify-content: center; align-items: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); padding: 1rem; text-align: center; color: var(--faint);
  height: 100%; min-height: 90px;
}
.ad-rail .ad-placeholder { min-height: 600px; }
.ad-slot-native .ad-placeholder { min-height: 250px; }
.ad-tag { font-size: .6rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.ad-name { font-size: .85rem; font-weight: 600; color: var(--muted); }
.ad-size { font-family: var(--mono); font-size: .72rem; }
.ad-note { font-size: .72rem; line-height: 1.45; max-width: 32ch; margin-top: .3rem; }

/* ------------------------------------------------------------------ *
   footer
 * ------------------------------------------------------------------ */

.site-foot {
  max-width: 1560px; margin: 2.5rem auto 0; padding: 1.4rem 1rem 2.5rem;
  border-top: 1px solid var(--border); color: var(--muted); font-size: .84rem;
}
.site-foot-links { display: flex; gap: 1rem; flex-wrap: wrap; margin: .5rem 0; }
.site-foot-fine { font-size: .76rem; color: var(--faint); }

/* ------------------------------------------------------------------ *
   landing page
 * ------------------------------------------------------------------ */

.lp-nav { display: flex; gap: 1rem; align-items: center; flex: 1; justify-content: flex-end; font-size: .87rem; }
.lp-nav a { color: var(--muted); text-decoration: none; }
.lp-nav a:hover { color: var(--text); }
.lp-nav .btn-primary { color: #fff; }
@media (max-width: 720px) { .lp-nav a:not(.btn) { display: none; } }

.hero { padding: 3.4rem 1rem 2rem; }
.hero-inner { max-width: 880px; margin: 0 auto; text-align: center; }
.hero-eyebrow {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--key); font-weight: 650;
}
.hero h1 { font-size: clamp(1.9rem, 5vw, 3.1rem); line-height: 1.1; margin: .5rem 0 1rem; }
.hero h1 em { color: var(--key); font-style: normal; }
.hero-lede { font-size: 1.05rem; color: var(--muted); max-width: 62ch; margin: 0 auto 1.8rem; }
.hero-lede em { color: var(--text); font-style: italic; }

.hero-demo {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  max-width: 540px; margin: 0 auto 1.8rem; text-align: left;
  box-shadow: var(--shadow);
}
.hero-demo-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
/* One box per character. The letter under each group is what stops a
   beginner reading "···· ·" as "·····", which is the number 5. */
.hero-demo-code {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: .28rem; margin: .6rem 0 .4rem; min-height: 3rem;
}
.mgroup {
  display: flex; flex-direction: column; align-items: center; gap: .05rem;
  padding: .18rem .34rem; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.mgroup.is-live {
  background: var(--key); border-color: var(--key);
}
.mcode {
  font-family: var(--mono); font-size: 1rem; line-height: 1.35;
  letter-spacing: .1em; color: var(--key); white-space: nowrap;
}
.mletter {
  font-family: var(--mono); font-size: .64rem; font-weight: 700;
  color: var(--faint); letter-spacing: .04em;
}
.mgroup.is-live .mcode, .mgroup.is-live .mletter { color: #1a1206; }
.mgap { align-self: center; color: var(--faint); font-family: var(--mono); padding: 0 .3rem; }
.mgroup-empty { color: var(--faint); font-size: .85rem; align-self: center; }
.hero-demo-hint { font-size: .78rem; color: var(--faint); margin: 0; }

.hero-demo-controls {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: .6rem 0 .5rem; padding-top: .6rem;
  border-top: 1px solid var(--border);
}
.hero-demo-try { margin-left: .4rem; }

/* The alphabet on the landing page: a reference that makes a sound. */
.alpha-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: .35rem; margin: .9rem 0 1.4rem;
}
.alpha-cell {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: .4rem .3rem;
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  font: inherit; color: inherit;
}
.alpha-cell:hover { border-color: var(--key); background: var(--key-soft); }
.alpha-char { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.alpha-code {
  font-family: var(--mono); font-size: .82rem; letter-spacing: .12em;
  color: var(--key); white-space: nowrap;
}

.glossary { margin: 1rem 0 0; max-width: 78ch; }
.glossary dt {
  font-weight: 650; color: var(--accent);
  margin-top: .9rem; font-size: .95rem;
}
.glossary dd {
  margin: .15rem 0 0; color: var(--muted); font-size: .9rem; line-height: 1.55;
}

.hero-cta { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.hero-facts {
  display: flex; gap: 1.8rem; justify-content: center; flex-wrap: wrap;
  list-style: none; padding: 0; margin: 2.2rem 0 0;
  font-size: .84rem; color: var(--muted);
}
.hero-facts b { font-family: var(--mono); font-size: 1.3rem; color: var(--text); display: block; }

.lp-section { max-width: 1100px; margin: 0 auto; padding: 2.6rem 1rem; }
.lp-section h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: .5rem; }
.lp-lede { color: var(--muted); max-width: 70ch; margin-bottom: 1.6rem; }
.lp-prose { max-width: 72ch; color: var(--muted); font-size: .95rem; }
.lp-prose .mono { color: var(--text); }
.lp-ad { max-width: 1100px; margin-left: auto; margin-right: auto; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem; }
.feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.feature h3 { font-size: .98rem; margin-bottom: .3rem; }
.feature p { font-size: .87rem; color: var(--muted); margin: 0; }
.feature em { color: var(--text); font-style: italic; }

.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin-top: 1.6rem; }
.how-step {
  border-left: 2px solid var(--key); padding-left: .9rem;
}
.how-num {
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  color: var(--key); display: block;
}
.how-step h3 { font-size: .95rem; margin: .1rem 0 .2rem; }
.how-step p { font-size: .85rem; color: var(--muted); margin: 0; }

.faq {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: .7rem 1rem; margin-bottom: .5rem;
}
.faq summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
.faq summary::marker { color: var(--key); }
.faq p { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; max-width: 74ch; }
.faq[open] { border-color: var(--border-strong); }

.lp-final { text-align: center; padding-bottom: 3.4rem; }

/* ------------------------------------------------------------------ *
   print — the chart, and nothing else
 * ------------------------------------------------------------------ */

@media print {
  .topbar, .strip-wrap, .rail, .site-foot, .toast, .sheet,
  .ad-slot, .no-print, .seg, .panel-head .lede { display: none !important; }
  body { background: #fff; color: #000; }
  .shell { display: block; padding: 0; }
  .print-sheet { border: 0; padding: 0; }
  .panel[hidden] { display: none !important; }
}

/* ------------------------------------------------------------------ *
   reduced motion
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  body.flashing .flash-layer { opacity: .18; }
}

/* ------------------------------------------------------------------ *
   the signals reference — anything hearable is a button
 * ------------------------------------------------------------------ */

.sig {
  display: inline-flex; flex-direction: column; gap: .05rem;
  cursor: pointer; user-select: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: .25rem .5rem;
  font-family: var(--mono); font-weight: 700; font-size: .9rem;
  letter-spacing: .06em; color: var(--text);
}
.sig:hover { border-color: var(--key); background: var(--key-soft); }
.sig:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sig.is-playing { background: var(--key); border-color: var(--key); color: #1a1206; }
.sig.is-playing .sig-code, .sig.is-playing em { color: #1a1206; }

.sig-code {
  font-family: var(--mono); font-size: .68rem; font-weight: 400;
  letter-spacing: .1em; color: var(--key); white-space: nowrap;
}
.sig em {
  font-style: normal; font-weight: 400; font-size: .68rem;
  letter-spacing: 0; color: var(--muted);
}
.sig-big { font-size: 1.05rem; padding: .45rem .8rem; }
.sig-bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.sig-bad .sig-code { color: var(--bad); }
.sig-warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.sig-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }

.sig-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .9rem 0; }
.station-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem; margin: .9rem 0; }

.exchange { margin: .9rem 0; padding-left: 1.4rem; }
.exchange li { margin-bottom: .55rem; }
.exchange li em { display: block; font-size: .8rem; color: var(--muted); margin-top: .15rem; }

.warn-card { border-left: 3px solid var(--bad); }
.warn-card h3 { color: var(--bad); }

.alarm-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem; margin: 1rem 0;
}
.alarm-count { font-family: var(--mono); font-size: .82rem; color: var(--muted); }

/* the radio room clock, with the silent periods on the face */
.clockwrap { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.rclock { width: 190px; height: 190px; flex: none; }
.rclock-face { fill: var(--surface); }
.rclock-ring { fill: none; stroke: var(--border-strong); stroke-width: 2; }
.rclock-silent { fill: color-mix(in srgb, var(--bad) 45%, transparent); }
.rclock-num { fill: var(--muted); font-family: var(--mono); font-size: 13px; text-anchor: middle; }
.rclock-pin { fill: var(--border-strong); }
.clockwrap .field-hint { flex: 1; min-width: 220px; }

/* ------------------------------------------------------------------ *
   the decoder: one numbered card per job, because "microphone / tab /
   file" are mechanisms and nobody arrives wanting a mechanism
 * ------------------------------------------------------------------ */

.decode-jobs { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }

.decode-job {
  display: flex; gap: .8rem; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem .9rem;
}
.decode-job-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-size: .85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.decode-job-body { flex: 1; min-width: 0; }
.decode-job-body h4 { margin: 0 0 .15rem; font-size: .95rem; }
.decode-job-body .field-hint { margin: 0 0 .55rem; }
