[hidden] { display: none !important; }
:root {
  --bg: #0f1215;
  --panel: #1a1e23;
  --panel-2: #23282f;
  --line: #2f363e;
  --text: #e6e9ec;
  --muted: #8b949e;
  --lcd-fg: #ffb547;
  --tx: #e5484d;
  --busy: #3dd68c;
  --accent: #4c9aff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button:disabled { opacity: .4; cursor: not-allowed; }
button { touch-action: manipulation; } /* no double-tap zoom on iOS */
.head { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.banner {
  width: 100%; background: var(--lcd-fg); border-color: var(--lcd-fg); color: #1a1a1a;
  font-weight: 700;
}
.note { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--tx); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 720px; margin: 0 auto; padding: 14px 0;
}
.brand { font-weight: 700; letter-spacing: .02em; }
.brand .sub { color: var(--muted); font-weight: 400; }
.status {
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted);
}
.status::before { content: "●"; margin-right: 6px; }
.status[data-state="online"] { color: var(--busy); }
.status[data-state="connecting"] { color: var(--lcd-fg); }
.status[data-state="offline"] { color: var(--tx); }

.panel {
  max-width: 420px; margin: 8vh auto 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px;
}
.login h1 { font-size: 20px; margin: 0 0 16px; }
.login form { display: grid; gap: 14px; }
.login label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login input:not([type=checkbox]) {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.login .check { display: flex; align-items: center; gap: 8px; }
.error { color: var(--tx); margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

.head { max-width: 720px; margin: 0 auto; display: grid; gap: 18px; padding-bottom: 32px; }

/* Control head: web/control-head/control-head.svg (desk) or handheld.svg (phones), inserted by
   app.js (mountHead). Colours inside the artwork come from the generators in assets/control-head/;
   these rules size it and add interaction states. */
.radio-head:empty { aspect-ratio: 1600 / 460; } /* hold its space while the SVG loads */
@media (max-width: 600px) { .radio-head:empty { aspect-ratio: 560 / 1192; max-height: 62vh; } }
.radio-head svg {
  display: block; width: 100%; height: auto;
  touch-action: none; /* knob drags must not scroll the page */
  user-select: none; -webkit-user-select: none;
}
.radio-head [data-control], .radio-head [data-knob] { cursor: pointer; outline: none; }
.radio-head [data-control].pressed { fill: rgba(255, 255, 255, .22); }
.radio-head [data-control]:focus-visible { stroke: var(--accent); stroke-width: 4; }
.radio-head [data-knob]:focus-visible .focus-ring { stroke: var(--accent); stroke-width: 4; }
/* The handheld is tall: cap its height so the PTT button below it stays on a phone's screen. */
.radio-head svg[data-template="handheld"] { width: auto; max-width: 100%; max-height: 62vh; margin: 0 auto; }
/* The IC-F6330D mic (radio.type icom): tall, so capped like the handheld. */
.radio-head svg[data-template="ipmic"] { width: auto; max-width: 100%; max-height: 72vh; margin: 0 auto; }
/* No knobs on the mic: a swipe on it scrolls the page (it fills most of a phone's screen), and
   only the keys keep the touch for themselves, so a held key doesn't scroll. */
.radio-head svg[data-template="ipmic"] { touch-action: pan-y; }
.radio-head svg[data-template="ipmic"] .mkey { touch-action: none; }
@media (max-width: 600px) { .radio-head svg[data-template="ipmic"] { max-height: 60vh; } }
.radio-head .mkey { cursor: pointer; }
.radio-head .mkey.pressed { fill: rgba(255, 255, 255, .22); }
.radio-head .mkey[data-ptt].pressed { fill: rgba(229, 72, 77, .35); }
/* Transmitting from this device: red status text and a red glow around the head. */
.radio-head.tx #display-status { fill: var(--tx); }
.radio-head.recording #display-status { fill: var(--tx); }
.radio-head.recording [data-control="emergency"] { fill: rgba(255, 60, 40, .45); }
.radio-head.recording [data-control="emergency"].pressed { fill: rgba(255, 255, 255, .3); }
.radio-head.tx svg { filter: drop-shadow(0 0 10px rgba(229, 72, 77, .6)); }
/* Channel picked with the knob but not on the radio yet: amber until the radio confirms it. */
.radio-head.picking #display-zone, .radio-head.picking #display-channel { fill: var(--lcd-fg); }
.radio-head.picking [data-template="handheld"] :is(#display-zone, #display-channel) { fill: #b35c00; } /* on white */

.ptt {
  min-height: 164px; border-radius: 22px; border: 2px solid #5a1d20;
  background: radial-gradient(circle at 50% 35%, #3a2224, #22171a);
  display: grid; place-content: center; gap: 4px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; /* no iOS long-press magnifier/menu while holding PTT */
}
.ptt-label { font-size: 34px; font-weight: 800; letter-spacing: .08em; }
.ptt-sub { font-size: 12px; color: var(--muted); }
.ptt.pending { border-color: var(--lcd-fg); }
.ptt.live {
  background: radial-gradient(circle at 50% 35%, #ff5a5f, #b0262b);
  border-color: #ff8a8d; box-shadow: 0 0 32px rgba(229,72,77,.55);
}
.ptt.live .ptt-sub { color: #ffe1e2; }
.ptt.locked { opacity: .5; }

.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.channels button { text-align: left; padding: 8px 10px; }
.channels button b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.channels button.current { border-color: var(--lcd-fg); color: var(--lcd-fg); }

.sliders { display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.sliders label { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.sliders input { width: 100%; }
.micmeter { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.micmeter div { height: 100%; width: 0%; background: var(--busy); transition: width .08s linear; }

.tune { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 10px; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tune label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.tune input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; width: 100%;
  font-variant-numeric: tabular-nums; }
.tune-hint { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 12px; }
.tune-hint:empty { display: none; }
.ctcss { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 4px 0 12px; color: var(--muted); font-size: 14px; }
.ctcss label { display: flex; align-items: center; gap: 8px; }
.ctcss select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); }
.ctcss .muted { font-size: 12px; }
.ctcss-note { font-size: 12px; }
.ctcss-note:empty { display: none; }
.selcall, .clips, .fx, .say { display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.selcall-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.selcall h2, .clips h2, .fx h2, .say h2 { margin: 0; font-size: 15px; }
.selcall-std { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.selcall label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.selcall input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 20px; letter-spacing: .12em; font-variant-numeric: tabular-nums; width: 100%; }
.selcall-hint { margin: 0; color: var(--muted); font-size: 12px; }
.selcall-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.selcall-presets:empty { display: none; }
.selcall-presets button { padding: 6px 10px; font-size: 13px; }
.selcall-presets button b { color: var(--muted); font-weight: 500; margin-left: 6px; font-variant-numeric: tabular-nums; }
.selcall-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 9.5em; overflow-y: auto; }
.selcall-log:empty { display: none; }
.selcall-log li { display: grid; grid-template-columns: 3.8em 1fr auto; gap: 8px; align-items: baseline;
  font-size: 13px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.selcall-log li:hover { background: var(--panel-2); }
.selcall-log .dir { color: var(--muted); font-size: 11px; font-weight: 700; }
.selcall-log .num { font-variant-numeric: tabular-nums; letter-spacing: .06em; overflow-wrap: anywhere; }
.selcall-log .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.selcall-log li.me .num { color: var(--lcd-fg); font-weight: 700; }
.clip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 16em; overflow-y: auto; }
.clip-list:empty, .clip-empty[hidden] { display: none; }
.clip-list li { display: grid; grid-template-columns: auto 1fr auto auto auto auto; gap: 10px; align-items: center;
  padding: 4px 6px; border-radius: 8px; }
.clip-list li:hover { background: var(--panel-2); }
.clip-list li.on { background: var(--panel-2); outline: 1px solid var(--line); }
.clip-list li.playing .clip-name { color: var(--tx); font-weight: 700; }
.clip-list label { display: contents; cursor: pointer; }
.clip-list input { accent-color: var(--lcd-fg); width: 18px; height: 18px; margin: 0; }
.clip-name { overflow-wrap: anywhere; }
.clip-len { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.clip-list button { padding: 2px 9px; font-size: 13px; color: var(--muted); }
.clip-list li[title] .clip-name { color: var(--muted); } /* too long to transmit */
.clip-listen { color: var(--accent); font-size: 13px; text-decoration: none; }
.clip-listen:hover { text-decoration: underline; }
.record-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.record-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.record-state { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.record-row.on { border-color: var(--tx); }
.record-row.on .record-dot { background: var(--tx); animation: rec-blink 1s steps(2, jump-none) infinite; }
.record-row.on .record-state { color: var(--text); }
.record-row button { padding: 6px 12px; font-size: 13px; }
.record-row.on button { color: var(--tx); }
@keyframes rec-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .record-row.on .record-dot { animation: none; } }
.clip-empty { margin: 0; color: var(--muted); font-size: 13px; }
.clip-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.clip-progress { color: var(--muted); font-size: 13px; }
.fx-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.fx-presets button { padding: 8px 6px; font-size: 14px; }
.fx-presets button.sel { border-color: var(--lcd-fg); color: var(--lcd-fg); }
.fx-presets button.on { background: var(--lcd-fg); border-color: var(--lcd-fg); color: #1a1a1a; font-weight: 700; }
.fx-toggle.on { background: var(--lcd-fg); border-color: var(--lcd-fg); color: #1a1a1a; font-weight: 700; }
/* Say */
.say label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.say select, .say textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; color: inherit; font: inherit; font-size: 15px; }
.say textarea { resize: vertical; min-height: 4.5em; }
.say-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* AI agent */
.bot { display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.bot h2 { margin: 0; font-size: 15px; }
.bot-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bot-modes button { padding: 8px 6px; font-size: 14px; }
.bot-modes button.on { background: var(--lcd-fg); border-color: var(--lcd-fg); color: #1a1a1a; font-weight: 700; }
.bot-pending { display: grid; gap: 8px; border: 1px solid var(--lcd-fg); border-radius: 10px; padding: 10px; }
.bot-pending-text { margin: 0; }
.bot-pending .row { display: flex; gap: 8px; }
.bot-stage { margin: 0; color: var(--muted); font-size: 12px; }
.bot-stage:empty { display: none; }
.bot-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 22em; overflow-y: auto; }
.bot-feed:empty { display: none; }
.bot-feed li { display: grid; grid-template-columns: 3.4em 1fr auto; gap: 8px; align-items: baseline;
  padding: 5px 6px; border-radius: 6px; font-size: 14px; }
.bot-feed li:hover { background: var(--panel-2); }
.bot-feed .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.bot-feed .who { font-weight: 600; margin-right: 6px; }
.bot-feed .who.anonymous { color: var(--muted); font-style: italic; }
.bot-feed .who.none { color: var(--muted); font-weight: 400; }
.bot-feed .meta { color: var(--muted); font-size: 11px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.bot-feed .said { overflow-wrap: anywhere; }
.bot-feed li.reply { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.bot-feed li.reply .who { color: var(--accent); }
.bot-feed li.reply.gone .said { color: var(--muted); text-decoration: line-through; }
.bot-feed button { padding: 2px 8px; font-size: 12px; color: var(--muted); }
.bot-people summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.bot-people ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.bot-people li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 4px 6px;
  border-radius: 6px; font-size: 14px; }
.bot-people li:hover { background: var(--panel-2); }
.bot-people .kind { color: var(--muted); font-size: 12px; }
.bot-people button { padding: 2px 8px; font-size: 12px; color: var(--muted); }
.bot-people button.danger { color: var(--tx); }
.sync { display: grid; gap: 10px; }
.settings { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.settings summary { cursor: pointer; color: var(--muted); }
.settings-body { display: grid; gap: 10px; padding-top: 10px; }
.settings p { margin: 0; color: var(--muted); font-size: 13px; }
.settings .row { display: flex; gap: 8px; flex-wrap: wrap; }
.settings select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

.toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--lcd-fg);
  border-radius: 8px; padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.error { border-left-color: var(--tx); }

@media (max-width: 480px) {
  .ptt { min-height: 140px; }
  .sliders label { grid-template-columns: 1fr; }
  .tune { grid-template-columns: 1fr 1fr; }
  .tune label:first-child { grid-column: 1 / -1; }
}

/* ---- accounts ---- */
.resume { display: grid; gap: 10px; margin-bottom: 16px; }
.resume p { margin: 0; }
button.linkish { background: none; border: none; color: var(--accent); padding: 4px 0; justify-self: start; }
.account { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.pwform { display: grid; gap: 8px; }
.pwform label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.pwform input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.account .row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Listen-only accounts: hide everything that transmits or changes the radio. The server refuses
   those actions anyway; this just keeps them off the screen. */
.listen-only #ptt, .listen-only #tuneForm, .listen-only #fxPanel, .listen-only #syncBlock,
.listen-only #selcallPanel label, .listen-only #selcallHint, .listen-only #selcallPresets,
.listen-only .clip-actions, .listen-only #recordBtn, .listen-only #selcallSend, .listen-only #recordModeRow, .listen-only #clipList input,
.listen-only #clipList button, .listen-only #clipsHint, .listen-only .sliders label:nth-child(2),
.listen-only .micmeter, .listen-only #botModes, .listen-only #botTalkOverRow, .listen-only #ctcssRow, .listen-only #sayPanel, .listen-only #botPending .row, .listen-only #botStop,
.listen-only .bot-feed button, .listen-only #botPeople button { display: none !important; }
.record-mode { font-size: 13px; color: var(--muted); }
