/* style.css — A-Comm user app */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@700;800&family=Space+Grotesk:wght@500;700&family=IBM+Plex+Sans:wght@400;500;600&family=Space+Mono:wght@400;700&display=swap');

/* Form controls follow the page theme (dark-mode dropdown fix) — MUST stay below the @import */
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
select, option { background: var(--surface, #23272f); color: var(--text, #e6e9ef); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Active theme: GRAPHITE (Avitsi-aligned). Preset source: themes/graphite.css.
     Neutral graphite environment; Avitsi blue #2D63A3 is the single hero accent
     (carried in the --cyan token for cascade compatibility); amber #F9AD35 alerts.
     Swap the whole theme by pasting another themes/*.css preset over these two blocks. ── */

  /* Backgrounds — graphite (neutral, not blue) */
  --bg:         #1b1e24;
  --surface:    #23272f;
  --surface2:   #2c313b;

  /* Borders */
  --border:     #333a45;
  --border2:    #414a58;

  /* Text */
  --text:       #eef1f5;
  --text2:      #a6afbb;
  --muted:      #79828f;   /* readability/WCAG (brand guide v1.2 Graphite) */
  --green:      #3ddc84;   /* connected/stable presence (formalized token) */
  --green-glow: rgba(61, 220, 132, 0.30);

  /* Accent — Avitsi blue hero (token name kept as --cyan for cascade) */
  --cyan:       #5a95d8;   /* brightened Avitsi blue for label/active use on graphite */
  --cyan-dim:   #1e3a5c;   /* deep Avitsi-blue fill */
  --cyan-glow:  rgba(45, 99, 163, 0.30);

  /* States */
  --amber:      #f9ad35;   /* Avitsi complementary amber */
  --amber-glow: rgba(249, 173, 53, 0.24);
  --red:        #e5484d;
  --red-dim:    #3a1214;
  --red-glow:   rgba(229, 72, 77, 0.22);

  /* Typography */
  --font-display: 'Barlow Condensed', sans-serif;
  --font-wm:      'Space Grotesk', sans-serif;   /* wordmark — matches the logo */
  --font-mono:    'Space Mono', monospace;
  --font-body:    'IBM Plex Sans', sans-serif;
  /* subtle glass (brand guide v1.0) */
  --glass:        rgba(255,255,255,.045);
  --glass-brd:    rgba(255,255,255,.09);
  --glass-sheen:  linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,0) 46%);
  --glass-blur:   12px;

  /* Layout */
  --ptt-size: 216px;
}

/* ── Light theme — GRAPHITE light: neutral light grey base (never stark white) +
   Avitsi blue #2D63A3 accent. Text tiers kept dark for readability. ── */
:root[data-theme="light"] {
  --bg:         #e9ebef;   /* neutral light grey so cards pop and text reads */
  --surface:    #f4f6f8;   /* cards / panels — lighter than bg for elevation */
  --surface2:   #ffffff;   /* elevated */

  --border:     #d3d8e0;
  --border2:    #b9c0cb;

  --text:       #1c2029;   /* near-black — strong contrast */
  --text2:      #444c59;   /* darker secondary */
  --muted:      #6b7280;   /* readable muted */

  --cyan:       #2d63a3;   /* Avitsi main — ideal contrast on light grey */
  --cyan-dim:   #d3e0f0;   /* light blue tint used as a fill */
  --cyan-glow:  rgba(45, 99, 163, 0.28);

  --amber:      #b07400;   /* deepened amber for contrast on light */
  --amber-glow: rgba(176, 116, 0, 0.22);
  --red:        #c62828;
  --red-dim:    #f3d6d6;
  --red-glow:   rgba(198, 40, 40, 0.20);
}

/* Light mode: the PTT buttons + active channel card are intentionally dark "device"
   surfaces in dark mode; route them to light equivalents so light mode is cohesive.
   (Accent borders + label colors already adapt via variables.) */
:root[data-theme="light"] .ptt-ch-btn,
:root[data-theme="light"] #ptt-btn {
  background: radial-gradient(circle at 40% 38%, #ffffff, #d9dfe9);
  box-shadow: 0 6px 22px rgba(30,40,60,0.14), 0 2px 6px rgba(30,40,60,0.10),
              inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -2px 4px rgba(30,40,60,0.06);
}
:root[data-theme="light"] .ptt-ch-btn.talking { background: radial-gradient(circle at 40% 38%, #dbe8f7, #bcd5ef); }
:root[data-theme="light"] .ptt-ch-btn.latched { background: radial-gradient(circle at 40% 38%, #fbf0d4, #efe1b6); }
:root[data-theme="light"] .ptt-ch-btn.muted   { background: radial-gradient(circle at 40% 38%, #f7dede, #eecccc); border-color:#e0a5a5; }
:root[data-theme="light"] .ptt-ch-btn.locked  { background: radial-gradient(circle at 40% 38%, #f7d6d6, #eec2c2); }
/* .channel-btn.selected needs no light override — it uses var(--cyan-dim) directly */

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Layout ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  /* In standalone PWA mode the status bar overlaps the top. */
  padding: max(18px, env(safe-area-inset-top)) 16px 0;
  gap: 14px;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 14px;
  border-bottom: 1px solid var(--glass-brd);
  background: var(--glass);
  background-image: var(--glass-sheen);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  border-radius: 12px;
}
/* Logo badge in the header — hero-scale mark, the brand carries the header */
.header-badge {
  width: 64px; height: 64px; border-radius: 16px; flex-shrink: 0;
}

/* Brand cluster */
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Wordmark row: connection light sits to the right of the A-COMM text */
.wm-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

/* Gear / icon buttons in the header */
.icon-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.14s, color 0.14s, transform 0.06s;
}
.icon-btn:hover  { background: var(--surface2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

#header h1 {
  font-family: var(--font-wm);          /* Space Grotesk — matches the logo wordmark */
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
}

#powered-by {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 5px;
}

/* Connection status dot */
#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.4s, box-shadow 0.4s;
}
#status-dot.connected  {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow), 0 0 2px var(--green);
}
#status-dot.connecting {
  background: var(--amber);
  animation: pulse-dot-amber 1.2s infinite;
}
#status-dot.error { background: var(--red); }

/* ── Settings sheet ── */
#settings-overlay {
  position: fixed;
  inset: 0;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  z-index: 210;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
}
.sheet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sheet-title {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.settings-label {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 12px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;             /* breathing room — rows never sit on top of each other */
}
.settings-row + .settings-row { border-top: 1px solid var(--border); }

/* Inline mic/DSP drop-down inside the settings sheet */
#audio-drop {
  margin: 6px 0 12px;
  padding: 4px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.drop-chev { font-size: 0.7em; opacity: 0.8; }
.settings-row-label {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text);
}
.settings-hint {
  margin-top: 12px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}
/* Segmented control */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
  background: none;
  border: none;
  border-radius: 7px;
  padding: 7px 13px;
  min-height: 44px;            /* 44 pt touch target (UI Layout Standard; FIX-11, 2026-10-17) */
  min-width: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.14s, color 0.14s;
}
.seg-btn.active { background: var(--cyan); color: #071a17; }

/* Log out — session action in the settings sheet */
.btn-logout {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s, filter 0.14s;
}
.btn-logout:hover  { filter: brightness(1.08); }
.btn-logout:active { transform: scale(0.95); }

/* Neutral row-action button in the settings sheet (e.g. Audio → OPEN) */
.btn-settings-row {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--cyan);
  border-radius: 999px;
  padding: 7px 16px;
  min-height: 44px;            /* 44 pt touch target (UI Layout Standard; FIX-11, 2026-10-17) */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s, filter 0.14s;
}
.btn-settings-row:hover  { filter: brightness(1.15); }
.btn-settings-row:active { transform: scale(0.95); }

/* ── Channel selector ── */
/* Grid, not flex: the license decides how many channels exist (1–25), so the strip
   must scale from four large buttons to a 25-button wall. data-count / data-density
   are set at generation time (renderChannelButtons, refined to visible buttons in
   updateUI). The wall scrolls vertically inside its own box when it gets tall —
   the page itself never scrolls, in either axis. */
#channels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  justify-content: center;
  /* 1.51.0 (Layout Standard rule 5): the grid takes what its count needs, capped by count, and
     the talk orbs get the rest of the column (#ptt-wrap flex:1). Was one fixed min(38dvh,340px). */
  flex: 0 1 auto;
  max-height: 30dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
/* 1–4 visible channels: one centered row of large buttons — the classic look.
   minmax(0, 150px) shrinks evenly on narrow phones exactly like the old flex row. */
#channels[data-count="1"] { grid-template-columns: minmax(0, 150px); }
#channels[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 150px)); }
#channels[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 150px)); }
#channels[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 150px)); }
/* 5–10: medium buttons — auto-fit wraps to a second row on phones */
#channels[data-density="md"] { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); max-height: 38dvh; }
/* 11–25: compact wall — 64px min keeps ~5 across on a 375px phone, still a real tap target */
#channels[data-density="sm"] { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); max-height: 46dvh; }

.channel-btn {
  container-type: inline-size;   /* name labels scale with the button (1.41.0) */
  min-width: 0;       /* the grid track owns the width; content must never force overflow */
  min-height: 44px;   /* touch-target floor at every density */
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 19px 4px 12px;   /* 19px top = the roster badge's slot (FIX-12): it never sits on the label */
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.channel-btn .ch-label {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.02em;
  transition: color 0.15s;
  line-height: 1;
}

/* Names mode: the operator's channel name IS the label — sized to the button, two lines max */
.channel-btn .ch-label.ch-name {
  font-size: clamp(0.62rem, 17cqw, 1.15rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  max-width: 92%;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.channel-btn .ch-tx {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-height: 0.7rem;
  text-align: center;
}

.channel-btn .ch-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border2);
  transition: all 0.2s;
}

/* medium/compact densities shrink padding + type — never below the tap floor */
#channels[data-density="md"] .channel-btn { padding: 19px 3px 8px; gap: 6px; }
#channels[data-density="md"] .channel-btn .ch-label:not(.ch-name) { font-size: 1.35rem; }
#channels[data-density="sm"] .channel-btn { padding: 19px 2px 6px; gap: 4px; border-radius: 5px; }
#channels[data-density="sm"] .channel-btn .ch-label:not(.ch-name) { font-size: 1.1rem; }
/* :not(.ch-name) above (1.51.0): these used to out-rank .ch-label.ch-name and hand named channels a
   fixed rem size that overflowed a 64–92px tile (the icon/text overlap on phones). */
#channels[data-density="sm"] .channel-btn .ch-tx { min-height: 0.6rem; }

/* ── The three answers-at-a-glance states ──────────────────────────────────────
   NOT JOINED   = flat + inert: plain surface, plain border, muted label (base above).
   JOINED       = accent fill + doubled accent ring — readable across a room.
   TRANSMITTING = pulsing glow + the talker's callsign in .ch-tx.
   All colors ride the theme tokens, so light and dark stay equally distinct. */

/* Joined (monitoring) */
.channel-btn.selected {
  background: var(--cyan-dim);   /* theme-aware fill tint (deep blue dark / pale blue light) */
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px var(--cyan), 0 0 14px var(--cyan-glow);   /* inset doubles the ring */
}
.channel-btn.selected .ch-label    { color: var(--cyan); }
.channel-btn.selected .ch-indicator {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
}

/* Someone transmitting — applies whether or not YOU are joined, so the glow pulses
   (animation overrides the .selected box-shadow while it runs; the fill still tells
   joined from not-joined underneath it). */
.channel-btn.transmitting {
  border-color: var(--cyan);
  animation: ch-rx-glow 1.1s ease-in-out infinite;
}
.channel-btn.transmitting .ch-tx { color: var(--cyan); font-weight: 700; }
.channel-btn.transmitting .ch-indicator {
  background: var(--cyan);
  border-color: var(--cyan);
  animation: pulse-indicator 0.9s infinite;
}
@keyframes ch-rx-glow {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--cyan), 0 0 6px var(--cyan-glow); }
  50%      { box-shadow: inset 0 0 0 1px var(--cyan), 0 0 22px var(--cyan-glow); }
}

/* I am transmitting */
.channel-btn.i-am-tx .ch-indicator {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
  animation: none;
}

/* Blocked */
.channel-btn.blocked {
  opacity: 0.25;
  cursor: not-allowed;
}
.channel-btn.blocked .ch-label { color: var(--muted); }
.channel-btn.blocked .ch-tx    { color: var(--red); }

/* ── PTT area ── */
/* Column + min-height:0 + overflow: with many orbs the area scrolls inside itself
   instead of its centered content overflowing upward over the channel bar (RaceOn,
   8+ channels on a laptop). #ptt-buttons uses margin:auto to center when it fits. */
#ptt-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
}

/* Mic level ring */
#ptt-ring {
  position: absolute;
  width: var(--ptt-size);
  height: var(--ptt-size);
  border-radius: 50%;
  border: 1.5px solid var(--cyan);
  opacity: 0;
  transform: scale(1);
  pointer-events: none;
  will-change: transform, opacity;
}

/* PTT button */
#ptt-btn {
  width: var(--ptt-size);
  height: var(--ptt-size);
  border-radius: 50%;
  border: 5px solid var(--border2);
  background: radial-gradient(circle at 40% 38%, #1c2333, #0c0e11);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 8px 40px rgba(0,0,0,0.8),
    0 2px 8px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 -2px 4px rgba(0,0,0,0.4);
}

.ptt-icon {
  width: 38px;
  height: 38px;
  color: var(--text2);
  transition: color 0.15s;
  flex-shrink: 0;
}

#ptt-btn .ptt-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.15s;
}

/* Transmitting */
#ptt-btn.transmitting {
  border-color: var(--cyan);
  background: radial-gradient(circle at 40% 38%, #14263c, #0a1622);
  box-shadow:
    0 0 48px var(--cyan-glow),
    0 8px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(45, 99, 163,0.08),
    inset 0 -2px 4px rgba(0,0,0,0.4);
}
#ptt-btn.transmitting .ptt-label { color: var(--cyan); }
#ptt-btn.transmitting .ptt-icon  { color: var(--cyan); }

/* Open mic */
#ptt-btn.open-mic {
  border-color: var(--amber);
  background: radial-gradient(circle at 40% 38%, #1e1500, #0d0900);
  box-shadow:
    0 0 48px var(--amber-glow),
    0 8px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(240,165,0,0.06),
    inset 0 -2px 4px rgba(0,0,0,0.4);
  animation: pulse-amber-btn 1.6s infinite;
}
#ptt-btn.open-mic .ptt-label { color: var(--amber); }
#ptt-btn.open-mic .ptt-icon  { color: var(--amber); }

/* Muted */
#ptt-btn.muted {
  border-color: #3a1818;
  background: radial-gradient(circle at 40% 38%, #1a0a0a, #0c0606);
  box-shadow:
    0 8px 40px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.02),
    inset 0 -2px 4px rgba(0,0,0,0.4);
}
#ptt-btn.muted .ptt-label { color: var(--red); }
#ptt-btn.muted .ptt-icon  { color: #3a1818; }

/* Locked */
#ptt-btn.locked {
  border-color: var(--red);
  background: radial-gradient(circle at 40% 38%, #1a0808, #0c0404);
  box-shadow:
    0 0 32px var(--red-glow),
    0 8px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(229,57,53,0.06),
    inset 0 -2px 4px rgba(0,0,0,0.4);
  animation: pulse-red-btn 2s infinite;
}
#ptt-btn.locked .ptt-label { color: var(--red); }
#ptt-btn.locked .ptt-icon  { color: var(--red); }

/* No channel */
#ptt-btn.no-channel {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Footer ── */
#footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

#device-name-row {
  display: flex;
  align-items: center;
}

#device-name {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#online-count {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  margin-left: auto;
  letter-spacing: 0.05em;
}
/* ── Online-count roster drop-up ─────────────────────────────────────────── */
#online-wrap { position: relative; margin-left: auto; display: inline-flex; }
#online-count { margin-left: 0; cursor: pointer; }
#online-count:hover { color: var(--text2); }
.online-dropup {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  padding: 5px;
  z-index: 60;
}
.online-dropup[hidden] { display: none; }
.online-dropup .odu-hd {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 8px 6px;
}
.online-dropup .odu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
}
.online-dropup .odu-row:hover { background: rgba(255, 255, 255, 0.05); }
.online-dropup .odu-name {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-dropup .odu-chips { display: flex; gap: 3px; }
.online-dropup .odu-chip {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--cyan-dim);
  color: var(--cyan);
}
.online-dropup .odu-empty {
  font-size: 0.72rem;
  color: var(--text2);
  padding: 10px 8px;
  text-align: center;
}
.online-dropup .odu-row-nodm { cursor: default; opacity: 0.55; }
.online-dropup .odu-row-nodm:hover { background: none; }
.online-dropup .odu-chip-none {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
}
/* Your own row: full opacity even though it's not DM-able (nodm dims to 0.55) */
.online-dropup .odu-row-self { opacity: 1; }
.online-dropup .odu-row-self .odu-name { font-weight: 700; }
.online-dropup .odu-chip-admin {
  background: var(--amber-dim, rgba(255, 179, 71, 0.12));
  color: var(--amber, #ffb347);
}

#channel-status {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  min-height: 1rem;
  letter-spacing: 0.06em;
}

/* Floating top toast — above chat/settings/DSP sheets (200-300), below the page alert */
#top-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 50%;
  transform: translate(-50%, -12px);
  background: var(--surface);
  border: 1px solid var(--cyan);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 12px var(--cyan-glow);
  z-index: 9500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
#top-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* PAGE buttons: unmistakable press feedback */
#thread-page-btn:active,
.inbox-page-btn:active {
  transform: scale(0.9);
  background: var(--red) !important;
  color: #fff !important;
}
#thread-page-btn,
.inbox-page-btn {
  transition: transform 0.08s, background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

/* ── Servers picker sheet (#12e) ── */
#servers-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 260;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#servers-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 80dvh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 0 16px 24px;
}
.server-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.server-info { min-width: 0; flex: 1; }
.server-name {
  font-family: var(--font-wm);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-name .server-here {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: var(--cyan);
  letter-spacing: 0.12em;
  vertical-align: middle;
  margin-left: 8px;
}
.server-meta {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-meta .srv-online       { color: var(--green, #3ddc84); }
.server-meta .srv-offline      { color: var(--red); }
.server-meta .srv-incompatible { color: var(--amber); }
.server-actions { display: flex; gap: 8px; flex-shrink: 0; }
.server-switch-btn, .server-remove-btn {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 13px;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, color 0.12s, transform 0.06s;
}
.server-switch-btn { border: 1px solid var(--cyan); color: var(--cyan); }
.server-switch-btn:active:not(:disabled) { transform: scale(0.95); }
.server-switch-btn[data-armed="1"] { background: var(--cyan); color: #000; }
.server-switch-btn:disabled { opacity: 0.35; cursor: default; }
.server-remove-btn { border: 1px solid var(--border2); color: var(--muted); }
.server-remove-btn:active { background: var(--red); border-color: var(--red); color: #fff; }
.servers-add-row { display: flex; gap: 8px; margin-top: 14px; }
#servers-add-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 11px 14px;
  border-radius: 8px;
  outline: none;
  min-width: 0;
}
#servers-add-input:focus { border-color: var(--cyan); }
#servers-add-btn {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
}
#servers-add-btn:active { transform: scale(0.96); }
.servers-note {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1.6;
  margin-top: 12px;
}

/* ── Director waiting-room button + sheet ── */
#waiting-staff-btn {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 74px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--amber);
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  -webkit-tap-highlight-color: transparent;
}
#waiting-staff-btn:active { transform: translateX(-50%) scale(0.96); }
#waiting-staff-count {
  display: inline-block;
  min-width: 18px;
  padding: 2px 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--amber);
  color: #000;
  text-align: center;
}
#waiting-staff-btn.has-waiting { animation: pulse-dot-amber 1.6s infinite; }

#waiting-staff-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 260;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#waiting-staff-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 70dvh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 0 16px 24px;
}
.waiting-staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.waiting-staff-name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}
.waiting-staff-controls { display: flex; gap: 8px; align-items: center; }
.waiting-role-select option { background: var(--surface); color: var(--text); }
.waiting-role-select {
  color-scheme: inherit;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}
.waiting-admit-btn, .waiting-deny-btn {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 7px 12px;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.waiting-admit-btn { border: 1px solid #22c55e; color: #22c55e; }
.waiting-admit-btn:active { background: #22c55e; color: #000; }
.waiting-deny-btn  { border: 1px solid var(--red); color: var(--red); }
.waiting-deny-btn:active  { background: var(--red); color: #fff; }
.waiting-empty-msg {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  padding: 18px 0;
  text-align: center;
}

/* ── Waiting room overlay ── */
#waiting-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 32px;
  z-index: 120;
  text-align: center;
}
#waiting-overlay h2 {
  font-family: var(--font-wm);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}
#waiting-overlay .setup-sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 40px;
}
.waiting-event {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.waiting-pulse {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--amber);
  animation: pulse-dot-amber 1.4s infinite;
  margin-bottom: 18px;
}
.waiting-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--amber);
  margin-bottom: 8px;
}
#waiting-overlay .hint { margin-bottom: 36px; }
#waiting-leave-btn {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 22px;
  cursor: pointer;
}
#waiting-leave-btn:active { transform: scale(0.95); }

/* ── Setup overlay ── */
#setup-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 32px;
  z-index: 100;
}

/* Hero logo mark on the sign-in screen — identical spec on the admin login */
.hero-logo {
  width: 128px;
  height: 128px;
  border-radius: 30px;
  margin-bottom: 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
}

#setup-overlay h2 {
  font-family: var(--font-wm);          /* Space Grotesk — matches the logo wordmark */
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}

#setup-overlay .avitsi-link { color: inherit; text-decoration: none; transition: color .15s; }
#setup-overlay .avitsi-link:hover { color: var(--cyan); text-decoration: underline; }
/* demo-only back link to the landing site (hidden unless server sends landingUrl) */
#landing-back {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.08em;
  color: var(--muted); text-decoration: none; margin-top: 6px; transition: color .15s;
}
#landing-back:hover { color: var(--cyan); text-decoration: underline; }
#setup-overlay .setup-sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 44px;
}

#code-step,
#callsign-step {
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

#setup-overlay input {
  width: 100%;
  max-width: 280px;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  outline: none;
  text-align: center;
  letter-spacing: 0.1em;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#setup-overlay input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45, 99, 163,0.1);
}
#setup-overlay input::placeholder {
  color: var(--muted);
  letter-spacing: 0.12em;
}

#setup-overlay button {
  width: 100%;
  max-width: 280px;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
}
#setup-overlay button:hover {
  opacity: 0.88;
  box-shadow: 0 0 20px var(--cyan-glow);
}

.hint {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.06em;
}

.disclaimer {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  color: #252a33;
  text-align: center;
  max-width: 280px;
  line-height: 1.7;
  margin-top: 36px;
}

/* ── Channel roster badge ── */
.ch-roster-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  background: var(--cyan);
  color: #000;
  font-family: var(--font-mono);
  font-size: 0.48rem;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* ── Channel sublabel ── */
.ch-sublabel {
  font-family: var(--font-mono);
  font-size: 0.45rem;
  letter-spacing: 0.06em;
  opacity: 0.7;
  display: block;
  margin-top: 2px;
  text-transform: uppercase;
}

/* ── Footer chat button ── */
#footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

#chat-btn {
  position: relative;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#chat-btn:hover { color: var(--text2); }
#chat-btn svg { width: 18px; height: 18px; }

#chat-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--cyan);
  color: #000;
  font-family: var(--font-mono);
  font-size: 0.45rem;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ── Chat overlay ── */
#chat-overlay {
  position: fixed;
  inset: 0;
  padding-top: env(safe-area-inset-top);   /* clear the status bar in standalone/bookmarked PWA mode */
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 0;
  flex-shrink: 0;
}

#chat-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border2);
  border-radius: 6px;
  overflow: hidden;
}

.chat-tab {
  background: none;
  border: none;
  border-right: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chat-tab:last-child { border-right: none; }
.chat-tab:hover { color: var(--text2); }
.chat-tab.active {
  background: var(--surface2);
  color: var(--cyan);
}

#chat-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 12px;
  margin: -6px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#chat-close:hover { color: var(--text); }
#chat-close svg { width: 20px; height: 20px; display: block; flex-shrink: 0; }

/* ── Chat panes ── */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 0 0;
}

/* Channel picker */
#chat-ch-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.chat-ch-pick {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-ch-pick.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(45, 99, 163,0.08);
}

.chat-ch-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Message feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.chat-empty {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
  letter-spacing: 0.06em;
}

/* Individual messages */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 3px;
}

.chat-other {
  align-self: flex-start;
}

.chat-own {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-from {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chat-text {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-own .chat-text {
  background: var(--cyan-dim);
  border-color: rgba(45, 99, 163,0.3);
  color: var(--text);
}

.chat-ts {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Broadcast message */
.chat-broadcast {
  align-self: stretch;
  max-width: 100%;
  background: rgba(240,165,0,0.06);
  border: 1px solid rgba(240,165,0,0.2);
  border-radius: 6px;
  padding: 8px 12px;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-from-broadcast {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.1em;
  flex-shrink: 0;
}

.chat-broadcast .chat-text {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.85rem;
}

.chat-broadcast .chat-ts {
  margin-left: auto;
  flex-shrink: 0;
}

/* Input row */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.chat-input-row input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.chat-input-row input:focus { border-color: var(--cyan); }
.chat-input-row input::placeholder { color: var(--muted); }

.chat-input-row button {
  background: var(--cyan);
  border: none;
  border-radius: 6px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chat-input-row button:hover { opacity: 0.85; }
.chat-input-row button svg { width: 16px; height: 16px; color: #000; stroke: #000; }

/* DM tab */
#tab-dm { padding-top: 0; }

#dm-user-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.dm-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.dm-user-item:hover { background: var(--surface); }

.dm-user-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  flex: 1;
}

.dm-unread-dot {
  background: var(--cyan);
  color: #000;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.dm-arrow { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }

#dm-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#dm-thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#dm-back {
  background: none;
  border: none;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

#dm-thread-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

/* ── Animations ── */
@keyframes pulse-dot-amber {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@keyframes pulse-indicator {
  0%, 100% { opacity: 1;   box-shadow: 0 0 6px var(--cyan-glow); }
  50%       { opacity: 0.4; box-shadow: none; }
}

@keyframes pulse-amber-btn {
  0%, 100% { box-shadow: 0 0 48px var(--amber-glow), 0 8px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(240,165,0,0.06), inset 0 -2px 4px rgba(0,0,0,0.4); }
  50%       { box-shadow: 0 0 72px rgba(240,165,0,0.38), 0 8px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(240,165,0,0.06), inset 0 -2px 4px rgba(0,0,0,0.4); }
}

@keyframes pulse-red-btn {
  0%, 100% { box-shadow: 0 0 32px var(--red-glow), 0 8px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(229,57,53,0.06), inset 0 -2px 4px rgba(0,0,0,0.4); }
  50%       { box-shadow: 0 0 52px rgba(229,57,53,0.38), 0 8px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(229,57,53,0.06), inset 0 -2px 4px rgba(0,0,0,0.4); }
}

/* ── Quick-reply chips ── */
/* ── Quick-reply chips popup ── */
.chat-input-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* Not-joined state: a disabled composer must LOOK disabled (both themes) —
   before this rule it rendered identical to a live input, so a message to an
   unjoined channel read as a silent dead send. */
.chat-input-area input:disabled,
.chat-input-area button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chat-input-area input:disabled::placeholder {
  color: var(--text2);
}

.chips-popup {
  display: none; /* toggled via JS */
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  animation: chipsSlideUp 0.15s ease;
}

.chips-popup.open {
  display: flex;
}

@keyframes chipsSlideUp {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.chat-chip {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 20px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.chat-chip:hover,
.chat-chip:active {
  background: rgba(45, 99, 163,0.12);
  border-color: var(--cyan);
  color: var(--cyan);
}

.chat-chip.sent {
  background: rgba(45, 99, 163,0.22);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Lightning bolt toggle button */
.chips-toggle-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chips-toggle-btn:hover,
.chips-toggle-btn.active {
  color: var(--cyan);
  background: var(--cyan-dim);
}
.chips-toggle-btn svg { width: 18px; height: 18px; display: block; }

/* ── Channel join from chat ── */
.chat-join-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 2px 0 4px;
}

.chat-join-label {
  font-family: var(--font-mono);
  font-size: 0.54rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chat-join-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-join-ch-btn {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  color: var(--text2);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  min-width: 46px;
  padding: 6px 10px;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chat-join-ch-btn:hover,
.chat-join-ch-btn:active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(45, 99, 163,0.08);
}
.chat-join-ch-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.chat-join-sublabel {
  display: block;
  font-family: var(--font-body);
  font-size: 0.44rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: none;
  margin-top: 2px;
}

/* ── Page alert overlay ── */
#page-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
}

#page-overlay.paging {
  animation: page-flash 0.5s ease-in-out 3;
}

@keyframes page-flash {
  0%, 100% { background: rgba(0,0,0,0.88); }
  50%       { background: rgba(240,60,0,0.35); }
}

#page-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 32px;
  position: relative;
}

#page-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #f03c00;
  animation: page-ring 0.8s ease-out infinite;
  position: relative;
}

#page-pulse::after {
  content: '!';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  color: #f03c00;
}

@keyframes page-ring {
  0%   { box-shadow: 0 0 0 0 rgba(240,60,0,0.7); }
  70%  { box-shadow: 0 0 0 24px rgba(240,60,0,0); }
  100% { box-shadow: 0 0 0 0 rgba(240,60,0,0); }
}

#page-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #f03c00;
  text-transform: uppercase;
}

#page-from {
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  color: #e8edf5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#page-ts {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.06em;
}

#page-dismiss {
  margin-top: 8px;
  background: #f03c00;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 36px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
}
#page-dismiss:hover { opacity: 0.85; }

/* ── Event name (admin-set, replaces "Powered by Avitsi") ── */
#event-name {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: var(--cyan);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 4px;
  line-height: 1;
}

/* ── Channel lock indicator ── */
.channel-btn.ch-locked {
  border-color: var(--amber);
  opacity: 0.75;
}
.channel-btn.ch-locked .ch-tx {
  color: var(--amber);
  letter-spacing: 0.08em;
}

/* ── iOS install banner ── */
#ios-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: #0a1018;
  border-top: 1px solid var(--cyan);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}
.iib-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  padding-top: 1px;
}
.iib-text { flex: 1; }
.iib-text strong { color: var(--cyan); }
.iib-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

/* ── Admin broadcast popup ─────────────────────────────────────────────────── */
#broadcast-popup {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  max-width: min(340px, 90vw);
  width: max-content;
  cursor: pointer;
  animation: popup-in 0.2s ease;
}
@keyframes popup-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#broadcast-popup-inner {
  background: #1a1a2e;
  border: 1px solid #38bdf8;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 24px rgba(56,189,248,0.25);
}
#broadcast-popup-from {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #38bdf8;
}
#broadcast-popup-text {
  font-size: 0.88rem;
  color: #e2e8f0;
  line-height: 1.4;
}
#broadcast-popup-tail {
  width: 14px;
  height: 8px;
  margin: 0 auto;
  background: #1a1a2e;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-left: 1px solid #38bdf8;
  border-right: 1px solid #38bdf8;
}

/* ── ALL tab badge ─────────────────────────────────────────────────────────── */
#all-tab-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  padding: 0 3px;
  text-align: center;
  line-height: 14px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── ALL tab feed (legacy, kept for no-op) ──────────────────────────────────── */
#tab-all { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#chat-all-feed { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-empty-hint { color: var(--muted); font-size: 0.78rem; text-align: center; padding: 24px 16px; }

/* ── Chat overlay — inbox / thread layout ─────────────────────────────────── */

/* Inbox and thread panes fill the overlay */
#chat-inbox,
#chat-thread {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

/* Shared header bar */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header-title {
  flex: 1;
  min-width: 0;                /* allow the title to shrink instead of squashing the buttons */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text2);
}

/* Keep header action buttons (PAGE / MUTE / LOCK / close) full-size on narrow + standalone screens */
.chat-header > button { flex-shrink: 0; }

/* Close button (X) used in both inbox and thread headers */
.chat-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  margin: -4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chat-close-btn:hover { color: var(--text); }
.chat-close-btn svg { width: 20px; height: 20px; display: block; flex-shrink: 0; }

/* Back arrow button in thread header */
.thread-back-btn {
  background: none;
  border: none;
  color: var(--cyan);
  cursor: pointer;
  padding: 8px;
  margin: -4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.thread-back-btn:hover { opacity: 0.7; }
.thread-back-btn svg { width: 18px; height: 18px; display: block; }

/* ── Inbox list ── */
#inbox-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.inbox-section-hd {
  padding: 10px 16px 4px;
  font-family: var(--font-mono);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.inbox-hint {
  opacity: 0.45;
  font-style: italic;
}

.inbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.inbox-item:hover { background: var(--surface); }
.inbox-item:last-child { border-bottom: none; }

/* Colored badge (CH / DM / BC) */
.inbox-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.ibadge-ch  { background: rgba(45, 99, 163,0.15);   color: var(--cyan);  border: 1px solid rgba(45, 99, 163,0.3); }
.ibadge-dm  { background: rgba(138,154,181,0.12); color: var(--text2); border: 1px solid rgba(138,154,181,0.25); }
.ibadge-bc  { background: rgba(240,165,0,0.12);   color: var(--amber); border: 1px solid rgba(240,165,0,0.25); }
.ibadge-ops { background: rgba(229,57,53,0.12);   color: #ef5350;      border: 1px solid rgba(229,57,53,0.3); }
.ibadge-away { background: transparent;           color: var(--muted); border: 1px dashed var(--border2); }

.inbox-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inbox-name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.inbox-name {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-ts {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.46rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.inbox-preview {
  font-family: var(--font-body);
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.inbox-unread {
  flex-shrink: 0;
  background: var(--cyan);
  color: #000;
  font-family: var(--font-mono);
  font-size: 0.44rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* PAGE button on a DM row — page without opening the thread */
.inbox-page-btn {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: rgba(229,57,53,0.14);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.inbox-page-btn:hover  { background: rgba(229,57,53,0.24); }
.inbox-page-btn:active { transform: scale(0.94); }

/* Centered system note in a thread (e.g. page acknowledgements) */
.chat-system-note {
  align-self: center;
  max-width: 88%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 12px;
  margin: 4px 0;
}

/* ── Thread bubbles (user side) ── */
.chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 4px;
}

.chat-bubble.incoming {
  align-self: flex-start;
}

.chat-bubble.outgoing {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.bubble-name {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bubble-time {
  font-family: var(--font-mono);
  font-size: 0.46rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.bubble-text {
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
  padding: 8px 12px;
  border-radius: 10px;
}

.chat-bubble.incoming .bubble-text {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px 10px 10px 10px;
}

.chat-bubble.outgoing .bubble-text {
  background: var(--cyan-dim);
  border: 1px solid rgba(45, 99, 163,0.3);
  color: var(--text);
  border-radius: 10px 4px 10px 10px;
}

.chat-bubble.broadcast-bubble {
  max-width: 100%;
  align-self: stretch;
}
.chat-bubble.broadcast-bubble .bubble-text {
  background: rgba(240,165,0,0.07);
  border-color: rgba(240,165,0,0.22);
  border-radius: 6px;
}

/* Small pill button (chat JOIN / LEAVE, etc.) — was undefined, hence the boxy default look */
.btn-sm {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(45, 99, 163,0.12);
  border: 1px solid rgba(45, 99, 163,0.35);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.06s;
}
.btn-sm:hover  { background: rgba(45, 99, 163,0.2); }
.btn-sm:active { transform: scale(0.95); }

/* Leave channel button */
.btn-leave {
  background: rgba(229,57,53,0.12) !important;
  border-color: rgba(229,57,53,0.4) !important;
  color: #ef5350 !important;
}
.btn-leave:hover { background: rgba(229,57,53,0.22) !important; }

/* Thread join row */
#thread-join-row {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.thread-join-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* iOS zoom fix — input must be ≥ 16px to prevent auto-zoom on focus */
#thread-input {
  font-size: 16px !important;
}

/* ── DSP settings panel ────────────────────────────────────────────────────── */
#dsp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 800;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#dsp-panel {
  background: #111318;
  border: 1px solid #2a2f38;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  max-height: 80vh;
  overflow-y: auto;
}
#dsp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #2a2f38;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #38bdf8;
}
#dsp-header button {
  background: none;
  border: none;
  color: #8a95a3;
  cursor: pointer;
  padding: 4px;
  display: flex;
}
#dsp-header button svg { width: 18px; height: 18px; }
.dsp-section {
  padding: 14px 20px;
  border-bottom: 1px solid #1c2128;
}
.dsp-section:last-child { border-bottom: none; }
.dsp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.dsp-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #e2e8f0;
}
.dsp-hint {
  font-size: 0.72rem;
  color: #38bdf8;
  font-family: var(--mono, monospace);
}
.dsp-desc {
  font-size: 0.68rem;
  color: #4a5568;
  line-height: 1.5;
  margin: 6px 0 0;
}
.dsp-slider {
  width: 100%;
  accent-color: #38bdf8;
  cursor: pointer;
}

/* toggle switch */
.dsp-toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.dsp-toggle input { opacity: 0; width: 0; height: 0; }
.dsp-toggle-track {
  position: absolute;
  inset: 0;
  background: #2a2f38;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.dsp-toggle-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #8a95a3;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.dsp-toggle input:checked + .dsp-toggle-track { background: #1e3a5f; }
.dsp-toggle input:checked + .dsp-toggle-track::before {
  transform: translateX(18px);
  background: #38bdf8;
}

/* live meter */
#dsp-meter-track {
  height: 6px;
  background: #1c2128;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
#dsp-meter-fill {
  height: 100%;
  width: 0%;
  background: #38bdf8;
  border-radius: 3px;
  transition: width 0.05s linear;
}

/* restart button */
.dsp-restart-btn {
  width: 100%;
  background: #1e3a5f;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}
.dsp-restart-btn:active { background: #2a4a6f; }

/* ── Per-user connection-state dot (roster drop-up) ─────────────────────────── */
.online-dropup .odu-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 8px; flex: 0 0 auto;
  background: var(--green, #3ddc84);
}
.online-dropup .odu-dot.unstable {
  background: var(--amber, #ffb454);
  animation: odu-pulse 1.2s ease-in-out infinite;
}
/* Away = seen in the last 15 min, socket gone (phone locked / app backgrounded) */
.online-dropup .odu-dot.away { background: transparent; border: 1.5px solid var(--muted); }
.online-dropup .odu-row-away .odu-name { opacity: 0.6; }
.online-dropup .odu-chip-away { background: transparent; color: var(--muted); border: 1px dashed var(--border2); }
@keyframes odu-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Light mode: deep surfaces that were still hardcoded dark ───────────────── */
/* Broadcast popup */
:root[data-theme="light"] #broadcast-popup-inner {
  background: var(--surface2, #ffffff);
  border-color: var(--cyan, #2d63a3);
  box-shadow: 0 4px 24px rgba(45, 99, 163, 0.20);
}
:root[data-theme="light"] #broadcast-popup-from { color: var(--cyan, #2d63a3); }
:root[data-theme="light"] #broadcast-popup-text { color: var(--text, #121620); }
:root[data-theme="light"] #broadcast-popup-tail {
  background: var(--surface2, #ffffff);
  border-left-color: var(--cyan, #2d63a3);
  border-right-color: var(--cyan, #2d63a3);
}
/* DSP settings panel */
:root[data-theme="light"] #dsp-panel { background: var(--surface, #eef1f6); border-color: var(--border, #c3cbd8); }
:root[data-theme="light"] #dsp-header { border-bottom-color: var(--border, #c3cbd8); }
:root[data-theme="light"] #dsp-header { color: var(--cyan, #2d63a3); }
:root[data-theme="light"] #dsp-header button { color: var(--muted, #697184); }
:root[data-theme="light"] .dsp-section { border-bottom-color: var(--border, #c3cbd8); }
:root[data-theme="light"] .dsp-label { color: var(--text, #121620); }
:root[data-theme="light"] .dsp-hint { color: var(--cyan, #2d63a3); }
:root[data-theme="light"] .dsp-desc { color: var(--muted, #697184); }
:root[data-theme="light"] .dsp-slider { accent-color: var(--cyan, #2d63a3); }
:root[data-theme="light"] .dsp-toggle-track { background: var(--border2, #aab4c4); }
:root[data-theme="light"] .dsp-toggle-track::before { background: var(--surface2, #ffffff); }
:root[data-theme="light"] .dsp-toggle input:checked + .dsp-toggle-track { background: var(--cyan, #2d63a3); }
/* iOS install banner */
:root[data-theme="light"] #ios-install-banner {
  background: var(--surface, #eef1f6);
  color: var(--muted, #697184);
  border-top-color: var(--cyan, #2d63a3);
}

/* ── Subtle glass on primary surfaces (brand guide v1.0) ─────────────────────── */
.channel-btn {
  background-image: var(--glass-sheen);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
#footer {
  background: var(--glass);
  background-image: var(--glass-sheen);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--glass-brd);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  border-radius: 12px;
  padding-left: 12px; padding-right: 12px;
}
.sheet-body, #settings-overlay .sheet {
  background-image: var(--glass-sheen);
}

/* Settings → Account inputs (v1.40.0) */
#settings-account .settings-input { display:block; width:100%; box-sizing:border-box; margin:6px 0; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:8px 10px; font-size:.78rem; font-family:inherit; }
#settings-account .settings-row { margin-top:4px; }

/* Join screen: account sign-in is a real second button, not a footnote (Quincy, 2026-09-26) */
#setup-overlay .setup-or { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); margin: 2px 0 -6px; }
#setup-overlay button.btn-alt { background: transparent; color: var(--cyan); border: 2px solid var(--cyan); padding: 12px; font-size: 0.88rem; }
#setup-overlay button.btn-alt:hover { background: color-mix(in srgb, var(--cyan) 14%, transparent); box-shadow: none; }


/* ── Settings → Volume (1.41.0) ── */
.vol-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.vol-label { flex: 0 0 34%; font-size: 0.78rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vol-row-ch .vol-label { font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.04em; }
.vol-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--cyan); }
.vol-val { flex: 0 0 3.2em; text-align: right; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.vol-sub { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 8px 0 2px; }

/* ══ Simple Mode (v1.45.0) — Native Apps Design §8, option B "two slabs" ══════════
   Fluid layout standard: every size is a proportion of the safe-area viewport.
   Talk slab = 46% of the safe-area height, latch = 28%, talker strip = the rest,
   8-pt gutter. Side by side on tablet/desktop (wider than 3:2). Type is clamp() on
   container-query units so labels grow with the control. One source of sizes: */
:root {
  --simple-talk:   46%;    /* of the safe-area height (portrait); talker strip = the rest */
  --simple-latch:  28%;
  --simple-strip-wide: 26%; /* wide: strip on top, the slabs side by side below */
  --simple-talk-w:  46fr;  /* wide: column ratio talk : latch */
  --simple-latch-w: 28fr;
  --simple-gutter: 8px;
  --simple-radius: clamp(14px, 3.2vmin, 28px);
  --simple-border: clamp(4px, 0.9vmin, 7px);
  --simple-min-target: 48px; /* 44pt iOS / 48dp Android floor */
}
body.simple-mode #header,
body.simple-mode #channels,
body.simple-mode #ptt-wrap,
body.simple-mode #footer,
body.simple-mode #waiting-staff-btn,
body.simple-mode #broadcast-popup { display: none !important; }
#simple-view {
  position: fixed; inset: 0; z-index: 5;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) max(var(--simple-min-target), var(--simple-talk)) max(var(--simple-min-target), var(--simple-latch));
  grid-template-areas: "strip" "talk" "latch";
  gap: var(--simple-gutter);
  padding-top:    calc(env(safe-area-inset-top, 0px)    + var(--simple-gutter));
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--simple-gutter));
  padding-left:   calc(env(safe-area-inset-left, 0px)   + var(--simple-gutter));
  padding-right:  calc(env(safe-area-inset-right, 0px)  + var(--simple-gutter));
  background: var(--bg);
  touch-action: none;
}
#simple-view[hidden] { display: none !important; }
@media (min-aspect-ratio: 3/2) {
  #simple-view {
    grid-template-columns: minmax(var(--simple-min-target), var(--simple-talk-w)) minmax(var(--simple-min-target), var(--simple-latch-w));
    grid-template-rows: var(--simple-strip-wide) minmax(var(--simple-min-target), 1fr);
    grid-template-areas: "strip strip" "talk latch";
  }
  /* Short wide strip: tools at the side, the name centred between equal side pads. */
  .simple-strip { padding-top: 0; padding-inline: calc(var(--simple-min-target) + 2 * var(--simple-gutter)); }
  .simple-strip.can-exit { padding-inline: clamp(150px, 24vw, 220px); }
}
.simple-strip {
  grid-area: strip; container-type: size; position: relative; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2%;
  min-height: 0; overflow: hidden; text-align: center;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  /* Portrait: the tool row (gear + Full view) owns the top of the strip, in its own band, so
     the talker name never runs under it. Wide: the tools sit at the side instead (below). */
  padding-top: calc(var(--simple-min-target) + var(--simple-gutter));
}
/* Way out of Simple Mode (v1.46.2): top-right of the talker strip, inside the safe area
   (#simple-view already pads by the insets), clear of the HOLD / LATCH slabs (own grid row). */
.simple-tools {
  position: absolute; top: 0; right: 0; z-index: 1;
  display: flex; align-items: center; gap: var(--simple-gutter);
}
.simple-cog, .simple-full-btn {
  box-sizing: border-box; min-width: var(--simple-min-target); min-height: var(--simple-min-target);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border2); border-radius: 12px;
  background: var(--surface); color: var(--text); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.simple-cog { width: var(--simple-min-target); height: var(--simple-min-target); padding: 0; }
.simple-cog svg { width: 24px; height: 24px; }
.simple-full-btn {
  padding: 0 16px; font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(0.72rem, 3.4vw, 0.9rem); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  border-color: var(--cyan); color: var(--cyan);
}
.simple-full-btn[hidden] { display: none; }
.simple-cog:active, .simple-full-btn:active { filter: brightness(1.2); }
.simple-cog:focus-visible, .simple-full-btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
:root[data-theme="light"] .simple-cog, :root[data-theme="light"] .simple-full-btn { background: #ffffff; }
.simple-chan {
  font-family: var(--font-mono); font-size: clamp(0.62rem, 3.2cqw, 0.9rem); letter-spacing: .12em;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96%;
}
/* 1.49.0: channel dropdown in Simple Mode (shown instead of .simple-chan when >1 channel allowed) */
.simple-chan-sel {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1rem, 5cqw, 1.5rem); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text); background: var(--surface2); border: 2px solid var(--border2); border-radius: 999px;
  padding: 0 44px 0 18px; appearance: none; -webkit-appearance: none;
  /* Pinned top-left in the tools band (gear + Full view own the top-right), out of the centred
     label + talker block, so the strip's centre and lower half (the long-press backup, and
     where a thumb lands) stay free of the dropdown. */
  position: absolute; left: 3%; top: 2%; min-width: 0; max-width: 55%; min-height: 48px; font-size: clamp(0.9rem, 4.2cqw, 1.3rem);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' fill='none' stroke='%23a6afbb' stroke-width='2'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
}
.simple-chan-sel[hidden] { display: none; }
.simple-talker-label {
  font-family: var(--font-mono); font-size: clamp(0.55rem, 2.6cqw, 0.8rem); letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.simple-talker {
  font-family: var(--font-display); font-weight: 800; letter-spacing: .03em; line-height: 1;
  font-size: clamp(1.6rem, min(16cqw, 44cqh), 9rem);
  color: var(--muted); max-width: 96%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .15s;
}
.simple-status {
  font-family: var(--font-mono); font-size: clamp(0.55rem, 2.6cqw, 0.8rem); letter-spacing: .08em;
  color: var(--amber); min-height: 1.2em; max-width: 96%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.simple-strip.rx   .simple-talker { color: var(--cyan); }
.simple-strip.self .simple-talker { color: var(--cyan); }
.simple-strip.latched .simple-talker { color: var(--amber); }
.simple-strip.muted .simple-talker, .simple-strip.locked .simple-talker { color: var(--red); }

.simple-slab {
  container-type: size; box-sizing: border-box; min-height: var(--simple-min-target); min-width: var(--simple-min-target);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3%;
  border-radius: var(--simple-radius); border: var(--simple-border) solid var(--border2);
  background: radial-gradient(circle at 40% 30%, #1c2333, #0c0e11);
  box-shadow: 0 8px 40px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.04), inset 0 -2px 4px rgba(0,0,0,.4);
  color: var(--text); text-align: center; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none;
  transition: border-color .12s, background .12s, box-shadow .12s, filter .12s;
}
.simple-talk  { grid-area: talk; }
.simple-latch { grid-area: latch; }
.simple-slab:active { filter: brightness(1.15); }
.simple-slab:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.simple-slab-l {
  font-family: var(--font-display); font-weight: 800; letter-spacing: .06em; line-height: 1;
  font-size: clamp(1.3rem, min(13cqw, 30cqh), 7rem); max-width: 94%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.simple-slab-s {
  font-family: var(--font-mono); letter-spacing: .14em; text-transform: lowercase; color: var(--muted);
  font-size: clamp(0.58rem, min(3.4cqw, 9cqh), 1.1rem); max-width: 94%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Someone else talking: the talk slab edge lifts in blue */
.simple-talk.rx { border-color: color-mix(in srgb, var(--cyan) 55%, var(--border2)); }
/* You, holding: blue */
.simple-talk.talking { border-color: var(--cyan); background: radial-gradient(circle at 40% 30%, #0d2220, #061210); box-shadow: 0 0 48px var(--cyan-glow), 0 8px 40px rgba(0,0,0,.7); }
.simple-talk.talking .simple-slab-l, .simple-talk.talking .simple-slab-s { color: var(--cyan); }
/* You, latched: amber, on the latch slab and the talk slab dimmed */
.simple-latch.on { border-color: var(--amber); background: radial-gradient(circle at 40% 30%, #1e1500, #0d0900); box-shadow: 0 0 44px var(--amber-glow), 0 8px 30px rgba(0,0,0,.7); }
.simple-latch.on .simple-slab-l, .simple-latch.on .simple-slab-s { color: var(--amber); }
.simple-talk.latched { opacity: .55; }
/* Muted / locked / listen-only */
.simple-slab.muted, .simple-slab.locked { border-color: var(--red); background: radial-gradient(circle at 40% 30%, #1a0808, #0c0404); }
.simple-slab.muted .simple-slab-l, .simple-slab.muted .simple-slab-s,
.simple-slab.locked .simple-slab-l, .simple-slab.locked .simple-slab-s { color: var(--red); }
.simple-slab.listen { opacity: .45; cursor: default; }

:root[data-theme="light"] .simple-slab { background: radial-gradient(circle at 40% 30%, #ffffff, #d9dfe9); box-shadow: 0 6px 22px rgba(30,40,60,.14), inset 0 1px 0 rgba(255,255,255,.7); }
:root[data-theme="light"] .simple-talk.talking { background: radial-gradient(circle at 40% 30%, #dbe8f7, #bcd5ef); }
:root[data-theme="light"] .simple-latch.on { background: radial-gradient(circle at 40% 30%, #fbf0d4, #efe1b6); }
:root[data-theme="light"] .simple-slab.muted, :root[data-theme="light"] .simple-slab.locked { background: radial-gradient(circle at 40% 30%, #f7d6d6, #eec2c2); }

/* Settings → View: the Simple Mode switch */
.simple-switch { position: relative; display: inline-flex; align-items: center; min-width: 52px; min-height: 44px; cursor: pointer; }
.simple-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.simple-switch-track { width: 46px; height: 26px; border-radius: 999px; background: var(--border2); position: relative; transition: background .15s; }
.simple-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.simple-switch input:checked + .simple-switch-track { background: var(--cyan); }
.simple-switch input:checked + .simple-switch-track::after { transform: translateX(20px); }
.simple-switch input:focus-visible + .simple-switch-track { outline: 2px solid var(--cyan); outline-offset: 2px; }
/* Locked to Simple: the long-press settings sheet shows only audio devices + volume */
#settings-overlay.simple-locked .settings-section:not([data-simple-keep]) { display: none !important; }

/* Volume panel (v1.46.2): channels always visible; people in a collapsible list with a count,
   and a filter box past 8 people. Rows and controls hold the 44 pt touch floor. */
.vol-row { min-height: 44px; }
.vol-row input[type="range"] { height: 44px; margin: 0; touch-action: pan-y; }
.vol-people { margin-top: 8px; border-top: 1px solid var(--border); }
.vol-people[hidden] { display: none; }
.vol-people-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 2px;
  background: none; border: 0; color: var(--text); cursor: pointer; text-align: left; font: inherit;
}
.vol-people-chev { display: inline-block; flex: 0 0 auto; width: 7px; height: 7px; margin: 0 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.vol-people.open .vol-people-chev { transform: rotate(45deg); }
.vol-people-title { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.vol-people-count { margin-left: auto; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text); white-space: nowrap; }
.vol-people-body[hidden] { display: none; }
.vol-filter {
  box-sizing: border-box; width: 100%; min-height: 44px; margin: 4px 0 6px; padding: 0 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border2); border-radius: 8px; font-size: 16px;
}
.vol-filter[hidden] { display: none; }
.vol-row[hidden] { display: none; }
.vol-people-list { max-height: min(50vh, 420px); overflow-y: auto; overscroll-behavior: contain; }

/* ── What's new (v1.50.0) ───────────────────────────────────────────────── */
#settings-btn { position: relative; }
.settings-new-dot { position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 2px var(--bg, #0f1218); }
.whatsnew-body .wn-ver { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); margin: 10px 0 2px; }
.whatsnew-body .wn-ver:first-child { margin-top: 0; }
.whatsnew-body .wn-title { font-weight: 700; margin: 0 0 4px; font-size: 14px; }
.whatsnew-body ul { margin: 0 0 4px 18px; padding: 0; font-size: 13px; line-height: 1.45; }
.whatsnew-body li { margin: 3px 0; }
.whatsnew-body .wn-where { font-size: 11px; color: var(--muted); margin: 0 0 4px; }

/* ── Operator notice bar (v1.50.0) ─────────────────────────────────────── */
.notice-bar { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; background: var(--surface2); border-left: 4px solid var(--cyan); color: var(--text); font-size: clamp(13px, 3.6vw, 15px); line-height: 1.35; }
.notice-bar.warn { border-left-color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, var(--surface2)); }
.notice-bar[hidden] { display: none; }
.notice-text { flex: 1 1 auto; min-width: 0; }
.notice-close { flex: 0 0 auto; min-width: 44px; min-height: 44px; background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; border-radius: 8px; }
.notice-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
body.simple-mode .notice-bar { font-size: clamp(14px, 4vw, 17px); }

/* ── Embedded chat (v1.50.0): the native app's chat view = this page with ?embed=chat ── */
body.embed-chat #header, body.embed-chat #channels, body.embed-chat #ptt-wrap, body.embed-chat #footer,
body.embed-chat #simple-view, body.embed-chat #notice-bar, body.embed-chat #channel-status, body.embed-chat #settings-overlay { display: none !important; }
body.embed-chat #chat-close, body.embed-chat #chat-close-thread { display: none !important; }
body.embed-chat #chat-overlay { animation: none; padding-top: 0; }
/* v1.50.5: the join screen and the CONNECTING… screen never show inside the app's Messages view.
   The native app already signed in; the web view resumes that session silently (bootstrap script
   + session resume) and the chat opens on the first state snapshot. Until then: one quiet line. */
body.embed-chat #setup-overlay, body.embed-chat #waiting-overlay { display: none !important; }
body.embed-chat::before {
  content: 'Loading messages…'; position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; opacity: .5; pointer-events: none;
}
body.embed-chat.chat-open::before { display: none; }

/* ── Environment badge (1.51.0): STAGING / DEMO / SANDBOX / LOCAL next to the status dot, so a
   tester always knows which box the app resumed on. Customer boxes show nothing. ── */
.env-badge { display:inline-block; margin-left:8px; padding:2px 7px; border-radius:3px; font:700 10px/1.4 ui-monospace, Menlo, monospace; letter-spacing:.12em; vertical-align:middle;
  color:#111; background:var(--t-warn, #f2b700); }
.env-badge[data-env="demo"] { background:var(--t-accent, #5a95d8); }
.env-badge[data-env="sandbox"], .env-badge[data-env="local"] { background:#8c8a84; color:#fff; }
/* Simple Mode: single permitted channel and nothing joined — the pill text is the join control */
.simple-chan.pick { text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
