/* AI Radio main styles.
   Tokens and component classes ported from Vail CW School (globals.css),
   written as plain CSS: no framework, no build step. Mobile first. */

:root {
  --color-primary: #008866;
  --color-primary-hover: #009977;
  --color-accent: #00AAFF;
  --color-background: #0A0A0A;
  --color-surface: #1A1A1A;
  --color-elevated: #2A2A2A;
  --color-border: #3A3A3A;
  --color-border-hover: #4A4A4A;
  --color-text: #E0E0E0;
  --color-text-bright: #E8E8E8;
  --color-text-muted: #999999;
  --color-success: #00D1B2;
  --color-active: #FFA500;
  --color-warning: #FF3860;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --radius-card: 16px;
  --radius-control: 12px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--color-accent); }
a:hover { color: #4cc3ff; }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-primary);
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--color-text-muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */

.app { min-height: 100vh; min-height: 100dvh; }

.screen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.screen > main { flex: 1 0 auto; }

.wrap {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
  min-height: 64px;
}

.topbar-title { flex: 1 1 auto; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 20px; font-weight: 700; color: var(--color-text-bright); }
.topbar-title .subtitle { margin: 2px 0 0; font-size: 12px; color: var(--color-text-muted); }
.topbar-title .line1 { font-size: 15px; font-weight: 700; color: var(--color-text-bright); }
.topbar-title .line2 {
  font-size: 12px; color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-control);
  color: var(--color-text);
  transition: background-color 200ms;
}
.icon-btn:hover { background: var(--color-elevated); }
.icon-btn.filled { background: var(--color-elevated); }
.icon-btn.filled:hover { background: var(--color-border); }
.icon-btn svg { width: 20px; height: 20px; }

.stack { display: flex; flex-direction: column; gap: 14px; padding-top: 16px; padding-bottom: 24px; }

/* ---------- Components ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.card.stack-in { display: flex; flex-direction: column; gap: 10px; }

.card-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-text-bright);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Buttons (ported from Vail globals.css) */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 0.75rem;
  font-weight: 600;
  transition: all 200ms;
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  min-height: 2.75rem;
  touch-action: manipulation;
  text-decoration: none;
}
.btn-primary { background-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background-color: var(--color-primary-hover); color: #fff; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background-color: var(--color-elevated); color: var(--color-text); }
.btn-secondary:hover { background-color: var(--color-border); color: var(--color-text); }
.btn-secondary:active { transform: scale(0.97); }
.btn-ghost { background-color: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background-color: var(--color-elevated); color: var(--color-text); }
.btn-danger { background: transparent; color: var(--color-warning); }
.btn-danger:hover { background: var(--color-elevated); color: var(--color-warning); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; min-height: 2.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.125rem; }
.btn-xl { padding: 1rem 2rem; font-size: 1.25rem; min-height: 3.25rem; }
.btn-block { display: flex; width: 100%; }

/* Segmented control */
.segmented { display: grid; gap: 8px; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.seg {
  min-height: 44px;
  border-radius: 10px;
  background: var(--color-elevated);
  color: var(--color-text-muted);
  font-size: 13px; font-weight: 600;
  padding: 0 8px;
  transition: background-color 200ms, color 200ms;
}
.seg:hover { color: var(--color-text); }
.seg[aria-checked="true"], .seg[aria-pressed="true"] { background: var(--color-primary); color: #fff; }
.seg.outlined[aria-checked="true"] {
  background: var(--color-elevated); color: var(--color-text-bright);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Option cards (mode picker) */
.option {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left;
  border-radius: var(--radius-control);
  padding: 12px 14px;
  background: var(--color-elevated);
  color: var(--color-text-muted);
  transition: background-color 200ms;
}
.option:hover { background: var(--color-border); }
.option .opt-title { font-size: 14px; font-weight: 700; color: var(--color-text); }
.option .opt-desc { font-size: 12px; }
.option[aria-checked="true"] { background: var(--color-primary); color: rgba(255,255,255,0.85); }
.option[aria-checked="true"] .opt-title { color: #fff; }
.role-row { padding: 0 2px; }

/* Pill / status chip */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--color-elevated);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 999px; background: currentColor; display: inline-block; }
.pill.is-active { color: var(--color-active); }
.pill.is-ok { color: var(--color-success); }
.pill.is-idle { color: var(--color-text-muted); }
.pill.is-error { color: var(--color-warning); }

/* Range input styled with accent */
input[type="range"] {
  width: 100%; height: 44px; margin: 0;
  background: transparent; accent-color: var(--color-primary);
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--color-elevated); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--color-elevated); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--color-primary); border: 2px solid var(--color-text-bright);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--color-primary); border: 2px solid var(--color-text-bright);
}
.range-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.range-value { font-size: 14px; font-weight: 700; color: var(--color-success); font-variant-numeric: tabular-nums; }

/* Text inputs */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 11px; color: var(--color-text-muted); }
.input {
  width: 100%; min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-elevated);
  color: var(--color-text-bright);
  padding: 0 10px;
}
.input.mono { font-size: 15px; text-transform: uppercase; }
.input.is-correct { border-color: var(--color-success); }
.input.is-wrong { border-color: var(--color-warning); }
.input:disabled { opacity: 0.9; }
.grade-note { font-size: 12px; margin: 0; }
.grade-note.ok { color: var(--color-success); }
.grade-note.bad { color: var(--color-warning); }

/* ---------- Setup ---------- */

.budget { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.budget-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--color-text-muted); }
.budget-row { align-items: center; }
.budget-row .value { color: var(--color-text); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.budget-support { min-height: 44px; margin: -8px -8px -8px 0; }
.intro { margin: 0; font-size: 13px; line-height: 1.45; color: var(--color-text-muted); }
.chip {
  display: inline-block; flex: 0 0 auto; margin-left: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--color-elevated); color: var(--color-text-muted);
  border-radius: 999px; padding: 2px 8px; line-height: 1.4; vertical-align: 1px;
}
.topbar-title .line2 { display: flex; align-items: center; min-width: 0; }
.topbar-title .line2 .working { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* three animated dots in the status pill while the AI thinks */
.dots { display: inline-flex; gap: 2px; margin-left: 3px; }
.dots i {
  width: 3px; height: 3px; border-radius: 50%; background: currentColor; display: block;
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* AI stats card */
.stats-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 10px 0 0; font-size: 13px;
}
.stats-grid dt { color: var(--color-text-muted); }
.stats-grid dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--color-text-bright); }

/* Site footer */
.site-footer { border-top: 1px solid var(--color-border); margin-top: 8px; padding: 20px 0 calc(20px + env(safe-area-inset-bottom)); }
.site-footer-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.donate-line { margin: 0; font-size: 13px; line-height: 1.45; color: var(--color-text); }
.footer-row { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.donate-form { margin: 0; }
.donate-form .btn { gap: 8px; }
.heart { width: 16px; height: 16px; color: var(--color-warning); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.credit { font-size: 12px; color: var(--color-text-muted); padding: 0 8px; }
@media (min-width: 640px) {
  .site-footer-inner { align-items: stretch; text-align: left; }
  .footer-row { flex-direction: row; justify-content: space-between; }
}
.usage-line { margin: 0; font-size: 13px; color: var(--color-text-muted); }

.bar { height: 4px; border-radius: 999px; background: var(--color-elevated); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--color-primary); transition: width 300ms; }
.bar.warn > span { background: var(--color-active); }
.bar.full > span { background: var(--color-warning); }
.hint { font-size: 12px; color: var(--color-text-muted); margin: 0; }
.banner {
  border-radius: var(--radius-control); padding: 10px 14px; font-size: 13px;
  background: var(--color-elevated); border: 1px solid var(--color-active); color: var(--color-text);
}
.banner.error { border-color: var(--color-warning); }

/* ---------- On air ---------- */

.screen-onair { height: calc(100vh - var(--sim-banner-h)); height: calc(100dvh - var(--sim-banner-h)); min-height: 0; }
.onair-body {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
  padding-top: 14px; padding-bottom: 12px;
}
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wpm-readouts { display: flex; gap: 12px; font-size: 12px; color: var(--color-text-muted); }
.wpm-readouts b { color: var(--color-text-bright); font-size: 14px; font-variant-numeric: tabular-nums; }

.sending-card { border-color: var(--color-primary); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.sending-head {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.sending-head .wpm { color: var(--color-text); }
.decoded {
  font-family: var(--font-mono); font-size: 22px; font-weight: 700;
  color: var(--color-text-bright); letter-spacing: 0.04em;
  min-height: 32px; word-break: break-all;
  max-height: 3.4em; overflow: hidden; display: flex; align-items: flex-end;
}
.decoded .text { overflow-wrap: anywhere; }
.decoded .caret {
  display: inline-block; width: 10px; height: 24px; background: var(--color-primary);
  vertical-align: -4px; margin-left: 2px; flex: 0 0 auto;
}
.decoded.empty .text { color: var(--color-text-muted); font-weight: 500; }

.morse-strip {
  display: flex; align-items: center; gap: 4px; height: 10px; overflow: hidden;
  justify-content: flex-start; white-space: nowrap;
}
.morse-strip .dit, .morse-strip .dah {
  flex: 0 0 auto; display: inline-block; height: 6px; border-radius: 3px; background: var(--color-primary);
  font-size: 0; /* hide the glyph text DisplayManager writes */
}
.morse-strip .dit { width: 6px; }
.morse-strip .dah { width: 14px; }
.morse-strip .space { flex: 0 0 auto; width: 12px; display: inline-block; font-size: 0; }

.transcript {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
}
.transcript::before { content: ''; margin-top: auto; }

.bubble-wrap { display: flex; flex-direction: column; gap: 4px; max-width: 85%; }
.bubble-wrap.ai { align-items: flex-start; align-self: flex-start; }
.bubble-wrap.user { align-items: flex-end; align-self: flex-end; }
.bubble-wrap.system { align-self: center; max-width: 100%; }
.bubble {
  font-family: var(--font-mono); font-size: 15px; font-weight: 500;
  padding: 10px 12px; overflow-wrap: anywhere;
}
.bubble-ai {
  color: var(--color-text-bright); background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 14px 14px 14px 4px;
}
.bubble-user { color: #fff; background: var(--color-primary); border-radius: 14px 14px 4px 14px; }
.bubble-masked {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 44px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--color-text-muted);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.bubble-masked svg { width: 16px; height: 16px; flex: 0 0 auto; }
.bubble-masked:hover { color: var(--color-text-bright); }
.bubble-masked:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.bubble-ai:not(.bubble-masked) { animation: bubble-reveal 180ms ease-out; }
@keyframes bubble-reveal { from { opacity: 0.4; } to { opacity: 1; } }
.result-call.is-hidden, .result-sub.is-hidden { color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: 0.2em; }
.bubble-system {
  font-family: var(--font-sans); font-size: 11px; font-weight: 500; text-align: center;
  color: var(--color-text-muted); background: var(--color-surface);
  border-radius: 999px; padding: 3px 10px;
}
.bubble-system.error { color: var(--color-warning); }
.bubble-caption { font-size: 11px; color: var(--color-text-muted); padding: 0 4px; }

.bottom-bar { background: var(--color-surface); border-top: 1px solid var(--color-border); }
.bottom-inner { padding-top: 12px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }

.paddles { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (pointer: coarse) { .paddles { display: grid; } }
body.show-paddles .paddles { display: grid; }
.paddle {
  min-height: 72px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-elevated);
  color: var(--color-text-bright);
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.paddle.down { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.paddle .mark { height: 10px; border-radius: 999px; background: var(--color-primary); display: inline-block; }
.paddle.down .mark { background: #fff; }
.paddle .mark.dit { width: 10px; }
.paddle .mark.dah { width: 26px; }

.actions-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.actions-right { display: flex; gap: 6px; align-items: center; }

/* Desktop two-column on-air layout */
.side-col { display: contents; }
@media (min-width: 960px) {
  .screen-onair .wrap { max-width: 80rem; padding-left: 24px; padding-right: 24px; }
  .onair-body {
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    gap: 24px; padding-top: 24px; padding-bottom: 24px;
  }
  .transcript-col {
    grid-column: span 7; min-height: 0; display: flex; flex-direction: column;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-card); padding: 20px 24px; gap: 14px;
  }
  .transcript-col .card-label { flex: 0 0 auto; }
  .transcript-col .transcript { max-width: none; }
  .side-col { grid-column: span 5; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
  .side-col .status-card { order: 0; }
  .side-col .sending-card { order: 1; flex: 1 1 auto; }
  .bubble-wrap { max-width: 70%; }
  .screen-onair .bottom-inner { max-width: 80rem; padding-left: 24px; padding-right: 24px; margin: 0 auto; }
  .transcript-col { order: -1; }
  .bubble { font-size: 16px; padding: 12px 14px; }
  .transcript-col .bubble-ai, .transcript-col .bubble-system { background: var(--color-elevated); }
}
.transcript-col { display: contents; }
.desktop-only { display: none; }
@media (min-width: 960px) { .transcript-col { display: flex; } .desktop-only { display: block; } }
.status-card { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 960px) {
  .status-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-card); padding: 16px 20px; }
}

/* ---------- Results ---------- */

.result-hero { text-align: center; padding: 6px 0 2px; display: flex; flex-direction: column; gap: 4px; }
.result-call { font-family: var(--font-mono); font-size: 30px; font-weight: 700; color: var(--color-text-bright); letter-spacing: 0.04em; }
.result-sub { font-size: 13px; color: var(--color-text-muted); }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; padding: 14px; }
.stat .num { font-size: 24px; font-weight: 700; color: var(--color-text-bright); font-variant-numeric: tabular-nums; }
.stat .num.good { color: var(--color-success); }
.stat .lbl { font-size: 11px; color: var(--color-text-muted); }
.copy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.notes { display: flex; flex-direction: column; gap: 8px; }
.note { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.4; }
.note .bullet { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 999px; margin-top: 6px; background: var(--color-active); }
.note.good .bullet { background: var(--color-success); }
.notes-placeholder { font-size: 13px; color: var(--color-text-muted); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.rate-row { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 2px 0; }
.rate-row span { font-size: 12px; color: var(--color-text-muted); }
.thumb {
  width: 44px; height: 44px; border-radius: var(--radius-control);
  border: 1px solid var(--color-border); background: var(--color-elevated); color: var(--color-text);
  display: inline-flex; align-items: center; justify-content: center;
}
.thumb svg { width: 18px; height: 18px; }
.thumb.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.results-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.results-actions .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.recent { display: flex; flex-direction: column; gap: 6px; }
.recent-row {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  background: var(--color-elevated); border-radius: 10px; padding: 8px 12px;
}
.recent-row .mono { font-size: 13px; }
.recent-row .tick { margin-left: auto; font-weight: 700; }
.recent-row.ok .tick { color: var(--color-success); }
.recent-row.bad .tick { color: var(--color-warning); }
.recent-row .actual { color: var(--color-text-muted); font-size: 12px; }

/* ---------- Sheets / modals ---------- */

.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.overlay .scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.sheet {
  position: relative; width: 100%; max-width: 42rem; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 20px 20px 0 0;
  padding: 20px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h2 { margin: 0; font-size: 18px; color: var(--color-text-bright); }
.sheet h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-bright); }
.sheet p { margin: 0; font-size: 14px; }
.sheet ul { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.sheet pre {
  margin: 0; padding: 10px 12px; background: var(--color-elevated); border-radius: 10px;
  font-family: var(--font-mono); font-size: 12px; overflow-x: auto; color: var(--color-text-bright);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet section { display: flex; flex-direction: column; gap: 8px; }
.kbd {
  font-family: var(--font-mono); font-size: 12px; background: var(--color-elevated);
  border: 1px solid var(--color-border); border-radius: 6px; padding: 1px 6px; color: var(--color-text-bright);
}
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 14px; }
.toggle {
  width: 48px; height: 28px; border-radius: 999px; background: var(--color-elevated);
  border: 1px solid var(--color-border); position: relative; flex: 0 0 auto; transition: background-color 200ms;
}
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--color-text-muted); transition: transform 200ms, background-color 200ms;
}
.toggle::before { content: ''; position: absolute; inset: -8px -4px; } /* 44px tap target */
.toggle[aria-checked="true"] { background: var(--color-primary); border-color: var(--color-primary); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); background: #fff; }
.id-row { display: flex; gap: 8px; align-items: center; }
.id-row code {
  flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap;
  font-family: var(--font-mono); font-size: 12px; background: var(--color-elevated);
  border-radius: 10px; padding: 12px 10px; color: var(--color-text-bright);
}
.quiet-link { font-size: 13px; color: var(--color-text-muted); }
.quiet-link:hover { color: var(--color-text); }
.version { font-size: 12px; color: var(--color-text-muted); }

/* Centered modal variant (limit reached, confirm) */
.overlay.center { align-items: center; padding: var(--gutter); }
.overlay.center .sheet { border-radius: var(--radius-card); max-width: 28rem; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }

@media (min-width: 640px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { border-radius: var(--radius-card); }
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; max-width: calc(100vw - 32px);
  background: var(--color-elevated); border: 1px solid var(--color-border); border-radius: 999px;
  padding: 10px 16px; font-size: 13px; color: var(--color-text-bright);
}

/* ---------- Realism: radio screen ---------- */

.screen-radio .wrap { max-width: none; }
.radio-head { gap: 6px; padding-top: 8px; padding-bottom: 8px; min-height: 56px; }
.radio-head .icon-btn { width: 40px; height: 40px; }
.radio-head .topbar-title { flex: 1 1 0; }
.radio-head .topbar-title .line1 { font-size: 14px; }
.radio-head .topbar-title .line2 { font-size: 11px; }
.radio-freq {
  display: flex; align-items: baseline; flex: 0 0 auto;
  font-family: var(--font-mono); font-weight: 700; font-size: 17px; color: var(--color-text-bright);
  white-space: nowrap;
}
.radio-freq .f-hund { color: var(--color-success); }
.radio-freq .f-tens { font-size: 0.75em; color: var(--color-text-muted); }
.radio-freq .f-unit { display: none; margin-left: 6px; font-family: var(--font-sans); font-size: 12px; font-weight: 500; color: var(--color-text-muted); }
.radio-chips { display: none; gap: 8px; }
.role-n { display: none; }
.rchip {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
  color: var(--color-text-muted); background: var(--color-elevated); border-radius: 999px; padding: 6px 10px;
}
.tx-pill {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 5px 9px;
  background: var(--color-elevated); color: var(--color-text-muted);
  transition: background-color 120ms, color 120ms;
}
.tx-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-border); }
.tx-pill.on { background: var(--color-active); color: #0A0A0A; }
.tx-pill.on .dot { background: #0A0A0A; }
.radio-budget { display: none; font-size: 12px; color: var(--color-text-muted); white-space: nowrap; }

.radio-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; padding-bottom: 16px; }
.radio-scope { position: relative; flex: 0 0 auto; }
.radio-wf {
  height: clamp(220px, 34dvh, 300px);
  border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-background); overflow: hidden;
}
.radio-wf:focus-visible { box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-primary); }
.wf-pill {
  position: absolute; top: 68px; z-index: 2; pointer-events: none;
  font-size: 10px; line-height: 1.5; color: var(--color-text-bright);
  background: rgba(26, 26, 26, 0.85); border: 1px solid var(--color-border); border-radius: 999px; padding: 2px 7px;
}
.wf-vfo { right: 8px; font-family: var(--font-mono); }
.wf-vfo-long { display: none; }
.wf-hint { display: none; left: 12px; color: var(--color-text-muted); }

.radio-tabs { flex: 0 0 auto; gap: 6px; }
.radio-tabs .seg { min-height: 40px; font-size: 13px; font-weight: 700; }

.radio-panels { display: block; }
.radio-rig, .radio-log { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.radio-spots { order: -1; }
.radio-spots .spots { max-height: 142px; }

@media (max-width: 959px) {
  .screen-radio { height: calc(100vh - var(--sim-banner-h)); height: calc(100dvh - var(--sim-banner-h)); min-height: 0; }
  .radio-main { min-height: 0; padding-bottom: 0; }
  .radio-panels { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
  .radio-panels[data-tab="rig"] .radio-log { display: none; }
  .radio-panels[data-tab="log"] .radio-rig { display: none; }
}

/* Rig card */
.radio-rig-card { gap: 12px; }
.smeter { color: var(--color-success); font-weight: 700; }
#radioBands .seg { min-height: 40px; }
.tune-row { display: none; align-items: center; justify-content: center; gap: 18px; }
.tune-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--color-border); background: var(--color-elevated); color: var(--color-text);
  display: flex; align-items: center; justify-content: center; touch-action: manipulation;
}
.tune-btn:hover { background: var(--color-border); }
.tune-btn svg { width: 16px; height: 16px; }
.knob {
  position: relative; width: 96px; height: 96px; flex: 0 0 auto; border-radius: 50%;
  background: var(--color-elevated); border: 2px solid var(--color-border);
  box-shadow: inset 0 0 0 10px var(--color-surface);
  touch-action: none; cursor: grab; user-select: none;
}
.knob:active { cursor: grabbing; }
.knob .notch {
  position: absolute; left: 42px; top: 6px; width: 8px; height: 22px; border-radius: 4px;
  background: var(--color-success); transform-origin: 4px 40px; transform: rotate(var(--knob-deg, 0deg));
}
.tune-strip {
  position: relative; height: 56px; border-radius: 12px; overflow: hidden;
  background-color: var(--color-elevated); border: 1px solid var(--color-border);
  background-image:
    repeating-linear-gradient(to right, var(--color-text-muted) 0 2px, transparent 2px 70px),
    repeating-linear-gradient(to right, var(--color-border-hover) 0 1px, transparent 1px 14px);
  background-size: 70px 26px, 14px 14px;
  background-repeat: repeat-x;
  background-position: 0 100%, 0 100%;
  touch-action: none; cursor: ew-resize; user-select: none;
}
.strip-mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--color-success); }
.strip-mark::before {
  content: ''; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top-color: var(--color-success); border-bottom: 0;
}
.rig-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.rig-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chips { gap: 4px; }
.chips .seg { min-height: 40px; border-radius: 8px; font-size: 12px; padding: 0 4px; }
.rig-val { font-size: 12px; color: var(--color-text); font-variant-numeric: tabular-nums; }
.radio-rig-card input[type="range"] { height: 32px; }

/* RX / TX lamps */
.lamps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lamp {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--color-text-muted);
  background: var(--color-elevated); border-radius: 999px; padding: 6px 10px;
}
.lamp .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-border); }
.lamp-note { display: none; }
.lamp.on { color: var(--color-success); }
.lamp.on .dot { background: var(--color-success); }
#lampTx.on { color: var(--color-active); }
#lampTx.on .dot { background: var(--color-active); }
.radio-clock { margin-left: auto; font-size: 11px; color: var(--color-text-muted); }
.radio-clock b, .radio-foot-wpm b { color: var(--color-text-bright); font-family: var(--font-mono); }
.clock-wpm { display: none; }

/* Quick | Radio view switch in the Setup header */
.view-switch { flex: 0 0 auto; gap: 2px; width: 150px; padding: 2px; background: var(--color-elevated); border-radius: 12px; }
.view-switch .seg { min-height: 44px; font-size: 14px; font-weight: 700; }

/* Log */
.log-card { gap: 12px; }
.log-hint { display: none; }
.log-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.log-form .f-call { grid-column: 1 / -1; }
.log-in { font-family: var(--font-mono); font-size: 18px; font-weight: 700; text-transform: uppercase; }
.log-form .f-call .log-in { font-size: 22px; min-height: 48px; }
.log-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.log-meta { font-family: var(--font-mono); font-size: 11px; color: var(--color-text-muted); }
.log-submit { margin-left: auto; min-height: 40px; padding: 0 18px; font-size: 14px; font-weight: 700; }
.log-rows { border-top: 1px solid var(--color-border); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.log-head { display: none; }
.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-row {
  display: grid; gap: 4px 6px; align-items: center;
  grid-template-columns: 1.5fr 1fr 1fr 1.2fr 1fr;
  grid-template-areas: "time time time freq freq del" "call sent rcvd name state";
  font-family: var(--font-mono); font-size: 12px; color: var(--color-text);
  background: var(--color-elevated); border-radius: 8px; padding: 6px 8px;
}
.lr-time { grid-area: time; color: var(--color-text-muted); }
.lr-freq { grid-area: freq; color: var(--color-text-muted); }
.lr-del { grid-area: del; justify-self: end; width: 28px; height: 28px; border-radius: 6px; color: var(--color-text-muted); font-size: 18px; line-height: 1; }
.lr-del:hover { background: var(--color-border); color: var(--color-warning); }
.lr-call { grid-area: call; } .lr-sent { grid-area: sent; } .lr-rcvd { grid-area: rcvd; } .lr-name { grid-area: name; } .lr-state { grid-area: state; }
.lr-in {
  width: 100%; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--color-text); font: inherit; padding: 4px 3px; text-transform: uppercase;
}
.lr-in:hover { border-color: var(--color-border); }
.lr-in:focus { border-color: var(--color-primary); outline: none; background: var(--color-surface); }
.lr-call { font-weight: 700; }

/* Spots */
.spots { display: flex; flex-direction: column; gap: 6px; max-height: 232px; overflow-y: auto; }
.spot {
  display: flex; align-items: center; gap: 6px; min-height: 44px; width: 100%; text-align: left;
  background: var(--color-elevated); border-radius: 10px; padding: 8px 12px;
  font-family: var(--font-mono); font-size: 13px; color: var(--color-text);
}
.spot:hover { background: var(--color-border); }
.spot .sp-s { color: var(--color-success); font-weight: 700; }
.spot .sp-dim { color: var(--color-text-muted); }
.spots-empty { font-size: 12px; color: var(--color-text-muted); }

/* Bottom bar */
.radio-bar .bottom-inner { max-width: none; padding-top: 8px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); gap: 6px; }
.radio-bar .paddle { min-height: 60px; }
.radio-foot-hint { display: none; font-size: 12px; color: var(--color-text-muted); }
.radio-foot-wpm { font-size: 11px; color: var(--color-text-muted); }

/* Settings sheet: Realism section */
.rs-group { display: flex; flex-direction: column; gap: 6px; }
.rs-label { font-size: 13px; color: var(--color-text); }
.rs-seg { gap: 6px; }
.rs-seg .seg { min-height: 40px; }

@media (min-width: 1240px) {
  .radio-budget { display: inline; }
}

@media (min-width: 960px) {
  .screen-radio .wrap { max-width: 80rem; padding-left: 24px; padding-right: 24px; }
  .radio-head { gap: 16px; padding-top: 10px; padding-bottom: 10px; }
  .radio-head .icon-btn { width: 40px; height: 40px; border-radius: 10px; background: var(--color-elevated); }
  .radio-head .topbar-title { flex: 0 0 auto; }
  .radio-head .topbar-title .line1 { font-size: 15px; }
  .radio-head .topbar-title .line2 { font-size: 12px; }
  .radio-freq { font-size: 30px; margin-left: 24px; }
  .radio-freq .f-unit { display: inline; }
  .radio-chips { display: flex; margin-left: 8px; }
  .role-n { display: inline; }
  .tx-pill { margin-left: auto; font-size: 12px; padding: 6px 12px; gap: 6px; }
  .tx-pill .dot { width: 8px; height: 8px; }
  .radio-main { padding-top: 16px; }
  .radio-wf { height: 408px; }
  .wf-vfo-long { display: inline; }
  .wf-hint { display: block; }
  .radio-tabs { display: none; }
  .radio-panels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
  .radio-rig { grid-column: span 5; }
  .radio-log { grid-column: span 7; }
  .radio-spots { order: 0; }
  .radio-spots .spots { max-height: 232px; }
  .radio-rig .radio-spots { order: 2; }
  .radio-rig-card { padding: 16px 20px; }
  .tune-row { display: flex; }
  .tune-strip { display: none; }
  .rig-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .chips .seg { min-height: 32px; }
  #radioBands .seg { min-height: 36px; }
  .lamp-note { display: none; }
  .lamp.on .lamp-note { display: inline; }
  .radio-clock { font-size: 12px; }
  .clock-wpm { display: inline; }
  .log-card { padding: 16px 20px; }
  .log-hint { display: inline; }
  .log-form { grid-template-columns: 2fr 1fr 1fr 1.2fr 1fr; }
  .log-form .f-call { grid-column: auto; }
  .log-form .f-call .log-in { font-size: 18px; min-height: 44px; }
  .log-head, .log-row { grid-template-columns: 0.9fr 2fr 1fr 1fr 1.2fr 1fr 1.2fr 28px; gap: 8px; }
  .log-head {
    display: grid; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted);
  }
  .log-row { grid-template-areas: none; font-size: 13px; padding: 4px 10px; }
  .log-row > * { grid-area: auto; }
  .lr-del { justify-self: stretch; }
  .radio-bar .bottom-inner { padding-top: 10px; padding-bottom: 12px; }
  .radio-bar .actions-row { flex-direction: row; }
  .radio-foot-hint { display: inline; order: -1; margin-right: auto; }
  .radio-foot-wpm { display: none; }
  .radio-end { border: 1px solid var(--color-warning); padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Realism Results */
.radio-session-2 { display: none; }
@media (max-width: 760px) { #radioSessionBtn { display: none; } .radio-session-2 { display: inline-flex; } }
.ss-totals { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.ss-totals b { color: var(--color-text-bright, #fff); }
.ss-entry .ss-meta { color: #888; font-size: 12px; margin: 2px 0 8px; }
.ss-entry audio { width: 100%; margin-top: 8px; }
.ss-links { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }
.ss-notes { margin-top: 8px; font-size: 13px; color: #bbb; }
.rz-rows { display: grid; gap: 4px; }
.rz-row { display: grid; grid-template-columns: 5.5rem 1fr 1fr 1.5rem; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #2a2a2a; font-size: 14px; }
.rz-row span:nth-child(2), .rz-row span:nth-child(3) { font-family: 'JetBrains Mono', monospace; }
.rz-head { color: #888; font-size: 12px; }
.rz-ok span:last-child { color: #00d1b2; }
.rz-bad span:last-child, .rz-bad span:nth-child(2) { color: #ff6b6b; }
.rz-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.rz-lines { display: grid; gap: 6px; }
.rz-line { display: grid; grid-template-columns: 5.5rem 1fr; gap: 8px; font-size: 14px; }
.rz-who { color: #888; }
.rz-line.user .rz-who { color: #00d1b2; }

/* Always-visible disclaimer: this is a simulation, never the real air. */
:root { --sim-banner-h: 28px; }
.sim-banner {
  box-sizing: border-box; min-height: var(--sim-banner-h);
  display: flex; align-items: center; justify-content: center;
  padding: 5px 16px; text-align: center;
  font-size: 12px; line-height: 1.3; color: var(--color-text-bright);
  background: #2A2A2A; border-bottom: 1px solid var(--color-border);
}
@media (max-width: 480px) { :root { --sim-banner-h: 44px; } }
