/* ==========================================================================
 * Voice Chat — dark ASCII-art aesthetic.
 * Background: blurred Sistine Adam in ASCII characters; glass-morphism
 * overlay UI; mono accents on technical numbers (room id, ping, kbps).
 * ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* Always-dark, monochrome ASCII-aesthetic palette */
  --bg-deep: #060608;
  --surface-glass:    rgba(14, 14, 16, 0.74);
  --surface-glass-2:  rgba(22, 22, 26, 0.88);
  --surface-glass-3:  rgba(30, 30, 34, 0.94);
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text:  #e6e6ea;
  --text2: #8d9097;
  --text3: #54575c;

  --accent:      #c8ccd4;         /* soft silver — fits the ASCII art */
  --accent-2:    #8a92a3;
  --accent-soft: rgba(200, 204, 212, 0.10);
  --green: #4ec47b;
  --red:   #e0584f;
  --amber: #d9a444;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --avatar-size: 36px;

  --shadow-1: 0 2px 10px rgba(0,0,0,0.4);
  --shadow-2: 0 14px 44px rgba(0,0,0,0.68);

  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html, body { height: 100%; height: 100dvh; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Looping ambient background video — slight blur, slight lift, then a
 * vignette overlay for legibility. The video element below is fixed, full
 * viewport, behind everything (z-index -3). */
.bg-video {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  object-fit: cover;
  z-index: -3;
  pointer-events: none;
  filter: blur(4px) brightness(0.62) saturate(0.6);
  transform: scale(1.06); /* hide blur edges */
}
/* JS-fallback colour while the video loads / on devices that block autoplay */
body { background: var(--bg-deep); }
body::after {
  content: '';
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.45) 70%, rgba(0,0,0,0.78) 100%),
    linear-gradient(180deg, rgba(6,6,8,0.40) 0%, rgba(6,6,8,0.18) 50%, rgba(6,6,8,0.40) 100%);
}
@media (prefers-reduced-motion: reduce) {
  .bg-video { display: none; }
}

.app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }

/* ==========================================================================
 *  Top bar
 * ========================================================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  flex-shrink: 0;
  z-index: 6;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-weight: 700; font-size: 15px; letter-spacing: -0.2px;
}
.brand svg { color: var(--accent); }
.top-bar-right { display: flex; align-items: center; gap: 8px; }
body[data-screen="chat"] .top-bar { display: none; }

/* ==========================================================================
 *  Buttons
 * ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  background: var(--surface-glass-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-glass-3); border-color: rgba(255,255,255,0.24); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, rgba(60,60,68,0.95) 0%, rgba(30,30,34,0.95) 100%);
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 4px 14px rgba(0,0,0,0.5);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(72,72,82,0.97) 0%, rgba(38,38,44,0.97) 100%);
  border-color: rgba(255,255,255,0.28);
}
.btn-secondary { background: var(--surface-glass-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.link-btn {
  background: none; border: none; color: var(--accent-2); cursor: pointer;
  padding: 0; font-size: inherit; text-decoration: underline; text-underline-offset: 2px;
}

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-glass-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; color: var(--text);
  transition: background 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { background: var(--surface-glass-3); border-color: rgba(255,255,255,0.24); }
.icon-btn svg { width: 16px; height: 16px; }

/* ==========================================================================
 *  Home screen
 * ========================================================================== */
.screen.home {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 24px;
  padding-bottom: env(safe-area-inset-bottom, 24px);
  overflow-y: auto;
}
.home-card {
  width: 100%; max-width: 420px;
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-2);
}
.home-logo { width: 40px; height: 40px; margin-bottom: 18px; color: var(--accent); }
.home-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.4px; }
.home-card > p { font-size: 14px; color: var(--text2); margin-bottom: 22px; }
.home-card .btn-primary { padding: 14px 18px; font-size: 15px; }
.home-join { margin-top: 22px; }
.home-auth { margin-top: 18px; font-size: 13px; color: var(--text3); text-align: center; }
.home-recent { margin-top: 24px; }
.home-recent h3 {
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text2);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.8px;
}
.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  background: var(--surface-glass-2); border: 1px solid var(--border);
  cursor: pointer; text-align: left; color: inherit;
  transition: background 120ms ease;
}
.recent-row:hover { background: var(--surface-glass-3); }
.recent-name { font-size: 14px; font-weight: 500; }
.recent-id { font-family: var(--mono); font-size: 12px; color: var(--text3); }

/* ==========================================================================
 *  Inputs
 * ========================================================================== */
.input-group { margin-bottom: 14px; }
.input-group label {
  display: block; font-family: var(--mono);
  font-size: 11px; font-weight: 700; color: var(--text2);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.8px;
}
.input-group label .hint {
  color: var(--text3); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', sans-serif;
}
.input-group input, .share-row input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.45); color: var(--text);
  font-size: 16px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.input-group input:focus { border-color: rgba(255,255,255,0.32); box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }
.input-group input::placeholder { color: var(--text3); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text2); margin-top: 6px; }
.checkbox-row input { width: 16px; height: 16px; }

/* ==========================================================================
 *  Avatar dropdown / top-bar avatar
 * ========================================================================== */
.avatar-dropdown { position: relative; }
.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface-glass-2); padding: 0; cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.avatar-btn:hover { border-color: rgba(255,255,255,0.32); }
.avatar-btn .user-avatar { width: 100%; height: 100%; border: none; }
.avatar-btn .user-avatar-img { width: 100%; height: 100%; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface-glass-3);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 6px; z-index: 100;
}
.dropdown-header {
  padding: 10px 12px; font-size: 13px; font-weight: 600;
  color: var(--text); border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; border: none; background: transparent;
  text-align: left; font-size: 13px; color: var(--text);
  cursor: pointer; border-radius: var(--radius-sm);
}
.dropdown-item:hover { background: rgba(255,255,255,0.06); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

/* ==========================================================================
 *  Modals
 * ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; padding-top: max(16px, env(safe-area-inset-top));
  animation: fade-in 120ms ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 440px;
  background: var(--surface-glass-3);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: pop-in 130ms cubic-bezier(0.16,1,0.3,1);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column;
}
@keyframes pop-in { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent; border: none; color: var(--text2); cursor: pointer;
  width: 32px; height: 32px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-actions {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0;
}
.modal-actions .btn { padding: 9px 16px; }
.modal-divider {
  display: flex; align-items: center; gap: 8px; margin: 14px 0;
  color: var(--text3); font-size: 12px; font-family: var(--mono);
}
.modal-divider::before, .modal-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.modal-foot { font-size: 13px; color: var(--text2); margin-top: 8px; text-align: center; }
.modal-lead { font-size: 14px; color: var(--text2); margin-bottom: 14px; line-height: 1.55; }
.google-btn-host { display: flex; justify-content: center; min-height: 40px; }
.google-btn-host:empty { display: none; }
.google-btn-host:empty + .modal-divider { display: none; }

/* Profile preview */
.profile-row { display: flex; gap: 14px; align-items: center; }
.profile-avatar { position: relative; cursor: pointer; border-radius: 50%; transition: outline-color 0.15s; outline: 2px solid transparent; }
.profile-avatar.drag { outline: 2px dashed var(--accent-2); }
.profile-avatar .user-avatar.big,
.profile-avatar .user-avatar-img.big { width: 64px; height: 64px; }
.profile-username { font-size: 16px; font-weight: 600; }
.profile-email { font-size: 13px; color: var(--text2); margin-top: 2px; }
.hint { font-size: 12px; color: var(--text3); }

.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.profile-actions .btn { padding: 8px 12px; font-size: 13px; }
.profile-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.profile-section h3 {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--text2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.8px;
}
.profile-section .btn-sm { padding: 7px 14px; }

/* Join Gate Tabs */
.gate-tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.gate-tab {
  flex: 1; padding: 9px 10px;
  background: var(--surface-glass-2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  font-size: 13px; color: var(--text2);
}
.gate-tab.active {
  background: var(--surface-glass-3);
  color: var(--text);
  border-color: rgba(255,255,255,0.28);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ==========================================================================
 *  Badges (host) — guest/hand-raise removed at the user's request
 * ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 6px;
  margin-left: 6px; vertical-align: middle;
  background: rgba(255,255,255,0.08); color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.badge svg { width: 11px; height: 11px; }
.badge-host { background: rgba(240,181,78,0.18); color: var(--amber); }
.badge-guest { background: rgba(255,255,255,0.06); color: var(--text2); }

/* ==========================================================================
 *  Chat (call) screen
 * ========================================================================== */
.screen.chat { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; }

.chat-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  z-index: 5;
}

.room-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); position: relative; flex-shrink: 0; }
.pulse-dot::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; background: var(--green); opacity: 0; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(0.8); opacity: 0; } 50% { transform: scale(1.3); opacity: 0.35; } }
.room-label { font-size: 15px; font-weight: 600; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-count { font-family: var(--mono); font-size: 13px; color: var(--text3); flex-shrink: 0; }

.ping-container {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 4px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-left: 4px;
}
#ping-graph { width: 100px; height: 24px; display: block; }
.ping { font-family: var(--mono); font-size: 11px; font-weight: 600; min-width: 36px; text-align: right; }
.ping-good { color: var(--green); }
.ping-mid  { color: var(--amber); }
.ping-bad  { color: var(--red); }

.leave-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-glass-2); color: var(--text2);
  font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.leave-btn:hover { border-color: var(--red); color: var(--red); background: rgba(239,93,93,0.08); }

/* split layout: media+users on the left, chat sidebar on the right */
.chat-main { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.chat-content { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.media-area {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px;
  padding: 6px;
  max-height: 50vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}
.video-tile {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  min-height: 120px;
  box-shadow: var(--shadow-1);
}
.video-tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-label {
  position: absolute; bottom: 8px; left: 10px;
  font-size: 11px; font-weight: 500; color: #fff;
  background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px;
  backdrop-filter: blur(4px);
}
.video-fullscreen {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  border-radius: 8px; border: none; background: rgba(0,0,0,0.55); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s, background 0.15s; backdrop-filter: blur(4px);
}
.video-fullscreen:hover { background: rgba(0,0,0,0.75); }
.video-tile:hover .video-fullscreen { opacity: 1; }
@media (hover: none) { .video-fullscreen { opacity: 0.85; } }

/* Custom fullscreen overlay (replaces browser fullscreen) */
.vc-fullscreen {
  position: fixed; inset: 0; z-index: 500;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  animation: fade-in 140ms ease-out;
}
.vc-fullscreen video {
  width: 100%; height: 100%; object-fit: contain; display: block;
  background: #000;
  pointer-events: none;          /* block built-in fullscreen affordances */
}
.vc-fullscreen .vcfs-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.12); color: #fff;
  border: 1px solid rgba(255,255,255,0.2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.vc-fullscreen .vcfs-close:hover { background: rgba(255,255,255,0.22); }
.vc-fullscreen .vcfs-label {
  position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); left: 16px;
  padding: 6px 12px; border-radius: 8px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 13px;
  backdrop-filter: blur(8px);
}

.users-area { flex: 1; overflow-y: auto; padding: 8px 14px; -webkit-overflow-scrolling: touch; min-height: 0; }
.user-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 3px;
  transition: background 0.12s;
}
.user-item:hover { background: rgba(255,255,255,0.04); }
.user-avatar {
  width: var(--avatar-size); height: var(--avatar-size); border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: 2px solid transparent; transition: border-color 0.2s, box-shadow 0.25s;
  overflow: hidden;
}
.user-avatar span { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent); }
.user-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.user-item.speaking .user-avatar { border-color: var(--green); box-shadow: 0 0 0 3px rgba(93,216,122,0.18); }
.user-item.speaking .user-avatar span { color: var(--green); }
.user-item.muted-user .user-avatar { opacity: 0.45; }
.user-item.muted-user .user-avatar span { color: var(--text3); }
.user-item.locally-muted { opacity: 0.6; }
.user-item.locally-muted .user-avatar { filter: grayscale(0.6); }

.user-details { flex: 1; min-width: 0; }
.user-details .name {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-details .tag { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 2px; transition: color 0.2s; letter-spacing: 0.4px; text-transform: uppercase; }
.user-item.speaking .tag { color: var(--green); }

/* Status row */
.status-text { text-align: center; font-family: var(--mono); font-size: 12px; color: var(--text3); padding: 4px 16px; min-height: 20px; }

/* Controls bar */
.controls-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 18px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  flex-shrink: 0; z-index: 5;
}
.ctrl-btn {
  width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-glass-2);
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s; -webkit-appearance: none; padding: 0;
  position: relative;
}
.ctrl-btn:hover { background: var(--surface-glass-3); border-color: rgba(255,255,255,0.24); }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn svg { width: 22px; height: 22px; }
.ctrl-btn.active {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.10);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.ctrl-btn#mute-btn.active    { background: rgba(224,88,79,0.18);  border-color: rgba(224,88,79,0.55);  color: var(--red); }
.ctrl-btn#denoise-btn.active { background: rgba(78,196,123,0.16); border-color: rgba(78,196,123,0.50); color: var(--green); }

/* Chat sidebar */
.chat-sidebar {
  width: 340px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}
.chat-side-head {
  padding: 12px 14px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble {
  max-width: 100%;
  padding: 6px 10px 8px;
  background: var(--surface-glass-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.chat-bubble.continued { margin-top: -4px; padding-top: 4px; }
.chat-bubble.own {
  background: var(--accent-soft); border-color: rgba(124,142,255,0.3);
  align-self: flex-end; max-width: 90%;
}
.chat-bubble-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.chat-avatar {
  width: 18px; height: 18px; border-radius: 50%; object-fit: cover;
  background: rgba(255,255,255,0.08);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--accent);
}
.chat-name { font-size: 12px; font-weight: 600; color: var(--text); }
.chat-time { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-left: auto; }
.chat-text { font-size: 14px; color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.chat-input-row {
  display: flex; gap: 6px; padding: 10px;
  border-top: 1px solid var(--border);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.chat-input-row input {
  flex: 1; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: rgba(0,0,0,0.35); color: var(--text);
  font-size: 14px; outline: none;
}
.chat-input-row input:focus { border-color: var(--accent-2); }

.slash-autocomplete {
  position: absolute; bottom: 100%; left: 10px; right: 10px;
  background: var(--surface-glass-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  margin-bottom: 4px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-2);
}
.slash-item {
  display: flex; flex-direction: column; padding: 8px 12px;
  cursor: pointer; border-radius: var(--radius-sm);
  color: var(--text);
}
.slash-item:hover, .slash-item.selected {
  background: rgba(255,255,255,0.06);
}
.slash-item .slash-cmd { font-size: 13px; font-weight: 600; color: var(--accent); }
.slash-item .slash-desc { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* Chat unread badge on the toggle button */
.chat-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700; line-height: 18px;
  text-align: center;
  border: 2px solid var(--bg-deep);
}
#chat-toggle-btn { position: relative; }

/* ==========================================================================
 *  Reactions
 * ========================================================================== */
.reactions-picker {
  position: fixed; z-index: 300;
  width: 260px; max-width: calc(100vw - 16px);
  background: var(--surface-glass-3);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  box-shadow: var(--shadow-2);
}
.reaction-cell {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; padding: 6px 0; border-radius: 6px;
}
.reaction-cell:hover { background: rgba(255,255,255,0.08); }
.reaction-bubble {
  position: fixed; pointer-events: none; z-index: 999;
  font-size: 28px; transform: translate(-50%, -50%);
  animation: floatUp 2.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  60%  { opacity: 1; transform: translate(-50%, -100%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(0.9); }
}

/* ==========================================================================
 *  Context menu (mute/volume/pin/host actions)
 * ========================================================================== */
.context-menu {
  position: fixed; z-index: 350;
  background: var(--surface-glass-3);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 6px;
  min-width: 240px;
  display: flex; flex-direction: column; gap: 2px;
}
.cm-row {
  display: flex; flex-direction: column; padding: 8px 12px 10px; gap: 6px;
}
.cm-row label {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px;
}
.cm-row label .cm-vol-val { color: var(--text); font-weight: 600; }
.cm-row input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.18); outline: none;
}
.cm-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.6);
}
.cm-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.6);
}
.cm-btn {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; padding: 8px 12px;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  color: var(--text); font-size: 13px;
}
.cm-btn:hover { background: rgba(255,255,255,0.06); }
.cm-btn svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.8; }
.cm-btn.danger { color: var(--red); }
.cm-btn.danger:hover { background: rgba(239,93,93,0.1); }
.cm-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ==========================================================================
 *  Pin layout
 * ========================================================================== */
body.has-pin .media-area { display: block; max-height: 70vh; padding: 6px; position: relative; }
.media-area .video-tile.pinned { display: block; aspect-ratio: auto; height: 100%; width: 100%; }
.media-area .video-tile.thumbnail {
  position: absolute; right: 12px; bottom: 12px;
  width: 160px; height: 90px; aspect-ratio: 16/9;
  z-index: 2; box-shadow: var(--shadow-2);
}
.media-area .video-tile.thumbnail + .video-tile.thumbnail { right: 184px; }

/* ==========================================================================
 *  Stats overlay (Ctrl+Shift+D)
 * ========================================================================== */
#stats-overlay {
  position: fixed; bottom: 16px; left: 16px; z-index: 999;
  background: rgba(0,0,0,0.8); color: #c8e1ff;
  border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--mono); font-size: 11px;
  max-width: 360px;
  backdrop-filter: blur(8px);
}
#stats-overlay .stats-head { font-weight: 700; color: #fff; margin-bottom: 4px; opacity: 0.7; }
#stats-overlay pre { white-space: pre-wrap; margin: 0; }

/* ==========================================================================
 *  Toasts
 * ========================================================================== */
.toast-container {
  position: fixed; top: max(56px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  padding: 8px 16px; border-radius: 16px; font-size: 12px; font-weight: 500;
  background: var(--surface-glass-3);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--border-strong);
  color: var(--text);
  opacity: 0; transform: translateY(-8px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1); pointer-events: auto;
  box-shadow: var(--shadow-1);
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-error { border-color: rgba(239,93,93,0.5); color: var(--red); }

/* ==========================================================================
 *  Share modal row
 * ========================================================================== */
.share-row { display: flex; gap: 8px; align-items: center; }
.share-row input { font-family: var(--mono); font-size: 13px; }

/* ==========================================================================
 *  Responsive — phones / tablets / desktop
 * ========================================================================== */
@media (max-width: 720px) {
  /* Sidebar overlays the call instead of pushing it */
  .chat-sidebar {
    position: absolute; top: 0; right: 0; bottom: 0; width: 100%;
    z-index: 10;
    border-left: none;
  }
  .room-label { max-width: 40vw; }
  .ping-container { display: none; } /* save space */
  .home-card { padding: 24px 18px; max-width: 100%; }
}
@media (max-width: 480px) {
  .controls-bar { gap: 8px; padding: 10px 12px; }
  .ctrl-btn { width: 46px; height: 46px; }
  .ctrl-btn svg { width: 20px; height: 20px; }
  .media-area { grid-template-columns: 1fr; }
  .top-bar { padding: 8px 12px; }
}
@media (max-height: 500px) {
  .media-area { max-height: 35vh; }
  .users-area { padding: 4px 8px; }
  .user-item { padding: 6px 10px; }
  :root { --avatar-size: 30px; }
  .controls-bar { padding: 8px; }
  .ctrl-btn { width: 42px; height: 42px; }
  .ctrl-btn svg { width: 18px; height: 18px; }
}
@media (min-width: 1400px) {
  .media-area { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 8px; padding: 8px; }
  .home-card { max-width: 460px; padding: 38px 32px; }
}

/* Single video tile fills the area */
.media-area:has(.video-tile:only-child) { max-height: 60vh; }
.media-area:has(.video-tile:only-child) .video-tile { aspect-ratio: auto; height: 100%; }
