@font-face { font-family: "DSEG7"; src: url(fonts/DSEG7Classic-Bold.woff2) format("woff2"); font-display: block; }
@font-face { font-family: "DSEG14"; src: url(fonts/DSEG14Classic-Regular.woff2) format("woff2"); font-display: block; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-semi-condensed-latin-400-normal.woff2) format("woff2"); font-weight: 400; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); font-weight: 600; }

:root {
  --panel: #232a30;        /* anodised faceplate */
  --panel-2: #2c343b;
  --edge: #3b454e;
  --ink: #c9d1d7;          /* brushed-aluminium text */
  --ink-dim: #8a959e;
  --glass: #07131a;        /* display window */
  --phos: #7ef0e3;         /* VFD phosphor */
  --phos-ghost: #12302f;   /* unlit segments */
  --phos-mid: #3fa79c;
  --amber: #ffb547;
  --red: #ff6b5a;
  --r-s: 4px;
  --r-l: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--panel); color: var(--ink);
  font: 400 15px/1.45 "Barlow SC", system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
h1, h2 { font-weight: 600; margin: 0; }
h1 { font-size: 19px; letter-spacing: .02em; }
h2 { font-size: 16px; }
.muted { color: var(--ink-dim); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: linear-gradient(#2f383f, #262e34); border-bottom: 1px solid #161b1f; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--edge); }
.pill.on { color: var(--phos); border-color: var(--phos-mid); }
.pill.off { color: var(--red); border-color: #6b3a35; }
#lockstate { color: var(--amber); border-color: #6b5530; }

main { padding: 16px 20px 28px; max-width: 1500px; margin: 0 auto; display: grid; gap: 14px; }
main > *, .lower > *, .side > * { min-width: 0; }

/* ---------- display window ---------- */
.window {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 20% 0%, #0d2029 0%, var(--glass) 55%);
  border-radius: var(--r-l); border: 2px solid #11181d;
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, .7), 0 1px 0 #3a444c;
  padding: 18px 22px 16px; color: var(--phos);
  display: grid; gap: 10px 28px;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "freq ps pi"
    "rt rt rt"
    "meter meter tx"
    "cand cand cand"
    "af af af";
}
.glare { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(170deg, rgba(255,255,255,.05) 0%, rgba(255,255,255,0) 38%); }
/* lit text and its ghost of unlit segments share one grid cell */
.seg7, .seg14 { display: inline-grid; line-height: 1; justify-content: start; }
.seg7 > span, .seg14 > span { grid-area: 1 / 1; white-space: pre; }
.seg7 { font-family: "DSEG7"; }
.seg14 { font-family: "DSEG14"; }
.seg7 .ghost, .seg14 .ghost { color: var(--phos-ghost); }
.seg7 > span:last-child, .seg14 > span:last-child {
  text-shadow: 0 0 6px rgba(126, 240, 227, .55), 0 0 18px rgba(126, 240, 227, .25); }
.piblock .seg14 { justify-content: end; }
.compass:not(.on):not(.anton) { visibility: hidden; }

.freqblock { grid-area: freq; display: flex; align-items: flex-end; gap: 10px; }
.big { font-size: clamp(44px, 7vw, 76px); }
.units { display: grid; gap: 4px; font-weight: 600; font-size: 14px; color: var(--phos-mid); padding-bottom: 6px; }
.units #modeLabel { color: var(--phos); }

.psblock { grid-area: ps; display: grid; align-content: end; gap: 8px; }
.ps { font-size: clamp(28px, 4vw, 44px); letter-spacing: .04em; }
.ps .partial { opacity: .45; }
.ann { display: flex; gap: 14px; font-weight: 600; font-size: 12px; letter-spacing: .08em; }
.ann span { color: var(--phos-ghost); transition: color .15s; }
.ann span.lit { color: var(--phos); text-shadow: 0 0 6px rgba(126,240,227,.5); }
.ann #annSt.lit { color: var(--amber); text-shadow: 0 0 6px rgba(255,181,71,.5); }

.piblock { grid-area: pi; text-align: right; display: grid; align-content: end; gap: 4px; justify-items: end; }
.pi { font-size: 30px; }
.call { font-size: 22px; font-weight: 600; height: 1.25em; white-space: nowrap; }
.call .derived { color: var(--phos-mid); font-weight: 400; font-size: 14px; }
.call .mismatch { color: var(--amber); cursor: help; }
.piblock .falsepi > span:last-child { color: var(--amber); text-shadow: 0 0 6px rgba(255,181,71,.5); }
.dist { font-size: 17px; font-weight: 600; color: var(--phos); height: 1.25em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ann #annHd.lit { color: var(--amber); text-shadow: 0 0 6px rgba(255,181,71,.5); }
.pty { font-size: 14px; color: var(--phos-mid); height: 1.3em; white-space: nowrap; }

.rt { grid-area: rt; font-size: 19px; border-top: 1px solid #12252b; padding-top: 8px;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
  /* fixed two-line box so arriving RadioText never moves anything below it */
  height: calc(2 * 1.35em + 8px); overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rt .partial { opacity: .5; }

.meterrow { grid-area: meter; display: grid; gap: 6px; align-content: center; }
.bars { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; height: 16px; max-width: 560px; }
.bars i { background: var(--phos-ghost); border-radius: 1px; }
.bars i.on { background: var(--phos); box-shadow: 0 0 6px rgba(126,240,227,.45); }
.bars i.hot { background: var(--amber); }
.readout { font-size: 14px; color: var(--phos-mid); }
.readout b { color: var(--phos); font-size: 17px; }
.sep { display: inline-block; width: 14px; }

.tx { grid-area: tx; display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; align-items: center; min-width: 260px; }
.txmain { font-size: 17px; font-weight: 600; grid-column: 1; height: 1.35em; }
.txsub { font-size: 14px; color: var(--phos-mid); grid-column: 1; height: 1.35em; }
.txmain, .txsub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.compass { grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--phos-ghost); position: relative; }
.compass i { position: absolute; left: 50%; top: 4px; width: 2px; height: 18px; margin-left: -1px;
  background: var(--phos); transform-origin: 50% 18px; transform: rotate(0deg); opacity: 0; transition: transform .4s; }
.compass.on i#needle { opacity: 1; }
.compass i.ant { background: var(--amber); width: 3px; margin-left: -1.5px; }
.compass.anton i.ant { opacity: .9; }

/* possible stations on the tuned channel: fixed height, scrolls, so it never moves the page */
.cands { grid-area: cand; height: 8.6em; overflow-y: auto; font-size: 14px; border-top: 1px solid #12252b; padding-top: 6px; }
.cands .head { color: var(--phos-mid); font-size: 13px; margin-bottom: 2px; }
.cands table { font-size: 14px; }
.cands th { background: var(--glass); color: var(--phos-mid); font-weight: 600; padding: 2px 8px; border-bottom: 1px solid #12252b; }
.cands td { padding: 1px 8px; border-bottom: none; color: var(--phos); }
.cands tr { cursor: default; }
.cands tbody tr:hover td { background: #0d2029; }
.cands tr.hit td { color: var(--amber); }
.cands tr.dim td { color: var(--phos-mid); opacity: .7; }
.cands .beam { color: var(--amber); }

.af { grid-area: af; display: flex; flex-wrap: nowrap; gap: 6px; font-size: 13px; height: 22px; overflow: hidden; }
.af button { background: none; border: 1px solid var(--phos-ghost); color: var(--phos-mid);
  border-radius: var(--r-s); padding: 1px 7px; cursor: pointer; }
.af button:hover { color: var(--phos); border-color: var(--phos-mid); }

/* ---------- HD Radio ---------- */
.hdbox { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start;
  background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--r-l); padding: 12px 14px; }
.hdart { display: flex; gap: 8px; }
.hdart { width: 96px; height: 96px; border-radius: var(--r-s); background: #11181d; overflow: hidden; }
.hdart img { width: 96px; height: 96px; object-fit: contain; }
.hdart img[hidden] { display: none; }
.hdart img:not([hidden]) + img { display: none; }      /* one 96px tile: album art, else station logo */
.hdmain { display: grid; gap: 8px; min-width: 0; }
.hdtop { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.hdtop b { font-size: 17px; }
.hdprogs { flex-wrap: wrap; }
.hdprogs button[aria-pressed=true] { background: #1d4a47; border-color: var(--phos-mid); color: #dffaf6; position: relative; }
.hdprogs button.pending { color: var(--ink-dim); }
.hdnow { font-size: 16px; color: var(--phos); height: 1.4em; }
.hdnow, #hdMsg, .hdtop { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hdMsg { height: 1.4em; }
.hdtop { flex-wrap: nowrap; height: 1.6em; }

/* ---------- RDS details ---------- */
.rdsbox { background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--r-l); padding: 10px 14px; }
.rdsbox summary { cursor: pointer; font-weight: 600; }
.rdslist { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 10px 0 2px; font-size: 14px; }
.rdslist dt { color: var(--ink-dim); }
.rdslist dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.rdslist dd.pre { white-space: pre-line; }

/* ---------- scope ---------- */
.scope { position: relative; background: var(--glass); border-radius: var(--r-l); overflow: hidden;
  border: 2px solid #11181d; }
.scope canvas { display: block; width: 100%; }
#spec { height: 150px; cursor: crosshair; }
.cursorinfo { position: absolute; top: 6px; right: 8px; pointer-events: none; font-size: 13px;
  font-variant-numeric: tabular-nums; color: var(--phos); background: rgba(7,19,26,.85); padding: 2px 8px;
  border-radius: var(--r-s); border: 1px solid var(--phos-ghost); }
.scope canvas[hidden], .scopetools label[hidden] { display: none !important; }
.scopebox { background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--r-l); padding: 10px 14px; }
.scopebox summary { cursor: pointer; font-weight: 600; }
.scopebox[open] summary { margin-bottom: 10px; }
.scopetools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.scopetools label { display: flex; align-items: center; gap: 8px; color: var(--ink-dim); }
#scale { height: 26px; background: #0b1a21; cursor: crosshair; }
#wf { height: 300px; cursor: crosshair; }
.banner { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 5; background: rgba(7,19,26,.95);
  color: var(--amber); border: 1px solid #6b5530; padding: 4px 14px; border-radius: 99px; font-size: 14px; }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.controls label { display: flex; align-items: center; gap: 8px; color: var(--ink-dim); }
.group { display: flex; gap: 0; }
.gainctl { display: flex; align-items: center; gap: 6px; }
.group > * { border-radius: 0; }
.group > *:first-child { border-radius: var(--r-s) 0 0 var(--r-s); }
.group > *:last-child { border-radius: 0 var(--r-s) var(--r-s) 0; }
.group > * + * { margin-left: -1px; }
button, select, input:not([type=range]):not([type=checkbox]), a.button {
  background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--r-s);
  padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block; color: var(--ink); }
input:not([type=range]):not([type=checkbox]) { cursor: text; background: #1b2126; }
#freqIn { width: 7.5em; text-align: right; }
button:hover, select:hover, a.button:hover { border-color: #56636e; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--phos); outline-offset: 2px; }
button.primary { background: #1d4a47; border-color: var(--phos-mid); color: #dffaf6; }
button.primary.waiting { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(126,240,227,.25); } }
button.ghost, a.ghost { background: transparent; }
button.danger { color: var(--red); }
.modes button[aria-pressed=true] { background: #1d4a47; border-color: var(--phos-mid); color: #dffaf6; position: relative; }
input[type=range] { accent-color: var(--phos-mid); width: 96px; }
.check { gap: 6px !important; color: var(--ink) !important; }
input[type=checkbox] { accent-color: var(--phos-mid); }

/* ---------- lower ---------- */
.lower { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
.logbox, .adminbox, .chatbox { background: var(--panel-2); border: 1px solid var(--edge); border-radius: var(--r-l); padding: 12px 14px; }
.boxhead { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.tablewrap { max-height: 420px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--ink-dim); position: sticky; top: 0; background: var(--panel-2);
  padding: 6px 8px; border-bottom: 1px solid var(--edge); }
td { padding: 5px 8px; border-bottom: 1px solid #2f383f; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #333c44; }
tr.isnew td { color: var(--amber); }
tr.isnew td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(255,181,71,.25); } to { background: transparent; } }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .03em; }
td.falsepi { color: var(--amber); cursor: help; }
.calrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ovform { display: grid; gap: 6px; border-top: 1px solid var(--edge); padding-top: 10px; }
.ovform input { width: 9em; text-transform: uppercase; }
.ovlist { margin: 0; padding-left: 18px; color: var(--ink-dim); }
.empty { color: var(--ink-dim); margin: 14px 4px; }

.side { display: grid; gap: 14px; }
.adminbox { display: grid; gap: 10px; }
.adminbox label { display: flex; gap: 8px; align-items: center; color: var(--ink-dim); }
.adminrow { display: flex; gap: 8px; flex-wrap: wrap; }
.chat { height: 220px; overflow-y: auto; font-size: 14px; display: grid; align-content: start; gap: 4px; margin: 8px 0; }
.chat .who { color: var(--phos-mid); font-weight: 600; margin-right: 6px; }
.chat .who.admin { color: var(--amber); }
#chatForm { display: grid; grid-template-columns: 90px 1fr auto; gap: 6px; }
#chatForm input { min-width: 0; }

dialog { background: var(--panel-2); color: var(--ink); border: 1px solid var(--edge); border-radius: var(--r-l); padding: 18px; width: 320px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog form { display: grid; gap: 12px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #11181d; color: var(--ink);
  border: 1px solid var(--edge); padding: 8px 16px; border-radius: var(--r-s); z-index: 10; }

@media (max-width: 1000px) {
  .window { grid-template-columns: 1fr auto; grid-template-areas: "freq pi" "ps ps" "rt rt" "meter meter" "tx tx" "cand cand" "af af"; }
  .lower { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .hdbox { grid-template-columns: 1fr; }
  .rdslist { grid-template-columns: 1fr; }
  .rdslist dd { margin-bottom: 6px; }
  main { padding: 10px 10px 20px; }
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .window { padding: 14px; grid-template-columns: 1fr; grid-template-areas: "freq" "pi" "ps" "rt" "meter" "tx" "cand" "af"; }
  .piblock { text-align: left; justify-items: start; }
  #wf { height: 220px; }
  .big { font-size: 38px; }
  .ps { font-size: 26px; }
  .tx { min-width: 0; }
  .ann { gap: 10px; flex-wrap: wrap; }
  .controls .spacer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
