:root {
  --bg0: #0c1220;
  --bg1: #141c2e;
  --bg2: #1c2740;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef8;
  --muted: #93a0b8;
  --accent: #2dd4a8;
  --accent-2: #3b82f6;
  --danger: #f07178;
  --warn: #e6c07b;
  --radius: 14px;
  --font-display: "Sora", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(45, 212, 168, 0.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(59, 130, 246, 0.16), transparent 50%),
    linear-gradient(160deg, var(--bg0), #10182a 45%, #0a101b);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.35rem;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-block;
  box-shadow: 0 0 20px rgba(45, 212, 168, 0.25);
}

.nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap;
}
.nav-links { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.03em; margin: 0 0 0.5rem; }
.lead { color: var(--muted); margin: 0 0 1.5rem; line-height: 1.5; max-width: 42rem; }

.panel {
  background: rgba(20, 28, 46, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  animation: panelIn 0.45s ease both;
}
.panel-auth {
  max-width: 440px;
  margin: 2.5rem auto 1rem;
  padding: 1.6rem 1.5rem 1.5rem;
}
.panel-join {
  max-width: 560px;
  margin: 1.25rem auto;
  padding: 1.5rem 1.45rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(45, 212, 168, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 168, 0.15);
}
.field { margin-bottom: 0.95rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 0; border-radius: 10px; padding: 0.7rem 1.05rem; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #22b8a0);
  color: #06241c; font-weight: 650; transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.btn-secondary {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
}
.btn-danger { background: linear-gradient(135deg, #f07178, #e85d6a); color: #2a0b0e; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.hero {
  display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1.5rem; align-items: stretch;
  min-height: calc(100vh - 7rem);
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
}
.hero-copy { animation: panelIn 0.5s ease both; }
.hero-copy h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.05;
  margin-bottom: 0.8rem;
}
.hero-visual {
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(45, 212, 168, 0.15), transparent 40%),
    linear-gradient(20deg, rgba(59, 130, 246, 0.2), transparent 45%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 40 40'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M0 0h20v20H0zM20 20h20v20H20z'/%3E%3C/g%3E%3C/svg%3E"),
    var(--bg1);
  position: relative; overflow: hidden; min-height: 280px;
  animation: panelIn 0.55s ease 0.08s both;
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(2px);
  animation: float 8s ease-in-out infinite;
}
.orb-a { width: 180px; height: 180px; background: rgba(45,212,168,0.25); top: 18%; left: 16%; }
.orb-b { width: 120px; height: 120px; background: rgba(59,130,246,0.28); bottom: 16%; right: 18%; animation-delay: -2s; }
.orb-c { width: 70px; height: 70px; background: rgba(230,192,123,0.25); top: 55%; left: 55%; animation-delay: -4s; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td {
  text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line);
}
.table th { color: var(--muted); font-weight: 560; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.55rem; border-radius: 999px; font-size: 0.78rem;
  background: rgba(45, 212, 168, 0.12); color: var(--accent); border: 1px solid rgba(45,212,168,0.25);
}
.chip-muted { background: rgba(255,255,255,0.05); color: var(--muted); border-color: var(--line); }
.chip-warn { background: rgba(230,192,123,0.12); color: var(--warn); border-color: rgba(230,192,123,0.3); }
.chip-ok { background: rgba(45, 212, 168, 0.14); color: var(--accent); border-color: rgba(45,212,168,0.35); }
.chip-busy {
  background: rgba(59, 130, 246, 0.12); color: #93c5fd; border-color: rgba(59,130,246,0.3);
}
.chip-busy::before {
  content: "";
  width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: currentColor;
  animation: pulseDot 1s ease-in-out infinite;
}

.alert {
  padding: 0.75rem 0.9rem; border-radius: 10px; margin-bottom: 1rem;
  background: rgba(240, 113, 120, 0.12); border: 1px solid rgba(240,113,120,0.3); color: #ffb4b8;
  display: none;
}
.alert.show { display: block; animation: panelIn 0.25s ease both; }
.alert-ok {
  background: rgba(45, 212, 168, 0.12); border-color: rgba(45,212,168,0.3); color: #9af0d6;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  min-height: 0;
  margin-top: 0.65rem;
}
.country-select {
  margin-top: 0.55rem;
  min-height: 11rem;
  max-height: 14rem;
}
.lang-btn {
  background: var(--bg2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 0.55rem;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.lang-btn:hover {
  border-color: rgba(45,212,168,0.45); background: rgba(45,212,168,0.08); transform: translateY(-1px);
}
.lang-btn.active {
  border-color: rgba(45,212,168,0.7); background: rgba(45,212,168,0.14);
  box-shadow: 0 0 0 2px rgba(45, 212, 168, 0.12);
}

/* —— Call room —— */
.call-body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
.call-layout {
  display: grid;
  grid-template-columns: 1fr min(360px, 34vw);
  gap: 0.85rem;
  height: 100vh;
  height: 100dvh;
  padding: max(0.65rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.65rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}
@media (max-width: 900px) {
  .call-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
}
.call-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.stage {
  display: flex; flex-direction: column; gap: 0.75rem; min-height: 0;
}
.video-grid {
  flex: 1; display: grid; gap: 0.6rem; min-height: 240px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-content: start;
}
@media (max-width: 900px) {
  .video-grid { min-height: 280px; }
}
.video-tile {
  position: relative; background: #070b14; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; aspect-ratio: 16/10; min-height: 160px;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35);
}
.video-tile video, .video-tile #localPlayer, .video-tile [id^="player-"] {
  width: 100%; height: 100%; object-fit: cover; background: #000;
}
.video-label {
  position: absolute; left: 0.55rem; bottom: 0.55rem;
  background: rgba(0,0,0,0.55); padding: 0.25rem 0.5rem; border-radius: 6px; font-size: 0.78rem;
  backdrop-filter: blur(4px);
}
.video-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.9rem; min-height: 160px;
  border: 1px dashed var(--line); border-radius: 12px;
}

.controls {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  justify-content: center; padding: 0.7rem;
  background: rgba(20,28,46,0.92);
  border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(8px);
}
.controls .mode-group { display: flex; gap: 0.35rem; margin-left: auto; flex-wrap: wrap; }
@media (max-width: 900px) {
  .controls {
    position: sticky;
    bottom: env(safe-area-inset-bottom, 0);
    z-index: 5;
  }
  .controls .mode-group { margin-left: 0; width: 100%; justify-content: center; }
}

.ctrl-btn {
  min-width: 5.5rem;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-btn.is-off {
  background: rgba(240, 113, 120, 0.15);
  border-color: rgba(240, 113, 120, 0.4);
  color: #ffb4b8;
}
.ctrl-btn.is-on {
  border-color: rgba(45, 212, 168, 0.45);
}
.mode-btn.active {
  outline: 2px solid var(--accent);
  color: var(--text);
  background: rgba(45, 212, 168, 0.1);
}

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(20,28,46,0.92); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
}
@media (max-width: 900px) {
  .sidebar { max-height: 42vh; }
}
.sidebar-head { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); }
.chat-log {
  flex: 1; overflow-y: auto; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.55rem;
  min-height: 180px; max-height: 55vh;
  position: relative;
}
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1.5rem 1rem;
  line-height: 1.45;
}
.chat-item {
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.55rem 0.7rem;
  animation: panelIn 0.2s ease both;
}
.chat-item.caption { border-color: rgba(59,130,246,0.35); background: rgba(59,130,246,0.08); }
.chat-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.chat-text { line-height: 1.4; word-break: break-word; }
.chat-orig { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; opacity: 0.85; }
.chat-form {
  display: flex; gap: 0.45rem; padding: 0.75rem; border-top: 1px solid var(--line);
}
.chat-form input { flex: 1; }
.captions-bar {
  min-height: 2.2rem; padding: 0.45rem 0.7rem; border-radius: 10px;
  background: rgba(0,0,0,0.35); border: 1px solid var(--line);
  color: #cfe8ff; font-size: 0.92rem;
}
.peers { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; }

.loading-inline {
  display: inline-flex; align-items: center; gap: 0.45rem;
  color: var(--muted); font-size: 0.9rem;
}
.loading-dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--accent);
  animation: pulseDot 0.9s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(20, 28, 46, 0.95);
  border: 1px solid rgba(45, 212, 168, 0.35);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }
.muted-text { color: var(--muted); font-size: 0.9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.copy-row { display: flex; gap: 0.5rem; align-items: center; }
.copy-row input { flex: 1; }

.step-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.how-strip h2 { margin-bottom: 0; }
.how-strip { animation: panelIn 0.5s ease 0.12s both; }
.empty-state {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}
.setup-form .field { margin-bottom: 0.85rem; }

@media (prefers-reduced-motion: reduce) {
  .orb, .chip-busy::before, .loading-dot { animation: none; }
  .panel, .hero-copy, .hero-visual, .how-strip, .chat-item, .alert.show {
    animation: none;
  }
}
