/* ══════════════════════════════════════════════════════════════
   ANGOCHAT — Design System
   Light mode, true glassmorphism, tonal surfaces
   © 2026 Terabytus, LDA.
══════════════════════════════════════════════════════════════ */

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  /* Tipografia */
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font: var(--font-body);

  /* Paleta principal — roxo vibrante */
  --color-primary: #644AF1;
  --color-primary-light: #8A73F5;
  --color-primary-dark: #4B34D6;
  --color-secondary: #3DDC97;
  --color-accent: #FF8FA3;
  --color-warning: #F5C451;
  --color-danger: #FF6B6B;
  --color-error: #FF6B6B;
  --color-success: #3DDC97;

  /* Cores de fundo e superfície */
  --bg-base: #FAFAF9;
  --bg-surface: #F1EFFB;
  --color-bg: #FAFAF9;
  --color-bg-alt: #F1EFFB;
  --color-surface: #FFFFFF;
  --color-border: #E6E4F5;

  --bg-card: rgba(255,255,255,0.75);
  --bg-card-hover: rgba(255,255,255,0.92);
  --border: rgba(0,0,0,0.07);
  --border-active: rgba(0,0,0,0.14);
  --border-glass: rgba(255,255,255,0.7);

  /* Texto */
  --text-primary: #1E2129;
  --text-secondary: #767B8A;
  --text-muted: rgba(118,123,138,0.55);
  --color-text: #1E2129;
  --color-text-muted: #767B8A;

  /* Modos tonais */
  --video-h: 252;
  --voice-h: 272;
  --text-h: 158;

  --video: #644AF1;
  --video-dim: rgba(100,74,241,0.08);
  --video-glow: rgba(100,74,241,0.14);

  --voice: #8A73F5;
  --voice-dim: rgba(138,115,245,0.08);
  --voice-glow: rgba(138,115,245,0.14);

  --text-col: #3DDC97;
  --text-dim: rgba(61,220,151,0.08);
  --text-glow: rgba(61,220,151,0.14);

  /* Gradientes */
  --gradient-primary: linear-gradient(135deg, #644AF1 0%, #8A73F5 100%);
  --gradient-vivid: linear-gradient(135deg, #644AF1 0%, #FF8FA3 100%);
  --logo-gradient: linear-gradient(135deg, #644AF1, #8A73F5, #FF8FA3, #644AF1);

  /* Backgrounds */
  --media-bg: #f2f2f7;
  --video-bg: #e8e8ee;
  --grain-opacity: 0.06;
  --grain-blend: multiply;
  --home-bg-1: rgba(100,74,241,0.05);
  --home-bg-2: rgba(138,115,245,0.04);
  --home-bg-3: rgba(61,220,151,0.03);

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(30, 33, 41, 0.06);
  --shadow-md: 0 8px 24px rgba(100, 74, 241, 0.15);
  --shadow-lg: 0 16px 40px rgba(100, 74, 241, 0.2);

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Safe area insets */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);

  /* Dynamic viewport height */
  --dvh: 100dvh;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; border: none; background: none; font-family: var(--font-display); color: inherit; }
input  { font-family: inherit; color: inherit; }

/* ── Focus visible — keyboard accessibility ─────────── */
:focus-visible {
  outline: 2px solid var(--video);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Site Navigation ─────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: 52px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.site-nav.visible {
  opacity: 1;
  pointer-events: auto;
}
.site-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}
.site-nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-display);
}
.site-nav-logo .logo-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}
.site-nav-logo .logo-text {
  background: var(--logo-gradient);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-nav-links {
  display: flex;
  gap: 24px;
}
.site-nav-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
  padding: 4px 0;
  position: relative;
}
.site-nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--video);
  border-radius: 1px;
  transform: scaleX(0);
  transition: transform var(--transition);
}
.site-nav-links a:hover { color: var(--text-primary); }
.site-nav-links a:hover::after { transform: scaleX(1); }
.site-nav-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all var(--transition);
}
.site-nav-toggle:hover { background: rgba(255,255,255,0.85); color: var(--text-primary); }
.site-nav-toggle svg { width: 20px; height: 20px; }

/* ── Site Footer ──────────────────────────────────── */
.site-footer {
  margin-top: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-links {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
.footer-links a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  padding: 2px 0;
}
.footer-links a:hover { color: var(--text-secondary); text-decoration: underline; }
.footer-company {
  font-size: 11px;
  color: var(--text-muted);
}
.footer-company strong { color: var(--text-secondary); font-weight: 600; }

/* ── Content Pages ────────────────────────────────── */
.page {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-base);
}
.page-container {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 76px 20px 40px;
  min-height: 100%;
}
.page-card {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--video);
  font-family: var(--font-display);
  cursor: pointer;
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  align-self: flex-start;
  transition: all var(--transition-spring);
  margin-bottom: 4px;
  box-shadow:
    0 2px 0 0 rgba(0,0,0,0.06),
    0 2px 6px rgba(0,0,0,0.03),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
  position: relative;
}
.page-back:hover {
  background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #4230B0,
    0 4px 12px var(--video-glow);
  transform: translateY(-2px);
}
.page-back:active {
  background: linear-gradient(180deg, #5A3FE0 0%, #4B34D6 100%);
  box-shadow:
    0 1px 0 0 #4230B0,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}
.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: -4px;
  line-height: 1.5;
}
.page-section {
  margin-top: 8px;
}
.page-section h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.page-section p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.page-section ul {
  margin: 6px 0 6px 20px;
  list-style: none;
}
.page-section ul li {
  position: relative;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  padding-left: 18px;
  margin-bottom: 4px;
}
.page-section ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--video);
  opacity: 0.5;
}
.page-footer-text {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.page-footer-text strong { color: var(--text-secondary); font-weight: 600; }

/* ── Contact Form ─────────────────────────────────── */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.7);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--video);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}
.form-group textarea {
  resize: vertical;
  min-height: 100px;
}
.btn-contact-send {
  align-self: flex-start;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 28px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all var(--transition-spring);
  box-shadow:
    0 2px 0 0 #4230B0,
    0 4px 12px rgba(100,74,241,0.15);
}
.btn-contact-send:hover {
  background: linear-gradient(180deg, #9C7CFC 0%, #7454F1 100%);
  transform: translateY(-2px);
  box-shadow:
    0 4px 0 0 #4230B0,
    0 8px 20px rgba(100,74,241,0.25);
}
.btn-contact-send:active {
  background: linear-gradient(180deg, #644AF1 0%, #4B34D6 100%);
  box-shadow:
    0 1px 0 0 #4230B0,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}

/* ═══════════════════════════════════════════════════════════
   COMPONENTES — Classes utilitárias do novo design system
═══════════════════════════════════════════════════════════ */

/* ── Headings ────────────────────────────────────────── */
h1, h2, h3, .brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Botões base ─────────────────────────────────────── */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  padding: 14px 32px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}
.btn-secondary:hover {
  background: var(--bg-surface);
}
.btn-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  padding: 0;
  font-size: 20px;
}
.btn-icon:hover {
  background: var(--bg-surface);
}
.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-skip-cta {
  background: var(--gradient-vivid);
  color: white;
  font-size: 18px;
  padding: 16px 40px;
  box-shadow: var(--shadow-md);
}

/* ── Cards / Superfícies ─────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.video-box {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #16181D;
  position: relative;
  aspect-ratio: 16 / 9;
}
.video-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-online {
  background: rgba(61, 220, 151, 0.15);
  color: #1E9B67;
}
.badge-searching {
  background: rgba(100, 74, 241, 0.12);
  color: var(--color-primary);
}
.badge-searching::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* ── Chat bubbles ────────────────────────────────────── */
.chat-bubble {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  max-width: 75%;
  line-height: 1.4;
}
.chat-bubble.mine {
  background: var(--gradient-primary);
  color: white;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
.chat-bubble.theirs {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.chat-input {
  font-family: var(--font-body);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 12px 20px;
  font-size: 14px;
  width: 100%;
  transition: var(--transition);
}
.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ── Grain noise overlay (subtle texture, breaks digital flatness) ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  mix-blend-mode: var(--grain-blend);
}

/* ═══════════════════════════════════════════════════════════
   SCREEN HOME — Mode Selection
═══════════════════════════════════════════════════════════ */
#screen-home {
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
#screen-home::-webkit-scrollbar { width: 4px; }
#screen-home::-webkit-scrollbar-track { background: transparent; }
#screen-home::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Background — subtle radial mesh */
.home-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, var(--home-bg-1) 0%, transparent 65%),
    radial-gradient(ellipse 50% 60% at 80% 80%, var(--home-bg-2) 0%, transparent 65%),
    radial-gradient(ellipse 40% 40% at 50% 50%, var(--home-bg-3) 0%, transparent 55%);
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 76px 24px 40px;
  max-width: 900px;
  width: 100%;
  min-height: 100%;
  justify-content: center;
  flex-shrink: 0;
}

/* Logo */
.home-header { text-align: center; }
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo.small { font-size: 18px; }
.logo-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 12px hsl(48,100%,65%));
}
.logo.small .logo-icon {
  width: 24px;
  height: 24px;
}

/* ── Animated gradient text for logo ──────────── */
.logo-text {
  background: var(--logo-gradient);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 6s ease-in-out infinite;
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.tagline {
  margin-top: 14px;
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 300;
}

/* Mode cards */
.mode-label {
  text-align: center;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 500;
}
.mode-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 32px;
  width: 200px;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: transform var(--transition-spring), border-color var(--transition), background var(--transition), box-shadow 0.35s ease;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.7) inset,
    0 4px 16px rgba(0,0,0,0.05);
}
.mode-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.06) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.mode-card:hover::after {
  opacity: 1;
}
.mode-card:hover {
  transform: translateY(-6px) scale(1.01);
  background: rgba(255,255,255,0.85);
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.9) inset,
    0 0 20px var(--accent-glow),
    0 8px 28px rgba(0,0,0,0.08);
}
.mode-card:active {
  transform: translateY(-2px) scale(0.98);
  transition-duration: 0.1s;
}
.mode-card-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  border-radius: inherit;
}
.mode-card:hover .mode-card-glow { opacity: 1; }

/* Per-mode glow + border */
.mode-video { --accent: var(--video); --accent-dim: var(--video-dim); --accent-glow: var(--video-glow); }
.mode-voice { --accent: var(--voice); --accent-dim: var(--voice-dim); --accent-glow: var(--voice-glow); }
.mode-text  { --accent: var(--text-col); --accent-dim: var(--text-dim); --accent-glow: var(--text-glow); }

.mode-card:hover { border-color: var(--accent); }
.mode-card .mode-card-glow { background: radial-gradient(circle at 50% 100%, var(--accent-glow), transparent 70%); }

.mode-card-icon {
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: var(--accent-dim);
  color: var(--accent);
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  /* Subtle 3D base perspective */
  perspective: 300px;
  transform-style: preserve-3d;
}
.mode-card:hover .mode-card-icon {
  background: var(--accent-dim);
  box-shadow:
    0 0 24px var(--accent-glow),
    0 8px 28px rgba(0,0,0,0.08);
  transform: scale(1.08) rotateX(-3deg) rotateY(4deg);
}
.mode-card:active .mode-card-icon {
  transform: scale(0.96) rotateX(1deg) rotateY(-2deg);
}
.mode-card-icon svg { width: 28px; height: 28px; }

/* ── 3D Icon effects ──────────────────────────── */
.icon-3d {
  position: relative;
}
.icon-3d svg {
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.1));
  transition: filter var(--transition-spring), transform var(--transition-spring);
}
.mode-card:hover .icon-3d svg {
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.15));
  transform: translateZ(6px);
}

/* Floating animation for 3D icons (on home screen) */
#screen-home .mode-card-icon.icon-3d {
  animation: iconFloat 3s ease-in-out infinite;
}
#screen-home .mode-card:nth-child(1) .mode-card-icon.icon-3d { animation-delay: 0s; }
#screen-home .mode-card:nth-child(2) .mode-card-icon.icon-3d { animation-delay: 0.4s; }
#screen-home .mode-card:nth-child(3) .mode-card-icon.icon-3d { animation-delay: 0.8s; }

/* Reduce float on hover (user is interacting) */
#screen-home .mode-card:hover .mode-card-icon.icon-3d {
  animation: none;
}

@keyframes iconFloat {
  0%, 100% {
    transform: translateY(0px) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.02);
  }
}

/* Mode-specific 3D icon glow */
.mode-video .icon-3d svg { filter: drop-shadow(0 3px 6px rgba(100,74,241,0.2)); }
.mode-voice .icon-3d svg { filter: drop-shadow(0 3px 6px rgba(138,115,245,0.2)); }
.mode-text  .icon-3d svg { filter: drop-shadow(0 3px 6px rgba(61,220,151,0.2)); }
.mode-card.mode-video:hover .icon-3d svg { filter: drop-shadow(0 6px 16px rgba(100,74,241,0.3)); }
.mode-card.mode-voice:hover .icon-3d svg { filter: drop-shadow(0 6px 16px rgba(138,115,245,0.3)); }
.mode-card.mode-text:hover  .icon-3d svg { filter: drop-shadow(0 6px 16px rgba(61,220,151,0.3)); }

/* ── Responsive 3D icon adjustments ──────────── */
@media (max-width: 900px) {
  .mode-card-icon { border-radius: 14px; }
}
@media (max-width: 700px) {
  .icon-3d svg {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08)) !important;
  }
}

.mode-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.mode-card-content p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.mode-card-badge {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--video-glow);
  color: var(--video);
  border: 1px solid var(--video);
}

.disclaimer {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  max-width: 480px;
}

/* ── Online Counter ─────────────────────────────── */
.online-counter {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
  border: none;
  border-radius: var(--radius-md);
  animation: fadeIn 0.6s ease;
  box-shadow:
    0 2px 0 0 rgba(0,0,0,0.06),
    0 4px 16px rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
  position: relative;
}
.online-counter::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.5);
}
.online-counter-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(61,220,151,0.12) 0%, rgba(61,220,151,0.06) 100%);
  color: var(--success);
  flex-shrink: 0;
}
.online-counter-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.online-counter-number {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  font-family: var(--font-display);
}
.online-counter-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(61,220,151,0.5);
  animation: pulse-dot-online 2s ease-in-out infinite;
}
@keyframes pulse-dot-online {
  0%,100% { box-shadow: 0 0 0 0 rgba(61,220,151,0.4); transform: scale(1); }
  50%     { box-shadow: 0 0 0 5px rgba(61,220,151,0); transform: scale(1.15); }
}

/* ── Header Typing Indicator ─────────────────────────── */
.typing-header {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.typing-header.hidden { display: none; }
.typing-header-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: headerTypingBounce 1.2s ease-in-out infinite;
}
.typing-header-dot:nth-child(1) { animation-delay: 0s; }
.typing-header-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-header-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes headerTypingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%         { transform: translateY(-4px); opacity: 1; }
}
.typing-header-text {
  margin-left: 2px;
}

/* ── Session Timer ──────────────────────────────── */
.session-timer {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 500;
}
.session-timer.hidden { display: none; }
.session-timer-icon {
  opacity: 0.5;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .session-timer { font-size: 11px; }
  .session-timer-icon { width: 10px; height: 10px; }
}

/* ── Connection Quality ───────────────────────────── */
.conn-quality {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}
.conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.conn-dot.good { background: var(--success); box-shadow: 0 0 6px rgba(61,220,151,0.4); }
.conn-dot.fair { background: var(--warning); box-shadow: 0 0 6px rgba(245,196,81,0.4); }
.conn-dot.poor { background: var(--error); box-shadow: 0 0 6px rgba(255,107,107,0.4); }
.conn-dot.offline { background: var(--text-muted); }

/* ── Typing Indicator ──────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px 8px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  min-height: 28px;
}
.typing-indicator.hidden { display: none; }
.typing-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%         { transform: translateY(-5px); opacity: 1; }
}
.typing-text {
  margin-left: 6px;
  font-style: italic;
}

/* ── Emoji Bar ────────────────────────────────────── */
.emoji-bar {
  display: flex;
  gap: 2px;
  padding: 4px 2px;
  overflow-x: auto;
  flex-shrink: 0;
}
.emoji-bar::-webkit-scrollbar { display: none; }
.emoji-btn {
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
  cursor: pointer;
  background: transparent;
  border: none;
  flex-shrink: 0;
}
.emoji-btn:hover {
  background: var(--bg-card-hover);
  transform: scale(1.2);
}
.emoji-btn:active {
  transform: scale(0.9);
}

/* ── Message Timestamp ────────────────────────────── */
.message {
  position: relative;
}
.message-time {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  opacity: 0.6;
}
.message.me .message-time {
  text-align: right;
}

/* ── Report Button ────────────────────────────────── */
.btn-report {
  color: var(--text-secondary);
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
}
.btn-report:hover {
  background: linear-gradient(180deg, #FFFFFF 0%, #FFE8E8 100%);
  color: var(--error);
  box-shadow:
    0 4px 0 0 rgba(200,80,80,0.1),
    0 8px 24px rgba(255,107,107,0.08),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
}
.btn-report.active {
  background: linear-gradient(180deg, #FF8A8A 0%, #FF6B6B 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #CC4A4A,
    0 4px 12px rgba(255,107,107,0.2),
    inset 0 1px 0 0 rgba(255,255,255,0.2);
}
.btn-report.active::after {
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.12),
    inset 0 1px 0 0 rgba(255,255,255,0.1);
}
.btn-report.active:hover {
  background: linear-gradient(180deg, #FF9A9A 0%, #FF7A7A 100%);
}

/* ── Keyboard Shortcuts Help ──────────────────────── */
.shortcuts-help {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
  z-index: 200;
  animation: fadeIn 0.2s ease;
}
.shortcuts-help.hidden { display: none; }
.shortcuts-card {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  max-width: 360px;
  width: calc(100% - 32px);
  max-height: calc(var(--dvh, 100vh) - 64px);
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.shortcuts-card h3 {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--text-primary);
}

/* ── Keyboard shortcut hint on buttons ────────────── */
.btn-shortcut-hint {
  font-size: 9px;
  opacity: 0.5;
  margin-left: 2px;
  font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════
   SCREEN CHAT
═══════════════════════════════════════════════════════════ */
#screen-chat {
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

/* ── Chat Header ──────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--sat, 0px) + 0px) 20px 0;
  height: calc(56px + var(--sat, 0px));
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;
  flex-shrink: 0;
  z-index: 10;
}

.chat-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.waiting  { background: var(--warning); animation: pulse-dot 1.5s ease-in-out infinite; }
.status-dot.matched  { background: var(--success); }
.status-dot.disconnected { background: var(--error); }

@keyframes pulse-dot {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245,196,81,0.5); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 5px rgba(245,196,81,0); }
}

.chat-header-controls { display: flex; align-items: center; gap: 10px; }
.mode-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 20px;
}
.mode-badge.video { background: var(--video-dim); color: var(--video); border: 1px solid var(--video); }
.mode-badge.voice { background: var(--voice-dim); color: var(--voice); border: 1px solid var(--voice); }
.mode-badge.text  { background: var(--text-dim);  color: var(--text-col); border: 1px solid var(--text-col); }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
  border: none;
  color: var(--text-secondary);
  transition: all var(--transition-spring);
  box-shadow:
    0 2px 0 0 rgba(0,0,0,0.08),
    0 2px 6px rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
  position: relative;
}
.btn-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.5);
}
.btn-icon:hover { background: linear-gradient(180deg, #FFFFFF 0%, #EAEAF5 100%); color: var(--text-primary);
  box-shadow:
    0 3px 0 0 rgba(0,0,0,0.06),
    0 4px 12px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.btn-icon:active {
  box-shadow:
    0 1px 0 0 rgba(0,0,0,0.06),
    inset 0 2px 6px rgba(0,0,0,0.06);
  transform: translateY(1px) scale(0.95);
  transition-duration: 0.08s;
}
.btn-icon svg { width: 18px; height: 18px; }

/* ── Chat Main ────────────────────────────────────────────── */
.chat-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ── Media Panel ──────────────────────────────────────────── */
.media-panel {
  flex: 1;
  min-width: 0;
  position: relative;
  background: var(--media-bg);
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.02);
}

.hidden { display: none !important; }

/* Video area */
.video-area {
  position: relative;
  width: 100%; height: 100%;
  background: var(--media-bg);
}

.video-remote-wrapper {
  position: absolute;
  inset: 0;
  transition: box-shadow var(--transition-slow);
}
.video-remote-wrapper.connected {
  box-shadow: inset 0 0 40px rgba(100,74,241,0.06);
}
.video-remote-wrapper video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--video-bg);
}

.waiting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--media-bg);
  z-index: 2;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
  transition: opacity var(--transition-slow);
}
.waiting-overlay.hidden { opacity: 0; pointer-events: none; }

/* ── Logo Loader (replaces waiting-spinner) ────────── */
.logo-loader {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-loader-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 50%;
  z-index: 1;
  animation: logoPulse 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(100,74,241,0.25));
}
.logo-loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--video);
  border-right-color: var(--color-secondary);
  animation: logoSpin 0.9s linear infinite;
}
@keyframes logoSpin {
  to { transform: rotate(360deg); }
}
@keyframes logoPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

.remote-label, .local-label {
  position: absolute;
  bottom: 12px; left: 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  background: rgba(30,33,41,0.55);
  backdrop-filter: blur(12px);
  padding: 4px 12px;
  border-radius: 20px;
  z-index: 3;
  letter-spacing: 0.3px;
}

.video-local-wrapper {
  position: absolute;
  bottom: 16px; right: 16px;
  width: 160px; height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 4;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.video-local-wrapper.dragging {
  cursor: grabbing;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  border-color: var(--video);
}
.video-remote-wrapper.connected + .video-local-wrapper,
.video-local-wrapper.connected {
  border-color: var(--video);
  box-shadow: 0 4px 20px var(--video-glow);
}
.video-local-wrapper video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.local-label { position: static; /* override */ }
.video-local-wrapper .local-label {
  position: absolute;
  bottom: 6px; left: 8px;
  font-size: 11px;
}

/* Voice area */
.voice-area {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.voice-waiting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

.voice-connected {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.voice-avatars {
  display: flex;
  align-items: center;
  gap: 32px;
}
.voice-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.voice-avatar {
  position: relative;
  width: 100px; height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-secondary);
  transition: box-shadow 0.4s ease, border-color 0.4s ease, transform 0.3s ease;
  background: radial-gradient(circle at 30% 30%, rgba(138,115,245,0.06), rgba(255,255,255,0.7));
  border: 2px solid rgba(0,0,0,0.06);
}
.voice-avatar canvas {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.voice-avatar.speaking {
  box-shadow: 0 0 0 6px var(--voice-glow), 0 0 0 12px rgba(138,115,245,0.06);
  border-color: var(--voice);
  transform: scale(1.03);
}

/* ── Avatar pulse when waiting for connection ──── */
.voice-avatar.pulse-avatar {
  animation: avatarPulse 2s ease-in-out infinite;
}
@keyframes avatarPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(138,115,245,0.08); }
  50% { box-shadow: 0 0 0 12px rgba(138,115,245,0); }
}
.voice-avatar-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.voice-wave {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 40px;
}
.wave-bar {
  width: 5px;
  border-radius: 3px;
  background: linear-gradient(to top, var(--voice), hsl(270, 80%, 75%));
  animation: waveAnim 1.2s ease-in-out infinite;
  min-height: 6px;
}
.wave-bar:nth-child(1) { height: 18px; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 32px; animation-delay: 0.2s; }
.wave-bar:nth-child(3) { height: 24px; animation-delay: 0.4s; }
.wave-bar:nth-child(4) { height: 36px; animation-delay: 0.1s; }
.wave-bar:nth-child(5) { height: 20px; animation-delay: 0.3s; }
@keyframes waveAnim {
  0%,100% { transform: scaleY(0.5); opacity: 0.5; }
  50%      { transform: scaleY(1); opacity: 1; }
}

.voice-status-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Text area */
.text-area {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
}
.text-waiting-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 15px;
}
.text-connected-banner {
  padding: 16px 32px;
  background: rgba(61,220,151,0.06);
  border: 1px solid rgba(61,220,151,0.2);
  border-radius: var(--radius-xl);
  color: var(--text-col);
  font-weight: 700;
  font-size: 16px;
  animation: slideInBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 16px rgba(61,220,151,0.08);
  letter-spacing: 0.3px;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Stronger entrance (for match/reconnect) ──── */
@keyframes slideInBounce {
  0%   { opacity: 0; transform: translateY(-20px) scale(0.9); }
  60%  { opacity: 1; transform: translateY(3px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.match-banner {
  animation: slideInBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Remote disconnect fade-out ─────────── */
.remote-fade-out {
  opacity: 0 !important;
  transform: scale(0.95) !important;
  transition: opacity 0.4s ease, transform 0.4s ease !important;
}

/* ── Ripple effect on buttons ─────────────────── */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

.btn-control, .btn-icon, .btn-send, .mode-card, .emoji-btn {
  position: relative;
  overflow: hidden;
}

/* ── Chat Panel ───────────────────────────────────────────── */
.chat-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  background: rgba(241,239,251,0.88);
  border-left: 2px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
  box-shadow:
    -8px 0 40px rgba(0,0,0,0.06),
    -1px 0 0 rgba(255,255,255,0.6) inset;
  position: relative;
  z-index: 2;
}

/* ── Aria live region for screen readers ──────────── */
[aria-live="polite"] {
  position: relative;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.messages-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: msgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered message animation */
.message:nth-child(2) { animation-delay: 0.05s; }
.message:nth-child(3) { animation-delay: 0.1s; }
.message:nth-child(4) { animation-delay: 0.15s; }
.message:nth-child(5) { animation-delay: 0.2s; }

.message.me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--msg-gradient-from), var(--msg-gradient-to));
  border: 1px solid var(--msg-border);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}
.message.partner {
  align-self: flex-start;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(0,0,0,0.04);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.system-message {
  align-self: center;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 7px 16px;
  background: rgba(255,255,255,0.5);
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.04);
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

/* Match banner — special system message for match/reconnect */
.system-message.match-banner {
  background: rgba(100,74,241,0.06);
  border-color: rgba(100,74,241,0.15);
  color: var(--video);
  font-weight: 600;
  padding: 10px 20px;
  font-size: 13px;
  animation: slideInBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 12px rgba(100,74,241,0.08);
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.5);
  box-shadow: 0 -1px 0 rgba(255,255,255,0.8) inset;
}

/* Input row: text field + send button */
.chat-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

#chat-input {
  flex: 1;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
#chat-input:focus { border-color: rgba(0,0,0,0.15); }
#chat-input::placeholder { color: var(--text-muted); }

.btn-send, .btn-image {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
  border: none;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-spring);
  flex-shrink: 0;
  box-shadow:
    0 2px 0 0 rgba(0,0,0,0.08),
    0 2px 6px rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
  position: relative;
}
.btn-send::after, .btn-image::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.5);
}
.btn-send svg { width: 18px; height: 18px; }
.btn-send:hover {
  background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #4230B0,
    0 4px 12px var(--video-glow);
  transform: translateY(-2px);
}
.btn-send:active {
  background: linear-gradient(180deg, #5A3FE0 0%, #4B34D6 100%);
  box-shadow:
    0 1px 0 0 #4230B0,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}
.btn-image svg { width: 18px; height: 18px; }
.btn-image:hover {
  background: linear-gradient(180deg, #6EEAB0 0%, #3DC484 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #2B9B68,
    0 4px 12px var(--text-glow);
  transform: translateY(-2px);
}
.btn-image:active {
  background: linear-gradient(180deg, #3DC484 0%, #2DB87A 100%);
  box-shadow:
    0 1px 0 0 #2B9B68,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}
.btn-image:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Image messages ──────────────────────────────── */
.message.image-message {
  padding: 4px;
  max-width: 75%;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
}
.message.image-message.me {
  align-self: flex-end;
  background: transparent;
  border: none;
}
.message.image-message img {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.message.image-message img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Image loading placeholder */
.image-loading {
  width: 120px;
  height: 90px;
  background: rgba(255,255,255,0.5);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.image-loading::after {
  content: '';
  width: 8px; height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: imgLoadDot 0.8s ease-in-out infinite;
}
.image-loading::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: imgLoadDot 0.8s ease-in-out infinite 0.15s;
}
.image-loading span {
  width: 8px; height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  display: block;
  animation: imgLoadDot 0.8s ease-in-out infinite 0.3s;
}
@keyframes imgLoadDot {
  0%,100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1.2); }
}

/* Expanded image overlay (fullscreen) */
.image-expanded {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}
.image-expanded img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Chat Footer ──────────────────────────────────────────── */
.chat-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  padding-bottom: calc(12px + var(--sab, 0px));
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 0 rgba(255,255,255,0.8) inset;
  flex-shrink: 0;
}

.btn-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  border: none;
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
  color: var(--text-secondary);
  box-shadow:
    0 2px 0 0 rgba(0,0,0,0.08),
    0 4px 12px rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
  transition: all var(--transition-spring);
  position: relative;
}
.btn-control::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.04),
    inset 0 1px 0 0 rgba(255,255,255,0.5);
}
.btn-control svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-control:hover {
  transform: translateY(-3px);
  box-shadow:
    0 4px 0 0 rgba(0,0,0,0.06),
    0 8px 24px rgba(0,0,0,0.08),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
}
.btn-control:active {
  transform: translateY(1px) scale(0.97);
  box-shadow:
    0 1px 0 0 rgba(0,0,0,0.06),
    inset 0 2px 6px rgba(0,0,0,0.06),
    inset 0 1px 0 0 rgba(255,255,255,0.4);
  transition-duration: 0.08s;
}

.btn-skip {
  background: linear-gradient(180deg, #7C5CFC 0%, #5A3FE0 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #4230B0,
    0 6px 20px rgba(100,74,241,0.2),
    inset 0 1px 0 0 rgba(255,255,255,0.25);
}
.btn-skip::after {
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.12),
    inset 0 1px 0 0 rgba(255,255,255,0.15);
}
.btn-skip:hover {
  background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
  box-shadow:
    0 5px 0 0 #4230B0,
    0 10px 28px rgba(100,74,241,0.25),
    inset 0 1px 0 0 rgba(255,255,255,0.3);
  transform: translateY(-3px);
}
.btn-skip:active {
  background: linear-gradient(180deg, #5A3FE0 0%, #4B34D6 100%);
  box-shadow:
    0 1px 0 0 #4230B0,
    inset 0 2px 6px rgba(0,0,0,0.15),
    inset 0 1px 0 0 rgba(255,255,255,0.1);
  transform: translateY(1px) scale(0.97);
}

.btn-mute {
  color: var(--text-secondary);
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
}
.btn-mute:hover { background: linear-gradient(180deg, #FFFFFF 0%, #EAEAF5 100%); color: var(--text-primary); }
.btn-mute.active {
  background: linear-gradient(180deg, #FF8A8A 0%, #FF6B6B 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #CC4A4A,
    0 4px 12px rgba(255,107,107,0.2),
    inset 0 1px 0 0 rgba(255,255,255,0.2);
}
.btn-mute.active::after {
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.12),
    inset 0 1px 0 0 rgba(255,255,255,0.1);
}
.btn-mute.active:hover {
  background: linear-gradient(180deg, #FF9A9A 0%, #FF7A7A 100%);
}

.btn-cam {
  color: var(--text-secondary);
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
}
.btn-cam:hover { background: linear-gradient(180deg, #FFFFFF 0%, #EAEAF5 100%); color: var(--text-primary); }
.btn-cam.active {
  background: linear-gradient(180deg, #FF8A8A 0%, #FF6B6B 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #CC4A4A,
    0 4px 12px rgba(255,107,107,0.2),
    inset 0 1px 0 0 rgba(255,255,255,0.2);
}
.btn-cam.active::after {
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.12),
    inset 0 1px 0 0 rgba(255,255,255,0.1);
}
.btn-cam.active:hover {
  background: linear-gradient(180deg, #FF9A9A 0%, #FF7A7A 100%);
}

.btn-stop {
  background: linear-gradient(180deg, #FF7A7A 0%, #E85050 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #B33A3A,
    0 6px 20px rgba(255,107,107,0.2),
    inset 0 1px 0 0 rgba(255,255,255,0.25);
}
.btn-stop::after {
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.12),
    inset 0 1px 0 0 rgba(255,255,255,0.15);
}
.btn-stop:hover {
  background: linear-gradient(180deg, #FF8A8A 0%, #F06060 100%);
  box-shadow:
    0 5px 0 0 #B33A3A,
    0 10px 28px rgba(255,107,107,0.25),
    inset 0 1px 0 0 rgba(255,255,255,0.3);
  transform: translateY(-3px);
}
.btn-stop:active {
  background: linear-gradient(180deg, #E85050 0%, #D04040 100%);
  box-shadow:
    0 1px 0 0 #B33A3A,
    inset 0 2px 6px rgba(0,0,0,0.15),
    inset 0 1px 0 0 rgba(255,255,255,0.1);
  transform: translateY(1px) scale(0.97);
}

/* ── Match Effect ──────────────────────────────────────────── */
.match-effect {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: matchFadeIn 0.3s ease;
}
.match-effect.hidden { display: none; }
@keyframes matchFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.match-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 48px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(245,245,250,0.95) 100%);
  border: 1px solid rgba(100,74,241,0.15);
  border-radius: var(--radius-xl);
  box-shadow:
    0 0 40px rgba(100,74,241,0.2),
    0 16px 48px rgba(0,0,0,0.1),
    inset 0 1px 0 0 rgba(255,255,255,0.9);
  animation: matchCardPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.match-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(100,74,241,0.06) 0%, transparent 60%);
  pointer-events: none;
}
@keyframes matchCardPop {
  0%   { opacity: 0; transform: scale(0.7) translateY(20px); }
  60%  { opacity: 1; transform: scale(1.05) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.match-icon {
  font-size: 56px;
  line-height: 1;
  animation: matchIconBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}
@keyframes matchIconBounce {
  0%   { transform: scale(0) rotate(-15deg); }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.match-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  animation: matchTitleReveal 0.4s ease 0.3s both;
}
@keyframes matchTitleReveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.match-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  animation: matchTitleReveal 0.4s ease 0.45s both;
}

/* ── Confetti pieces ─────────────────────────────── */
.match-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  --c1: var(--video);
  --c2: var(--color-secondary);
  --c3: var(--color-accent);
  --c4: var(--color-warning);
}
.match-confetti i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  animation: confettiPiece 2s ease-out forwards;
}
@keyframes confettiPiece {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translateY(calc(100vh + 20px)) rotate(calc(var(--r, 1) * 360deg)) scale(0.4); opacity: 0; }
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(88px + var(--sab, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius);
  padding: 14px 22px;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: 0 8px 28px rgba(0,0,0,0.08), 0 0 0 1px rgba(255,255,255,0.8) inset;
  z-index: 100;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── Toast progress bar ─────────────────────────── */
.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: var(--video);
  border-radius: 0 0 var(--radius) var(--radius);
  animation: toastProgress 3s linear forwards;
}
@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ── Status transitions ─────────────────────────── */
.status-dot {
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

#status-text {
  transition: color 0.3s ease;
}
.status-dot.matched ~ #status-text {
  color: var(--success);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Multi-device support
═══════════════════════════════════════════════════════════ */

/* ── Mobile nav toggle (hidden on desktop) ───────── */
.site-nav-links.mobile-open { display: flex; }
.site-nav-toggle.active {
  background: var(--video-dim);
  color: var(--video);
  border-color: var(--video);
}

/* ── Desktop: chat panel sempre à direita ──────────── */
.chat-panel-mobile-header { display: none; }
#btn-chat-toggle { display: none; }

/* Split layout separator — subtle vertical line between panels */
.chat-main::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  right: 320px;
  width: 1px;
  background: linear-gradient(to bottom, transparent 5%, rgba(0,0,0,0.06) 30%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.06) 70%, transparent 95%);
  z-index: 1;
  pointer-events: none;
}

/* ── Desktop L (1200-1400px) ──────────────────────── */
@media (max-width: 1400px) {
  .chat-panel { width: 290px; }
  .chat-main::after { right: 290px; }
  .home-content { gap: 36px; }
  .mode-card { width: 180px; padding: 28px 24px; }
}

/* ── Desktop S / Tablet paisagem (900-1200px) ────── */
@media (max-width: 1200px) {
  .chat-panel { width: 270px; }
  .chat-main::after { right: 270px; }
  .home-content { gap: 32px; padding: 20px; }
  .mode-card { width: 170px; padding: 24px 20px; gap: 12px; }
  .mode-card-icon { width: 56px; height: 56px; }
  .mode-card-icon svg { width: 26px; height: 26px; }
  .mode-card-title { font-size: 18px; }

}

/* ── Tablet retrato (700-900px) ───────────────────── */
@media (max-width: 900px) {
  .chat-panel { width: 260px; }
  .chat-main::after { right: 260px; }
  .btn-control span { font-size: 13px; }
  .btn-control { padding: 9px 16px; }
  .home-content { gap: 28px; }
  .mode-card { width: 160px; padding: 22px 18px; gap: 10px; }
  .mode-card-icon { width: 48px; height: 48px; border-radius: 14px; }
  .mode-card-icon svg { width: 22px; height: 22px; }
  .mode-card-title { font-size: 16px; }
  .video-local-wrapper { width: 130px; height: 98px; }
  .voice-avatar { width: 80px; height: 80px; }
  .voice-avatars { gap: 24px; }
  .online-counter { padding: 10px 16px; gap: 10px; }
  .online-counter-icon { width: 30px; height: 30px; }
  .online-counter-icon svg { width: 15px; height: 15px; }
  .online-counter-number { font-size: 15px; }
  .online-counter-label { font-size: 10px; }
}

/* ── Mobile: empilhamento vertical ────────────────── */
@media (max-width: 700px) {

  html, body {
    /* Prevent mobile browser UI from resizing */
    height: -webkit-fill-available;
  }

  .chat-main {
    flex-direction: column;
    position: relative;
  }

  /* Hide the split separator on mobile */
  .chat-main::after { display: none; }

  /* Site nav mobile: hamburger visible, links as dropdown */
  .site-nav-toggle { display: flex; }
  .site-nav-links {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  }
  .site-nav-links.mobile-open { display: flex; }
  .site-nav-links a {
    padding: 10px 0;
    font-size: 14px;
  }
  .site-nav-links a::after { display: none; }
  .site-nav-inner { padding: 0 14px; }

  /* Media panel: dynamic height using dvh */
  .media-panel {
    flex: 0 0 calc(var(--dvh, 100vh) * 0.42 - 56px - 60px);
    min-height: 180px;
    width: 100%;
  }

  /* Chat panel como bottom sheet com safe area */
  .chat-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    height: calc(var(--dvh, 100vh) * 0.62);
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    background: rgba(241,239,251,0.95);
    z-index: 40;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    opacity: 0;
    transition:
      transform 0.4s cubic-bezier(0.32, 0.94, 0.6, 1),
      opacity 0.3s ease;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.06);
    padding-bottom: calc(64px + var(--sab, 0px));
    will-change: transform, opacity;
  }
  .chat-panel.mobile-open {
    transform: translateY(0);
    opacity: 1;
  }

  /* Staggered entrance for panel children */
  .chat-panel .chat-panel-mobile-header > * {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
  }
  .chat-panel.mobile-open .chat-panel-mobile-header > * {
    opacity: 1;
    transform: translateY(0);
  }
  .chat-panel.mobile-open .chat-panel-mobile-header > *:nth-child(1) { transition-delay: 0.05s; }
  .chat-panel.mobile-open .chat-panel-mobile-header > *:nth-child(2) { transition-delay: 0.1s; }
  .chat-panel .messages-container {
    opacity: 0;
    transition: opacity 0.4s ease 0.1s;
  }
  .chat-panel.mobile-open .messages-container {
    opacity: 1;
  }
  .chat-panel .chat-input-area {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    transition-delay: 0.12s;
  }
  .chat-panel.mobile-open .chat-input-area {
    opacity: 1;
    transform: translateY(0);
  }

  /* Backdrop overlay that fades in behind the chat panel */
  .chat-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .chat-panel-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Drag handle + mobile header */
  .chat-panel-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
  position: relative;
  background: rgba(241,239,251,0.95);
}
.chat-panel-mobile-header::before {
  content: '';
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 2px;
}
  .chat-panel-mobile-header > span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
  }
  .btn-chat-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #FFFFFF 0%, #F5F5FA 100%);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-spring);
    box-shadow:
      0 2px 0 0 rgba(0,0,0,0.08),
      0 2px 6px rgba(0,0,0,0.04),
      inset 0 1px 0 0 rgba(255,255,255,0.9);
  }
  .btn-chat-close:hover { background: linear-gradient(180deg, #FFFFFF 0%, #EAEAF5 100%); color: var(--text-primary);
    box-shadow:
      0 3px 0 0 rgba(0,0,0,0.06),
      0 4px 12px rgba(0,0,0,0.06);
    transform: translateY(-1px);
  }
  .btn-chat-close:active {
    box-shadow:
      0 1px 0 0 rgba(0,0,0,0.06),
      inset 0 2px 6px rgba(0,0,0,0.06);
    transform: translateY(1px) scale(0.95);
  }
  .btn-chat-close svg { width: 16px; height: 16px; }

  /* Chat input accessible, no iOS zoom */
  .chat-input-area {
    padding: 6px 8px 8px;
    gap: 3px;
  }
  .chat-input-row {
    gap: 4px;
  }
  #chat-input { font-size: 16px; padding: 10px 12px; }
  .emoji-bar { gap: 1px; padding: 2px 2px; }
  .emoji-btn { width: 26px; height: 26px; font-size: 14px; }
  .btn-send, .btn-image { width: 36px; height: 36px; }
  .btn-send svg { width: 16px; height: 16px; }
  .btn-image svg { width: 16px; height: 16px; }

  /* Chat toggle: visible on mobile, always with text, highlighted */
  #btn-chat-toggle { 
    display: flex; 
    position: relative; 
    flex-shrink: 0;
    background: linear-gradient(180deg, #EFEBFF 0%, #E6DFFF 100%);
    border: none;
    color: var(--video);
    font-weight: 700;
    box-shadow:
      0 2px 0 0 #B09CF0,
      0 2px 6px rgba(100,74,241,0.08);
  }
  #btn-chat-toggle span { 
    display: inline; 
    font-size: 12px; 
  }
  #btn-chat-toggle.active {
    background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
    color: #fff;
    box-shadow:
      0 2px 0 0 #4230B0,
      inset 0 1px 0 0 rgba(255,255,255,0.2);
  }

  /* Pulse on toggle when there are unread messages */
  #btn-chat-toggle.has-unread {
    animation: togglePulse 1.5s ease-in-out infinite;
  }
  @keyframes togglePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(100,74,241,0.25); }
    50% { box-shadow: 0 0 12px 2px rgba(100,74,241,0.12); }
  }

  /* Footer: compact horizontal scrollable row */
  .chat-footer {
    padding: 9px 10px;
    padding-bottom: calc(9px + var(--sab, 0px));
    gap: 6px;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .chat-footer::-webkit-scrollbar { display: none; }
  .btn-control { padding: 8px 10px; flex-shrink: 0; font-size: 12px; gap: 5px; }
  .btn-control span { font-size: 11px; }
  .btn-control svg { width: 16px; height: 16px; }
  .btn-report span { display: none; }  /* Icon only on mobile */

  /* Mode cards */
  .mode-card { width: 160px; padding: 28px 20px; }
  .mode-card-icon { width: 52px; height: 52px; }
  .mode-card-icon svg { width: 24px; height: 24px; }
  .mode-card-title { font-size: 17px; }
  .video-local-wrapper { width: 100px; height: 75px; bottom: 12px; right: 12px; }

  /* Voice avatars smaller */
  .voice-avatar { width: 72px; height: 72px; font-size: 12px; }
  .voice-avatar canvas { width: 72px; height: 72px; }
  .voice-avatars { gap: 16px; }
  .voice-connected { gap: 20px; }
  .voice-avatar-label { font-size: 11px; }

  /* Home content compact */
  .home-content { gap: 24px; padding: 16px; }
  .tagline { font-size: 14px; }
  .online-counter { font-size: 11px; padding: 4px 12px; }
  .disclaimer { font-size: 10.5px; }

  /* Hide logo text on mobile */
  .logo-text { display: none; }

  /* Toast repositioned for mobile */
  .toast {
    bottom: calc(70px + var(--sab, 0px));
    font-size: 13px;
    padding: 10px 18px;
  }

  /* Suggestion card repositioned */
  .mode-suggestion {
    bottom: calc(70px + var(--sab, 0px));
    min-width: 260px;
    max-width: calc(100% - 32px);
  }

  /* Connection quality hidden on mobile header (too crowded) */
  .conn-quality { display: none !important; }

  /* Shortcuts modal more compact */
  .shortcuts-card { padding: 20px 22px; margin: 16px; max-width: 100%; }
  .shortcut-row { font-size: 12px; }
}

/* ── Mobile pequeno (320-480px) ───────────────────── */
@media (max-width: 480px) {
  .mode-cards { flex-direction: column; align-items: center; }
  .mode-card {
    width: 100%; max-width: 280px;
    flex-direction: row;
    padding: 14px 18px;
    gap: 14px;
    text-align: left;
  }
  .mode-card-icon { width: 42px; height: 42px; border-radius: 12px; }
  .mode-card-icon svg { width: 20px; height: 20px; }
  .mode-card-title { font-size: 15px; }
  .mode-card-content p { font-size: 11px; }
  .mode-card-badge { top: 8px; right: 8px; font-size: 9px; padding: 2px 6px; }

  /* Keep Chat visible, hide other button texts */
  .btn-control:not(#btn-chat-toggle) span { display: none; }
  .btn-control { padding: 10px; }
  .btn-control svg { width: 18px; height: 18px; }
  #btn-chat-toggle { padding: 9px 13px; }
  #btn-chat-toggle span { display: inline; }

  .media-panel { 
    flex: 0 0 calc(var(--dvh, 100vh) * 0.35 - 56px - 60px);
    min-height: 140px; 
  }
  .chat-panel { height: calc(var(--dvh, 100vh) * 0.56); }

  .video-local-wrapper { width: 80px; height: 60px; bottom: 10px; right: 10px; }
  .voice-avatar { width: 60px; height: 60px; font-size: 10px; }
  .voice-avatar canvas { width: 60px; height: 60px; }
  .voice-avatars { gap: 12px; }
  .voice-wave .wave-bar:nth-child(1) { height: 10px; }
  .voice-wave .wave-bar:nth-child(2) { height: 16px; }
  .voice-wave .wave-bar:nth-child(3) { height: 10px; }

  .emoji-bar { gap: 0px; padding: 2px 0; }
  .emoji-btn { width: 22px; height: 22px; font-size: 12px; }
  .btn-send, .btn-image { width: 34px; height: 34px; }
  .btn-send svg { width: 14px; height: 14px; }
  .btn-image svg { width: 14px; height: 14px; }

  .logo { font-size: 20px; }
  .logo-icon { width: 26px; height: 26px; }
  .tagline br { display: none; }

  .home-content { gap: 18px; padding: 12px; }

  .shortcuts-card { padding: 16px 18px; }
  .shortcuts-card h3 { font-size: 14px; }
}

/* ── Mobile em modo paisagem ──────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  .media-panel {
    flex: 0 0 calc(var(--dvh, 100vh) * 0.65 - 56px - 50px);
    min-height: 120px;
  }
  .chat-panel {
    height: calc(var(--dvh, 100vh) * 0.75);
  }
  .chat-footer {
    padding: 6px 8px;
    padding-bottom: calc(6px + var(--sab, 0px));
    gap: 5px;
  }
  .btn-control { padding: 6px 10px; font-size: 11px; gap: 4px; }
  .btn-control span { font-size: 11px; }
  .btn-control svg { width: 14px; height: 14px; }
  .video-local-wrapper { width: 72px; height: 54px; bottom: 8px; right: 8px; }
  .voice-avatar { width: 50px; height: 50px; }
  .voice-avatar canvas { width: 50px; height: 50px; }
  .voice-avatars { gap: 10px; }
  .voice-connected { gap: 12px; }
  .chat-header { height: calc(44px + var(--sat, 0px)); padding: 0 12px; }
  .logo.small { font-size: 15px; }
  .mode-badge { font-size: 10px; padding: 3px 8px; }
  .text-connected-banner { padding: 10px 20px; font-size: 13px; }
}

/* ── Ecrãs muito grandes (>1400px) ─────────────── */
@media (min-width: 1400px) {
  .chat-panel { width: 380px; }
  .chat-main::after { right: 380px; }
  .home-content { max-width: 1100px; gap: 56px; }
  .mode-card { width: 220px; padding: 40px 36px; }
  .mode-card-icon { width: 72px; height: 72px; }
  .mode-card-icon svg { width: 34px; height: 34px; }
  .mode-card-title { font-size: 22px; }
  .media-panel video { object-fit: contain; }  /* Letterbox on ultra-wide */
}

/* ── Reduzir animações em dispositivos que preferem menos movimento ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Suporte para ecrãs foldable (Samsung Galaxy Fold, etc.) ─── */
@media (spanning: single-fold-vertical) {
  .chat-main { flex-direction: row; }
  .media-panel { flex: 1; }
  .chat-panel { width: calc(env(fold-right, 0px) - env(fold-left, 0px)); }
}

@media (spanning: single-fold-horizontal) {
  .chat-main { flex-direction: column; }
  .media-panel { flex: 1; }
  .chat-panel { width: 100%; }
}

/* ── Notification dot (for mobile) ──────────────── */
.msg-notification {
  display: none;
}

/* ── Orientation transition helper (JS) ─────────── */
.orientation-changing {
  transition: height 0.15s ease-out !important;
}

/* ── Emoji bar scroll horizontal no desktop também ── */
.emoji-bar {
  scrollbar-width: none;
}


/* -- Mode-aware image button hover ------------------------ */
body.mode-video .btn-image:hover { background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%); box-shadow: 0 3px 0 0 #4230B0, 0 4px 12px var(--video-glow); }
body.mode-voice .btn-image:hover { background: linear-gradient(180deg, #B091FF 0%, #8A73F5 100%); box-shadow: 0 3px 0 0 #5A3FE0, 0 4px 12px var(--voice-glow); }
body.mode-text  .btn-image:hover { background: linear-gradient(180deg, #6EEAB0 0%, #3DC484 100%); box-shadow: 0 3px 0 0 #2B9B68, 0 4px 12px var(--text-glow); }

/* Mode-aware message gradient */
body.mode-video { --msg-gradient-from: rgba(100,74,241,0.1); --msg-gradient-to: rgba(100,74,241,0.04); --msg-border: rgba(100,74,241,0.15); }
body.mode-voice { --msg-gradient-from: rgba(138,115,245,0.1); --msg-gradient-to: rgba(138,115,245,0.04); --msg-border: rgba(138,115,245,0.15); }
body.mode-text  { --msg-gradient-from: rgba(61,220,151,0.1);  --msg-gradient-to: rgba(61,220,151,0.04);  --msg-border: rgba(61,220,151,0.15); }

/* Chat toggle */
#btn-chat-toggle {
  transition: all var(--transition-spring);
}
#btn-chat-toggle.active {
  background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
  color: #fff;
  box-shadow:
    0 3px 0 0 #4230B0,
    inset 0 1px 0 0 rgba(255,255,255,0.2);
}
#btn-chat-toggle.active::after {
  box-shadow:
    inset 0 -2px 0 0 rgba(0,0,0,0.12),
    inset 0 1px 0 0 rgba(255,255,255,0.1);
}

/* -- Unread badge ----------------------------------------- */
.chat-unread-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  pointer-events: none;
  animation: badgePop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.chat-unread-badge.hidden { display: none; }
@keyframes badgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
#btn-chat-toggle { position: relative; }

/* -- Cam-off overlay -------------------------------------- */
.cam-off-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--video-bg);
  z-index: 3;
  color: var(--text-muted);
  font-size: 14px;
  flex-direction: column;
  gap: 12px;
}
.cam-off-overlay svg { width: 40px; height: 40px; opacity: 0.4; }

/* -- Mode Suggestion Card --------------------------------- */
.mode-suggestion {
  position: fixed;
  bottom: calc(80px + var(--sab, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  min-width: 290px;
  max-width: 370px;
  width: calc(100% - 32px);
  animation: suggestionIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.mode-suggestion.hidden { display: none; }
@keyframes suggestionIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1); }
}
.suggestion-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.suggestion-header { display: flex; align-items: flex-start; gap: 12px; }
.suggestion-icon { font-size: 26px; line-height: 1; }
.suggestion-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.suggestion-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.suggestion-cta {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}
.suggestion-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.suggestion-mode-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all var(--transition-spring);
  flex: 1; justify-content: center;
  border: none;
  color: #fff;
}
.suggestion-mode-btn:hover { transform: translateY(-2px); }
.suggestion-mode-btn.video {
  background: linear-gradient(180deg, #7C5CFC 0%, #5A3FE0 100%);
  box-shadow:
    0 2px 0 0 #3D27A8,
    0 4px 12px rgba(100,74,241,0.2);
}
.suggestion-mode-btn.video:hover {
  background: linear-gradient(180deg, #8C6CFC 0%, #644AF1 100%);
  box-shadow:
    0 4px 0 0 #3D27A8,
    0 8px 20px rgba(100,74,241,0.3);
  transform: translateY(-2px);
}
.suggestion-mode-btn.video:active {
  background: linear-gradient(180deg, #5A3FE0 0%, #4B34D6 100%);
  box-shadow:
    0 1px 0 0 #3D27A8,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}
.suggestion-mode-btn.voice {
  background: linear-gradient(180deg, #A081FF 0%, #7C5CFC 100%);
  box-shadow:
    0 2px 0 0 #5A3FE0,
    0 4px 12px rgba(138,115,245,0.2);
}
.suggestion-mode-btn.voice:hover {
  background: linear-gradient(180deg, #B091FF 0%, #8A73F5 100%);
  box-shadow:
    0 4px 0 0 #5A3FE0,
    0 8px 20px rgba(138,115,245,0.3);
  transform: translateY(-2px);
}
.suggestion-mode-btn.voice:active {
  background: linear-gradient(180deg, #7C5CFC 0%, #6B52E6 100%);
  box-shadow:
    0 1px 0 0 #5A3FE0,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}
.suggestion-mode-btn.text {
  background: linear-gradient(180deg, #5EE0A0 0%, #3DC484 100%);
  box-shadow:
    0 2px 0 0 #2B9B68,
    0 4px 12px rgba(61,220,151,0.2);
}
.suggestion-mode-btn.text:hover {
  background: linear-gradient(180deg, #6EEAB0 0%, #4CD494 100%);
  box-shadow:
    0 4px 0 0 #2B9B68,
    0 8px 20px rgba(61,220,151,0.3);
  transform: translateY(-2px);
}
.suggestion-mode-btn.text:active {
  background: linear-gradient(180deg, #3DC484 0%, #2DB87A 100%);
  box-shadow:
    0 1px 0 0 #2B9B68,
    inset 0 2px 6px rgba(0,0,0,0.15);
  transform: translateY(1px) scale(0.97);
}
.suggestion-keep {
  align-self: center;
  font-size: 12.5px; color: var(--text-muted);
  font-family: var(--font-display);
  cursor: pointer; background: none; border: none;
  text-decoration: underline; text-underline-offset: 3px;
  transition: color var(--transition);
}
.suggestion-keep:hover { color: var(--text-secondary); }
