:root {
  color-scheme: dark;
  --bg: #10141a;
  --bg-elev: #181e27;
  --bg-elev-2: #212938;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef2f6;
  --muted: #a8b3c4;
  --accent: #5ee0a0;
  --accent-ink: #06281c;
  --danger: #ff6d80;
  --warn: #ffd089;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
}

button, input, textarea { font: inherit; color: inherit; }

button, .tab { cursor: pointer; }

button:disabled { cursor: wait; opacity: 0.7; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lobby {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(94, 224, 160, 0.16), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(142, 182, 255, 0.14), transparent 50%),
    var(--bg);
}

.lobby-card {
  width: min(560px, 100%);
  background: rgba(24, 30, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.brand {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  line-height: 1.2;
  font-weight: 650;
}

.lead, .fine {
  color: var(--muted);
  line-height: 1.5;
}

.lead { margin: 12px 0 22px; }

.fine { margin: 14px 0 0; font-size: 0.86rem; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }

.field span { font-size: 0.92rem; color: var(--muted); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #0e131a;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}

textarea { resize: vertical; min-height: 64px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  background: #0e131a;
  padding: 4px;
  border-radius: 12px;
}

.tab, .primary, .ghost {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--bg-elev-2);
  color: var(--text);
}

.primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.primary.active, #mic.active {
  background: #29493c;
  color: var(--accent);
}

.ghost {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
}

.form-error {
  color: var(--danger);
  margin: 12px 0 0;
}

.room {
  height: 100dvh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  background: var(--bg);
}

.people, .chat, .stage {
  min-height: 0;
  min-width: 0;
}

.people, .chat {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
}

.chat { border-right: 0; border-left: 1px solid var(--line); }

.side-head, .side-actions, .controls {
  padding: 16px;
}

.side-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.code {
  margin: 4px 0 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
}

.count, .chat-title { margin: 4px 0 0; }

.side-actions { display: grid; gap: 8px; padding-top: 0; }

.side-actions .ghost, .leave { width: 100%; }

.peer-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow: auto;
  flex: 1;
}

.person {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
}

.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.person-actions .ghost {
  width: auto;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
}

.volume {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: var(--muted);
  font-size: 0.75rem;
}

.volume input {
  width: 100%;
  padding: 0;
  accent-color: var(--accent);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex: none;
}

.person-meta { min-width: 0; }

.person-name, .badges {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badges { color: var(--muted); font-size: 0.78rem; }

.person.speaking .avatar {
  box-shadow: 0 0 0 3px rgba(94, 224, 160, 0.75);
}

.leave { margin: 12px; margin-top: auto; }

.stage {
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(500px 220px at 50% 0%, rgba(94, 224, 160, 0.08), transparent 60%),
    #0c1016;
}

.tiles {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  padding: 12px;
}

.tiles:empty { display: none; }

.tile {
  position: relative;
  height: 100%;
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #07090d;
  border: 1px solid var(--line);
}

.tile.local { border-color: rgba(94, 224, 160, 0.45); }

.tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.tile-label, .tile-status, .voice-card {
  position: absolute;
  left: 10px;
  right: 10px;
}

.tile-label {
  bottom: 10px;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  font-size: 0.85rem;
}

.tile-hide {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: auto;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.watch {
  margin-left: auto;
  width: auto;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
  flex: none;
}

.tile-status, .voice-card {
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  color: var(--muted);
}

.empty-stage {
  margin: auto;
  text-align: center;
  max-width: 420px;
  padding: 24px;
  color: var(--muted);
}

.empty-stage h2 { color: var(--text); font-size: 1.25rem; }

.empty-icon { color: var(--accent); }

.banner {
  margin: 0 16px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 208, 137, 0.12);
  color: var(--warn);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.controls .primary, .controls .ghost { width: auto; }

.messages {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 95%;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-elev-2);
}

.message.own {
  align-self: flex-end;
  background: #1d3a30;
}

.message header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.message p { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }

.message a { color: #b7d0ff; }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.composer .primary { width: auto; align-self: end; }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 5;
}

.toast {
  background: #243044;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: 320px;
}

@media (max-width: 980px) {
  body { overflow: auto; }

  .room {
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .people, .chat { border: 0; border-top: 1px solid var(--line); }

  .stage { min-height: 46vh; }

  .people { order: 2; }

  .chat { order: 3; min-height: 0; }

  .messages {
    min-height: 160px;
    max-height: 42vh;
    flex: none;
  }

  .peer-list { max-height: 200px; }
}

* { scrollbar-width: thin; scrollbar-color: #334155 transparent; }
