:root {
  --bench: #121413;
  --body-hi: #3b3f3c;
  --body: #2b2e2c;
  --body-lo: #1b1d1c;
  --edge: #0c0d0c;
  --print: #c9c4b4; /* silk-screened labels */
  --print-dim: #8c887c;
  --lcd-bg: #170f04;
  --lcd-on: #ffb648;
  --lcd-glow: rgba(255, 160, 50, 0.55);
  --lcd-ghost: rgba(255, 182, 72, 0.07);
  --tx: #ff3b2f;
  --rx: #3dff7a;
  --needle: #ff4a2a;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(ellipse at 50% 0%, #252927 0%, transparent 60%),
    var(--bench);
  color: var(--print);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

.bench {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 16px;
}

.hint { margin: 0; color: var(--print-dim); font-size: 13px; text-align: center; }
kbd { font-family: var(--mono); border: 1px solid #444; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* ---------- Chassis ---------- */

.radio {
  position: relative;
  width: 100%;
  max-width: 760px;
  padding: 22px 26px 20px;
  border-radius: 22px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px), /* brushed grain */
    linear-gradient(180deg, var(--body-hi), var(--body) 18%, var(--body) 80%, var(--body-lo));
  border: 1px solid var(--edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.5),
    0 2px 0 #050505,
    0 30px 60px -20px rgba(0, 0, 0, 0.8),
    0 10px 20px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-select: none;
}

.screw {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 44%, #1a1a1a 44% 56%, transparent 56%),
    radial-gradient(circle at 35% 30%, #9a9a94, #4a4a46 70%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.08);
}
.screw.tl { top: 10px; left: 10px; }
.screw.tr { top: 10px; right: 10px; transform: rotate(70deg); }
.screw.bl { bottom: 10px; left: 10px; transform: rotate(20deg); }
.screw.br { bottom: 10px; right: 10px; transform: rotate(110deg); }

/* ---------- Top strip: brand, lights, power ---------- */

.radio-top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}

.brand { display: flex; flex-direction: column; line-height: 1; margin-right: auto; }
.brand-name { font-weight: 800; font-size: 22px; letter-spacing: 0.08em; color: #ddd8c8; text-shadow: 0 -1px 0 #000; }
.brand-sub { font-size: 9px; letter-spacing: 0.32em; color: var(--print-dim); margin-top: 4px; }

.lights { display: flex; gap: 16px; font-size: 10px; font-weight: 700; letter-spacing: 0.15em; color: var(--print-dim); }
.light { display: flex; align-items: center; gap: 6px; }

.led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #000;
  background: radial-gradient(circle at 35% 30%, #4a4a4a, #1a1a1a);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: background 0.08s, box-shadow 0.08s;
}
.led-tx.on {
  background: radial-gradient(circle at 35% 30%, #ffd0c8, var(--tx) 45%, #8a0c05);
  box-shadow: 0 0 8px 2px rgba(255, 59, 47, 0.7), 0 0 22px rgba(255, 59, 47, 0.4);
}
.led-rx.on {
  background: radial-gradient(circle at 35% 30%, #d8ffe2, var(--rx) 45%, #0a6b2a);
  box-shadow: 0 0 8px 2px rgba(61, 255, 122, 0.6), 0 0 22px rgba(61, 255, 122, 0.35);
}

/* Toggle switch */
.power {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  background: none;
  border: 0;
  color: var(--print-dim);
  cursor: pointer;
  font: 700 10px var(--sans);
  letter-spacing: 0.15em;
}
.power-track {
  position: relative;
  width: 54px;
  height: 26px;
  border-radius: 13px;
  background: linear-gradient(180deg, #0b0c0b, #1e201f);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.07);
}
.power-lever {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8e4d8, #8f8b80 70%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
  transition: transform 0.15s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.power[aria-checked="true"] .power-lever { transform: translateX(28px); }
.power[aria-checked="true"] .power-track { box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 182, 72, 0.35); }
.power-text { display: flex; flex-direction: column; line-height: 1.25; }
.power[aria-checked="false"] .power-text span:first-child,
.power[aria-checked="true"] .power-text span:last-child { color: var(--lcd-on); }

/* ---------- Body: grille + face ---------- */

.radio-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  padding: 20px 8px;
}

.grille {
  border-radius: 14px;
  background:
    radial-gradient(circle, #050505 0 2.4px, transparent 2.9px) 0 0 / 10px 10px,
    linear-gradient(180deg, #262827, #1c1e1d);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.06);
}

.face { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- LCD ---------- */

.lcd {
  position: relative;
  padding: 10px 16px 12px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 40%), /* glass reflection */
    radial-gradient(ellipse at 50% 60%, #2a1a06, var(--lcd-bg) 75%);
  border: 3px solid #0a0a0a;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--lcd-on);
  font-family: var(--mono);
  text-shadow: 0 0 6px var(--lcd-glow);
  overflow: hidden;
}

.lcd-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.lcd-row:last-child { justify-content: space-between; }
.lcd-mode { min-width: 2ch; }
.lcd-link:is([data-link="retry"], [data-link="full"], [data-link="wait"]) { animation: blink 1s steps(2, start) infinite; }
.lcd-link[data-link="scan"] { animation: blink 0.4s steps(2, start) infinite; }

.lcd-bars { display: flex; align-items: flex-end; gap: 3px; margin-left: auto; height: 14px; }
.lcd-bars i { width: 5px; background: var(--lcd-ghost); box-shadow: none; }
.lcd-bars i:nth-child(1) { height: 20%; }
.lcd-bars i:nth-child(2) { height: 40%; }
.lcd-bars i:nth-child(3) { height: 60%; }
.lcd-bars i:nth-child(4) { height: 80%; }
.lcd-bars i:nth-child(5) { height: 100%; }
.lcd-bars i.on { background: var(--lcd-on); box-shadow: 0 0 5px var(--lcd-glow); }

.lcd-freq { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; margin: 2px 0; }
.lcd-freq-digits { display: grid; font-size: clamp(48px, 11vw, 76px); font-weight: 700; line-height: 1; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.lcd-ghost, .lcd-freq-value { grid-area: 1 / 1; text-align: right; white-space: pre; }
.lcd-ghost { color: var(--lcd-ghost); text-shadow: none; }
.lcd-unit { font-size: 16px; font-weight: 700; letter-spacing: 0.1em; }
.lcd-talker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Powered off: dark glass, nothing lit. */
.radio[data-power="off"] .lcd { color: transparent; text-shadow: none; background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 40%), #0b0a08; }
.radio[data-power="off"] .lcd-ghost { color: rgba(255, 255, 255, 0.025); }
.radio[data-power="off"] .lcd-bars i { background: rgba(255, 255, 255, 0.025); box-shadow: none; }
/* Power-on self test: every segment lights briefly. */
.radio.booting .lcd-ghost { color: var(--lcd-on); text-shadow: 0 0 6px var(--lcd-glow); }
.radio.booting .lcd-freq-value { opacity: 0; }
.radio.booting .lcd-bars i { background: var(--lcd-on); }

@keyframes blink { to { visibility: hidden; } }

/* ---------- Dial scale ---------- */

.scale { position: relative; height: 34px; margin: 0 12px; }
.scale-ticks {
  position: absolute;
  inset: 0 0 auto 0;
  height: 14px;
  background:
    repeating-linear-gradient(90deg, var(--print) 0 1px, transparent 1px calc(100% / 20)) 0 0 / 100% 14px no-repeat,
    repeating-linear-gradient(90deg, var(--print-dim) 0 1px, transparent 1px calc(100% / 100)) 0 7px / 100% 7px no-repeat;
  /* Close the right edge with a final major tick. */
  border-right: 1px solid var(--print);
}
.scale-labels span {
  position: absolute;
  top: 17px;
  transform: translateX(-50%);
  font: 700 10px var(--mono);
  color: var(--print-dim);
}
.scale-needle {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 24px;
  margin-left: -1px;
  background: var(--needle);
  box-shadow: 0 0 4px rgba(255, 74, 42, 0.6);
  transition: left 0.12s ease-out;
}
.radio[data-power="off"] .scale-needle { box-shadow: none; filter: saturate(0.5) brightness(0.7); }

/* ---------- Knobs ---------- */

.controls { display: flex; align-items: flex-end; justify-content: space-around; gap: 16px; margin-top: 6px; }
.knob-group { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.knob-label { font-size: 10px; font-weight: 700; letter-spacing: 0.25em; color: var(--print-dim); }

.knob {
  --angle: 0deg;
  position: relative;
  border-radius: 50%;
  cursor: grab;
  outline: none;
  /* Fixed shading lives on ::before (doesn't rotate); the grip rotates with the knob. */
}
.knob::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, #0e0f0e 60%, #1d1f1e 72%, transparent 73%);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
}
.knob.dragging { cursor: grabbing; }
.knob:focus-visible::before { box-shadow: 0 0 0 2px var(--lcd-on), inset 0 2px 4px rgba(0, 0, 0, 0.7); }

.knob-cap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: rotate(var(--angle));
  background:
    radial-gradient(circle, transparent 58%, rgba(0, 0, 0, 0.35) 59%, transparent 61%),
    repeating-conic-gradient(#3e403e 0 5deg, #191a19 5deg 10deg); /* knurled grip */
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.6), 0 2px 2px rgba(0, 0, 0, 0.7);
}
.knob-cap::before {
  /* Machined top face. Conic sheen fakes brushed aluminium; it rotates with the knob like a real cap. */
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.25), transparent 60%),
    conic-gradient(from 20deg, #8a8a86, #d9d7d0, #7a7a76, #c8c6bf, #8a8a86, #e0ded6, #8a8a86);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.6);
}
.knob-mark {
  position: absolute;
  top: 20%;
  left: 50%;
  width: 4px;
  height: 18%;
  margin-left: -2px;
  border-radius: 2px;
  background: #ff6a3a;
  box-shadow: 0 0 3px rgba(255, 106, 58, 0.6);
}

.knob-tuning { width: 150px; height: 150px; }
.knob-small { width: 84px; height: 84px; }
.knob-small .knob-mark { width: 3px; margin-left: -1.5px; }

/* ---------- Bottom: callsign + PTT ---------- */

.radio-bottom {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: center;
  padding: 16px 8px 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Embossed label-maker tape */
.callsign { display: flex; flex-direction: column; gap: 6px; }
.callsign-label { font-size: 10px; font-weight: 700; letter-spacing: 0.25em; color: var(--print-dim); }
.callsign input {
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 3px;
  background: linear-gradient(180deg, #1f3f8f, #17306d);
  color: #f2f2f2;
  font: 700 16px var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35), 0 -1px 0 rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  user-select: text;
  -webkit-user-select: text;
}
.callsign input:focus { outline: 2px solid var(--lcd-on); outline-offset: 2px; }

.ptt {
  position: relative;
  height: 88px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #2a2a2a, #161616);
  color: var(--print);
  font: 800 16px var(--sans);
  letter-spacing: 0.2em;
  cursor: pointer;
  touch-action: none;
  -webkit-touch-callout: none;
  box-shadow:
    0 0 0 4px #0c0c0c,
    0 0 0 5px rgba(255, 255, 255, 0.06),
    inset 0 2px 0 rgba(255, 255, 255, 0.08),
    0 6px 0 #070707,
    0 10px 16px rgba(0, 0, 0, 0.6);
  transition: transform 0.05s, box-shadow 0.05s, background 0.15s, color 0.15s;
  overflow: hidden;
}
.ptt-ridges {
  position: absolute;
  inset: 10px 18px;
  border-radius: 10px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 3px, rgba(0, 0, 0, 0.25) 3px 7px);
  pointer-events: none;
}
.ptt > span:last-child { position: relative; }
.ptt.pressed {
  transform: translateY(5px);
  box-shadow: 0 0 0 4px #0c0c0c, 0 0 0 5px rgba(255, 255, 255, 0.06), inset 0 3px 8px rgba(0, 0, 0, 0.6), 0 1px 0 #070707;
}
.ptt[data-state="requesting"] { color: var(--lcd-on); }
.ptt[data-state="transmitting"] {
  background: linear-gradient(180deg, #b3241b, #7a120c);
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}
.ptt[data-state="busy"], .ptt[data-state="revoked"] { color: var(--lcd-on); background: linear-gradient(180deg, #2a2216, #17120a); }
.ptt[aria-disabled="true"] { color: #5a5a55; cursor: not-allowed; }
.ptt:focus-visible { outline: 2px solid var(--lcd-on); outline-offset: 6px; }

.error { min-height: 1.2em; margin: 12px 8px 0; color: #ff8a70; font: 600 13px var(--mono); }
.error:empty { margin: 0; min-height: 0; }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .bench { padding: 12px 10px; justify-content: flex-start; }
  .radio { padding: 18px 16px 16px; border-radius: 18px; }
  .radio-top { gap: 14px; padding: 0 4px 12px; }
  .brand-sub { display: none; }
  .radio-body { grid-template-columns: 1fr; gap: 14px; padding: 14px 0; }
  .grille { height: 36px; order: -1; }
  .scale { margin: 0 8px; }
  .knob-tuning { width: 132px; height: 132px; }
  .knob-small { width: 72px; height: 72px; }
  .radio-bottom { grid-template-columns: 1fr; gap: 14px; padding: 14px 0 2px; }
  .ptt { height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .scale-needle, .power-lever, .ptt { transition: none; }
  .lcd-link { animation: none !important; }
}
