:root {
  --g1: #7b2ff2; --g2: #2196f3; --ink: #0f1222; --muted: #6b7084; --soft: #f3f1fb; --paper: #fff; --danger: #e03131; --ok: #2b8a3e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: Inter, system-ui, -apple-system, sans-serif; background: #0b0d18; color: #fff; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 14px 22px; font: inherit; font-weight: 600; cursor: pointer;
  background: linear-gradient(90deg, var(--g1), var(--g2)); color: #fff; min-height: 48px;
}
.btn.secondary { background: rgba(255,255,255,.12); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.brand { font-family: Sora, Inter, sans-serif; font-weight: 700; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--g1), var(--g2)); }

/* lobby */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 440px; background: #151829; border-radius: 20px; padding: 24px; display: grid; gap: 16px; }
.card h1 { font-family: Sora, Inter, sans-serif; font-size: 24px; }
.card p { color: #b7bbcc; line-height: 1.45; font-size: 15px; }
.card label { display: grid; gap: 6px; font-size: 14px; color: #b7bbcc; }
.card input[type=text] { font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid #2b2f45; background: #0f1222; color: #fff; }
.preview { position: relative; aspect-ratio: 4/3; border-radius: 14px; overflow: hidden; background: #000; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.meter { position: absolute; left: 12px; bottom: 12px; height: 6px; width: 120px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.err { color: #ff8787; font-size: 14px; }
.hint { font-size: 13px; color: #8d92a8; }

/* room */
.room { height: 100%; display: grid; grid-template-rows: 1fr auto; }
.stage { position: relative; display: grid; grid-template-columns: 1fr 260px; gap: 10px; padding: 10px; min-height: 0; }
.main { position: relative; background: #000; border-radius: 16px; overflow: hidden; min-height: 0; }
.main video { width: 100%; height: 100%; object-fit: contain; }
.tiles { display: grid; grid-auto-rows: min-content; gap: 10px; min-height: 0; overflow: auto; }
.tile { position: relative; aspect-ratio: 4/3; background: #1a1d30; border-radius: 14px; overflow: hidden; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.local video { transform: scaleX(-1); }
.tile .name { position: absolute; left: 10px; bottom: 8px; font-size: 13px; background: rgba(0,0,0,.55); padding: 4px 8px; border-radius: 8px; }
.tile.speaking { outline: 3px solid var(--g2); }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; font-family: Sora, Inter, sans-serif; font-size: 40px; background: linear-gradient(135deg, var(--g1), var(--g2)); }
.captions { position: absolute; left: 16px; right: 16px; bottom: 16px; font-size: 18px; text-align: center; text-shadow: 0 2px 6px rgba(0,0,0,.8); pointer-events: none; }
.captions b { color: #c5d6ff; }
.controls { display: flex; gap: 10px; justify-content: center; padding: 12px 16px; background: #0f1222; flex-wrap: wrap; }
.controls .btn { min-width: 96px; }
.status { font-size: 13px; color: #8d92a8; text-align: center; padding: 0 16px 10px; }

@media (max-width: 720px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .tiles { grid-auto-flow: column; grid-auto-columns: 120px; grid-auto-rows: auto; }
  .tile { aspect-ratio: 1; }
  .captions { font-size: 15px; }
}
