/* The console look: dark desk, brand orange as the one accent, and colour
   otherwise reserved for meaning — each channel keeps one colour everywhere it
   appears, green is on air, amber is a warning, red is a fault. Shared by every
   page so a channel reads the same on the host's desk, in the booth and on a
   delegate's phone.

   Pages carry no explanatory text; what a control does is in the README and the
   checklists. Labels exist for screen readers where a control has no words. */

:root {
  --bg: #0f1117;
  --panel: #171a23;
  --inset: #11131c;
  --line: #262932;
  --line-strong: #2f333d;
  --text: #e8eaf0;
  --dim: #9a9da1;
  --faint: #6d6f71;
  --accent: #f47920;
  --accent-hot: #ff8f3d;
  --live: #22c55e;
  --warn: #f0a500;
  --bad: #ef4444;
  --bad-bg: rgba(239, 68, 68, 0.1);
  --bad-line: #5b2226;
  --mine-bg: #2a1d12;
  --mine-line: #4a2c14;
  --mine-text: #ffd9bd;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: Archivo, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input::placeholder { color: var(--faint); }

.hidden { display: none !important; }
.grow { flex-grow: 1; }
.mono { font-family: var(--mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes rsiPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes rsiSpin { to { transform: rotate(360deg); } }
@keyframes rsiBar { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
.pulse { animation: rsiPulse 1.2s infinite; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hot); border-color: var(--accent-hot); }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; font-weight: 700; }
.btn-light { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 700; }
.btn-block { width: 100%; height: 56px; font-size: 17px; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; }
.btn-text { border: 0; background: transparent; color: var(--dim); }
.btn-text.bad { color: var(--bad); }

.icon-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-decoration: none;
}
.icon-btn:hover { color: var(--text); }
.icon-btn.sm { width: 36px; height: 36px; border-radius: 9px; background: transparent; }
.icon-btn.bare { border-color: transparent; background: transparent; }
.icon-btn.on { border-color: var(--accent); background: rgba(244, 121, 32, 0.14); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm svg { width: 16px; height: 16px; }

/* Talk and similar: a label with an icon, lit solid while active. */
.pill-btn {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
  touch-action: none;
}
.pill-btn svg { width: 16px; height: 16px; }
.pill-btn.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.pill-btn.warn { background: var(--warn); border-color: var(--warn); color: var(--bg); }

/* --- Form pieces --------------------------------------------------------- */

.field {
  height: 52px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  width: 100%;
  font-size: 16px;
}
.field:focus { outline: none; border-color: var(--accent); }
.field.bad { border-color: var(--bad); }
.field-lg { height: 60px; font-size: 18px; font-weight: 600; }
.field-code {
  height: 64px;
  text-align: center;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.select-box {
  height: 52px;
  padding: 0 12px 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--dim);
}
.select-box select {
  flex-grow: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.select-box select option { background: var(--panel); }
.select-box svg { width: 16px; height: 16px; flex-shrink: 0; }
.select-box.inset { background: var(--inset); height: 48px; }

/* A row of equal choices, one lit. */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--inset);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1 1 0;
  min-width: 0;
  height: 38px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg button.on { background: var(--line-strong); color: var(--text); }
.seg.lg button { height: 40px; font-size: 14px; }

.switch {
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 14px;
  border: 0;
  padding: 3px;
  display: flex;
  justify-content: flex-start;
  background: var(--line-strong);
}
.switch::after {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
}
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }

.row-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 14px;
}

.range-row { display: flex; align-items: center; gap: 12px; color: var(--dim); }
.range-row svg { width: 18px; height: 18px; flex-shrink: 0; }
.range-row .value { width: 56px; text-align: right; font-family: var(--mono); font-size: 13px; }
.range-row .value.boosted { color: var(--warn); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex-grow: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }

.label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bad-bg);
  border: 1px solid var(--bad-line);
  color: #fca5a5;
  font-size: 14px;
  font-weight: 600;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; }
.alert-text { color: var(--bad); font-size: 14px; padding: 0 4px; margin: 0; }

/* --- Level bars ---------------------------------------------------------- */

.bars { display: flex; align-items: flex-end; gap: 3px; height: 20px; }
.bars span { flex: 1 1 0; border-radius: 1px; min-height: 2px; background: var(--line-strong); }
.bars span.lit { background: var(--live); }
.bars span.hot { background: var(--warn); }
.bars span.clip { background: var(--bad); }

.mini-meter { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.mini-meter span { width: 3px; border-radius: 1px; background: var(--line-strong); min-height: 2px; }
.mini-meter span.lit { background: var(--live); }

/* --- Centred entry screens ------------------------------------------------ */

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  position: relative;
}
.stack { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.stack.wide { max-width: 640px; gap: 18px; }
.logo-mark { width: 64px; height: auto; align-self: center; margin-bottom: 20px; }
.logo-sm { width: 30px; height: auto; }
.back-btn { position: absolute; left: 24px; top: 20px; }

/* --- Console chrome ------------------------------------------------------ */

.console-screen { height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 68px;
  flex-shrink: 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .code { font-family: var(--mono); font-size: 13px; color: var(--faint); letter-spacing: 0.1em; }

.code-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.code-pill .mono { font-size: 16px; font-weight: 600; letter-spacing: 0.12em; }

.live-state { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dim); }
.live-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: rsiPulse 2s infinite; }
.live-state strong { color: var(--text); }

.talk-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
}
.talk-pill::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg);
  animation: rsiPulse 1.2s infinite;
}

.link-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.link-dot.good { background: var(--live); }
.link-dot.fair { background: var(--warn); }
.link-dot.poor { background: var(--bad); }

.clock { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--faint); }
.clock.fresh { color: var(--text); }
.clock.due { color: var(--warn); }
.clock.over { color: var(--bad); animation: rsiPulse 1s infinite; }
.clock.theirs { color: var(--dim); }

.banner {
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  background: rgba(240, 165, 0, 0.12);
  border-bottom: 1px solid #5a4410;
  color: #f0c14b;
}
.banner.bad { background: var(--bad-bg); border-bottom-color: var(--bad-line); color: #fca5a5; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: rsiSpin 0.9s linear infinite;
}

.panel {
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

/* --- Chat ---------------------------------------------------------------- */

.chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px; border-bottom: 1px solid var(--line); }
.chat-tab {
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chat-tab.on { border-color: var(--text); background: var(--text); color: var(--bg); }
.chat-tab .unread { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.chat-note {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-note svg { width: 14px; height: 14px; }
.chat-log {
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-log::before { content: ""; margin-top: auto; }
.msg { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.msg.mine { align-items: flex-end; }
.msg .meta { font-size: 11px; color: var(--faint); }
.msg .bubble {
  max-width: 260px;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--inset);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--mine-bg); color: var(--mine-text); border-color: var(--mine-line); }
.chat-send { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-send input {
  flex-grow: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--inset);
  font-size: 14px;
}
.chat-send input:focus { outline: none; border-color: var(--line-strong); }
.send-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 10px; border: 0;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.send-btn svg { width: 18px; height: 18px; }

/* --- Overlays ------------------------------------------------------------ */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.scrim.right { justify-content: flex-end; align-items: stretch; padding: 0; }
.dialog {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.dialog.wide { max-width: 760px; }
.dialog h2 { margin: 0; font-size: 22px; font-weight: 700; }
.dialog-head { display: flex; align-items: center; gap: 12px; }
.dialog-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.drawer {
  width: 100%;
  max-width: 460px;
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px 28px;
  background: var(--panel);
  border-left: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.drawer section { display: flex; flex-direction: column; gap: 10px; }

/* --- Stats --------------------------------------------------------------- */

.big-time { font-family: var(--mono); font-size: 34px; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--inset);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .k { font-size: 12px; color: var(--faint); }
.stat .v { font-family: var(--mono); font-size: 18px; font-weight: 600; }

/* --- Channel colours ------------------------------------------------------ */
/* One per channel number, cycling. Set as --ch on the element that uses it. */

.chip {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--ch);
  border: 1px solid var(--ch);
  white-space: nowrap;
}
.badge {
  font-family: var(--mono);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--bg);
  background: var(--ch);
}

/* --- Video --------------------------------------------------------------- */

.video-box {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: 14px;
  background: var(--inset);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--line-strong);
}
.video-box video, .video-box iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000;
}
.video-box .empty svg { width: 48px; height: 48px; }
.video-tag {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 1;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--ch, var(--dim));
  color: var(--bg);
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .clock { font-size: 18px; }
  .back-btn { left: 16px; top: 16px; }
}
