/* OpComms Web & iOS PWA — Responsive Split-Rail Console Styles
 * Standard Mode: Arctic Titanium Pro (#0D1526 rail + #F1F5F9 frost workspace + Sapphire #0284C7 / Emerald #059669)
 * Stealth Mode:  Carbon Signal Orange (#0D0E11 rail + #15171B graphite workspace + Signal Orange #FF5C28 / Mint #10E890)
 */

:root {
  --rail-bg: #0D1526;
  --rail-border: #1E293B;
  --rail-pill: #17233B;
  --rail-pill-hover: #213254;
  --rail-text: #CBD5E1;
  --rail-muted: #64748B;

  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface-alt: #E2E8F0;
  --surface-hover: #F8FAFC;
  --border: #CBD5E1;
  --border-subtle: #E2E8F0;

  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;

  --accent: #0284C7;
  --accent-soft: rgba(2, 132, 199, 0.12);
  --accent-text: #FFFFFF;

  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.14);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.14);
  --warn: #D97706;
  --warn-soft: rgba(217, 119, 6, 0.15);

  --bubble-mine: #0284C7;
  --bubble-mine-text: #FFFFFF;
  --bubble-peer: #FFFFFF;
  --bubble-peer-text: #0F172A;
  --bubble-peer-border: #CBD5E1;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.24);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

body.stealth {
  --rail-bg: #0D0E11;
  --rail-border: #23262E;
  --rail-pill: #181A20;
  --rail-pill-hover: #242832;
  --rail-text: #E2E8F0;
  --rail-muted: #717684;

  --bg: #15171B;
  --surface: #1E2127;
  --surface-alt: #262A32;
  --surface-hover: #242830;
  --border: #2F343F;
  --border-subtle: #262A33;

  --text: #F1F5F9;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;

  --accent: #FF5C28;
  --accent-soft: rgba(255, 92, 40, 0.16);
  --accent-text: #FFFFFF;

  --ok: #10E890;
  --ok-soft: rgba(16, 232, 144, 0.14);
  --danger: #FF3B5C;
  --danger-soft: rgba(255, 59, 92, 0.16);
  --warn: #FFB020;
  --warn-soft: rgba(255, 176, 32, 0.16);

  --bubble-mine: #FF5C28;
  --bubble-mine-text: #FFFFFF;
  --bubble-peer: #242831;
  --bubble-peer-text: #F1F5F9;
  --bubble-peer-border: #323744;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.48);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; height: 100dvh; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  user-select: none; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
input, textarea, select, button { font-family: inherit; }
.selectable { user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,140,160,0.28); border-radius: 99px; }

/* ─── Auth Screen ───────────────────────────────────────────────────────────── */
.auth-screen {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background: radial-gradient(circle at 25% 20%, rgba(2,132,199,0.16), transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(5,150,105,0.14), transparent 50%),
              var(--bg);
  position: relative; overflow-y: auto;
}
body.stealth .auth-screen {
  background: radial-gradient(circle at 25% 20%, rgba(255,92,40,0.14), transparent 48%),
              radial-gradient(circle at 80% 80%, rgba(76,201,240,0.12), transparent 48%),
              var(--bg);
}
.auth-home-pill {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 18px;
  padding: 8px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px; font-weight: 700; text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.auth-home-pill:hover { color: var(--text); border-color: var(--accent); }
.auth-stealth-pill {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 18px;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.auth-stealth-pill:hover { border-color: var(--accent); }
.auth-card {
  width: 420px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.auth-brand h1 { font-size: 24px; font-weight: 800; letter-spacing: 0.3px; }
.auth-brand p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--surface-alt); padding: 4px; border-radius: 10px; margin-bottom: 16px;
}
.auth-tab {
  border: none; background: transparent; color: var(--text-secondary);
  padding: 9px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.form-field { margin-bottom: 13px; }
.form-field label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-secondary); margin-bottom: 5px;
}
.form-field input, .form-field select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 16px; outline: none; transition: border-color 0.15s;
}
.form-field input:focus, .form-field select:focus { border-color: var(--accent); }
.saved-accounts-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.saved-chip {
  padding: 6px 11px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; cursor: pointer;
}
.saved-chip:hover { border-color: var(--accent); }
.auth-error { color: var(--danger); font-size: 12px; font-weight: 600; margin-bottom: 10px; min-height: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #052014; font-weight: 700; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #FFFFFF; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); border-color: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; flex-shrink: 0; }
.btn-icon.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-icon.ok-active { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.btn-icon.danger-active { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-full { width: 100%; }

/* ─── Main Split-Rail Shell ─────────────────────────────────────────────────── */
.app-shell {
  width: 100%; height: 100%;
  display: flex; overflow: hidden;
  padding-top: env(safe-area-inset-top);
}

/* Left Rail */
.left-rail {
  width: 74px; flex-shrink: 0;
  background: var(--rail-bg);
  border-right: 1px solid var(--rail-border);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 6px; gap: 8px; z-index: 20;
}
.rail-logo {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 50%; transition: transform 0.15s;
}
.rail-logo:hover { transform: scale(1.06); }
.rail-power {
  width: 48px; height: 42px; border-radius: 12px;
  border: 1.5px solid #334155; background: #141E33; color: #94A3B8;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; font-size: 9px; font-weight: 800; letter-spacing: 0.6px;
  transition: all 0.2s;
}
body.stealth .rail-power { background: #1A1C22; border-color: #2E323D; }
.rail-power.on, .mobile-power-btn.on {
  background: rgba(16, 232, 144, 0.16); border-color: #10E890; color: #10E890;
  box-shadow: 0 0 12px rgba(16, 232, 144, 0.25);
}
.rail-divider { width: 34px; height: 1px; background: var(--rail-border); margin: 2px 0; }
.rail-channels {
  width: 100%; flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 2px 0;
}
.rail-ch-pill {
  width: 56px; min-height: 34px; padding: 4px 3px; border-radius: 10px;
  background: var(--rail-pill); border: 1px solid transparent;
  color: var(--rail-text); font-size: 10px; font-weight: 700;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; line-height: 1.15; position: relative; transition: all 0.15s; word-break: break-all;
}
.rail-ch-pill:hover { background: var(--rail-pill-hover); }
.rail-ch-pill.active { background: var(--accent); color: #FFFFFF; box-shadow: 0 4px 12px rgba(2,132,199,0.35); }
body.stealth .rail-ch-pill.active { box-shadow: 0 4px 14px rgba(255,92,40,0.38); }
.rail-ch-pill .lock-dot { font-size: 8px; opacity: 0.85; }
.rail-nav-btn {
  width: 52px; height: 46px; border-radius: 12px;
  background: transparent; border: 1px solid transparent;
  color: var(--rail-text); cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 9px; font-weight: 700; letter-spacing: 0.3px; transition: all 0.15s;
}
.rail-nav-btn:hover { background: var(--rail-pill); }
.rail-nav-btn.active { background: var(--rail-pill-hover); border-color: var(--accent); color: #FFFFFF; }
.rail-badge {
  position: absolute; top: 2px; right: 4px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
  background: #EF4444; color: #FFFFFF; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* Workspace Container */
.workspace {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; position: relative; background: var(--bg);
}

/* PWA Banner */
.pwa-banner {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent);
  padding: 7px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; font-weight: 600; color: var(--text); flex-shrink: 0;
}
.pwa-banner-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Top Bar */
.topbar {
  height: 54px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; gap: 10px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.channel-title { font-size: 16.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-badge {
  font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 99px;
  background: var(--surface-alt); color: var(--text-secondary); letter-spacing: 0.4px; flex-shrink: 0;
}
.channel-badge.live { background: var(--ok-soft); color: var(--ok); }
.channel-badge.connecting { background: var(--warn-soft); color: var(--warn); }
.channel-badge.custom { background: var(--accent-soft); color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Mobile Channel Strip */
.mobile-channel-strip {
  background: var(--rail-bg); border-bottom: 1px solid var(--rail-border);
  padding: 7px 10px; display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.mobile-channel-list {
  display: flex; align-items: center; gap: 6px; overflow-x: auto; flex: 1;
  scrollbar-width: none;
}
.mobile-channel-list::-webkit-scrollbar { display: none; }
.mobile-ch-pill {
  padding: 6px 11px; border-radius: 99px; border: 1px solid var(--rail-border);
  background: var(--rail-pill); color: var(--rail-text); font-size: 11.5px; font-weight: 700;
  white-space: nowrap; cursor: pointer; flex-shrink: 0;
}
.mobile-ch-pill.active { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }

/* Telemetry Ribbon */
.telemetry-ribbon {
  height: 30px; flex-shrink: 0;
  background: var(--surface-alt); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; font-size: 11px; color: var(--text-secondary); gap: 10px;
}
.telemetry-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tele-item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.tele-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.tele-dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.tele-dot.tx { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.hotkey-pill {
  padding: 2px 7px; border-radius: 6px; background: var(--surface);
  border: 1px solid var(--border); font-family: ui-monospace, monospace;
  font-size: 10px; font-weight: 700; color: var(--text);
}

/* Radio Console Split Body */
.radio-body { flex: 1; min-height: 0; display: flex; overflow: hidden; position: relative; }
.radio-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* Video & Screen Share Stage */
.video-stage {
  background: #090D16; border-bottom: 1px solid var(--border);
  padding: 8px 12px; display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; max-height: 44%; overflow-y: auto; flex-shrink: 0;
}
.video-tile {
  position: relative; background: #111827; border-radius: 12px; overflow: hidden;
  border: 1.5px solid #263147; flex: 1 1 220px; max-width: 540px; aspect-ratio: 16/9; min-height: 130px;
}
.video-tile.speaking { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(16,232,144,0.3); }
.video-tile video { width: 100%; height: 100%; object-fit: contain; background: #05070D; }
.video-tile video.mirrored { transform: scaleX(-1); }
.video-tile-label {
  position: absolute; bottom: 8px; left: 8px;
  padding: 3px 9px; border-radius: 99px;
  background: rgba(0,0,0,0.68); color: #FFFFFF; font-size: 11px; font-weight: 700;
}
.video-tile-fs {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: rgba(0,0,0,0.62); color: #FFF; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Chat Stream */
.chat-stream {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.empty-state { margin: auto; text-align: center; max-width: 380px; color: var(--text-secondary); padding: 20px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.45; }

.msg-row { display: flex; flex-direction: column; max-width: 80%; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.peer { align-self: flex-start; align-items: flex-start; }
.msg-row.sys { align-self: center; align-items: center; max-width: 90%; }
.msg-meta {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  margin-bottom: 3px; padding: 0 4px; display: flex; gap: 6px; align-items: center;
}
.msg-bubble {
  padding: 9px 13px; border-radius: 15px; font-size: 14px; line-height: 1.42;
  word-wrap: break-word; white-space: pre-wrap; user-select: text; -webkit-user-select: text;
  position: relative;
}
.msg-row.mine .msg-bubble {
  background: var(--bubble-mine); color: var(--bubble-mine-text); border-bottom-right-radius: 4px;
}
.msg-row.peer .msg-bubble {
  background: var(--bubble-peer); color: var(--bubble-peer-text);
  border: 1px solid var(--bubble-peer-border); border-bottom-left-radius: 4px;
}
.msg-row.sys .msg-bubble {
  background: var(--surface-alt); color: var(--text-secondary);
  font-size: 11.5px; padding: 5px 12px; border-radius: 99px;
}

/* Reply Quote & Reaction Pills */
.reply-quote-box {
  padding: 6px 9px; border-radius: 9px; margin-bottom: 6px;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.16);
  font-size: 11.5px; line-height: 1.3; cursor: pointer;
}
.msg-row.mine .reply-quote-box { border-left-color: rgba(255,255,255,0.85); background: rgba(0,0,0,0.2); }
.msg-row.peer .reply-quote-box { background: var(--surface-alt); }
.reply-quote-sender { font-weight: 800; font-size: 10.5px; opacity: 0.92; display: block; margin-bottom: 1px; }
.reply-quote-text { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; max-width: 240px; }

.reactions-row {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; padding: 0 2px;
}
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.reaction-chip.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.emoji-strip {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.emoji-pick-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 19px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.emoji-pick-btn.active { border-color: var(--accent); background: var(--accent-soft); }

.reply-composer-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; background: var(--surface-alt);
  border-top: 1px solid var(--border-subtle); flex-shrink: 0;
}
.reply-bar-line { width: 3px; height: 28px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.reply-bar-info { flex: 1; min-width: 0; font-size: 12px; }
.reply-bar-info strong { display: block; color: var(--accent); font-size: 11px; }
.reply-bar-info span { display: block; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Floating PTT Dock */
.ptt-dock {
  flex-shrink: 0; padding: 4px 14px 6px;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 28%);
}
.ptt-side-info { width: 155px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-secondary); }
.ptt-side-info.right { align-items: flex-end; text-align: right; }
.ptt-status-label { font-size: 11.5px; font-weight: 800; letter-spacing: 0.7px; text-transform: uppercase; color: var(--text); }
.ptt-status-label.tx { color: var(--danger); }
.ptt-status-label.openmic { color: var(--ok); }
.ptt-dial-wrap {
  position: relative; width: 120px; height: 120px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: none;
}
#pttDialCanvas { width: 120px; height: 120px; display: block; }
.vu-bar-bg { width: 110px; height: 6px; border-radius: 99px; background: var(--surface-alt); overflow: hidden; }
.vu-bar-fill { height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--ok), var(--accent), var(--danger)); transition: width 0.06s linear; }

/* Composer */
.composer {
  flex-shrink: 0; padding: 9px 12px 11px;
  background: var(--surface); border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: 7px;
}
.composer input[type="text"] {
  flex: 1; min-width: 0; padding: 10px 13px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 15px; outline: none;
}
.composer input[type="text"]:focus { border-color: var(--accent); }

/* Right Collapsible Peers Drawer */
.peers-drawer {
  width: 260px; flex-shrink: 0;
  background: var(--surface); border-left: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; overflow: hidden;
}
.peers-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-secondary);
}
.peers-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.peer-card {
  padding: 10px; border-radius: 12px; background: var(--bg);
  border: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 8px;
}
.peer-card.tx { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-soft); }
.peer-name { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.peer-sub { font-size: 11px; color: var(--text-muted); }
.peer-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* ─── Comms 2-Pane View ─────────────────────────────────────────────────────── */
.comms-shell { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.comms-sidebar {
  width: 286px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; overflow: hidden;
}
.comms-sidebar-hdr {
  padding: 13px 15px; border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.comms-sidebar-hdr h2 { font-size: 16px; font-weight: 800; }
.comms-thread-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.thread-item {
  padding: 10px 12px; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 10px; border: 1px solid transparent;
}
.thread-item:hover { background: var(--surface-hover); }
.thread-item.active { background: var(--accent-soft); border-color: var(--accent); }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--ok));
  color: #FFF; font-weight: 800; font-size: 13.5px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.avatar .online-dot {
  position: absolute; bottom: -2px; right: -2px;
  width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface);
}
.thread-info { flex: 1; min-width: 0; }
.thread-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.thread-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-time { font-size: 10.5px; color: var(--text-muted); flex-shrink: 0; }
.thread-preview { font-size: 12px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-pill {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--accent); color: #FFF; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.comms-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.comms-photo-thumb {
  max-width: 260px; max-height: 230px; border-radius: 10px;
  cursor: pointer; display: block; margin-top: 6px; object-fit: cover;
  border: 1px solid rgba(255,255,255,0.16);
}
.comms-file-card {
  display: flex; align-items: center; gap: 9px; margin-top: 4px;
  padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,0.12); min-width: 200px;
}
.msg-row.peer .comms-file-card { background: var(--surface-alt); }
.comms-audio { width: 230px; max-width: 100%; height: 34px; margin-top: 6px; display: block; }
.progress-bar { width: 100%; height: 5px; border-radius: 99px; background: rgba(128,140,160,0.28); overflow: hidden; margin-top: 5px; }
.progress-fill { height: 100%; background: var(--ok); transition: width 0.15s; }
.msg-actions-hover { display: flex; gap: 10px; margin-top: 4px; font-size: 11px; opacity: 0.78; align-items: center; }
.msg-actions-hover button {
  border: none; background: transparent; color: inherit; cursor: pointer;
  font-size: 11px; padding: 1px 0; display: inline-flex; align-items: center; gap: 3px;
}
.msg-actions-hover button:hover { opacity: 1; text-decoration: underline; }

.memo-rec-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 10px; background: var(--danger-soft); color: var(--danger);
  font-size: 12px; font-weight: 700; flex: 1;
}
.rec-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); } }

.active-call-banner {
  background: linear-gradient(135deg, #064E3B, #0F172A); color: #FFFFFF; padding: 10px 14px;
  border-bottom: 1px solid rgba(16, 232, 144, 0.35);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; flex-shrink: 0;
}
.active-call-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Friends View */
.page-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px;
  display: flex; flex-direction: column; gap: 16px; max-width: 960px; width: 100%; margin: 0 auto;
}
.card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); }
.card-title { font-size: 14px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.friend-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border-subtle); margin-bottom: 8px;
}

/* HUD Stack */
.hud-stack {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; width: 350px; max-width: calc(100vw - 28px);
}
.hud-card {
  background: #0F172A; color: #FFFFFF; border-radius: 16px; padding: 15px;
  border: 1.5px solid #10E890; box-shadow: var(--shadow-lg); animation: slideIn 0.2s ease-out;
}
.hud-card.ping { border-color: #38BDF8; }
.hud-card.friend { border-color: #F59E0B; }
@keyframes slideIn { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.hud-title { font-size: 13.5px; font-weight: 800; margin-bottom: 4px; }
.hud-body { font-size: 12.5px; color: #CBD5E1; margin-bottom: 12px; }
.hud-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(5, 10, 20, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  width: 540px; max-width: 100%; max-height: 88dvh;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15.5px; font-weight: 800; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 8px; }

/* Camera Capture Modal */
.camera-modal {
  width: 700px; max-width: 100%; background: #0B0E14; color: #FFF;
  border: 1px solid #2A3142; border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.camera-top { padding: 12px 14px; background: #111520; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.camera-stage { position: relative; background: #000; height: 52dvh; max-height: 420px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.camera-stage video, .camera-stage img { width: 100%; height: 100%; object-fit: contain; }
.camera-deck { padding: 14px 18px; background: #111520; display: flex; align-items: center; justify-content: center; gap: 16px; }
.shutter-btn { width: 62px; height: 62px; border-radius: 50%; border: 4px solid #FFF; background: rgba(255,255,255,0.2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.shutter-inner { width: 44px; height: 44px; border-radius: 50%; background: #FFF; }

/* Settings Rows */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border-subtle); }
.setting-row:last-child { border-bottom: none; }
.setting-label strong { display: block; font-size: 13.5px; }
.setting-label span { font-size: 12px; color: var(--text-secondary); }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer; transition: 0.2s; }
.toggle-slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #FFF; border-radius: 50%; transition: 0.2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Toast */
.toast {
  position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: #0F172A; color: #FFFFFF; padding: 9px 18px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-md);
  z-index: 500; border: 1px solid rgba(255,255,255,0.14); max-width: 90vw; text-align: center;
}

/* Icons */
.ic {
  width: 1.2em; height: 1.2em; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.22em; display: inline-block;
}
.btn-icon .ic { width: 18px; height: 18px; margin: 0; vertical-align: middle; }
.rail-power .ic { width: 19px; height: 19px; stroke-width: 2.1; }
.rail-nav-btn .ic { width: 21px; height: 21px; stroke-width: 1.7; }
.rail-ch-pill .ic { width: 9px; height: 9px; stroke-width: 2.4; }

/* ─── MOBILE / iPHONE / iPAD RESPONSIVE LAYOUT ──────────────────────────────── */
@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }

  .app-shell { flex-direction: column-reverse; }

  .left-rail {
    width: 100%; height: auto;
    flex-direction: row; justify-content: space-around; align-items: center;
    border-right: none; border-top: 1px solid var(--rail-border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
  }
  .rail-logo, .rail-power { display: none !important; }
  .rail-nav-btn { width: auto; flex: 1; height: 48px; border-radius: 10px; font-size: 10px; }

  .topbar { height: 50px; padding: 0 10px; }
  .channel-title { font-size: 15px; }
  .mobile-power-btn { padding: 5px 9px; font-weight: 800; font-size: 11px; }

  .ptt-dock { gap: 10px; padding: 4px 10px 6px; }
  .ptt-side-info { width: auto; flex: 1; min-width: 0; }
  .ptt-status-label { font-size: 10.5px; }
  .vu-bar-bg { width: 100%; max-width: 96px; }
  .ptt-dial-wrap, #pttDialCanvas { width: 106px; height: 106px; }

  /* Mobile slide-over Peers Drawer */
  .peers-drawer {
    position: absolute; top: 0; right: 0; bottom: 0; width: 270px; max-width: 82vw;
    z-index: 40; box-shadow: var(--shadow-lg);
  }

  /* Mobile Comms: 1-pane toggle between Thread List & Conversation */
  .comms-sidebar { width: 100%; border-right: none; }
  .comms-main { display: none; }
  .comms-shell.thread-open .comms-sidebar { display: none; }
  .comms-shell.thread-open .comms-main { display: flex; }

  .msg-row { max-width: 88%; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
