:root {
  --bg: #05070b;
  --panel: #0b0f17;
  --panel-hi: #111723;
  --line: #1c2433;
  --line-hi: #2a3548;
  --text: #e9eef6;
  --dim: #6e7a8f;
  --faint: #3d4757;
  --amber: #ff9f1c;
  --amber-hi: #ffbf5e;
  --amber-glow: rgba(255, 159, 28, 0.22);
  --cyan: #6fd3ff;
  --ok: #3ee07a;
  --bad: #ff4d4d;
  --font: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(80, 120, 200, 0.10), transparent 70%),
    var(--bg);
  min-height: 100vh;
}
/* The page fits the window: the waterfall takes whatever height is left
   (down to a minimum; below that the page scrolls). */
.rig {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.logo {
  font-weight: 700;
  letter-spacing: 0.28em;
  font-size: 1.05rem;
}
.logo::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  transform: translateY(-2px);
}
.model {
  color: var(--dim);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
}
.chips { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--dim);
  background: var(--panel);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 77, 77, 0.55);
  background: rgba(255, 77, 77, 0.10);
  color: #ff6b6b;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.icon-btn:hover { filter: brightness(1.15); }
.icon-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.icon-btn .ico-waves { display: none; }
.icon-btn.on {
  color: var(--amber-hi);
  border-color: rgba(255, 159, 28, 0.55);
  background: rgba(255, 159, 28, 0.10);
  box-shadow: 0 0 12px var(--amber-glow);
}
.icon-btn.on .ico-x { display: none; }
.icon-btn.on .ico-waves { display: inline; }
.chip i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}
.chip.ok i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.chip.ok { color: var(--text); }

/* ---------- display (VFO + meter) ---------- */
.display {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 12px;
}
.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), transparent 40%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 10px 30px rgba(0,0,0,0.35);
}
.vfo {
  padding: 14px 20px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.vfo-head, .vfo-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--dim);
}
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 2px 9px;
  border-radius: 3px;
  background: var(--amber);
  color: #1b0f00;
}
.badge.ghost {
  background: transparent;
  color: var(--amber-hi);
  border: 1px solid rgba(255, 159, 28, 0.45);
}
/* TAKE CONTROL (logged-in users): amber when the radio follows you */
.ctl-btn {
  margin-left: auto;
  font: 700 0.68rem var(--font);
  letter-spacing: 0.14em;
  padding: 3px 10px;
  border-radius: 3px;
  color: var(--amber-hi);
  background: transparent;
  border: 1px solid rgba(255, 159, 28, 0.45);
  cursor: pointer;
}
.ctl-btn small { font-weight: 500; letter-spacing: 0.06em; color: var(--dim); margin-left: 6px; }
.ctl-btn:hover { border-color: var(--amber); color: #fff; }
.ctl-btn.on { color: #1b0f00; background: var(--amber); border-color: var(--amber); box-shadow: 0 0 12px var(--amber-glow); }
.ctl-btn.on small { color: rgba(27, 15, 0, 0.7); }
.ctl-btn:not([hidden]) + .rx { margin-left: 0; }
.rx {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 2px 9px;
  border-radius: 3px;
  color: var(--faint);
  border: 1px solid var(--line);
}
.rx.on {
  color: #04220f;
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 0 12px rgba(62, 224, 122, 0.4);
}
.freq {
  display: flex;
  align-items: baseline;
  margin: 6px 0 4px;
  font-weight: 600;
  font-size: clamp(2.6rem, 7.2vw, 5rem);
  line-height: 1.05;
  color: #f5f8fc;
  text-shadow: 0 0 22px rgba(120, 190, 255, 0.22);
  user-select: none;
}
.freq .d {
  display: inline-block;
  width: 0.6em;
  text-align: center;
  border-radius: 3px;
  cursor: ns-resize;
  transition: background 0.12s, color 0.12s;
}
.freq .d:hover {
  color: var(--amber-hi);
  background: rgba(255, 159, 28, 0.08);
}
.freq .d.lead { color: rgba(255, 255, 255, 0.07); text-shadow: none; }
.freq .sep {
  display: inline-block;
  width: 0.28em;
  text-align: center;
  color: var(--dim);
  text-shadow: none;
}
.freq .unit {
  margin-left: 0.35em;
  font-size: 0.24em;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--dim);
  text-shadow: none;
}
.freq .hz { font-size: 0.72em; }
.freq .unit { cursor: text; transition: color 0.12s; }
.freq .unit:hover { color: var(--amber-hi); }
.freq-edit {
  display: block;
  width: 100%;
  margin: 6px 0 4px;
  padding: 0 0.15em;
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(2.6rem, 7.2vw, 5rem);
  line-height: 1.05;
  color: var(--amber-hi);
  background: rgba(255, 159, 28, 0.06);
  border: 1px solid rgba(255, 159, 28, 0.55);
  border-radius: 6px;
  outline: none;
  box-shadow: 0 0 0 3px var(--amber-glow);
}
.freq-edit::placeholder { color: var(--faint); }
.freq-edit::selection { background: rgba(255, 159, 28, 0.35); color: #fff; }
.vfo-foot {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  color: var(--dim);
}
.vfo-foot b { color: var(--text); font-weight: 600; }

/* VFO pickers (band / mode popovers) and cycling chips (step/filter/AGC/NB/NR/DIGI) */
.pick { position: relative; }
.pick-btn {
  font-family: var(--font);
  border: 0;
  cursor: pointer;
  transition: filter 0.12s, box-shadow 0.12s;
}
.badge.ghost.pick-btn { border: 1px solid rgba(255, 159, 28, 0.45); }
.pick-btn::after { content: "▾"; margin-left: 5px; font-size: 0.85em; opacity: 0.8; }
/* same width for USB/LSB and the two-letter modes */
#modeBadge { min-width: 5.4em; text-align: center; }
.pick-btn:hover, .pick-btn[aria-expanded="true"] {
  filter: brightness(1.12);
  box-shadow: 0 0 12px var(--amber-glow);
}
.pick-btn:focus-visible, .cyc:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  padding: 10px 12px 12px;
  background: rgba(12, 16, 25, 0.94);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.pop-title {
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  color: var(--dim);
  margin-bottom: 8px;
}
#modePop .keys { flex-wrap: nowrap; }
.pop-bands { width: min(400px, calc(100vw - 32px)); }
.pop-bands .keys.bands {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: visible;
}
.pop-bands .key { min-width: 0; }
.cyc {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.cyc:hover { border-color: rgba(255, 159, 28, 0.6); color: var(--text); }
.cyc:active { transform: translateY(1px); }
/* state buttons: grey when off, amber when on (STEP and FILTER are values, not states) */
.cyc b { color: var(--dim); }
.cyc.on b { color: var(--amber-hi); }
#stepCycle b, #filterCycle b { color: var(--text); }
.stack { display: inline-grid; }
.stack > span { grid-area: 1 / 1; text-align: center; }
.stack > .off { visibility: hidden; }

.meter { padding: 14px 18px; display: flex; flex-direction: column; gap: 9px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; }
.meter-value {
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.meter-value small { font-size: 0.55em; color: var(--dim); margin-left: 3px; }
.meter-bar {
  position: relative;
  height: 16px;
  border-radius: 3px;
  background: #070a10;
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #4fb6ff 0%, #a5e3ff 55%, #ffcf6b 75%, #ff8a1c 88%, #ff3d2e 100%);
  background-size: var(--meter-w, 340px) 100%;
  transition: width 0.08s linear;
}
.meter-bar::after {
  /* segment gaps, like an LCD bar meter */
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 7px, #070a10 7px 9px);
  pointer-events: none;
}
.meter-peak {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  left: 0%;
  background: #fff;
  box-shadow: 0 0 6px #fff;
  z-index: 1;
}
.meter-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--dim);
  letter-spacing: 0.06em;
}
.meter-scale span:nth-last-child(-n+2) { color: var(--amber); }
.meter-sub { font-size: 0.7rem; color: var(--dim); letter-spacing: 0.1em; }
.meter-sub b { color: var(--text); font-weight: 500; }

/* ---------- scope ---------- */
.scope {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  cursor: crosshair;
  touch-action: manipulation;
  flex: 1 1 0;
  min-height: 260px;
}
.scope-view { display: flex; flex-direction: column; height: 100%; }
#spectrum { display: block; width: 100%; height: 150px; flex: none; }
#scale {
  display: block;
  width: 100%;
  height: 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.wf { position: relative; flex: 1 1 0; min-height: 0; }
#waterfall, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#overlay { pointer-events: none; }

/* zoom: cycles x1 x2 x4 x8, the lit bars show the level (1-4) */
.zoom-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  color: var(--dim);
  background: rgba(10, 15, 24, 0.75);
  border: 1px solid var(--line-hi);
  border-radius: 4px;
  cursor: pointer;
  transition: right 0.25s ease;
}
.zoom-btn:hover { color: var(--text); border-color: rgba(255, 159, 28, 0.6); }
.scope.digi-on .zoom-btn { right: calc(50% + 10px); }
/* DX cluster spots on/off, left of the zoom button (logged-in users) */
.spots-btn {
  position: absolute;
  top: 8px;
  right: 74px;
  z-index: 2;
  height: 26px;
  padding: 0 9px;
  font: 600 0.7rem var(--font);
  letter-spacing: 0.1em;
  color: var(--dim);
  background: rgba(10, 15, 24, 0.75);
  border: 1px solid var(--line-hi);
  border-radius: 4px;
  cursor: pointer;
  transition: right 0.25s ease;
}
.spots-btn:hover { color: var(--text); border-color: rgba(255, 214, 130, 0.6); }
.spots-btn.on { color: rgb(255, 214, 130); border-color: rgba(255, 214, 130, 0.6); }
.scope.digi-on .spots-btn { right: calc(50% + 74px); }
/* reactions: the palette button, left of DX (or of the zoom without it) */
.react-btn {
  position: absolute;
  top: 8px;
  right: 74px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  padding: 0;
  color: var(--dim);
  background: rgba(10, 15, 24, 0.75);
  border: 1px solid var(--line-hi);
  border-radius: 4px;
  cursor: pointer;
  transition: right 0.25s ease;
}
.spots-btn:not([hidden]) + .react-btn { right: 120px; }
.react-btn:hover, .react-btn[aria-expanded="true"] { color: var(--amber); border-color: rgba(255, 159, 28, 0.6); }
.react-btn.off { opacity: 0.55; }
.scope.digi-on .react-btn { right: calc(50% + 74px); }
.scope.digi-on .spots-btn:not([hidden]) + .react-btn { right: calc(50% + 120px); }
.react-pal {
  position: absolute;
  top: 40px;
  right: 10px;
  z-index: 4;
  padding: 10px;
  background: rgba(11, 15, 23, 0.96);
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.scope.digi-on .react-pal { right: calc(50% + 10px); }
.react-head {
  margin: 0 2px 8px;
  font: 600 0.62rem var(--font);
  letter-spacing: 0.14em;
  color: var(--dim);
}
.react-grid { display: grid; grid-template-columns: repeat(4, 60px); gap: 6px; }
.react-pick {
  display: grid;
  place-items: center;
  height: 52px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.react-pick img { max-width: 100%; max-height: 42px; }
.react-pick:hover:not(:disabled) { transform: scale(1.08); border-color: rgba(255, 159, 28, 0.6); }
.react-pick:disabled { cursor: default; opacity: 0.35; }
.react-hide {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 0 0;
  font: 600 0.62rem var(--font);
  letter-spacing: 0.12em;
  color: var(--dim);
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.react-hide:hover { color: var(--text); }
.zoom-lv { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.zoom-lv i { width: 3px; background: var(--line-hi); border-radius: 1px; }
.zoom-lv i:nth-child(1) { height: 4px; }
.zoom-lv i:nth-child(2) { height: 6px; }
.zoom-lv i:nth-child(3) { height: 9px; }
.zoom-lv i:nth-child(4) { height: 12px; }
.zoom-btn[data-zoom="1"] .zoom-lv i:nth-child(-n+1),
.zoom-btn[data-zoom="2"] .zoom-lv i:nth-child(-n+2),
.zoom-btn[data-zoom="3"] .zoom-lv i:nth-child(-n+3),
.zoom-btn[data-zoom="4"] .zoom-lv i:nth-child(-n+4) { background: var(--amber); }

/* GAN / AF sliders inside the meter card */
.ctls {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ctl {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 48px;
  align-items: center;
  column-gap: 10px;
}
.ctl-name { font-size: 0.68rem; letter-spacing: 0.18em; color: var(--dim); }
.ctl input[type=range] { width: 100%; }
.ctl > b {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--amber-hi);
  font-variant-numeric: tabular-nums;
}
.keys { display: flex; flex-wrap: wrap; gap: 6px; }
.key {
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #c9d2df;
  background: linear-gradient(180deg, #1a2231, #111722);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 8px 12px;
  min-width: 54px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 0 rgba(0,0,0,0.4);
  transition: color 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.05s;
}
.key:hover { color: #fff; border-color: #3a4862; }
.key:active { transform: translateY(1px); }
.key:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.key.active {
  color: var(--amber-hi);
  border-color: rgba(255, 159, 28, 0.6);
  box-shadow:
    inset 0 -3px 0 var(--amber),
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 0 14px var(--amber-glow);
}
.bands .key { min-width: 62px; }
.bands .key small { display: block; font-size: 0.62rem; font-weight: 500; color: var(--dim); letter-spacing: 0.04em; }
.bands .key.active small { color: rgba(255, 191, 94, 0.75); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 170px;
  height: 34px;
  background: transparent;
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--amber) var(--fill, 50%), var(--line-hi) var(--fill, 50%));
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-hi); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--amber); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #c7ced9 60%, #8a93a3);
  border: 1px solid #0b0f17;
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.25), 0 2px 4px rgba(0,0,0,0.5);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #c7ced9 60%, #8a93a3);
  border: 1px solid #0b0f17;
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.25);
}
/* Tips: a bar floating over the bottom of the waterfall, as wide as the
   page. Desktop only: on phones and tablets the mouse/keyboard tips don't
   apply, see the media query below. */
.tips {
  position: fixed;
  left: max(16px, calc((100vw - 1440px) / 2 + 16px));
  right: max(16px, calc((100vw - 1440px) / 2 + 16px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 8px 7px 14px;
  background: rgba(11, 15, 23, 0.96);
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--dim);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  line-height: 1.6;
}
.tips .pop-title { margin: 0; flex: none; }
.tips ul { flex: 1; margin: 0; padding: 0; list-style: none; }
.tips li { display: inline; }
.tips li + li::before { content: " · "; color: var(--faint); }
.tips b { color: var(--text); font-weight: 600; }
.tips kbd {
  font-family: var(--font);
  font-size: 0.7rem;
  padding: 0 5px;
  border: 1px solid var(--line-hi);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
}
.tips-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.tips-x, .tips-never {
  font: inherit;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
}
.tips-x { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 3px; }
.tips-never { padding: 0 4px; font-size: 0.7rem; letter-spacing: 0.06em; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.tips-x:hover, .tips-never:hover { color: var(--amber-hi); }
.tips-x:focus-visible, .tips-never:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
@media (max-width: 760px), (hover: none) {
  .tips { display: none; }
}

/* Maintenance banner, under the top bar while the server is being worked on */
/* short-lived message from the server (e.g. decoder busy) */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  background: rgba(12, 16, 25, 0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 159, 28, 0.5);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--amber-hi);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -6px); } }
.maint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 159, 28, 0.55);
  border-radius: 6px;
  background: rgba(255, 159, 28, 0.1);
  color: var(--amber-hi);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  line-height: 1.4;
}
.maint svg { flex: none; }
/* the station is on the air: everyone's receiver is silent meanwhile */
.maint.txon { border-color: rgba(255, 77, 77, 0.6); background: rgba(255, 77, 77, 0.12); color: #ffb3b3; }
.rx.tx { color: #2a0000; background: var(--bad); border-color: var(--bad); box-shadow: 0 0 12px rgba(255, 77, 77, 0.5); }

/* transmit bar: admins in control, once transmitting is switched on */
.tx-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
}
.tx-bar .ctl-btn { margin-left: 0; }
.tx-bar .tx-arm.on { color: #2a0000; background: var(--bad); border-color: var(--bad); box-shadow: 0 0 12px rgba(255, 77, 77, 0.35); }
.tx-bar .ctl-btn:disabled { opacity: 0.4; cursor: default; }
.tx-mic { display: flex; align-items: center; gap: 8px; font-size: 0.68rem; letter-spacing: 0.18em; color: var(--dim); }
.tx-mic-bar { width: 90px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.tx-mic-bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.06s linear; }
.tx-mic-bar i.hot { background: var(--bad); }
.tx-drive { width: 230px; }
.tx-timer { font-size: 0.8rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.tx-timer.warn { color: var(--amber-hi); }
.tx-note { font-size: 0.74rem; color: var(--dim); flex: 1 1 200px; }
.tx-keys { margin-left: auto; display: flex; gap: 8px; }
.tx-ptt {
  min-width: 132px;
  padding: 10px 18px;
  font: 700 0.95rem var(--font);
  letter-spacing: 0.2em;
  color: #ffb3b3;
  background: linear-gradient(180deg, #2a1418, #170b0e);
  border: 1px solid rgba(255, 77, 77, 0.6);
  border-radius: 4px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tx-ptt:hover { border-color: var(--bad); color: #fff; }
.tx-ptt.on { color: #fff; background: var(--bad); border-color: var(--bad); box-shadow: 0 0 22px rgba(255, 77, 77, 0.6); }
.tx-bar.on-air { border-color: rgba(255, 77, 77, 0.6); }
.tx-ptt.tx-tune { min-width: 96px; color: var(--amber-hi); border-color: rgba(255, 159, 28, 0.6); background: linear-gradient(180deg, #2a2014, #17110b); }
.tx-ptt.tx-tune:hover { border-color: var(--amber); color: #fff; }
.tx-ptt.tx-tune.on { color: #1b0f00; background: var(--amber); border-color: var(--amber); box-shadow: 0 0 22px var(--amber-glow); }

/* FT8/FT4 panel: covers the right half of the scope. The scope itself isn't
   resized (that would rescale the waterfall); its content slides left a
   quarter so the dial stays centred in the half left visible. */
.scope-view { transition: transform 0.25s ease; }
.scope.digi-on .scope-view { transform: translateX(-25%); }
.digi-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 23, 0.97);
  border-left: 1px solid var(--line-hi);
  box-shadow: -12px 0 30px rgba(0, 0, 0, 0.45);
  cursor: default;
  font-size: 0.78rem;
  container: digi / inline-size;
}
.digi-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 8px;
  letter-spacing: 0.12em;
  color: var(--dim);
  font-size: 0.72rem;
}
.digi-head .tag { color: var(--amber-hi); font-weight: 700; letter-spacing: 0.18em; }
.digi-head b { color: var(--text); font-weight: 600; }
#digiStatus { margin-left: auto; text-align: right; }
#digiStatus.warn { color: var(--amber-hi); }
.digi-btn {
  font: inherit;
  letter-spacing: 0.12em;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  height: 24px;
  padding: 0 8px;
  line-height: 1;
  cursor: pointer;
}
.digi-close { width: 24px; padding: 0; letter-spacing: 0; }
.digi-btn:hover { color: var(--text); border-color: rgba(255, 159, 28, 0.6); }
.digi-progress { height: 2px; background: var(--line); }
.digi-progress i { display: block; height: 100%; width: 0; background: var(--amber); }
.digi-body { flex: 1; min-height: 0; display: flex; }
/* FT8 transmit strip (admins in control, FT8 frequency) */
.ft8-tx {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--dim);
}
.ft8-tx .tag { color: var(--bad); font-weight: 700; letter-spacing: 0.18em; }
.ft8-tx.on { background: rgba(255, 77, 77, 0.07); }
.ft8-tx.on-air .tag { animation: ft8-blink 1s steps(2) infinite; }
@keyframes ft8-blink { 50% { opacity: 0.35; } }
.ft8-cq { color: var(--ok); border-color: rgba(62, 224, 122, 0.5); }
.ft8-stop:not(:disabled) { color: #fff; background: var(--bad); border-color: var(--bad); }
.ft8-df input {
  width: 4.6em;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 3px 4px;
}
.ft8-msg { color: var(--text); font-family: ui-monospace, "DejaVu Sans Mono", monospace; letter-spacing: 0.02em; }
.ft8-state { flex: 1 1 100%; letter-spacing: 0.04em; }
.ft8-state.warn { color: var(--amber-hi); }
.digi-list tr.tx td { color: var(--bad); }
.digi-list tr.tx td:last-child { color: #ffb3b3; }
.digi-list tr.partner td:last-child { color: var(--amber-hi); }
.digi-panel.ft8-able .digi-list tbody tr:not(.tx) { cursor: pointer; }
.digi-list { flex: 0 0 auto; width: 345px; max-width: 58%; overflow-y: auto; }
.digi-list table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.digi-list th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--dim);
  font-weight: 500;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-align: right;
  padding: 6px 6px;
  border-bottom: 1px solid var(--line);
}
.digi-list td { padding: 3px 6px; text-align: right; color: var(--dim); white-space: nowrap; }
.digi-list th:last-child, .digi-list td:last-child { text-align: left; width: 100%; }
.digi-list td:last-child { color: var(--text); font-family: ui-monospace, "DejaVu Sans Mono", monospace; letter-spacing: 0.02em; }
.digi-list tr.cq td:last-child { color: var(--ok); }
.digi-list td a { color: inherit; text-decoration: none; border-radius: 2px; }
.digi-list td a:hover { color: var(--amber-hi); text-decoration: underline; text-underline-offset: 3px; }
.digi-list tr.slot-first td { border-top: 1px solid var(--line); }
.digi-list tr.fresh td { animation: digi-fresh 1.5s ease-out; }
@keyframes digi-fresh { from { background: rgba(255, 159, 28, 0.16); } to { background: transparent; } }
.digi-empty { padding: 18px 14px; color: var(--dim); line-height: 1.6; }
.digi-icon { width: 24px; padding: 0; display: inline-grid; place-items: center; }
.digi-icon .i-min, .digi-panel.max .digi-icon .i-max { display: none; }
.digi-panel.max .digi-icon .i-min { display: block; }

/* map of the stations heard, right of the list */
.digi-map {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
/* right of the decodes: the QSO (admins who transmit FT8) and the map */
.digi-side { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.digi-tabs { display: flex; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.digi-tab {
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  height: 22px;
  padding: 0 10px;
  cursor: pointer;
}
.digi-tab.on { color: var(--amber-hi); border-color: rgba(255, 159, 28, 0.6); }
.digi-panel .digi-side .digi-qso { flex: 1; width: auto; min-width: 0; max-width: none; }
.digi-qso tr.to-us td:last-child { color: var(--amber-hi); }
/* FT8 waterfall: 0-3000 Hz of the audio (ft8wf.js) */
.digi-panel:not(.max) .digi-wf { display: none; }  /* only maximized: room for it */
.digi-wf {
  flex: none;
  height: clamp(56px, 24%, 190px);
  display: flex;
  flex-direction: column;
  background: rgb(2, 6, 20);
  border-bottom: 1px solid var(--line);
}
/* the Hz scale, and the TX / other station's labels, on a strip of its own */
.digi-wf-scale {
  position: relative;
  flex: none;
  height: 18px;
  background: #05080f;
  border-bottom: 1px solid var(--line);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  color: var(--dim);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.digi-wf-scale span { position: absolute; top: 0; line-height: 18px; transform: translateX(-50%); white-space: nowrap; }
.digi-wf-scale span::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 4px;
  background: var(--line-hi);
}
.digi-wf-scale .wf-mark { transform: none; padding: 0 5px; font-weight: 700; letter-spacing: 0.1em; }
.digi-wf-scale .wf-mark::before { display: none; }
.digi-wf-scale .wf-tx { color: #fff; background: var(--bad); }
.digi-wf-scale .wf-them { color: #1b0f00; background: var(--amber); }
.digi-wf-pic { position: relative; flex: 1; min-height: 0; }
.digi-wf canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.digi-wf.pick #digiWfOver { cursor: crosshair; }
.digi-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.digi-map-legend {
  position: absolute;
  left: 10px;
  bottom: 8px;
  right: 10px;
  color: var(--dim);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
.digi-map-tip {
  position: absolute;
  padding: 6px 9px;
  background: rgba(12, 16, 25, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.digi-map-tip b { color: var(--text); font-weight: 600; letter-spacing: 0.06em; }
.digi-map-tip span { color: var(--amber-hi); }
.digi-map-tip div { margin-top: 2px; }

/* maximized: nearly the whole window, over a dimmed page */
.digi-panel.max {
  position: fixed;
  inset: 3vh 3vw;
  width: auto;
  z-index: 45;
  border: 1px solid var(--line-hi);
  border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(2, 4, 8, 0.72), 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: digi-max 0.22s ease-out;
}
@keyframes digi-max { from { opacity: 0; transform: scale(0.985); } }
.digi-panel.max .digi-list { width: 38%; min-width: 400px; max-width: none; }
.digi-panel.max .digi-head { padding: 12px 16px 10px; }

/* too narrow for both: list only, or stacked when maximized */
@container digi (max-width: 640px) {
  /* one column: the QSO (or map) above the decodes */
  .digi-body { flex-direction: column-reverse; }
  .digi-panel .digi-list { width: auto; min-width: 0; max-width: none; flex: 1; }
  .digi-panel:not(.max):not(.has-qso) .digi-side { display: none; }
  .digi-side { flex: 0 0 42%; border-left: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .display { grid-template-columns: 1fr; }
  /* stacked layout: too tall to fit, so the page scrolls normally */
  .rig { height: auto; }
  .scope { flex: none; height: 380px; min-height: 0; }
  #spectrum { height: 120px; }
  .vfo { padding: 12px 14px 10px; }
  /* too narrow to split: the panel covers the waterfall, spectrum stays */
  .scope.digi-on .scope-view { transform: none; }
  .digi-panel { width: 100%; top: 147px; border-left: 0; border-top: 1px solid var(--line-hi); }
  .digi-panel.max { inset: 0; border-radius: 0; border: 0; }
  .tx-drive { width: 100%; }
  .tx-keys { width: 100%; margin-left: 0; }
  .tx-ptt { flex: 1; padding: 16px; }
}

/* ---------- operators: login, presence, read-only listeners ---------- */
.chip b { color: var(--text); font-weight: 600; }
.chip-btn {
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.chip-btn:hover { border-color: rgba(255, 159, 28, 0.6); color: var(--text); }
.chip-btn.user { color: var(--amber-hi); border-color: rgba(255, 159, 28, 0.45); }
.pop-right { left: auto; right: 0; }
.login { display: flex; flex-direction: column; gap: 8px; width: min(250px, calc(100vw - 32px)); }
.login .pop-title { margin-bottom: 0; }
.login-note { margin: 0; color: var(--dim); font-size: 0.74rem; line-height: 1.45; }
.login-note b { color: var(--text); }
.login input {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: #0a0f18;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 7px 9px;
}
.login input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.login-err { margin: 0; color: #ff8a8a; font-size: 0.74rem; }
.key-link { display: block; text-align: center; text-decoration: none; }

/* listeners: the receiver controls are shown but disabled */
.cyc:disabled, .pick-btn:disabled, .digi-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.cyc:disabled:hover { border-color: var(--line-hi); color: inherit; }
input[type=range]:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- session: idle warning, disconnected / full notices ---------- */
.idle-warn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  border: 1px solid rgba(255, 159, 28, 0.6);
  border-radius: 6px;
  background: rgba(30, 20, 5, 0.95);
  color: var(--amber-hi);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.idle-warn b { color: #fff; }
.notice {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 5, 9, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.notice-card {
  width: min(360px, 100%);
  padding: 18px 20px 20px;
  background: var(--panel);
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.notice-card p { margin: 6px 0 16px; color: var(--text); font-size: 0.9rem; line-height: 1.5; }
.notice-card .key { width: 100%; }
/* first visit / reload: nothing connects (nor wakes the radio) until the
   visitor asks; that click also starts the audio */
.start-card { width: min(400px, 100%); }
.start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: var(--amber-hi);
  border-color: rgba(255, 159, 28, 0.6);
  box-shadow: 0 0 18px var(--amber-glow), inset 0 1px 0 rgba(255,255,255,0.06);
}
.start-btn:hover { color: #fff; border-color: var(--amber); }
.notice-card .start-note { margin: 12px 0 0; font-size: 0.76rem; color: var(--dim); text-align: center; }
.start-note a { color: var(--cyan); }

/* "How it works" link in the top bar: a neutral version of the speaker */
.icon-btn.help-btn {
  border-color: var(--line-hi);
  background: var(--panel);
  color: var(--dim);
}
.icon-btn.help-btn:hover { color: var(--text); }
.tips a { color: var(--cyan); }
