:root {
  --bg: #07080d;
  --surface: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --text: #f0f2f8;
  --muted: #8b93aa;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --accent-glow: rgba(124, 58, 237, 0.35);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 18px;
  --font: "Vazirmatn", "Inter", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ── Ambient ── */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.4;
}
.orb-1 { width: 600px; height: 600px; background: var(--accent); top: -250px; right: -150px; }
.orb-2 { width: 500px; height: 500px; background: var(--accent-2); bottom: -200px; left: -100px; }
.orb-3 { width: 300px; height: 300px; background: #ec4899; top: 40%; left: 30%; opacity: 0.15; }

/* ── Home ── */
.top-bar {
  position: relative; z-index: 2;
  max-width: 1100px; margin: 0 auto;
  padding: 28px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  color: white;
  box-shadow: 0 8px 32px var(--accent-glow);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand strong { display: block; font-size: 1.1rem; letter-spacing: 0.08em; }
.brand span { font-size: 0.75rem; color: var(--muted); }

.hero {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto;
  padding: 40px 24px 60px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 120px);
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 32px; min-height: auto; }
}

.badge {
  display: inline-block;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: #c4b5fd;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.78rem;
  margin-bottom: 16px;
}

.hero-text h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
}
.hero-text h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-text p { color: var(--muted); font-size: 1.05rem; max-width: 420px; }

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

.name-row { margin-bottom: 20px; }
.name-row label, .field label {
  display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.tabs {
  display: flex; gap: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  padding: 10px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.field { margin-bottom: 16px; }
.field-hint {
  display: block; margin-top: 6px;
  font-size: 0.78rem; color: var(--accent-2);
  font-family: var(--mono, monospace);
  direction: ltr; text-align: right;
  opacity: 0.85;
}

.toggle-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: all 0.2s;
}
.toggle small { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.toggle-icon { font-size: 1.3rem; display: block; margin-bottom: 4px; }
.toggle.active {
  border-color: var(--accent);
  background: rgba(124, 58, 237, 0.12);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.15);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px;
  font-family: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.2s;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: white;
  box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-lg { width: 100%; padding: 14px 24px; font-size: 1rem; margin-top: 8px; }
.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  font-size: 0.82rem;
}
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.error-msg {
  color: #fca5a5;
  font-size: 0.85rem;
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.footer {
  position: relative; z-index: 1;
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Room / Lobby ── */
.room-page { overflow: hidden; }

.lobby {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--bg);
  padding: 24px;
}
.lobby-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  max-width: 900px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  backdrop-filter: blur(20px);
}
@media (max-width: 700px) {
  .lobby-card { grid-template-columns: 1fr; }
}

.lobby-preview {
  aspect-ratio: 16/10;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}
.lobby-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}
.preview-placeholder span {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-size: 2rem; font-weight: 700;
}

.lobby-info h2 { font-size: 1.4rem; margin-bottom: 8px; }
.lobby-info > p { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.lobby-controls { display: flex; gap: 10px; margin-bottom: 20px; }
.lobby-controls .ctrl-btn {
  min-width: 56px; min-height: 56px;
  padding: 14px; flex-shrink: 0;
}
.lobby-controls .ctrl-btn svg { width: 24px; height: 24px; }

/* ── Meeting ── */
.meeting {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: #0a0b10;
  position: relative;
}

.room-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.room-info { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.live-dot {
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.room-info code {
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--accent-2);
}
.room-header-actions { display: flex; align-items: center; gap: 12px; }
.roster-bar { display: flex; gap: 6px; align-items: center; max-width: 280px; overflow-x: auto; }
.roster-avatar {
  position: relative;
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.roster-avatar.you { border-color: rgba(124,58,237,0.6); }
.roster-avatar.streaming { border-color: #e03e3e; box-shadow: 0 0 10px rgba(224,62,62,0.45); }
.roster-avatar.waiting { opacity: 0.55; }
.roster-live {
  position: absolute; top: -6px; right: -8px;
  background: #e03e3e; color: #fff;
  font-size: 0.45rem; font-weight: 800; font-style: normal;
  padding: 1px 4px; border-radius: 3px; letter-spacing: 0.04em;
}
.participant-count { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }

.filmstrip-scroll {
  flex-shrink: 0;
  padding: 10px 16px 100px;
  background: rgba(0,0,0,0.6);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
  min-height: 130px;
}
.video-tile.waiting { opacity: 0.85; }
.video-tile.waiting .conn-dot { background: #f0b232; }

/* ── Discord-style stage + filmstrip ── */
.meet-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #08090d;
}

.stage-main {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0e14;
  overflow: hidden;
}

.stage-empty {
  text-align: center;
  color: var(--text);
  padding: 28px 32px;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.stage-empty-icon { font-size: 2.4rem; opacity: 0.7; margin-bottom: 12px; }
.stage-empty p { font-size: 0.95rem; margin: 0; color: var(--muted); }

.stage-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
.stage-video.is-on {
  opacity: 1;
}

.stage-live-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #e03e3e;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 5;
  animation: livePulse 2s ease infinite;
  box-shadow: 0 0 20px rgba(224, 62, 62, 0.5);
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* ── Stream stats tags (FPS / Resolution) ── */
.stream-stats-tags {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.stream-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stat-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: "Inter", "Vazirmatn", monospace;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  backdrop-filter: blur(8px);
}
.stat-tag-fps { min-width: 58px; justify-content: center; }
.stat-tag-sm { font-size: 0.62rem; padding: 2px 7px; }
.stat-tag.stat-ok {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.2);
}
.stat-tag.stat-bad {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}
.stat-tag.stat-wait {
  border-color: rgba(250, 204, 21, 0.4);
  color: #fde68a;
}
.stream-stats-target {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 6px;
  max-width: 360px;
  line-height: 1.4;
}
.stream-stats-target.stat-match { color: #86efac; }
.stream-stats-target.stat-mismatch { color: #fca5a5; }

.tile-stat-tags {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.stage-presenter-label {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  z-index: 5;
}
.stage-screen-icon { font-size: 1rem; }

.stage-fs-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 6;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.15s;
}
.stage-fs-btn:hover { background: rgba(124,58,237,0.55); transform: scale(1.05); }
.stage-main:fullscreen { background: #000; }
.stage-main:fullscreen .stage-video { object-fit: contain; }

.video-tile.host-clickable,
.roster-avatar.clickable {
  cursor: pointer;
}
.video-tile.host-clickable:hover {
  box-shadow: 0 0 0 2px rgba(124,58,237,0.55);
  cursor: pointer;
}

.tile-host-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 8;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.video-tile.host-clickable:hover .tile-host-btn,
.tile-host-btn:focus {
  opacity: 1;
}
.tile-host-btn:hover {
  background: rgba(124,58,237,0.75);
}
.roster-avatar.clickable:hover {
  transform: translateY(-2px);
  border-color: rgba(124,58,237,0.7);
}

.host-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9998;
  min-width: 260px;
  background: #15161d;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.host-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
}
.host-menu-header button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.host-menu-btn {
  display: block;
  width: 100%;
  text-align: right;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.host-menu-btn:hover { background: rgba(124,58,237,0.15); }
.host-menu-btn.danger { color: #ff8a8a; border-color: rgba(255,80,80,0.35); }
.host-menu-btn.danger:hover { background: rgba(255,80,80,0.12); }

.filmstrip {
  display: flex;
  gap: 10px;
  min-height: 100px;
  align-items: stretch;
}

.filmstrip .video-tile {
  flex: 0 0 180px;
  width: 180px;
  aspect-ratio: 16/10;
  max-height: 110px;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.filmstrip .video-tile video { object-fit: cover; }
.filmstrip .video-tile.screen-share video { object-fit: cover; }
.filmstrip .video-tile:hover { transform: translateY(-2px); }
.filmstrip .video-tile.is-streaming {
  border: 2px solid #e03e3e;
  box-shadow: 0 0 16px rgba(224, 62, 62, 0.35);
}
.filmstrip .video-tile.speaking {
  border-color: #23a559 !important;
  box-shadow: 0 0 0 2px rgba(35, 165, 89, 0.5);
}

.live-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #e03e3e;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  z-index: 4;
  animation: livePulse 2s ease infinite;
}

.conn-dot {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  border: 2px solid rgba(0,0,0,0.5);
  z-index: 4;
}
.conn-dot.connected { background: #23a559; }
.conn-dot.connecting { background: #f0b232; animation: pulse 1s infinite; }
.conn-dot.reconnecting { background: #3b82f6; animation: pulse 0.8s infinite; }
.conn-dot.failed { background: #e03e3e; }
.video-tile.reconnecting { opacity: 0.72; }
.video-tile.reconnecting::after {
  content: "Reconnecting…";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: #93c5fd;
  background: rgba(7, 8, 13, 0.55);
  pointer-events: none;
}

.stream-type-icon { font-size: 0.75rem; opacity: 0.9; }

.video-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  overflow: hidden;
  align-content: center;
  justify-content: center;
}
.video-stage.layout-1 { grid-template-columns: 1fr; }
.video-stage.layout-2 { grid-template-columns: 1fr 1fr; }
.video-stage.layout-3, .video-stage.layout-4 { grid-template-columns: 1fr 1fr; }
.video-stage.layout-5, .video-stage.layout-6 { grid-template-columns: repeat(3, 1fr); }

/* Presenter spotlight layout */
.video-stage.has-presenter {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  grid-template-rows: minmax(320px, 1fr) auto;
  align-content: stretch;
  min-height: 0;
}
.video-stage.has-presenter .video-tile.presenting {
  grid-column: 1 / -1;
  grid-row: 1;
  aspect-ratio: unset;
  height: 100%;
  min-height: 320px;
  max-height: calc(100vh - 280px);
  border: 2px solid var(--accent-2);
  box-shadow: 0 0 40px rgba(6, 182, 212, 0.25);
}
.video-stage.has-presenter .video-tile.mini {
  grid-row: 2;
  aspect-ratio: 16/10;
  max-height: 130px;
  min-height: 80px;
}

.participants-bar {
  display: flex; gap: 8px; padding: 8px 16px; flex-wrap: wrap;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 44px;
  align-items: center;
}
.participant-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 12px 4px 6px;
  font-size: 0.78rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.participant-chip.speaking { border-color: #22c55e; box-shadow: 0 0 12px rgba(34,197,94,0.3); }
.participant-chip.presenting { border-color: var(--accent-2); background: rgba(6,182,212,0.1); }
.participant-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 700;
}
.settings-panel-compact { max-width: 420px; }
.settings-profile-row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-profile-fields { flex: 1; min-width: 0; }
.settings-profile-fields label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.settings-profile-fields input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-family: inherit;
  margin-bottom: 8px;
}
.settings-profile-fields .profile-avatar-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}
.settings-profile-row .profile-avatar-preview {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  margin: 0;
}
.settings-field { margin-bottom: 12px; }
.settings-field label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.settings-section h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}
.tile-avatar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.tile-avatar-img,
.no-video-placeholder .tile-avatar-img,
.preview-placeholder .tile-avatar-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
.no-video-placeholder .avatar-initial,
.preview-placeholder .avatar-initial {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(124,58,237,0.5), rgba(6,182,212,0.35));
}
.film-tile.local .tile-avatar-img,
.film-tile.local .avatar-initial { width: 48px; height: 48px; font-size: 1.1rem; }
.preview-placeholder .tile-avatar-img,
.preview-placeholder .avatar-initial { width: 80px; height: 80px; font-size: 1.8rem; }
.remote-audio-wrap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.participant-chip.you { border-color: rgba(124,58,237,0.4); }

.video-tile.speaking {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.45), 0 0 24px rgba(34, 197, 94, 0.2);
}
.video-tile.speaking .tile-label {
  border: 1px solid rgba(34, 197, 94, 0.5);
}

.share-badge {
  background: rgba(6, 182, 212, 0.25);
  border: 1px solid rgba(6, 182, 212, 0.5);
  color: #67e8f9;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.62rem;
  animation: sharePulse 2s infinite;
}
@keyframes sharePulse {
  50% { opacity: 0.7; }
}

.present-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(6,182,212,0.12), rgba(124,58,237,0.12));
  border-bottom: 1px solid rgba(6, 182, 212, 0.25);
  font-size: 0.88rem;
  color: #67e8f9;
  flex-shrink: 0;
}
.present-icon { font-size: 1.1rem; }

.toast-container {
  position: fixed; top: 70px; left: 20px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 320px;
}
.room-toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(15, 16, 24, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  backdrop-filter: blur(12px);
  transform: translateX(-120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.room-toast.show { transform: translateX(0); opacity: 1; }
.room-toast.toast-join { border-color: rgba(34, 197, 94, 0.4); }
.room-toast.toast-share { border-color: rgba(6, 182, 212, 0.5); }
.room-toast.toast-leave { border-color: rgba(239, 68, 68, 0.3); }
.toast-icon { font-size: 1.2rem; }

.video-tile {
  position: relative;
  background: #111;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16/9;
  min-height: 0;
  border: 1px solid var(--border);
  animation: tileIn 0.35s ease;
}
@keyframes tileIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.video-tile video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
.video-tile.local:not(.screen-share) video { transform: scaleX(-1); }
.video-tile.screen-share video,
.video-tile.local.screen-share video {
  transform: none !important;
  object-fit: contain !important;
  background: #0a0a0f;
}

.tile-label {
  position: absolute; bottom: 10px; left: 10px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  display: flex; align-items: center; gap: 6px;
}
.host-badge {
  background: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
}

.tile-status {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 4px;
}
.tile-status span {
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.75rem;
}

.no-video-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #1e1b4b, #0f172a);
}
.no-video-placeholder span {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 700;
}

/* ── Controls ── */
.control-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(24, 25, 32, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  z-index: 20;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.control-group { display: flex; gap: 8px; }

.ctrl-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  padding: 12px 18px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  transition: all 0.15s;
  min-width: 72px;
}
.ctrl-btn svg { width: 22px; height: 22px; }
.ctrl-btn:hover { background: rgba(255,255,255,0.1); }
.ctrl-btn.off {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.ctrl-btn.active-share {
  background: rgba(35, 165, 89, 0.25);
  border-color: #23a559;
  color: #57f287;
  box-shadow: 0 0 16px rgba(35, 165, 89, 0.3);
}
.ctrl-btn.leave {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  min-width: 80px;
}
.ctrl-btn.leave:hover { background: #dc2626; }

/* ── Chat ── */
.chat-panel {
  position: fixed;
  top: 56px; left: 0; bottom: 90px;
  width: 380px;
  background: linear-gradient(180deg, rgba(14,15,22,0.98) 0%, rgba(8,9,14,0.98) 100%);
  border-left: 1px solid rgba(124,58,237,0.15);
  display: flex; flex-direction: column;
  z-index: 20;
  backdrop-filter: blur(20px);
  box-shadow: 8px 0 40px rgba(0,0,0,0.35);
  transition: width 0.25s ease, left 0.25s ease, bottom 0.25s ease, top 0.25s ease;
}
.chat-panel.chat-fullscreen {
  top: 0; left: 0; bottom: 0; width: 100%;
  z-index: 50;
  border-left: none;
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(124,58,237,0.08);
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124,58,237,0.35), rgba(6,182,212,0.25));
  font-size: 1.1rem;
}
.chat-header-title strong { display: block; font-size: 0.95rem; }
.chat-header-title small { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.chat-header-actions { display: flex; gap: 6px; }
.chat-header-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s;
}
.chat-header-btn:hover { color: var(--text); background: rgba(124,58,237,0.2); }
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin;
}
.chat-empty {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  gap: 8px;
  min-height: 180px;
}
.chat-empty span { font-size: 2.5rem; opacity: 0.35; }
.chat-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 100%;
}
.chat-bubble-row.self {
  flex-direction: row-reverse;
}
.chat-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(124,58,237,0.35);
}
.chat-avatar-initial {
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}
.chat-bubble {
  max-width: calc(100% - 48px);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 12px;
}
.chat-bubble-row.self .chat-bubble {
  background: linear-gradient(135deg, rgba(124,58,237,0.22), rgba(6,182,212,0.12));
  border-color: rgba(124,58,237,0.25);
  border-radius: 14px 14px 4px 14px;
}
.chat-bubble-row.from-host .chat-bubble {
  border-color: rgba(224,62,62,0.25);
}
.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.chat-bubble-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-2);
}
.chat-bubble-row.self .chat-bubble-name { color: #c4b5fd; }
.chat-host-tag {
  font-style: normal;
  font-size: 0.62rem;
  background: rgba(224,62,62,0.2);
  color: #fca5a5;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 4px;
}
.chat-bubble-time {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}
.chat-bubble-text {
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
  color: var(--text);
}
.chat-blocked-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.12);
  border-top: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
  font-size: 0.82rem;
}
.chat-input-wrap {
  padding: 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
}
.chat-input {
  display: flex; gap: 10px;
  align-items: center;
}
.chat-input input {
  flex: 1;
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.chat-input input:focus { border-color: rgba(124,58,237,0.5); }
.chat-input input:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform 0.15s;
}
.chat-send-btn:hover { transform: scale(1.05); }
.chat-send-btn svg { width: 18px; height: 18px; }

@media (max-width: 600px) {
  .ctrl-btn span { display: none; }
  .ctrl-btn { min-width: 52px; padding: 12px; }
  .chat-panel { width: 100%; }
  .settings-panel { max-height: 90vh; }
}

/* ── Settings ── */
.settings-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.settings-overlay.hidden { display: none !important; }

.settings-panel {
  width: 100%; max-width: 460px;
  background: #12131a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: settingsIn 0.25s ease;
  margin: auto 0;
  flex-shrink: 0;
}
@keyframes settingsIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.settings-header h3 { font-size: 1.05rem; }
.settings-close {
  background: none; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
}
.settings-close:hover { color: var(--text); }
.settings-body {
  padding: 16px 20px 8px;
  display: flex; flex-direction: column; gap: 20px;
}
.settings-section h4 {
  font-size: 0.9rem; margin-bottom: 12px;
  color: var(--accent-2);
}
.settings-select {
  width: 100%;
  background: #1a1b24;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  margin-bottom: 12px;
  cursor: pointer;
  appearance: auto;
}
.settings-select option {
  background: #12131a;
  color: var(--text);
  padding: 8px;
}
.settings-select:focus { border-color: var(--accent); }
.settings-row {
  margin-bottom: 10px;
}
.settings-row label {
  display: block; font-size: 0.75rem;
  color: var(--muted); margin-bottom: 6px;
}
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 52px;
}
.chip:hover { border-color: rgba(124, 58, 237, 0.4); color: var(--text); }
.chip.active {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent);
  color: #c4b5fd;
}
.settings-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--muted);
  cursor: pointer; margin-top: 8px;
}
.settings-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.settings-note {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 4px 0 8px;
  padding: 8px 10px;
  background: rgba(124, 58, 237, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(124, 58, 237, 0.15);
}
.settings-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}
.settings-hint {
  font-size: 0.75rem; color: var(--muted);
  margin-bottom: 10px; min-height: 1em;
}
.settings-footer .btn { width: 100%; padding: 12px; }

/* ── Profile & Header ── */
.header-icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}
.header-icon-btn svg { width: 18px; height: 18px; }
.header-icon-btn:hover { color: var(--text); background: rgba(124,58,237,0.15); }

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  max-width: 160px;
}
.profile-chip:hover {
  border-color: rgba(124,58,237,0.45);
  background: rgba(124,58,237,0.1);
}
.profile-chip-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.profile-chip-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-initial {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  font-weight: 700;
  color: #fff;
}
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; }

.profile-section { text-align: center; }
.profile-avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.profile-avatar-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(124,58,237,0.4);
  box-shadow: 0 8px 32px var(--accent-glow);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}
.profile-avatar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.avatar-upload-label { cursor: pointer; }

.settings-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
}
.settings-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.settings-tab.active {
  background: rgba(124,58,237,0.12);
  color: #c4b5fd;
}
.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

.roster-avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.roster-avatar.muted-user { opacity: 0.75; }
.roster-muted {
  position: absolute;
  bottom: -4px; left: -4px;
  font-size: 0.55rem;
  font-style: normal;
}

.host-menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.host-menu-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.host-menu-status {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.ctrl-btn.host-locked {
  opacity: 0.65;
  box-shadow: 0 0 0 2px rgba(239,68,68,0.35);
}

.stage-fs-btn svg { width: 20px; height: 20px; }

.share-quality-bar {
  position: absolute;
  bottom: 16px;
  left: 16px;
  transform: none;
  z-index: 12;
  min-width: 260px;
  max-width: min(360px, calc(100% - 32px));
  background: rgba(10, 11, 18, 0.92);
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.04) inset;
  animation: shareBarIn 0.25s ease;
}
@keyframes shareBarIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.share-quality-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.88rem;
  font-weight: 600;
}
.share-quality-live {
  font-size: 0.75rem;
  color: #57f287;
  font-weight: 500;
  font-family: "Inter", monospace;
}
.share-quality-rows { display: flex; flex-direction: column; gap: 10px; }
.share-quality-row label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.live-share-chips .chip { min-width: 52px; padding: 6px 10px; font-size: 0.78rem; }

.room-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 700px) {
  .profile-chip-name { display: none; }
  .chat-panel { width: 100%; }
}

/* ── 60fps Capture (home) ── */
.capture-panel {
  position: relative;
  z-index: 1;
  padding: 48px 24px 64px;
  max-width: 960px;
  margin: 0 auto;
}
.capture-panel-inner h2 {
  font-size: 1.35rem;
  margin-bottom: 10px;
}
.capture-panel-inner > p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 24px;
}
.capture-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.capture-card {
  background: rgba(15, 15, 25, 0.72);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}
.capture-card-primary {
  border-color: rgba(124, 58, 237, 0.45);
  background: rgba(124, 58, 237, 0.1);
}
.capture-card h3 { font-size: 1rem; margin-bottom: 8px; }
.capture-card p, .capture-card li {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
}
.capture-card ol {
  margin: 10px 0 0;
  padding-right: 18px;
}
.capture-card code {
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
}
.capture-note { margin-top: 8px; }
.capture-api-link {
  margin-top: 20px;
  font-size: 0.78rem;
  color: var(--muted);
}
.capture-api-link a { color: #c4b5fd; }
.settings-note a { color: #c4b5fd; text-decoration: underline; }
