/* public/css/style.css - Modern Dark Glassmorphism Design */
:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #111726;
  --bg-card: rgba(19, 26, 42, 0.75);
  --bg-card-hover: rgba(28, 38, 62, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.3);

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  /* F11: lifted from #6b7280 (3.70:1 on --bg-secondary) to clear 4.5:1 —
     the token is used for 0.7rem labels that carry meaning. */
  --text-muted: #8b93a3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* F11: a visible focus ring for keyboard users. Interactive components that
   declare `outline: none` still get this via :focus-visible. */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* F11: honour the user's motion preference across every animated element. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* App Container */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Top Navigation Bar */
.top-nav {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.nav-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.room-badge-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.room-badge strong {
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--accent-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: opacity 0.2s;
}

.copy-btn:hover {
  opacity: 0.8;
}

.nav-right-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Prominent Main-Screen Running Call Timer */
.call-timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
}

.call-timer-badge .clock {
  font-family: monospace;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: 0.5px;
}

.timer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 6px #3b82f6;
  display: inline-block;
  animation: timer-pulse 2s infinite ease-in-out;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* Crypto Ledger / Wallet Drawer Trigger Button */
.crypto-wallet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  padding: 0;
  user-select: none;
}

.crypto-wallet-btn:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.65);
  transform: translateY(-1px) scale(1.06);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

.crypto-wallet-btn:active,
.crypto-wallet-btn.active {
  background: rgba(245, 158, 11, 0.3);
  border-color: #f59e0b;
  transform: scale(0.96);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

.crypto-icon {
  font-size: 1.15rem;
  line-height: 1;
  display: block;
}

/* Row 2: Secondary Quick Actions */
.nav-row-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

/* F2: mobile home for Night / Codec / health — hidden on desktop where row 2 holds them. */
.nav-compact-secondary {
  display: none;
  align-items: center;
  gap: 4px;
}

.nav-compact-secondary .nav-icon-btn {
  padding: 0;
  width: 40px;
  height: 40px;
  justify-content: center;
  flex: 0 0 auto;
}

.nav-compact-secondary .codec-dropdown.compact {
  font-size: 0.72rem;
  padding: 6px 2px;
  max-width: 64px;
  min-height: 40px;
}

/* F1: mobile overflow sheet for low-frequency controls. */
.more-controls-sheet {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  background: rgba(10, 13, 20, 0.95);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sheet-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.sheet-action:hover,
.sheet-action.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--accent-blue);
}

/* Help modal (F9) */
.help-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.shortcut-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shortcut-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.shortcut-list kbd {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  flex: 0 0 auto;
}

.chat-p2p-badge.relayed {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.nav-icon-btn.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: #818cf8;
  color: #c7d2fe;
}

.codec-selector-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.codec-dropdown {
  background: transparent;
  border: none;
  color: #93c5fd;
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.codec-dropdown option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-outline-sm {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-outline-sm:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.telemetry-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.telemetry-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
  }
/* Route badge: DIRECT vs RELAY network path, driven per-sample from the
   nominated ICE candidate pair (updateRouteBadge in app.js). */
  .route-badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
  }
  .route-badge.direct {
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.5);
  }
  .route-badge.relay {
    color: var(--accent-yellow);
    border-color: rgba(245, 158, 11, 0.6);
  }

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.health-dot.good {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.health-dot.fair {
  background: var(--accent-yellow);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

.health-dot.poor {
  background: var(--accent-red);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

/* Main Call Workspace */
.main-stage {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
}

.video-container {
  flex: 1;
  position: relative;
  background: #060911;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Remote Video (Primary Stage) */
.remote-video-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#primary-video,
#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), object-fit 0.2s ease;
}

#primary-video.flipped {
  transform: scaleX(-1);
}

#primary-video.screen-fit {
  object-fit: contain !important;
  background: #05070c;
}

.stage-flip-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 14;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, background 0.2s, transform 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.video-container:hover .stage-flip-btn {
  opacity: 1;
  pointer-events: auto;
}

.stage-flip-btn:hover {
  background: rgba(59, 130, 246, 0.85);
  border-color: #60a5fa;
  transform: scale(1.04);
}

.stage-flip-btn.active {
  background: rgba(59, 130, 246, 0.75);
  border-color: #93c5fd;
  color: #fff;
  opacity: 0.9;
  pointer-events: auto;
}

/* Empty Waiting State Placeholder */
.waiting-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(circle at center, rgba(17, 24, 39, 0.95), #060911);
  padding: 32px;
  text-align: center;
  z-index: 5;
}

.waiting-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  border: 1px dashed rgba(59, 130, 246, 0.4);
  animation: pulse 2.5s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 1; }
}

.waiting-title {
  font-size: 1.4rem;
  font-weight: 600;
}

.waiting-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 440px;
  line-height: 1.5;
}

.share-invite-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  margin-top: 8px;
}

.share-invite-box span {
  font-family: monospace;
  color: #93c5fd;
  font-size: 0.9rem;
}

.btn-primary-sm {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary-sm:hover {
  background: var(--accent-blue-hover);
}

/* Side Panel (Right Rail on Desktop / Bottom Chat on Mobile) */
.side-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  height: 100%;
}

.self-preview-dock {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

/* Local Video Picture-in-Picture & Dock */
.local-video-pip {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-sm);
  background: #0f172a;
  z-index: 10;
  transition: all 0.25s ease;
}

.local-video-pip:hover {
  transform: scale(1.02);
  border-color: var(--accent-blue);
}

#local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Default: Mirrored like a mirror */
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#local-video.unmirrored {
  transform: scaleX(1); /* Natural reality */
}

#local-video.hidden {
  display: none !important;
}

/* Side Dock Partner Video (YouTube Co-Watching Mode) */
.side-dock-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.side-dock-video.flipped {
  transform: scaleX(-1);
}

.side-dock-video.hidden {
  display: none !important;
}

/* Local Mini Preview Corner Thumbnail (Inside Dock during Co-Watch) */
.side-mini-self {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 76px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
  background: #090d16;
  z-index: 14;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.side-mini-self:hover {
  transform: scale(1.08);
  border-color: var(--accent-blue);
}

.side-mini-self.hidden {
  display: none !important;
}

#side-mini-self-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.side-mini-label {
  position: absolute;
  bottom: 2px;
  left: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
}

.pip-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  z-index: 12;
}

.pip-flip-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  z-index: 15;
  transition: all 0.2s ease;
}

.pip-exit-cowatch-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #dc2626;
  border: 1.5px solid #ef4444;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.pip-exit-cowatch-btn:hover {
  background: #b91c1c;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.pip-exit-cowatch-btn.hidden {
  display: none !important;
}

/* Corner Mini-Self Hide / Restore Buttons (YouTube Co-Watching) */
.side-mini-hide-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
  z-index: 15;
}

.side-mini-hide-btn:hover {
  background: #dc2626;
  border-color: #ef4444;
  transform: scale(1.1);
}

.side-mini-self.hidden-by-user {
  display: none !important;
}

.restore-self-pill {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #93c5fd;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 14;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.restore-self-pill:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: var(--accent-blue);
  color: #fff;
  transform: translateY(-1px);
}

.restore-self-pill.hidden {
  display: none !important;
}

/* Normal Mode Self-Preview Hide Button */
.pip-hide-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e5e7eb;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  z-index: 15;
  transition: all 0.15s ease;
}

.pip-hide-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.pip-hide-btn.active {
  background: rgba(59, 130, 246, 0.35);
  border-color: #60a5fa;
  color: #93c5fd;
}

.pip-hide-btn.hidden {
  display: none !important;
}

.self-hidden-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #090d16;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 11;
  text-align: center;
}

.self-hidden-placeholder.hidden {
  display: none !important;
}

.pip-flip-btn:hover {
  background: rgba(59, 130, 246, 0.85);
  border-color: #60a5fa;
  transform: scale(1.05);
}

.pip-flip-btn.active {
  background: rgba(59, 130, 246, 0.8);
  border-color: #93c5fd;
}

/* Chat Panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-panel.hidden {
  display: none;
}

/* View Switcher Bar (Appears when screen share is active) */
.view-switcher-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 15;
  transition: all 0.3s ease;
  max-width: 95vw;
}

.view-switcher-bar.hidden {
  display: none !important;
}

.view-switcher-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
}

.view-switcher-pill.hidden {
  display: none !important;
}

.switcher-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.switcher-label strong {
  color: var(--text-primary);
}

.switcher-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.switcher-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.switcher-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.switcher-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.switcher-btn.swap-accent {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
}

.switcher-btn.swap-accent:hover {
  background: rgba(139, 92, 246, 0.35);
}

.switcher-btn.pulse-accent {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
  color: #93c5fd;
  animation: float-pill-pulse 2.2s infinite ease-in-out;
}

@keyframes float-pill-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.35); }
  50% { box-shadow: 0 0 10px 2px rgba(59, 130, 246, 0.6); }
}

/* Presenter Mini-HUD (Document Picture-in-Picture Floating Window) */
.presenter-hud-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: #0b0f19;
  color: #f3f4f6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  box-sizing: border-box;
}

.presenter-hud-header {
  height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 23, 38, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.hud-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #ef4444;
}

.hud-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: timer-pulse 1.5s infinite;
}

.hud-timer {
  font-family: monospace;
  font-size: 0.8rem;
  color: #93c5fd;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.hud-close-btn {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.hud-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Partner Video in Floating HUD */
.presenter-partner-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  flex-shrink: 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.presenter-partner-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.presenter-partner-box video.flipped {
  transform: scaleX(-1);
}

.hud-partner-tag {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}

.hud-pip-flip-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e5e7eb;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
}

.hud-pip-flip-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Mini Chat in Floating HUD */
.presenter-chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: #0e1322;
}

.presenter-chat-header {
  padding: 4px 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  background: rgba(17, 23, 38, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-weight: 600;
  flex-shrink: 0;
}

.presenter-chat-messages {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.presenter-chat-messages .hud-msg {
  max-width: 90%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.3;
  word-break: break-word;
}

.presenter-chat-messages .hud-msg.local {
  align-self: flex-end;
  background: #1e3a8a;
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #fff;
}

.presenter-chat-messages .hud-msg.remote {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f3f4f6;
}

.presenter-chat-messages .hud-msg.system {
  align-self: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  color: #93c5fd;
  font-size: 0.72rem;
  text-align: center;
  padding: 4px 8px;
}

.presenter-chat-messages .hud-msg-sender {
  font-size: 0.65rem;
  font-weight: 600;
  margin-bottom: 2px;
  opacity: 0.75;
}

.presenter-chat-footer {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(17, 23, 38, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.presenter-chat-footer input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  outline: none;
}

.presenter-chat-footer input:focus {
  border-color: #3b82f6;
}

.presenter-chat-footer button {
  background: #3b82f6;
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

/* Presenter HUD Controls Footer */
.presenter-controls {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #080c14;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.presenter-controls .hud-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.presenter-controls .hud-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.presenter-controls .hud-btn.active-muted {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fca5a5;
}

.presenter-controls .hud-btn.danger-stop {
  background: #dc2626;
  border-color: #ef4444;
  color: #fff;
  flex: 1;
  justify-content: center;
}

.presenter-controls .hud-btn.danger-stop:hover {
  background: #b91c1c;
}

/* YouTube Synchronized Co-Watching Stage */
.youtube-stage-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  z-index: 15;
  overflow: hidden;
}

.youtube-stage-container.hidden {
  display: none !important;
}

.youtube-player-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.youtube-player-wrapper iframe,
.youtube-player-wrapper div#youtube-player-element {
  width: 100%;
  height: 100%;
  border: none;
}

.youtube-stage-bar {
  height: 44px;
  padding: 0 16px;
  background: rgba(11, 15, 25, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 30;
}

/* YouTube Co-Watching Dynamic Layout Switcher */
.youtube-layout-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 5px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.yt-layout-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.yt-layout-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.yt-layout-btn.active {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 1px 6px rgba(59, 130, 246, 0.4);
}

.yt-layout-btn.swap-accent {
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  margin-left: 2px;
  color: #c084fc;
}

.yt-layout-btn.swap-accent:hover {
  background: rgba(192, 132, 252, 0.18);
  color: #e9d5ff;
}

.btn-danger-sm {
  background: #dc2626;
  border: 1px solid #ef4444;
  color: #fff;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-danger-sm:hover {
  background: #b91c1c;
  border-color: #f87171;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.btn-danger-block {
  background: #dc2626;
  border: 1px solid #ef4444;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.btn-danger-block:hover {
  background: #b91c1c;
  border-color: #f87171;
}

.btn-danger-block.hidden {
  display: none !important;
}

.youtube-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.youtube-live-badge {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.youtube-video-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #f3f4f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.youtube-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.control-btn.youtube-toggle-btn {
  color: #ef4444;
}

.control-btn.youtube-toggle-btn:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

.control-btn.youtube-toggle-btn.active {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fff;
}

.quick-yt-btn {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #93c5fd;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-yt-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
  color: #fff;
}

/* YouTube Co-Watching Stage Layout Modes */

/* 1. Cinema Mode (Default: Full-Stage YouTube, Partner in Dock) */
.video-container.cowatch-cinema .youtube-stage-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 15;
}

/* 2. 50/50 Split Mode (Equal Side-by-Side YouTube & Partner Camera) */
.video-container.cowatch-split {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  justify-content: stretch !important;
}

.video-container.cowatch-split .remote-video-wrapper {
  position: relative !important;
  width: 50% !important;
  height: 100% !important;
  flex: 1 1 50% !important;
  min-width: 0 !important;
  z-index: 5;
}

.video-container.cowatch-split .youtube-stage-container {
  position: relative !important;
  width: 50% !important;
  height: 100% !important;
  flex: 1 1 50% !important;
  min-width: 0 !important;
  z-index: 5;
  border-left: 2px solid rgba(255, 255, 255, 0.15);
}

.video-container.cowatch-split.split-swapped {
  flex-direction: row-reverse !important;
}

.video-container.cowatch-split.split-swapped .youtube-stage-container {
  border-left: none !important;
  border-right: 2px solid rgba(255, 255, 255, 0.15);
}

/* 3. Partner Focus Mode (Partner Full Canvas, Floating YouTube Corner PiP) */
.video-container.cowatch-partner {
  position: relative;
}

.video-container.cowatch-partner .remote-video-wrapper {
  position: relative !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 5;
}

.video-container.cowatch-partner .youtube-stage-container {
  position: absolute !important;
  top: auto !important;
  left: auto !important;
  bottom: 24px !important;
  right: 24px !important;
  width: 380px !important;
  height: 236px !important;
  z-index: 25 !important;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.85), 0 0 0 1.5px rgba(255, 255, 255, 0.25);
  overflow: hidden;
  background: #000;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-container.cowatch-partner.split-swapped .youtube-stage-container {
  left: 24px !important;
  right: auto !important;
}

.video-container.cowatch-partner .youtube-stage-bar {
  height: 36px;
  padding: 0 8px;
}

.video-container.cowatch-partner .youtube-bar-left,
.video-container.cowatch-partner #youtube-change-video-btn {
  display: none !important;
}

.video-container.cowatch-partner .youtube-layout-pills {
  display: flex !important;
  padding: 2px 4px;
  gap: 2px;
}

.video-container.cowatch-partner .yt-layout-btn {
  padding: 2px 6px;
  font-size: 0.68rem;
  gap: 2px;
}

.video-container.cowatch-partner .btn-danger-sm {
  padding: 3px 8px;
  font-size: 0.72rem;
}

/* Interactive Remote Laser Pointer Guidance */
.pointer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.pointer-overlay.active {
  pointer-events: auto;
  cursor: crosshair;
}

.laser-pointer {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 12;
  transition: left 0.04s linear, top 0.04s linear, opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.laser-pointer.fading {
  opacity: 0;
}

.laser-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  position: relative;
}

.laser-pointer.remote .laser-dot {
  background: #ff2e63;
  box-shadow: 0 0 14px 4px rgba(255, 46, 99, 0.9), 0 0 28px 8px rgba(255, 46, 99, 0.4);
  animation: laser-throb 1.2s infinite ease-in-out;
}

.laser-pointer.local .laser-dot {
  background: #00fff5;
  box-shadow: 0 0 14px 4px rgba(0, 255, 245, 0.9), 0 0 28px 8px rgba(0, 255, 245, 0.4);
}

@keyframes laser-throb {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.laser-label {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.laser-pointer.remote .laser-label {
  background: rgba(255, 46, 99, 0.85);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.laser-pointer.local .laser-label {
  background: rgba(0, 255, 245, 0.85);
  color: #041017;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.laser-pulse-ring {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 11;
  animation: laser-ring-expand 0.85s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.laser-pulse-ring.remote {
  border: 3px solid #ff2e63;
  box-shadow: 0 0 12px rgba(255, 46, 99, 0.8);
}

.laser-pulse-ring.local {
  border: 3px solid #00fff5;
  box-shadow: 0 0 12px rgba(0, 255, 245, 0.8);
}

@keyframes laser-ring-expand {
  0% {
    width: 14px;
    height: 14px;
    opacity: 1;
  }
  100% {
    width: 72px;
    height: 72px;
    opacity: 0;
  }
}

.laser-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff2e63;
  box-shadow: 0 0 8px rgba(255, 46, 99, 0.8);
  display: inline-block;
  margin-right: 4px;
}

/* Tab/System Audio Volume Range Slider */
.screen-audio-range {
  -webkit-appearance: none;
  appearance: none;
  width: 85px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.25);
  outline: none;
  cursor: pointer;
}

.screen-audio-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent-blue);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.8);
  cursor: pointer;
  transition: transform 0.1s;
}

.screen-audio-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Bedside / Night Mode Overlay (OLED deep black for overnight calls) */
.bedside-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.5s ease;
}

.bedside-overlay.hidden {
  display: none !important;
}

.bedside-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 32px;
}

.bedside-icon {
  font-size: 2.5rem;
  opacity: 0.35;
  animation: bedside-glow 4s infinite ease-in-out;
}

@keyframes bedside-glow {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.05); }
}

.bedside-time {
  font-family: monospace;
  font-size: 3.5rem;
  font-weight: 300;
  color: #475569;
  letter-spacing: 2px;
}

.bedside-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: #64748b;
}

.bedside-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: pulse 3s infinite ease-in-out;
}

.bedside-hint {
  font-size: 0.8rem;
  color: #334155;
  margin-top: 12px;
  letter-spacing: 0.5px;
}

/* Secondary Video Tile (PiP when multi-stream / screen share is active) */
.secondary-video-pip {
  position: absolute;
  bottom: 24px;
  right: 256px;
  width: 220px;
  height: 140px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-lg);
  background: #0f172a;
  z-index: 12;
  cursor: pointer;
  transition: all 0.25s ease;
}

.secondary-video-pip.hidden {
  display: none;
}

.secondary-video-pip:hover {
  transform: scale(1.05);
  border-color: #8b5cf6;
}

#secondary-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.swap-pip-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
}

/* Low-Bandwidth Mode Badge */
.low-bandwidth-banner {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  display: none;
}

/* --- N7: Auto-rescue banner (audio-only / slideshow tier active) --- */
.rescue-banner {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(96, 165, 250, 0.5);
  color: var(--text-primary);
  padding: 8px 10px 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 16;
  box-shadow: var(--shadow-lg);
  max-width: calc(100% - 32px);
}

.rescue-banner-btn {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

/* AGENTS §14: interactive targets must not fall below the 44px floor on
   phones. The banner sits over the video, so grow the tap area vertically
   without letting it swallow the stage. */
@media (max-width: 768px) {
  .rescue-banner {
    bottom: 10px;
    left: 8px;
    right: 8px;
    transform: none;
    max-width: none;
    padding: 8px 10px;
    font-size: 0.76rem;
    gap: 8px;
    /* Stack the label above the action so the copy cannot be squeezed into
       one-word-per-line when the button takes its 44px share of the row. */
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    border-radius: var(--radius-md);
  }

  .rescue-banner > span {
    line-height: 1.3;
  }

  .rescue-banner-btn {
    min-height: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  .reconnect-card {
    padding: 16px 18px;
  }

  .media-error-actions .btn-primary-sm,
  .media-error-actions .btn-outline-sm {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
  }
}

.rescue-banner-btn:hover {
  background: var(--accent-blue-hover);
}

/* --- F8/N6: Reconnecting overlay (billing is paused while this is up) --- */
.reconnect-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 17, 0.72);
  backdrop-filter: blur(3px);
  z-index: 18;
}

.reconnect-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 26px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.reconnect-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(59, 130, 246, 0.25);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: reconnect-spin 0.9s linear infinite;
}

@keyframes reconnect-spin {
  to { transform: rotate(360deg); }
}

.reconnect-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.reconnect-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.reconnect-billing-note {
  margin-top: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* --- F10/I6: Media failure panel (typed, actionable) --- */
.media-error-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(circle at center, rgba(17, 24, 39, 0.97), #060911);
  padding: 28px;
  text-align: center;
  z-index: 19;
}

.media-error-icon {
  font-size: 2rem;
  line-height: 1;
}

.media-error-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.media-error-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 380px;
  line-height: 1.45;
}

.media-error-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.media-error-help {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  max-width: 420px;
  text-align: left;
  line-height: 1.5;
}

.media-error-help ol {
  margin: 6px 0 0 16px;
}

/* --- I6: Device picker --- */
.device-swap-status {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
}

.device-swap-status.is-error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* --- F8/N6: Connection doctor (inside #stats-drawer) --- */
.doctor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.doctor-toggle {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.doctor-toggle[aria-pressed="true"] {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.doctor-candidate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.doctor-candidate-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.doctor-col-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.doctor-candidate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-primary);
}

.doctor-chip {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-family: monospace;
}

.doctor-chip.host {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}

.doctor-chip.srflx {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
}

.doctor-chip.relay {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

.doctor-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.doctor-fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.doctor-fact strong {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: monospace;
}

.doctor-timeline summary {
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
}

.doctor-timeline ol {
  margin: 8px 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: monospace;
}

/* Floating Control Bar */
.bottom-control-bar {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  z-index: 20;
}

.control-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.control-btn.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--accent-blue);
  color: #60a5fa;
}

.control-btn.laser-active {
  background: rgba(0, 255, 245, 0.2);
  border-color: #00fff5;
  color: #00fff5;
  box-shadow: 0 0 14px rgba(0, 255, 245, 0.45);
}

.control-btn.muted {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--accent-red);
  color: #f87171;
}

.control-btn.danger {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}

.control-btn.danger:hover {
  background: #dc2626;
}

/* F1: the overflow trigger is mobile-only — desktop shows every control inline. */
.control-btn.more-controls-toggle {
  display: none;
}

.unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--accent-blue);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

/* Quality Profile Selector */
.quality-dropdown-wrapper {
  position: relative;
}

.quality-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quality-pill:hover {
  background: rgba(255, 255, 255, 0.15);
}

.quality-menu {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  width: 240px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 4px;
}

.quality-menu.show {
  display: flex;
}

.quality-option {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.15s;
}

.quality-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.quality-option.selected {
  background: rgba(59, 130, 246, 0.15);
  border-left: 3px solid var(--accent-blue);
}

.quality-name {
  font-weight: 600;
  color: var(--text-primary);
}

.quality-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Generic Side Drawer (Off-Canvas for Chat & Diagnostics) */
.side-drawer {
  width: 350px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 25;
  transition: width 0.3s ease;
}

.side-drawer.hidden {
  display: none;
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Space-Efficient Slim Header for In-Call Chat */
.chat-header-slim {
  padding: 6px 14px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(17, 23, 38, 0.5);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.chat-p2p-badge {
  font-size: 0.65rem;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.drawer-title {
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.close-drawer-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
}

.close-drawer-btn:hover {
  color: var(--text-primary);
}

.drawer-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Diagnostics Panel Styles */
.diagnostics-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diag-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.diag-health-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.diag-metric-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.metric-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: monospace;
}

.metric-value small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.diag-tier-badge {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--border-glow);
  color: #60a5fa;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}

.chat-messages {
  flex: 1;
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.35;
  word-break: break-word;
}

.local-bubble {
  align-self: flex-end;
  background: #1e3a8a;
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.remote-bubble {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border-bottom-left-radius: 3px;
}

.bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  font-size: 0.7rem;
  opacity: 0.75;
}

.bubble-sender {
  font-weight: 600;
}

.bubble-time {
  font-family: monospace;
  font-size: 0.68rem;
}

.chat-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: rgba(17, 23, 38, 0.75);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  outline: none;
  font-size: 0.85rem;
  transition: border-color 0.2s, background 0.2s;
}

#chat-input:focus {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#chat-send-btn {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}

#chat-send-btn:hover {
  background: var(--accent-blue-hover);
  transform: scale(1.05);
}

#chat-send-btn:active {
  transform: scale(0.95);
}

/* Reliable chat delivery state. Text communicates status without relying on
 * color alone, and the compact size keeps it clear of the message body. */
.bubble-delivery-status {
  margin-top: 4px;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.8;
}

.chat-bubble.delivery-sent .bubble-delivery-status {
  color: #86efac;
}

.chat-bubble.delivery-pending .bubble-delivery-status {
  color: #fde68a;
}

.chat-bubble.delivery-failed {
  border-color: rgba(248, 113, 113, 0.65);
}

.chat-bubble.delivery-failed .bubble-delivery-status {
  color: #fecaca;
}

/* Partner media state is repeated on every surface that can display the same
 * remote stream. Only the primary instance is a live region. */
.remote-media-badges {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 16;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

.remote-media-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.82);
  color: #cbd5e1;
  font-size: 0.68rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.remote-media-badge[data-active="true"] {
  border-color: rgba(52, 211, 153, 0.55);
  color: #a7f3d0;
}

.remote-media-badge[data-active="false"] {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.remote-media-badges.compact {
  top: 7px;
  left: 7px;
  gap: 4px;
}

.remote-media-badges.compact .remote-media-badge {
  min-height: 22px;
  padding: 2px 6px;
  font-size: 0.6rem;
}

.secondary-video-pip > .remote-media-badges {
  z-index: 14;
}

.local-video-pip > .remote-media-badges {
  display: none;
}

.local-video-pip > .side-dock-video:not(.hidden) + .remote-media-badges {
  display: flex;
}

/* A single polite live region for peer join and policy feedback. */
.app-toast-region {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 10000;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.app-toast {
  padding: 11px 15px;
  border: 1px solid rgba(96, 165, 250, 0.55);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.94);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(12px);
  animation: app-toast-enter 180ms ease-out;
}

@keyframes app-toast-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .app-toast { animation: none; }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-blue);
}

/* Free-only note in the create-room modal.
   Billing is deferred (F4), so there is no mode to choose. The `.mode-cards-grid`
   / `.mode-card` / `.price-inputs-row` rules were removed with the markup; they
   come back with the payments phase. */
.create-room-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0 0 14px;
}

.btn-primary-block {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  text-align: center;
}

.btn-primary-block:hover {
  opacity: 0.9;
}

/* Receipt Modal Styles */
.receipt-table {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Call Summary Modal.
   Billing is deferred (F4), so the table holds no charge rows — the summary is
   the call's duration. The `.receipt-row.total` rule previously rendered an
   accrued charge in green; the duration reads as the session's headline value
   instead. `.receipt-row` stays for the charge rows when the payments phase
   restores them. */
.call-summary-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Session Billing & Wallet Sub-Screen Modal */
.billing-modal-content {
  max-width: 440px;
}

.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.modal-title-with-icon svg {
  color: var(--accent-green);
}

.sub-screen-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.sub-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sub-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sub-status-pill {
  font-size: 0.72rem;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.sub-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sub-metric-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sub-metric-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sub-metric-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-metric-val.clock {
  font-family: monospace;
  color: #60a5fa;
}

.sub-metric-val.accrued {
  color: var(--accent-green);
}

.wallet-highlight {
  font-size: 1.25rem;
  font-weight: 700;
  color: #34d399;
  font-family: monospace;
}

.sub-card-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.topup-pill-row {
  display: flex;
  gap: 10px;
}

.topup-pill-btn {
  flex: 1;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topup-pill-btn:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.6);
  transform: translateY(-1px);
}

.sub-info-note {
  background: rgba(59, 130, 246, 0.06);
  border-left: 3px solid var(--accent-blue);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 16px;
}

.flash-green {
  animation: flash-green-anim 0.5s ease;
}

@keyframes flash-green-anim {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); color: #10b981; }
}

/* Responsive Form Factor Architecture: Desktop Side-Dock vs Mobile Stacked */

/* 1. DESKTOP VIEWPORT (Widescreen: Maximize Video Canvas, Dock Auxiliary UI to the Right) */
@media (min-width: 769px) {
  #app {
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-rows: auto 1fr 76px;
    grid-template-areas:
      "stage topnav"
      "stage sidepanel"
      "controls sidepanel";
    height: 100vh;
    width: 100vw;
    overflow: hidden;
  }

  .main-stage {
    grid-area: stage;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
  }

  /* Top Toolbar Row moved to the top of the right rail */
  .top-nav {
    grid-area: topnav;
    height: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    border-left: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    z-index: 20;
  }

  .top-nav .nav-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .top-nav .nav-row-secondary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }

  .top-nav .codec-selector-wrapper {
    flex: 1;
    justify-content: center;
  }

  .top-nav .telemetry-chip {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  /* Side Panel docked to the right */
  .side-panel {
    grid-area: sidepanel;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    height: 100%;
    overflow: hidden;
    position: relative;
  }

  .self-preview-dock {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
  }

  /* Self preview placed cleanly on the right, NOT on top of partner video */
  .self-preview-dock .local-video-pip {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    bottom: auto;
    right: auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-sm);
    background: #0f172a;
    transition: border-color 0.2s ease;
  }

  .chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  .bottom-control-bar {
    grid-area: controls;
    height: 76px;
    background: rgba(10, 13, 20, 0.95);
    border-top: 1px solid var(--border-color);
  }

  /* Secondary video PiP (when screensharing) sits in the bottom-right of the video stage */
  .secondary-video-pip {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 220px;
    height: 135px;
  }

  /* Stats & Billing drawers overlay the side panel on desktop */
  #stats-drawer,
  #billing-drawer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 30;
    background: var(--bg-secondary);
  }
}

/* 2. MOBILE VIEWPORT (Portrait: Video Pinned on Top, Chat Dedicated Underneath) */
@media (max-width: 768px) {
  #app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }

  /* Compact top bar */
  .top-nav {
    height: 46px;
    padding: 0 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 13, 20, 0.95);
    overflow: hidden;
  }

  .top-nav .nav-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }

  /* F2: row 2 holds Night / Codec / health on desktop; on mobile the compact
     cluster inside .nav-row-main takes over so those controls stay reachable. */
  .top-nav .nav-row-secondary {
    display: none;
  }

  .top-nav .nav-compact-secondary {
    display: flex;
  }

  /* F1: the prove was 8 buttons flex-shrinking to 23x38px on a 390px viewport.
     Low-frequency controls move to #more-controls-btn + the sheet below. */
  .bottom-control-bar .youtube-toggle-btn,
  .bottom-control-bar .quality-dropdown-wrapper,
  .bottom-control-bar #toggle-stats-btn,
  .bottom-control-bar #toggle-devices-btn {
    display: none;
  }

  .top-nav .nav-row-main {
    gap: 4px;
  }

  .top-nav .crypto-wallet-btn,
  .top-nav .nav-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    flex: 0 0 auto;
  }

  .top-nav .nav-icon-btn .nav-btn-text {
    display: none;
  }

  .top-nav .room-badge {
    padding: 2px 8px;
    font-size: 0.75rem;
  }

  .top-nav .room-badge-label {
    display: none;
  }

  .top-nav .call-timer-badge {
    padding: 3px 8px;
    font-size: 0.75rem;
  }

  .top-nav .wallet-pill-btn {
    padding: 3px 8px;
    font-size: 0.75rem;
  }

  /* Video Stage takes top 38% */
  .main-stage {
    flex-shrink: 0;
    height: 38vh;
    min-height: 200px;
    max-height: 42vh;
    position: relative;
    overflow: hidden;
    background: #000;
  }

  .video-container {
    height: 100%;
    width: 100%;
  }

  /* On mobile: Self Preview floats as a sleek mini PiP in the corner of the video */
  .self-preview-dock {
    display: contents;
  }

  .self-preview-dock .local-video-pip {
    position: fixed;
    top: 58px;
    right: 12px;
    width: 112px;
    height: 72px;
    border-radius: var(--radius-sm);
    z-index: 25;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
    touch-action: none;
  }

  .self-preview-dock .local-video-pip .pip-hide-btn,
  .self-preview-dock .local-video-pip .pip-flip-btn {
    padding: 10px 8px;
    font-size: 0.68rem;
    gap: 3px;
    min-height: 40px;
    min-width: 40px;
    justify-content: center;
  }

  /* Stage-level controls need thumbs too, not just hover targets. */
  .stage-flip-btn {
    min-height: 40px;
    padding: 10px 12px;
  }

  .placeholder-copy-btn,
  .btn-primary-sm {
    min-height: 40px;
    padding: 10px 14px;
  }

  /* During co-watch on mobile: move partner PiP to bottom-right of video stage so top bar is 100% visible */
  .self-preview-dock .local-video-pip.in-cowatch {
    top: auto;
    bottom: calc(100vh - 46px - 38vh + 8px);
    right: 10px;
    width: 100px;
    height: 64px;
    z-index: 25;
  }

  /* Compact floating restore pill on mobile when self-view is hidden */
  .self-preview-dock .local-video-pip.self-view-hidden {
    width: auto !important;
    height: 26px !important;
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: var(--radius-full) !important;
    padding: 0 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7) !important;
  }

  .self-preview-dock .local-video-pip.self-view-hidden #flip-self-btn,
  .self-preview-dock .local-video-pip.self-view-hidden #side-dock-label,
  .self-preview-dock .local-video-pip.self-view-hidden .self-hidden-placeholder {
    display: none !important;
  }

  .self-preview-dock .local-video-pip.self-view-hidden .pip-hide-btn {
    position: static !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-size: 0.72rem !important;
    color: #93c5fd !important;
  }

  /* YouTube Top Stage Bar on Mobile: compact and Left-Aligned Exit Button */
  .youtube-stage-bar {
    height: 38px;
    padding: 0 8px;
    gap: 6px;
  }

  .youtube-stage-bar .youtube-bar-right {
    order: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .youtube-stage-bar .youtube-bar-left {
    order: 2;
    flex: 1;
    min-width: 0;
    gap: 6px;
  }

  .youtube-live-badge {
    padding: 2px 6px;
    font-size: 0.65rem;
    gap: 4px;
  }

  .youtube-video-title {
    font-size: 0.72rem;
    max-width: 130px;
  }

  .btn-danger-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .btn-outline-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  /* YouTube Co-Watching Mobile Layout Switcher & Split/Partner Rules */
  .youtube-layout-pills {
    order: 3;
    padding: 2px 3px;
    gap: 2px;
  }

  .yt-layout-btn {
    padding: 3px 6px;
    font-size: 0.68rem;
    gap: 2px;
  }

  .video-container.cowatch-split {
    flex-direction: column !important;
  }

  .video-container.cowatch-split .remote-video-wrapper {
    width: 100% !important;
    height: 50% !important;
    flex: 1 1 50% !important;
  }

  .video-container.cowatch-split .youtube-stage-container {
    width: 100% !important;
    height: 50% !important;
    flex: 1 1 50% !important;
    border-left: none !important;
    border-top: 2px solid rgba(255, 255, 255, 0.15);
  }

  .video-container.cowatch-split.split-swapped {
    flex-direction: column-reverse !important;
  }

  .video-container.cowatch-split.split-swapped .youtube-stage-container {
    border-top: none !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  }

  .video-container.cowatch-partner .youtube-stage-container {
    top: auto !important;
    left: auto !important;
    bottom: 8px !important;
    right: 8px !important;
    width: 165px !important;
    height: 105px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.9) !important;
  }

  .video-container.cowatch-partner.split-swapped .youtube-stage-container {
    left: 8px !important;
    right: auto !important;
  }

  .video-container.cowatch-partner .youtube-stage-bar {
    height: 26px !important;
    padding: 0 4px !important;
  }

  .video-container.cowatch-partner .youtube-layout-pills,
  .video-container.cowatch-partner .youtube-video-title {
    display: none !important;
  }

  .video-container.cowatch-partner .btn-danger-sm {
    padding: 2px 6px !important;
    font-size: 0.65rem !important;
  }

  .secondary-video-pip {
    width: 105px;
    height: 68px;
    bottom: 10px;
    right: 10px;
    z-index: 24;
  }

  /* Call controls right below video */
  .bottom-control-bar {
    height: 52px;
    padding: 0 8px;
    gap: 8px;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 13, 20, 0.95);
  }

  .control-btn {
    /* F1: 44px minimum touch target; flex-shrink off so 23x38 ellipses cannot happen. */
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
  }

  .control-btn.more-controls-toggle {
    display: flex;
  }

  .bottom-control-bar {
    gap: 6px;
  }

  .more-controls-sheet:not(.hidden) {
    display: flex;
  }

  .quality-pill {
    height: 38px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  /* Chat is placed underneath the video and always visible! */
  .side-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    min-height: 0;
    border-left: none;
  }

  .chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  .chat-panel.hidden {
    display: flex !important; /* Always show chat underneath video on mobile */
  }

  .chat-panel .chat-header-slim {
    padding: 5px 12px;
    height: 26px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(17, 23, 38, 0.6);
  }

  .chat-messages {
    flex: 1;
    padding: 8px 12px;
    gap: 6px;
    overflow-y: auto;
  }

  .chat-bubble {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .chat-footer {
    padding: 8px 12px;
    background: var(--bg-secondary);
  }

  #chat-input {
    padding: 7px 12px;
    font-size: 0.82rem;
  }

  #chat-send-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
  }

  /* Stats & Billing drawers overlay screen on mobile */
  #stats-drawer,
  #billing-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    background: var(--bg-secondary);
  }
}

/* N14: Simple mode — Call / Hang up / Big-mic + chat only. Advanced controls *
 * hide; the simple-mode toggle, exit control, help and chat stay reachable. */
body.simple-mode .nav-row-secondary,
body.simple-mode #nav-compact-secondary,
body.simple-mode #more-controls-btn,
body.simple-mode #more-controls-sheet,
body.simple-mode #toggle-screen-btn,
body.simple-mode #toggle-youtube-btn,
body.simple-mode #toggle-laser-btn,
body.simple-mode #quality-pill-btn,
body.simple-mode #quality-menu,
body.simple-mode #sheet-devices-btn,
body.simple-mode #sheet-stats-btn,
body.simple-mode #stats-drawer,
body.simple-mode #open-presenter-hud-btn,
body.simple-mode #presenter-hud-pill,
body.simple-mode .view-switcher-bar,
body.simple-mode .youtube-stage-bar,
body.simple-mode #youtube-stage-container {
  display: none !important;
}
body.simple-mode #toggle-mic-btn,
body.simple-mode #toggle-camera-btn,
body.simple-mode #end-call-btn {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
}
