:root {
  color-scheme: light dark;
  --font: Bahnschrift, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --bg: #d9d7d0;
  --plate: #f1f0eb;
  --plate-2: #e6e4dd;
  --field: #fbfaf7;
  --ink: #17181a;
  --muted: #4c5056;
  --line: #a8a59b;
  --line-soft: #d2cfc6;
  --link: #0b55c0;
  --focus: #0b5bd3;
  --key: #2b3137;
  --key-edge: #14181c;
  --key-ink: #f5f5f2;
  --lcd: #c2cbb0;
  --lcd-edge: #8f9a7c;
  --lcd-ink: #142010;
  --off: #a4a197;
  --track: #d3d1c9;
  --green: #2a9d48;
  --amber: #e3970f;
  --lamp-red: #d0262c;
  --red: #b3131b;
  --red-edge: #6d0a0f;
  --red-hover: #9a0f16;
  --red-text: #a3121a;
  --red-soft: #f7dcdc;
  --amber-text: #7a4a00;
  --amber-soft: #f6e6c4;
  --hazard: #f2c200;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --plate: #1b1e22;
    --plate-2: #23272c;
    --field: #15181b;
    --ink: #e8e6e1;
    --muted: #a2a7ad;
    --line: #3d434b;
    --line-soft: #2c3137;
    --link: #7ab6ff;
    --focus: #7ab6ff;
    --key: #39414a;
    --key-edge: #5d6772;
    --key-ink: #ffffff;
    --lcd: #0b1310;
    --lcd-edge: #26332b;
    --lcd-ink: #93e2ab;
    --off: #4a5057;
    --track: #2a2f35;
    --green: #3cc263;
    --amber: #f0a52a;
    --lamp-red: #ef4444;
    --red: #c42020;
    --red-edge: #e46a6a;
    --red-hover: #d42a2a;
    --red-text: #ff7a7a;
    --red-soft: #3b1517;
    --amber-text: #f2b85a;
    --amber-soft: #3a2c10;
    --hazard: #d9ae00;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; }
h3 { font-size: 1.05rem; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.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;
}

.label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint { color: var(--muted); font-size: .92rem; }
.hint:empty { display: none; }

.error {
  color: var(--red-text);
  font-weight: 600;
  border-left: 4px solid var(--red-text);
  padding-left: 10px;
  overflow-wrap: anywhere;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--plate-2);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
/* kept at element specificity so class styles like the PTT modes win over hover */
button:where(:hover:not(:disabled)), .button:where(:hover) { border-color: var(--ink); }
button:disabled { cursor: not-allowed; color: var(--muted); border-style: dashed; }

button.primary {
  background: var(--key);
  border-color: var(--key-edge);
  color: var(--key-ink);
}
button.primary:hover:not(:disabled) { border-color: var(--key-edge); background: var(--key-edge); }
button.primary:disabled { background: var(--plate-2); border-color: var(--line); color: var(--muted); }

button.link {
  min-height: 0;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

input, select {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  font-size: 1rem;
}
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--focus); }
select:disabled { color: var(--muted); border-style: dashed; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label { font-weight: 600; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.auth { display: grid; justify-items: center; padding: 28px 16px 48px; }
.auth-inner { width: 100%; max-width: 440px; display: grid; gap: 14px; }

.card {
  display: grid;
  gap: 18px;
  padding: 20px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.policy {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--plate-2);
  border-left: 4px solid var(--line);
}
.policy p { white-space: pre-line; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 16px;
}
.topbar .brand { margin-right: auto; font-size: .95rem; }
.topbar button { white-space: nowrap; }
.topbar .link { min-height: 44px; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.badge {
  white-space: nowrap;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.safety {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--plate);
  border-top: 1px solid var(--line);
  border-bottom: 3px solid var(--line);
}
.sweep {
  position: absolute;
  right: 0;
  bottom: -3px;
  left: 0;
  height: 3px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .15s ease-in;
}
.on-air .sweep { transform: scaleX(1); transition: transform .3s cubic-bezier(.16, 1, .3, 1); }
.hazard {
  position: absolute;
  inset: 0;
  visibility: hidden;
  background: repeating-linear-gradient(135deg, var(--hazard) 0 18px, #111 18px 36px);
  pointer-events: none;
}
.safety-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 16px;
}
.txwrap { flex: 1; min-width: 0; }
.txline { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.txline[data-mode="onair"] {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  letter-spacing: .06em;
}
.txline[data-mode="cut"] { color: var(--red-text); }
.txline[data-mode="inuse"] { color: var(--amber-text); }

.cut {
  flex: none;
  min-width: 128px;
  max-width: 48%;
  min-height: 56px;
  margin: 4px;
  padding: 6px 16px;
  background: var(--red);
  border: 2px solid var(--red-edge);
  border-radius: 6px;
  box-shadow: 0 0 0 4px var(--hazard);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.cut:hover:not(:disabled) { background: var(--red-hover); border-color: var(--red-edge); }
.cut:disabled { background: var(--plate-2); border: 2px solid var(--line); box-shadow: 0 0 0 4px var(--line); color: var(--muted); }
.cut:focus-visible { outline-offset: 7px; }

.banner { background: var(--plate-2); border-bottom: 1px solid var(--line); }
.banner.alert { background: var(--amber-soft); }
.banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
}
.banner-inner p { flex: 1 1 16rem; font-weight: 600; }

.grid {
  display: grid;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px;
}
.side { display: grid; gap: 12px; align-content: start; }

.panel {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  padding: 14px;
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (min-width: 880px) {
  .grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-areas: "radio side" "tx side" "preset side" "admin admin";
    gap: 16px;
    padding: 16px;
  }
  .radio { grid-area: radio; }
  .tx { grid-area: tx; }
  .preset { grid-area: preset; }
  .side { grid-area: side; gap: 16px; }
  .admin { grid-area: admin; }
  .grid.dash { grid-template-areas: none; align-items: start; }
  .dash > .error { grid-column: 1 / -1; }
}

.lamps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.lamp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.lamp::before {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--off);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .35);
  transition: background-color .2s ease-out;
}
.lamp[data-on="green"]::before { background: var(--green); }
.lamp[data-on="amber"]::before { background: var(--amber); }
.lamp[data-on="red"]::before { background: var(--lamp-red); }
.listeners { margin-left: auto; color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }

.lcd {
  padding: 10px 14px;
  background: var(--lcd);
  border: 2px solid var(--lcd-edge);
  border-radius: 4px;
  color: var(--lcd-ink);
  font-family: var(--mono);
}
.freq { font-size: clamp(1.3rem, 6vw, 2rem); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.lcd-sub { margin-top: 2px; font-size: .92rem; overflow-wrap: anywhere; }
.lcd-sub.muted { opacity: .7; }

.lcd, .lamps, .meter-row, .toggles { transition: opacity .3s ease-out; }
.stale .lcd, .stale .lamps, .stale .meter-row, .stale .toggles { opacity: .5; }

.mismatch {
  padding: 10px 12px;
  background: var(--red);
  border-radius: 4px;
  color: #fff;
  font-weight: 700;
}

.meter-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
.meter { position: relative; height: 14px; overflow: hidden; background: var(--track); border-radius: 2px; }
.meter-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--green) 0 70%, var(--amber) 70% 88%, var(--lamp-red) 88%);
  clip-path: inset(0 100% 0 0);
}
.meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 8px, var(--plate) 8px 10px);
}

.listen { min-width: 7.5rem; }

.preset-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.ptt {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  flex-direction: column;
  width: 100%;
  min-height: 176px;
  padding: 16px;
  background: var(--key);
  border: 3px solid var(--key-edge);
  border-radius: 12px;
  color: var(--key-ink);
  text-align: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.ptt .flood { position: absolute; inset: 0; visibility: hidden; background: var(--red); pointer-events: none; }
.ptt > :not(.flood) { position: relative; }
.ptt.keying[data-mode="onair"] { background: var(--key); }
.ptt-main { font-size: 1.7rem; font-weight: 800; letter-spacing: .05em; line-height: 1.15; overflow-wrap: anywhere; }
.ptt-sub { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ptt-sub:empty { display: none; }
.ptt[data-mode="ready"] .ptt-main,
.ptt[data-mode="onair"] .ptt-main,
.ptt[data-mode="release"] .ptt-main { text-transform: uppercase; }
.ptt[data-mode="onair"] { background: var(--red); border-color: var(--red-edge); color: #fff; }
.ptt[data-mode="onair"] .ptt-main { font-size: 2.4rem; letter-spacing: .08em; }
.ptt[data-mode="onair"] .ptt-sub { font-size: 1.6rem; }
.ptt[data-mode="wait"] { background: var(--amber-soft); border-color: var(--amber); color: var(--ink); }
.ptt[data-mode="release"] { background: var(--red-soft); border: 3px dashed var(--red-text); color: var(--red-text); }
.ptt:disabled {
  background: repeating-linear-gradient(135deg, var(--plate-2) 0 12px, var(--plate) 12px 24px);
  border: 2px dashed var(--line);
  color: var(--ink);
}
.ptt:disabled .ptt-main { font-size: 1.25rem; letter-spacing: 0; }

.txtimer { display: grid; gap: 6px; }
.cap { height: 10px; overflow: hidden; background: var(--track); border-radius: 2px; }
.cap-fill { height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; }
.txtimer.warn .cap-fill { background: var(--lamp-red); }
.cap-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.txtimer.warn .cap-right { color: var(--red-text); font-size: 1.35rem; font-weight: 800; }

.ptt-note { font-weight: 600; }
.ptt-note:empty { display: none; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { gap: 10px; }
.switch-state {
  min-width: 3em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--track);
  transition: background-color .15s ease-out, color .15s ease-out;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.switch-state::after { content: "Off"; }
.switch[aria-pressed="true"] .switch-state { background: var(--green); color: #08210f; }
.switch[aria-pressed="true"] .switch-state::after { content: "On"; }
.reenable { border-color: var(--amber); }

.events { margin: 0; padding: 0; list-style: none; max-height: 22rem; overflow-y: auto; }
.events li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line-soft);
}
.events li:first-child { border-top: 0; }
.events time { padding-top: 1px; color: var(--muted); font-family: var(--mono); font-size: .85rem; }
.events span { overflow-wrap: anywhere; }

.admin { display: grid; gap: 12px; }
.admin-title { font-size: 1.15rem; }
.panel.fold { display: block; padding: 0; }
.fold > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "+"; width: 1em; font-family: var(--mono); font-weight: 700; }
.fold[open] > summary::before { content: "-"; }
.fold[open] > summary { border-bottom: 1px solid var(--line-soft); }
.fold-body { display: grid; gap: 12px; padding: 14px; }
.fold .form { max-width: 28rem; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.row .day { width: auto; min-width: 10rem; }

.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ask { font-weight: 700; }
.reset { display: grid; gap: 8px; min-width: 15rem; max-width: 22rem; }
.reset label { font-weight: 600; }

.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table.recent { border-collapse: separate; border-spacing: 0; }
.table th {
  padding: 6px 8px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
}
.table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; overflow-wrap: anywhere; }
.table td button { min-height: 40px; padding: 4px 12px; }
.table tr.revoked td { color: var(--muted); }

@media (max-width: 640px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .table td { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 8px; padding: 3px 0; border: 0; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
  .table td.action { display: block; padding-top: 6px; }
  .table td.action::before { content: none; }
  .recent tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .recent td { display: block; padding: 0; }
  .recent td::before { content: none; }
  .recent td:first-child { font-weight: 700; }
  .recent td:nth-child(even) { text-align: right; }
  .recent td:nth-child(n+3) { color: var(--muted); }
}

@media (max-width: 440px) {
  #station .brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .safety-inner { padding: 8px 12px; }
  .cut { padding: 6px 10px; font-size: .95rem; }
  .grid { padding: 10px; gap: 10px; }
  .panel { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sweep, .on-air .sweep { transition: none; }
}
