/* ------------------------------------------------------------------ *
 * On the Air - dark instrument-panel styling.
 * Colour roles: message = cyan, RF = amber, recovered audio = green,
 * spectrum = violet. The same colours are used by the canvases.
 * ------------------------------------------------------------------ */

:root {
  --bg: #0b0e13;
  --panel: #141922;
  --panel-2: #1b212c;
  --line: #263041;
  --line-soft: #1e2735;
  --ink: #e7edf6;
  --ink-dim: #9aa8bd;
  --ink-faint: #6b7a91;

  --msg: #35d1e0;
  --rf: #ffb347;
  --dem: #6ee787;
  --spec: #b78cff;
  --mark: #ff6b9d;
  --warnc: #ff8a5c;

  --radius: 12px;
  --font: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Author display rules below would otherwise beat the UA rule for [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------- top bar -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #161c26, #10151d);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.brand .sub { color: var(--ink-faint); font-size: 12px; }
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #3a4557; align-self: center;
  transition: background .25s, box-shadow .25s;
}
body.live .brand .dot { background: var(--dem); box-shadow: 0 0 10px var(--dem); }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.monitor-pick { display: flex; align-items: center; gap: 8px; }
.vol { display: flex; align-items: center; gap: 8px; }
.vol input { width: 110px; }

.mini-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* --------------------------------------------------------- buttons -- */

button {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover:not(:disabled) { background: #232b38; border-color: #33405a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--msg); outline-offset: 2px; }

.power {
  background: linear-gradient(180deg, #2b6cff, #1d51d8);
  border-color: #2f6bff;
  font-weight: 600;
  padding: 8px 16px;
}
.power:hover:not(:disabled) { background: linear-gradient(180deg, #3a79ff, #2a5ee6); }
body.live .power { background: #232b38; border-color: var(--line); font-weight: 500; }
.power.big { padding: 12px 26px; font-size: 15px; margin-top: 8px; }
.ghost-btn { background: transparent; }
.subtle { background: transparent; color: var(--ink-dim); }

.seg { display: inline-flex; background: #0e1219; border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { background: transparent; border: none; border-radius: 7px; padding: 6px 10px; color: var(--ink-dim); font-size: 13px; }
.seg button.active { background: #2b3446; color: var(--ink); box-shadow: inset 0 0 0 1px #3a4761; }
.seg.small button { padding: 5px 8px; font-size: 12px; }

/* --------------------------------------------------------- splash --- */

.splash {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(1200px 600px at 50% 20%, #16202e, #080a0f 70%);
  display: grid; place-items: center; padding: 24px;
}
.splash[hidden] { display: none; }
.splash-card {
  max-width: 560px; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 34px 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.splash-card h2 { margin: 0 0 14px; font-size: 24px; }
.splash-card p { color: var(--ink-dim); line-height: 1.6; margin: 0 0 12px; }
.fine { font-size: 12.5px; color: var(--ink-faint); }
.fine.warn { color: var(--warnc); margin-top: 14px; }

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

.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 370px;
  gap: 12px;
  padding: 12px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.controls, .lesson {
  position: sticky; top: 62px;
  max-height: calc(100vh - 74px);
  overflow-y: auto;
  padding: 4px 14px 16px;
}
.stage { padding: 12px; min-width: 0; }

.controls::-webkit-scrollbar, .lesson::-webkit-scrollbar, .lesson-body::-webkit-scrollbar { width: 9px; }
.controls::-webkit-scrollbar-thumb, .lesson::-webkit-scrollbar-thumb, .lesson-body::-webkit-scrollbar-thumb {
  background: #2a3444; border-radius: 6px;
}

/* --------------------------------------------------------- controls - */

.ctl-group { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.ctl-group:last-child { border-bottom: none; }
.ctl-group h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); margin: 0 0 12px;
}

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.wide-btn { flex: 1; }

.src-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.src { font-size: 12.5px; padding: 8px 6px; }
.src.active { background: #1f3350; border-color: #3f6ea8; color: #cfe4ff; }
.src.mic.active { background: #3a2036; border-color: #a34a7c; color: #ffd7ea; }

.mode-grid { display: grid; gap: 6px; }
.mode { display: flex; align-items: baseline; gap: 8px; text-align: left; padding: 9px 11px; }
.mode b { font-size: 13px; letter-spacing: .03em; }
.mode span { font-size: 11.5px; color: var(--ink-faint); }
.mode.active { background: #1d2b3f; border-color: #3f6ea8; }
.mode.active span { color: #9dc0e8; }

.slider { display: block; margin: 12px 0; }
.slider > span {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; color: var(--ink-dim); margin-bottom: 6px;
}
.slider b { color: var(--ink); font-family: var(--mono); font-size: 12px; font-weight: 500; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 3px;
  background: #2a3444; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #cfe0f5; border: 2px solid #55688a;
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: #cfe0f5; border: 2px solid #55688a; cursor: pointer;
}
.slider.tune input[type=range]::-webkit-slider-thumb { background: var(--mark); }
.slider.tune input[type=range]::-moz-range-thumb { background: var(--mark); }

.chk { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-dim); cursor: pointer; }
.chk input { accent-color: #3f7fe0; }

.hint {
  font-size: 12px; line-height: 1.5; color: var(--ink-faint);
  margin: 8px 0 0; padding-left: 9px; border-left: 2px solid var(--line);
}

.meter { height: 5px; background: #0d1119; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--dem), #e8d44d 70%, #ff6060); transition: width .08s linear; }

/* --------------------------------------------------------- scopes --- */

.scopes { display: grid; gap: 10px; }
.analysis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

.scope-box {
  margin: 0;
  background: #0a0d13;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px 6px;
  min-width: 0;
}
.scope-box figcaption {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-faint); margin-bottom: 6px;
}
.scope-box canvas { display: block; width: 100%; height: 120px; }
.scope-box.tall canvas { height: 190px; }
.scope-box.wide { grid-column: 1 / -1; }
.scope-box.wide canvas { height: 210px; }

.tag {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  padding: 2px 7px; border-radius: 5px; font-weight: 600;
}
.tag.msg { background: rgba(53,209,224,.14); color: var(--msg); }
.tag.rf { background: rgba(255,179,71,.14); color: var(--rf); }
.tag.dem { background: rgba(110,231,135,.14); color: var(--dem); }
.tag.spec, .tag.wf { background: rgba(183,140,255,.14); color: var(--spec); }
.tag.iq { background: rgba(255,107,157,.14); color: var(--mark); }

/* --------------------------------------------------------- lesson --- */

.lesson-head h2 { font-size: 18px; margin: 14px 0 4px; }
.tagline { color: var(--ink-faint); font-size: 12.5px; margin: 0 0 12px; line-height: 1.5; }

.diagram-wrap { background: #0a0d13; border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 12px; }
.diagram-wrap svg { display: block; width: 100%; height: auto; }

.tabs { display: flex; width: 100%; margin-bottom: 10px; }
.tabs button { flex: 1; }

.lesson-body { font-size: 13.2px; line-height: 1.65; color: #c9d5e6; }
.lesson-body p { margin: 0 0 12px; }
.lesson-body h4 { font-size: 12.5px; margin: 16px 0 6px; color: var(--ink); }
.lesson-body ul { margin: 0 0 12px; padding-left: 18px; }
.lesson-body li { margin-bottom: 7px; }
.lesson-body b, .lesson-body strong { color: var(--ink); font-weight: 600; }
.lesson-body code, .eq {
  font-family: var(--mono); font-size: 12.5px;
  background: #0e131b; border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 1px 5px; color: #d8e4f5;
}
.eq {
  display: block; padding: 12px 14px; margin: 10px 0 6px;
  text-align: center; font-size: 14px; line-height: 1.8; color: #e9f0fb;
}
.eq .v-msg { color: var(--msg); }
.eq .v-rf { color: var(--rf); }
.eq .v-dem { color: var(--dem); }
.eq-note { font-size: 12px; color: var(--ink-faint); margin: 0 0 14px; }

.exp {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 13px; margin-bottom: 10px;
}
.exp h5 { margin: 0 0 6px; font-size: 13px; color: var(--ink); }
.exp p { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-dim); line-height: 1.55; }
.exp button { font-size: 12px; padding: 6px 12px; background: #23406b; border-color: #35598f; }
.exp button:hover { background: #2c4f83; }

/* --------------------------------------------------------- diagram -- */

.blk { fill: #18202c; stroke: #33405a; }
.blk.on { fill: #1d3350; stroke: #4a7fc4; }
.blk-t { fill: #cfdcee; font-size: 9.5px; font-family: var(--font); text-anchor: middle; }
.blk-t.dim { fill: #5f6e85; }
.wire { stroke: #3b4a63; stroke-width: 1.4; fill: none; }
.wire.on { stroke: #4a7fc4; }
.wire-lbl { fill: #6b7a91; font-size: 8px; text-anchor: middle; font-family: var(--mono); }

/* --------------------------------------------------------- tour ----- */

.tour-card {
  position: sticky; bottom: 0;
  margin-top: 16px;
  background: linear-gradient(180deg, #1b2740, #141b28);
  border: 1px solid #35598f; border-radius: 12px; padding: 14px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.45);
}
.tour-card[hidden] { display: none; }
.tour-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tour-head span { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: #7fa8dd; }
.tour-card h3 { margin: 0 0 6px; font-size: 14px; }
.tour-card p { margin: 0 0 12px; font-size: 12.8px; line-height: 1.6; color: var(--ink-dim); }
.tour-nav { display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: none; color: var(--ink-faint); font-size: 18px; line-height: 1; padding: 0 4px; }

/* --------------------------------------------------------- toast ---- */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1d2635; border: 1px solid #3c4a63; color: var(--ink);
  padding: 10px 18px; border-radius: 10px; z-index: 90;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); font-size: 13px;
}
.toast[hidden] { display: none; }

/* --------------------------------------------------------- narrow --- */

@media (max-width: 1400px) {
  .layout { grid-template-columns: 290px minmax(0, 1fr) 330px; }
}
@media (max-width: 1150px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .lesson { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .controls { position: static; max-height: none; }
  .analysis { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
  .brand .sub { display: none; }
  /* On a phone the scopes are the point - do not bury them under the
     whole control panel. */
  .stage { order: 1; }
  .controls { order: 2; }
  .lesson { order: 3; }
}

/* Station callsign badge in the header. */
.brand .call {
  align-self: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--rf);
  background: rgba(255, 179, 71, .10);
  border: 1px solid rgba(255, 179, 71, .30);
  border-radius: 5px;
  padding: 2px 7px;
}
@media (max-width: 820px) { .brand .call { font-size: 10px; padding: 1px 5px; } }
