:root {
  --bg: #0b0c10;
  --panel: #14161d;
  --panel-2: #1b1e27;
  --line: #262a36;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --accent: #ffb648;
  --good: #4ade80;
  --bad: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #171a24 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ---------- join gate ---------- */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  display: grid;
  gap: 14px;
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.45);
}

.card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

label.row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

input[type='text'],
input:not([type]),
input[type='range'] {
  accent-color: var(--accent);
}

input:not([type='checkbox']):not([type='range']) {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

small {
  color: var(--muted);
  font-size: 12px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 14px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

button:active {
  transform: translateY(1px);
}

button[type='submit'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #241a05;
  font-weight: 650;
  padding: 12px;
}

.note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- app shell ---------- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgb(11 12 16 / 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 18px;
}

.grow {
  flex: 1;
}

.pill {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill.host {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
}

.status {
  font-size: 12px;
  color: var(--muted);
}

.status.ok {
  color: var(--good);
}

.status.err {
  color: var(--bad);
}

.ghost {
  font-size: 12px;
  padding: 6px 10px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  padding: 16px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- stage ---------- */
.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.player-frame iframe,
.player-frame > div {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.ctl.off {
  color: var(--bad);
  border-color: color-mix(in oklab, var(--bad) 35%, var(--line));
}

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}

.vol input {
  width: 110px;
}

.load {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 260px;
}

.load input {
  flex: 1;
  min-width: 0;
}

.load button {
  font-size: 13px;
  white-space: nowrap;
}

.drift {
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}

/* ---------- people + chat ---------- */
.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.tiles {
  display: grid;
  gap: 10px;
}

.tile {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile.self video {
  transform: scaleX(-1);
}

.tile .tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  background: rgb(0 0 0 / 0.6);
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.tile.connecting {
  border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
}

.chat {
  flex: 1;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.log {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.log .who {
  color: var(--accent);
  font-weight: 600;
}

.log .sys {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

.chat form {
  border-top: 1px solid var(--line);
}

.chat input {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: var(--panel-2);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .tiles {
    grid-template-columns: 1fr 1fr;
  }

  .chat {
    min-height: 200px;
  }
}
