/* ═══════════════════════════════════════════════════════════════════
   style.css — Omegle 2  |  Premium Dark UI System
   ─────────────────────────────────────────────────────────────────
   1.  Design Tokens
   2.  Base Reset
   3.  Auth Gate
   4.  App Layout
   5.  Header
   6.  Video Grid
   7.  Controls Dashboard
   8.  Buttons
   9.  Status Dot & Pill
   10. Keyframe Animations
   11. Responsive
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ──────────────────────────────────────────────── */
:root {
  /* ── Palette ── */
  --bg: #07090f;
  /* deepest background          */
  --surface-0: #0c0f1a;
  /* page canvas                 */
  --surface-1: #10141f;
  /* base cards                  */
  --surface-2: #161b2c;
  /* elevated panels             */
  --surface-3: #1d2338;
  /* inputs, pills               */
  --surface-4: #252c42;
  /* hovered surfaces            */

  --border: #252c44;
  --border-soft: #1e2438;
  --border-hover: #374060;
  --border-glow: rgba(91, 110, 245, 0.45);

  /* ── Text ── */
  --text-1: #eef0fa;
  /* headings, primary          */
  --text-2: #9aa3cc;
  /* body, secondary            */
  --text-3: #56617e;
  /* captions, placeholders     */
  --text-4: #363d5a;
  /* ultra-muted                */

  /* ── Brand accent (indigo) ── */
  --indigo: #5c6ff5;
  --indigo-light: #7b8cf7;
  --indigo-dim: rgba(92, 111, 245, 0.14);
  --indigo-glow: rgba(92, 111, 245, 0.38);

  /* ── Semantic colors ── */
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.14);
  --green-glow: rgba(16, 185, 129, 0.35);

  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.14);
  --amber-glow: rgba(245, 158, 11, 0.32);

  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.14);
  --red-glow: rgba(239, 68, 68, 0.30);

  /* ── Typography ── */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* ── Radius ── */
  --r-xs: 5px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;
  --r-pill: 9999px;

  /* ── Elevation shadows ── */
  --shadow-sm:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-md:
    0 4px 12px rgba(0, 0, 0, 0.55),
    0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-lg:
    0 12px 40px rgba(0, 0, 0, 0.65),
    0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-inset:
    inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* ── Motion ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --t-xs: 100ms var(--ease-std);
  --t-sm: 180ms var(--ease-std);
  --t-md: 260ms var(--ease-std);
  --t-lg: 400ms var(--ease-out);
}

/* ── 2. Base Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Ambient gradient — gives depth without distraction */
  background-image:
    radial-gradient(ellipse 70% 50% at 10% 30%,
      rgba(92, 111, 245, 0.07) 0%, transparent 65%),
    radial-gradient(ellipse 50% 40% at 90% 10%,
      rgba(16, 185, 129, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse 60% 60% at 50% 100%,
      rgba(92, 111, 245, 0.04) 0%, transparent 60%);
}

/* ── 3. Auth Gate ──────────────────────────────────────────────────── */

/* Full-screen overlay — JS sets display:'block' to show */
#gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  background-image: inherit;
  /* share body ambient gradient */
  /* centered layout achieved with inner card absolute positioning */
}

/* Glass-morphic centered card */
.gate-card {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: min(440px, calc(100vw - 36px));
  padding: 48px 40px 40px;
  text-align: center;

  background: var(--surface-2);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg), var(--shadow-inset);

  /* Gradient border via outline trick */
  outline: 1px solid var(--border);
}

/* Glowing top edge on the card */
.gate-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--r-2xl) + 1px);
  background: linear-gradient(145deg,
      rgba(92, 111, 245, 0.55) 0%,
      transparent 42%,
      rgba(16, 185, 129, 0.25) 100%);
  z-index: -1;
  pointer-events: none;
}

/* Logo mark in gate */
.gate-brand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 28px;
}

/* Anonymous person icon */
.gate-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  background: var(--indigo-dim);
  border: 1px solid rgba(92, 111, 245, 0.25);
  border-radius: var(--r-xl);
  color: var(--indigo-light);
}

.gate-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
  margin-bottom: 10px;
}

.gate-sub {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 32px;
  max-width: 320px;
  margin-inline: auto;
}

.gate-legal {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 20px;
  line-height: 1.55;
}

/* Subtle text-link below the legal copy — opens modal for preview/testing */
.gate-preview-btn {
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--text-3);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
  transition: color var(--t-sm);
}

.gate-preview-btn:hover {
  color: var(--indigo-light);
}

/* Google sign-in button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
  background: #ffffff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition:
    background var(--t-sm),
    box-shadow var(--t-sm),
    transform var(--t-sm);
}

.btn-google:hover {
  background: #f4f6ff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.btn-google:active {
  transform: scale(0.98) translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── 4. App Layout ─────────────────────────────────────────────────── */

/*
  JS sets #app to display:'flex' when the user is authenticated.
  We define the geometry here so it activates automatically.
*/
#app {
  /* display: flex — set by main.js */
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 18px 100px;
  width: 100%;
  gap: 18px;
}

/* ── 5. Header ─────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

/* Video camera icon next to brand name */
.brand-logo {
  display: flex;
  align-items: center;
  margin-right: 2px;
  color: var(--indigo-light);
  transform: translateY(2px);
  /* optical alignment */
}

.brand-wordmark {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-1);
}

.brand-accent {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--indigo-light);
}

.brand-tagline {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 400;
}

@media (max-width: 480px) {
  .brand-tagline {
    display: none;
  }
}

/* Account area (JS toggles display:'flex' when authed) */
.header-account {
  /* display: flex set by JS */
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.account-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 540px) {
  .account-email {
    display: none;
  }
}

/* ── 5.5 Matchmaking Filter Bar ────────────────────────────────────────── */
.lobby-filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 20px;
  background: rgba(15, 20, 32, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--r-md);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  max-height: 100px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.lobby-filter-bar.disabled {
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: -18px; /* Offset the app gap */
  border-width: 0;
  transform: translateY(-20px);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.filter-select, .filter-input {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-sm);
}

.filter-select:focus, .filter-input:focus, .filter-input-small:focus {
  border-color: var(--indigo);
}

.age-inputs-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-input-small {
  width: 44px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-1);
  padding: 4px;
  border-radius: 4px;
  text-align: center;
  font-size: 13px;
  -moz-appearance: textfield;
}

.filter-input-small::-webkit-outer-spin-button,
.filter-input-small::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dual-slider-container {
  position: relative;
  width: 140px;
  height: 24px;
  display: flex;
  align-items: center;
}

.dual-slider-container input[type="range"] {
  position: absolute;
  width: 100%;
  pointer-events: none;
  -webkit-appearance: none;
  background: transparent;
  z-index: 2;
  margin: 0;
  top: 50%;
  transform: translateY(-50%);
}

.dual-slider-container input[type="range"]::-webkit-slider-thumb {
  pointer-events: all;
  width: 16px;
  height: 16px;
  -webkit-appearance: none;
  background: var(--indigo);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.dual-slider-container input[type="range"]::-moz-range-thumb {
  pointer-events: all;
  width: 12px;
  height: 12px;
  background: var(--indigo);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.dual-slider-container .slider-track {
  position: absolute;
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  z-index: 1;
  top: 50%;
  transform: translateY(-50%);
}

.dual-slider-container .slider-track-fill {
  position: absolute;
  height: 4px;
  background: var(--indigo-light);
  border-radius: 2px;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
}

/* ── 6. Video Grid ─────────────────────────────────────────────────── */
.video-grid {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  width: 100%;
  position: relative;
  flex-grow: 1;
  min-height: 0;
  overflow: hidden;
  transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.video-grid.is-active {
  padding-right: 350px;
}

#local-card {
  flex: 1 1 0%;
  /* Absorb all shrinking space */
  min-width: 0;
  transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Individual video tile */
.vid-card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  height: 100%;
  /* aspect-ratio removed so they can stretch vertically */
  transition:
    border-color var(--t-md),
    box-shadow var(--t-md);
}

/* Glow border when a stream is active (remote card when connected) */
.vid-card:has(video:not([src=""])) {
  border-color: var(--border-hover);
}

/* Actual <video> element fills the tile */
.vid-card video {
  position: absolute;
  border-radius: inherit;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
  transform: scaleX(-1);
  /* Mirror both video feeds */
}

/* ── Camera-off local overlay ──
   Shown as a simple dark tile until JS sets srcObject.
   We can't detect srcObject via CSS, so we show it always and
   rely on the video element itself to cover it once streaming. */
.vid-pre-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface-1);
  border-radius: inherit;
  color: var(--text-4);
  pointer-events: none;
  /* Hidden once video is playing — the video covers this overlay */
}

.vid-pre-overlay span {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Remote placeholder overlay ──
   JS toggles display:'flex' / 'none' */
.vid-placeholder {
  /* display: flex  — set by main.js setState() */
  position: absolute;
  inset: 0;
  z-index: 2;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--surface-1);
  border-radius: inherit;
  transition: opacity var(--t-md);
}

/* Pulsing icon ring — visual cue when searching */
.placeholder-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-3);
}

/* Triggered by main.js adding class 'is-searching' via setState */
.vid-placeholder.is-searching .placeholder-icon {
  animation: icon-pulse 2s ease-in-out infinite;
  border-color: rgba(92, 111, 245, 0.3);
  color: var(--indigo-light);
}

.placeholder-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.01em;
}

/* Video tile label badge */
.vid-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 3;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 3px 10px 4px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── 7. Call Controls ──────────────────────────────────────────────── */
.controls-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 20, 32, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--r-xl);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: max-content;
  z-index: 100;
}

.status-section {
  flex-shrink: 0;
}

/* Status pill container */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}

/* Status label text */
.status-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Button row on the right */
.btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── 8. Buttons ────────────────────────────────────────────────────── */

/* Base */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  outline-offset: 3px;
  transition:
    color var(--t-sm),
    background var(--t-sm),
    border-color var(--t-sm),
    box-shadow var(--t-sm),
    transform var(--t-sm),
    opacity var(--t-sm);
}

.btn svg {
  flex-shrink: 0;
}

.btn:focus-visible {
  outline: 2px solid var(--indigo);
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Primary  — Indigo (Find Stranger) ── */
.btn-primary {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
  box-shadow: 0 2px 10px rgba(92, 111, 245, 0.30);
}

.btn-primary:hover:not(:disabled) {
  background: var(--indigo-light);
  border-color: var(--indigo-light);
  box-shadow:
    0 0 0 4px var(--indigo-dim),
    0 4px 18px var(--indigo-glow);
  transform: translateY(-2px);
}

/* ── Warning  — Amber (Next / Skip) ── */
.btn-warning {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.30);
}

.btn-warning:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.20);
  border-color: var(--amber);
  box-shadow:
    0 0 0 3px rgba(245, 158, 11, 0.10),
    0 4px 14px var(--amber-glow);
  transform: translateY(-2px);
}

/* ── Danger   — Red (Stop) ── */
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.28);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.20);
  border-color: var(--red);
  box-shadow:
    0 0 0 3px rgba(239, 68, 68, 0.10),
    0 4px 14px var(--red-glow);
  transform: translateY(-2px);
}

/* ── Secondary — Surface (Start camera) ── */
.btn-secondary {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-4);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* ── Ghost — Minimal (Sign out) ── */
.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border-color: var(--border);
  padding: 6px 12px;
  font-size: 13px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text-2);
}

/* ── Icon + text — compact header button variant ── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
}

/* ── 9. Status Dot ─────────────────────────────────────────────────── */

/* The dot element — JS sets class: 'dot' | 'dot on' | 'dot warn' | 'dot err' */
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-4);
  transition:
    background var(--t-md),
    box-shadow var(--t-md);
}

/* Connected — solid green with subtle halo */
.dot.on {
  background: var(--green);
  box-shadow:
    0 0 0 3px var(--green-dim),
    0 0 10px var(--green-glow);
}

/* Searching / Connecting — animated amber pulse */
.dot.warn {
  background: var(--amber);
  animation: dot-pulse 1.8s ease-in-out infinite;
}

/* Error — red */
.dot.err {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

/* ── 10. Keyframe Animations ───────────────────────────────────────── */

/* Pulsing ring on the status dot when searching */
@keyframes dot-pulse {

  0%,
  100% {
    box-shadow:
      0 0 0 0 rgba(245, 158, 11, 0.65),
      0 0 8px rgba(245, 158, 11, 0.35);
  }

  50% {
    box-shadow:
      0 0 0 7px rgba(245, 158, 11, 0),
      0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Pulsing icon in remote placeholder when searching */
@keyframes icon-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(92, 111, 245, 0.4);
    background: var(--surface-3);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(92, 111, 245, 0);
    background: rgba(92, 111, 245, 0.08);
  }
}

/* ── 10. Keyframe Animations ────────────────────────────────── */

/* Pulsing ring on the status dot when searching */
@keyframes dot-pulse {

  0%,
  100% {
    box-shadow:
      0 0 0 0 rgba(245, 158, 11, 0.65),
      0 0 8px rgba(245, 158, 11, 0.35);
  }

  50% {
    box-shadow:
      0 0 0 7px rgba(245, 158, 11, 0),
      0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Pulsing icon in remote placeholder when searching */
@keyframes icon-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(92, 111, 245, 0.4);
    background: var(--surface-3);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(92, 111, 245, 0);
    background: rgba(92, 111, 245, 0.08);
  }
}

/* Smooth fade-up entry for cards */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Profile modal sheet entrance */
@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(32px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Page-in animation for the app shell */
#app>* {
  animation: fade-up var(--t-lg) var(--ease-out) both;
}

#app>*:nth-child(1) {
  animation-delay: 0ms;
}

#app>*:nth-child(2) {
  animation-delay: 60ms;
}

#app>*:nth-child(3) {
  animation-delay: 120ms;
}

/* ── 12. Green Room Lobby ────────────────────────────────────── */

/* Full-viewport overlay */
#green-room-lobby {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: #090d16;
  /* Obscure underlying UI fully */
  /* Start invisible; JS adds .is-open to trigger transition */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  overflow: hidden;
}

#green-room-lobby.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Blurred dark background video ── */
#green-room-bg {
  position: absolute;
  inset: -10%;
  /* Oversize slightly to hide blurred edges */
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(20px) brightness(0.4);
  z-index: 0;
  pointer-events: none;
}

/* ── Glassmorphic card ── */
.green-room-card {
  position: relative;
  /* above background */
  z-index: 1;
  width: min(850px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  /* Contain scrollbar inside rounded corners */

  background: rgba(13, 16, 27, 0.65);
  /* Semi-transparent base */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-2xl);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);

  animation: sheet-up 360ms var(--ease-out) forwards;
  outline: none;
  display: flex;
  flex-direction: column;
}

/* Scrollable Inner Wrapper */
.gr-scroll-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 36px 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Header ── */
.gr-header {
  text-align: center;
}

.gr-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.gr-subtitle {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Body Grid ── */
.gr-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

@media (max-width: 768px) {
  .gr-body {
    grid-template-columns: 1fr;
  }
}

/* ── Hardware Section ── */
.gr-hardware {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gr-preview-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}

#green-room-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  /* mirror */
  display: block;
}

.gr-device-selects {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Profile Section ── */
.gr-profile {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Footer ── */
.gr-footer {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

/* ── Avatar section ── */
.prof-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

/* Clickable avatar ring */
.avatar-circle {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color var(--t-sm),
    box-shadow var(--t-sm);
}

.avatar-circle:hover {
  border-color: var(--indigo);
  box-shadow:
    0 0 0 4px var(--indigo-dim),
    0 0 18px var(--indigo-glow);
}

/* Default person icon inside the circle */
.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-4);
}

/* Uploaded photo preview */
.avatar-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Camera icon overlay — fades in on hover */
.avatar-camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity var(--t-sm);
  pointer-events: none;
  border-radius: 50%;
}

.avatar-circle:hover .avatar-camera-overlay {
  opacity: 1;
}

.avatar-hint {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ── Age + Gender row ── */
.prof-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.prof-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Full-width variant — spans both columns of .prof-row grid, or stands alone */
.prof-field--full {
  grid-column: 1 / -1;
  margin-bottom: 24px;
}

/* ── Pinned Selection Zone ── */
.selected-interests-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}

.selected-interests-zone:empty {
  display: none;
}

/* ── Accordion System ── */
.accordion-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accordion-item {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
}

.accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--t-sm), color var(--t-sm);
}

.accordion-header:hover {
  background: var(--surface-3);
  color: var(--text-1);
}

.accordion-chevron {
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.accordion-item.is-open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-item.is-open .accordion-header {
  background: var(--surface-3);
  color: var(--text-1);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.accordion-body-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-soft);
}

/* ── Section wrapper (activities, songs) ── */
.prof-section {
  margin-bottom: 24px;
}

/* ── Form labels ── */
.prof-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 8px;
}

.prof-label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  font-size: 11px;
}

/* ── Text / number inputs and select ── */
.prof-input {
  width: 100%;
  padding: 10px 13px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition:
    border-color var(--t-sm),
    box-shadow var(--t-sm),
    background var(--t-sm);
  /* Remove browser number spinners */
  -moz-appearance: textfield;
  appearance: textfield;
}

.prof-input::-webkit-inner-spin-button,
.prof-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.prof-input::placeholder {
  color: var(--text-4);
}

.prof-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-dim);
  background: var(--surface-4);
}

/* Select-specific overrides */
.prof-select {
  cursor: pointer;
  /* Custom dropdown arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3cc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  -webkit-appearance: none;
  appearance: none;
}

.prof-select option {
  background: var(--surface-2);
  color: var(--text-1);
}

/* ── Activity pills grid ── */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

/* Individual pill button */
.activity-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background var(--t-sm),
    border-color var(--t-sm),
    color var(--t-sm),
    box-shadow var(--t-sm),
    transform var(--t-sm);
}

.activity-pill:hover {
  background: var(--surface-4);
  border-color: var(--border-hover);
  color: var(--text-1);
  transform: translateY(-1px);
}

/* Selected state — indigo filled */
.activity-pill.active {
  background: var(--indigo-dim);
  border-color: var(--indigo);
  color: var(--indigo-light);
  box-shadow:
    0 0 0 3px var(--indigo-dim),
    0 0 12px var(--indigo-glow);
}

.activity-pill.active:hover {
  background: rgba(92, 111, 245, 0.22);
}

.pill-emoji {
  font-size: 15px;
  line-height: 1;
}

.pill-label {
  font-size: 13px;
}

/* ── Song search bar ── */

.song-tag-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition:
    border-color var(--t-sm),
    box-shadow var(--t-sm),
    background var(--t-sm);
}

.song-tag-box:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-dim);
  background: var(--surface-4);
}

/* Dim and lock when 5-song cap is reached */
.song-tag-box[data-full='true'] {
  opacity: 0.45;
  pointer-events: none;
}

/* Magnifier icon */
.song-search-icon {
  flex-shrink: 0;
  color: var(--text-3);
  transition: color var(--t-sm);
}

.song-tag-box:focus-within .song-search-icon {
  color: var(--indigo-light);
}

/* The text input inside the bar */
.song-tag-input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  caret-color: var(--indigo-light);
}

.song-tag-input::placeholder {
  color: var(--text-4);
}

/* ── Vertical selected track list ── */

.song-selected-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  /* min-height: 0 allows the list to shrink when empty */
}

/* Individual track row — Spotify-style card */
.song-row-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition:
    border-color var(--t-sm),
    background var(--t-sm);
  animation: fade-up 220ms var(--ease-out) both;
}

.song-row-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-3);
}

/* Track number badge */
.song-row-num {
  flex-shrink: 0;
  width: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-4);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Album art thumbnail */
.song-row-art {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--r-xs);
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
}

/* Track name + artist stack */
.song-row-info {
  flex: 1;
  min-width: 0;
}

.song-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.song-row-artist {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Trash/remove button */
.song-row-remove {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-4);
  cursor: pointer;
  transition:
    background var(--t-xs),
    border-color var(--t-xs),
    color var(--t-xs);
}

.song-row-remove:hover {
  background: var(--red-dim);
  border-color: rgba(239, 68, 68, 0.28);
  color: var(--red);
}

/* ── Counter line below the list ── */
.song-tag-counter {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  transition: color var(--t-sm);
}

/* Turn counter green when all 5 slots are filled */
.song-tag-counter.is-full {
  color: var(--green);
}

/* ── Autocomplete dropdown ── */

/* Positioning anchor for the floating panel */
.song-search-wrap {
  position: relative;
}

/* The floating results panel */
.song-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 600;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-md);
  box-shadow:
    var(--shadow-lg),
    0 0 0 1px rgba(92, 111, 245, 0.12);
  overflow: hidden;
  /* Entrance animation */
  animation: dropdown-drop 160ms var(--ease-out) both;
}

@keyframes dropdown-drop {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Each result row */
.song-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--t-xs);
  border-bottom: 1px solid var(--border-soft);
}

.song-dropdown-item:last-child {
  border-bottom: none;
}

.song-dropdown-item:hover {
  background: var(--surface-3);
}

.song-dropdown-item:active {
  background: var(--surface-4);
}

/* Album artwork thumbnail */
.song-dropdown-artwork {
  width: 38px;
  height: 38px;
  border-radius: var(--r-xs);
  flex-shrink: 0;
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
}

/* Text block */
.song-dropdown-info {
  flex: 1;
  min-width: 0;
}

.song-dropdown-track {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-dropdown-artist {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Loading / no-results message */
.song-dropdown-msg {
  padding: 14px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  font-style: italic;
}

/* ── Error banner ── */
.prof-error {
  margin-bottom: 16px;
  padding: 11px 14px;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--r-sm);
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
  animation: fade-up 200ms var(--ease-out) both;
}

/* ── Save button (full-width) ── */
.prof-save-btn {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 15px;
  margin-top: 4px;
  box-shadow: 0 4px 20px rgba(92, 111, 245, 0.35);
}

.prof-save-btn:hover:not(:disabled) {
  box-shadow:
    0 0 0 4px var(--indigo-dim),
    0 6px 24px var(--indigo-glow);
  transform: translateY(-2px);
}

/* ── Remote Column ─────────────────────────────────────────────────── */
.remote-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 calc((min(100vw, 1400px) - 50px) / 2);
  /* ALWAYS rigid 50%! */
  min-width: 0;
  transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ── Partner Profile Trigger & Expansion ─────────────────────────────── */
.partner-profile-container {
  position: absolute;
  bottom: 12px;
  right: 12px;
  transform: none !important;
  margin: 0 !important;
  z-index: 10;
}

.partner-profile-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--t-sm);
}

.partner-profile-btn:hover,
.partner-profile-btn:focus,
.partner-profile-btn:active {
  background: var(--surface-4);
  color: var(--text-1);
  transform: none !important;
}

.partner-profile-panel {
  flex-shrink: 0;
  width: 0px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm), var(--shadow-inset);

  /* Hidden by default (slide-out style) */
  opacity: 0;
  overflow: hidden;
  padding: 0;
  border-width: 0;
  transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);

  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  max-height: 100%;
  z-index: 20;
}

/* Show the panel when JS adds .is-active to the video-grid */
.video-grid.is-active .partner-profile-panel {
  width: 350px;
  opacity: 1;
  padding: 16px;
  padding-bottom: 90px;
  border-width: 1px;
  overflow-y: auto;
}

.partner-profile-panel::-webkit-scrollbar {
  width: 6px;
}

.partner-profile-panel::-webkit-scrollbar-track {
  background: transparent;
}

.partner-profile-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--r-pill);
}

.partner-profile-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.partner-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.partner-avatar-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.partner-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.partner-avatar-fallback {
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.partner-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.partner-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.partner-demographics {
  font-size: 13px;
  color: var(--text-3);
}

.partner-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.partner-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.partner-activity-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.partner-activity-grid .activity-pill {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--surface-3);
  border-color: transparent;
  cursor: default;
}

.partner-activity-grid .activity-pill:hover {
  transform: none;
  border-color: transparent;
}

.partner-song-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.partner-song-list .song-row-card {
  padding: 6px 10px 6px 6px;
  background: var(--surface-3);
}

.partner-song-list .song-row-remove {
  display: none !important;
}

/* Stranger Interests Tags */
.stranger-interests-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.stranger-interest-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ccc;
  font-weight: 500;
  white-space: nowrap;
}

.stranger-interest-pill.shared-interest {
  background: rgba(92, 111, 245, 0.25);
  border: 1px solid rgba(92, 111, 245, 0.8);
  color: #fff;
  box-shadow: 0 0 10px rgba(92, 111, 245, 0.4);
}

/* ── 11. Responsive ────────────────────────────────────────────────── */

/* Tablet — tighter padding */
@media (max-width: 768px) {
  #app {
    padding: 14px 14px 24px;
    gap: 14px;
  }

  .app-header {
    padding: 12px 16px;
  }

  .controls-card {
    padding: 12px 16px;
  }

  .gate-card {
    padding: 40px 28px 32px;
  }

  .profile-sheet {
    padding: 28px 24px 32px;
  }
}

/* Mobile — stack videos vertically */
@media (max-width: 580px) {
  .video-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .controls-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .status-section {
    text-align: center;
  }

  .status-pill {
    justify-content: center;
    width: 100%;
  }

  .status-text {
    max-width: unset;
  }

  .btn-row {
    justify-content: center;
  }

  .gate-card {
    padding: 36px 22px 28px;
  }

  /* Profile modal — stack age/gender vertically on mobile */
  .prof-row {
    grid-template-columns: 1fr;
  }

  .profile-sheet {
    padding: 24px 18px 28px;
  }

  .activity-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

/* Very small — even tighter */
@media (max-width: 380px) {
  .btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .btn-row {
    gap: 8px;
  }

  .activity-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Chat Interface ────────────────────────────────────────────── */

#chat-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  width: 320px;
  background: rgba(15, 20, 32, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding: 12px;
  transition: all var(--t-md);
}

#chat-messages {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  margin-bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--t-md);
}

#chat-container.active #chat-messages {
  max-height: 250px;
  opacity: 1;
  visibility: visible;
  margin-bottom: 12px;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--r-pill);
}

.chat-message {
  padding: 8px 12px;
  border-radius: 14px;
  max-width: 85%;
  font-size: 14px;
  word-wrap: break-word;
  color: #fff;
  line-height: 1.4;
}

.chat-message.me {
  align-self: flex-end;
  background: rgba(74, 222, 128, 0.25);
  border-bottom-right-radius: 4px;
}

.chat-message.stranger {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.15);
  border-bottom-left-radius: 4px;
}

#chat-input {
  width: 100%;
  height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--r-pill);
  color: #fff;
  padding: 0 16px;
  font-size: 14px;
  outline: none;
  transition: all var(--t-sm);
  box-sizing: border-box;
}

#chat-input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

#chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#chat-input.cooldown {
  opacity: 0.6;
}
/* -- Fullscreen Image Overlay -------------------------------------- */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fullscreen-overlay.active {
  opacity: 1;
}

.fullscreen-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

#fullscreen-image {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.fullscreen-overlay.active #fullscreen-image {
  transform: scale(1);
}


/* -- Friends UI -------------------------------------------------------- */

.friends-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 340px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

.friends-sidebar.open {
  transform: translateX(0);
}

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

.friends-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.friends-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.friend-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px;
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.friend-tab:hover {
  color: var(--text-1);
}

.friend-tab.active {
  color: var(--indigo-light);
  border-bottom-color: var(--indigo-light);
}

.badge {
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-pill);
}

.friends-view {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Friend Item Row */
.friend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--t-sm);
}

.friend-item:hover {
  background: var(--surface-4);
  transform: translateY(-2px);
}

.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-1);
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-status {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.friend-actions {
  display: flex;
  gap: 6px;
}

/* -- Messenger Window ------------------------------------------- */

.messenger-window {
  position: fixed;
  bottom: 20px;
  right: 80px;
  width: 320px;
  height: 400px;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-xl);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fade-up 0.3s ease-out;
}

.messenger-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}

.messenger-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messenger-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.messenger-details {
  display: flex;
  flex-direction: column;
}

.messenger-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

.messenger-status {
  font-size: 11px;
  color: var(--text-3);
}

.messenger-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.msg-received {
  align-self: flex-start;
  background: var(--surface-4);
  color: var(--text-1);
  border-bottom-left-radius: 4px;
}

.msg-sent {
  align-self: flex-end;
  background: var(--indigo);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.messenger-input-area {
  display: flex;
  padding: 12px;
  gap: 8px;
  background: var(--surface-3);
  border-top: 1px solid var(--border);
}

#messenger-input {
  flex: 1;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  color: var(--text-1);
  font-size: 14px;
}

#messenger-input:focus {
  outline: none;
  border-color: var(--indigo);
}

.messenger-send-btn {
  background: var(--indigo);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.messenger-send-btn:hover {
  transform: scale(1.1);
}

