:root {
  color-scheme: dark;
  --bg: #05070c;
  --bg2: #07111f;
  --panel: rgba(13, 18, 30, 0.92);
  --line: rgba(231, 190, 95, 0.2);
  --gold: #e7be5f;
  --gold2: #b98a2f;
  --text: #f7f2e7;
  --muted: #aeb7c6;
  --danger: #b94b4b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(231, 190, 95, 0.13), transparent 30%),
    radial-gradient(circle at 85% 0%, rgba(43, 111, 142, 0.16), transparent 35%),
    linear-gradient(135deg, var(--bg), var(--bg2));
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.topbar, .room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 56px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #111;
  background: linear-gradient(135deg, #f5d889, var(--gold2));
}

.nav { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.auth-shell { min-height: calc(100vh - 90px); display: grid; place-items: center; padding: 24px; }
.dashboard { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 56px; }
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  padding: clamp(20px, 3vw, 32px);
}
.auth-card { width: min(520px, 100%); }
.hero-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 28px 0 24px;
}

h1, h2 { margin: 0 0 14px; line-height: 1.1; }
h1 { font-size: clamp(2rem, 4vw, 4rem); }
h2 { font-size: 1.25rem; }
.eyebrow { color: var(--gold); text-transform: uppercase; font-size: 0.78rem; font-weight: 800; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.alert { border: 1px solid rgba(185, 75, 75, 0.5); color: #ffd8d8; padding: 12px; border-radius: 8px; margin: 18px 0; }
.badge { border: 1px solid var(--line); color: var(--gold); padding: 10px 14px; border-radius: 999px; background: rgba(231, 190, 95, 0.07); white-space: nowrap; }

.form-stack, .settings-grid { display: grid; gap: 16px; }
.settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 8px; color: var(--muted); font-size: 0.92rem; }
input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
}

.button, button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.button.primary { background: linear-gradient(135deg, #f5d889, var(--gold2)); color: #111; }
.button.secondary { background: rgba(231, 190, 95, 0.1); color: var(--gold); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; }
.button.danger { background: rgba(185, 75, 75, 0.16); color: #ffdada; border: 1px solid rgba(185, 75, 75, 0.4); }
.link-button { background: none; color: var(--gold); padding: 0; min-height: 0; }
.sticky-play { display: inline-flex; align-items: center; justify-content: center; }
.sticky-play[hidden] { display: none; }

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.copy-row, .inline-form, .seek-row { display: flex; gap: 10px; align-items: end; }
.host-link-manager { display: grid; gap: 12px; margin-top: 18px; }
.section-head.compact { align-items: center; }
.section-head.compact h3 { margin: 0; }
.host-link-form { display: grid; grid-template-columns: minmax(120px, 0.45fr) minmax(180px, 1fr) auto; gap: 10px; align-items: end; }
.host-link-list { display: grid; gap: 12px; }
.host-link-item {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  padding: 12px;
}
.host-link-item .copy-row { align-items: stretch; }
.control-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.compact-controls { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.compact-controls .button {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.9rem;
  white-space: nowrap;
}
.host-preview { margin: 0 0 18px; }
.host-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #020408;
}
.host-player iframe { width: 100%; height: 100%; }
.host-preview-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  color: var(--muted);
}
.host-preview-status strong { color: var(--text); }
.status-grid { display: grid; grid-template-columns: auto 1fr; gap: 12px 22px; color: var(--muted); }
.status-grid strong { color: var(--text); }
.table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.08); text-align: left; vertical-align: top; }

.room-shell { width: min(1180px, calc(100% - 32px)); min-height: 100vh; min-height: 100dvh; margin: 0 auto; display: grid; grid-template-rows: auto 1fr auto; }
.video-stage {
  position: relative;
  min-height: 62vh;
  min-height: 62dvh;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #020408;
}
.vimeo-frame, .vimeo-frame iframe { width: 100%; height: 100%; min-height: 62vh; }
.waiting-poster {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 10px;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 35%, rgba(231, 190, 95, 0.16), transparent 34%),
    linear-gradient(145deg, rgba(4, 7, 12, 0.96), rgba(7, 17, 31, 0.94));
}
.waiting-poster.hidden { display: none; }
.waiting-poster .brand-mark { width: 58px; height: 58px; margin-bottom: 4px; }
.waiting-poster h2 { font-size: clamp(1.75rem, 5vw, 3.25rem); margin: 0; max-width: 720px; }
.waiting-poster p:last-child { color: var(--muted); margin: 0; }
.playback-overlay {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 7, 12, 0.88);
  padding: 16px;
  backdrop-filter: blur(12px);
}
.playback-overlay.needs-action {
  inset: 18px;
  bottom: 18px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}
.playback-overlay.needs-action h2 { font-size: clamp(1.5rem, 6vw, 2.4rem); }
.playback-overlay.needs-action p { max-width: 520px; }
.playback-overlay.needs-action .button { min-height: 56px; padding: 0 26px; font-size: 1rem; }
.playback-actions { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.playback-overlay.hidden { display: none; }
.playback-overlay h2 { margin: 0 0 4px; font-size: 1rem; }
.playback-overlay p { margin: 0; color: var(--muted); }
.ready-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 35%, rgba(231, 190, 95, 0.18), transparent 35%),
    rgba(4, 7, 12, 0.95);
}
.ready-overlay p { max-width: 560px; color: var(--muted); }
.ready-overlay.hidden { display: none; }
.room-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 0 36px; }
.guest-video-controls {
  display: grid;
  gap: 10px;
  min-width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(231, 190, 95, 0.06);
  padding: 12px;
}
.guest-video-controls[hidden] { display: none; }
.guest-video-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.guest-video-buttons .button { min-height: 40px; padding: 0 12px; }
.ready-name-label { width: min(380px, 100%); margin: 10px 0 14px; text-align: left; }
.inline-error { color: #ffd8d8; margin: -4px 0 12px; }
.ready-panel { margin-top: 18px; }
.ready-list { display: grid; gap: 10px; margin-top: 14px; }
.ready-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  padding: 12px 14px;
}
.ready-item span { color: var(--gold); }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.audio-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.audio-actions .button { min-width: 148px; }
.audio-panel.voice-open {
  border-color: rgba(91, 180, 102, 0.72);
  box-shadow: 0 0 0 1px rgba(91, 180, 102, 0.22), 0 24px 80px rgba(0, 0, 0, 0.28);
}
.voice-chat-state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
}
.voice-state-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.voice-state-badge.open {
  color: #07110a;
  background: #8ee69b;
  border: 1px solid rgba(142, 230, 155, 0.8);
}
.voice-state-badge.closed {
  color: #ffdada;
  background: rgba(185, 75, 75, 0.18);
  border: 1px solid rgba(185, 75, 75, 0.5);
}
.button.voice-start.is-open {
  background: rgba(91, 180, 102, 0.18);
  color: #d9f7de;
  border: 1px solid rgba(91, 180, 102, 0.55);
}
.button.voice-end:not(:disabled) {
  min-height: 52px;
  padding: 0 22px;
  box-shadow: 0 0 0 2px rgba(185, 75, 75, 0.22);
}
.audio-panel h3 { margin: 18px 0 8px; }
.audio-join { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.permission-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
}
.permission-pill.granted { color: #d9f7de; border-color: rgba(91, 180, 102, 0.45); background: rgba(91, 180, 102, 0.12); }
.permission-pill.prompt, .permission-pill.unknown { color: var(--gold); border-color: var(--line); background: rgba(231, 190, 95, 0.08); }
.permission-pill.denied { color: #ffd8d8; border-color: rgba(185, 75, 75, 0.55); background: rgba(185, 75, 75, 0.16); }
.chat-panel, .visitor-chat { margin-top: 18px; }
.chat-layout { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 16px; }
.chat-thread-list { display: grid; gap: 8px; align-content: start; }
.chat-thread {
  text-align: left;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}
.chat-thread.active { border-color: var(--gold); color: var(--gold); }
.chat-window { display: grid; gap: 10px; }
.chat-messages {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 12px;
  background: rgba(0,0,0,0.2);
}
.chat-message { display: grid; gap: 4px; margin-bottom: 10px; }
.chat-message strong { color: var(--gold); font-size: 0.82rem; }
.chat-message span {
  display: inline-block;
  width: fit-content;
  max-width: 92%;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  padding: 9px 11px;
}
.chat-message.own { justify-items: end; }
.chat-message.own span { background: rgba(231,190,95,0.16); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

@media (max-width: 780px) {
  body { background: linear-gradient(180deg, #05070c, #07111f); }
  .room-shell { width: 100%; min-height: 100dvh; grid-template-rows: auto minmax(420px, 1fr) auto; }
  .room-header { padding: 14px 16px; gap: 12px; }
  .room-header .brand-mark { width: 36px; height: 36px; }
  .room-header .badge { font-size: 0.86rem; padding: 8px 10px; }
  .video-stage {
    min-height: 58dvh;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .vimeo-frame, .vimeo-frame iframe { min-height: 58dvh; }
  .ready-overlay { padding: 22px 18px; align-content: center; }
  .ready-overlay h1 { font-size: 2rem; }
  .playback-overlay {
    left: 14px;
    right: 14px;
    bottom: 14px;
    padding: 16px;
    align-items: stretch;
    flex-direction: column;
  }
  .playback-overlay.needs-action {
    inset: 14px;
    min-height: calc(58dvh - 28px);
  }
  .playback-actions { width: 100%; display: grid; }
  .playback-actions .button { width: 100%; }
  .room-actions { padding: 14px 16px 20px; gap: 12px; }
  .room-actions .button { width: 100%; }
  .guest-video-controls { width: 100%; }
  .guest-video-buttons { grid-template-columns: 1fr; }
  .audio-join { width: 100%; display: grid; }
  .section-head, .audio-actions { flex-direction: column; align-items: stretch; }
  .audio-actions .button { width: 100%; }
  .voice-chat-state { align-items: stretch; flex-direction: column; }
  .voice-state-badge { justify-content: center; }
  .chat-layout, .chat-form { grid-template-columns: 1fr; }
  .sticky-play {
    position: sticky;
    bottom: 12px;
    z-index: 6;
    min-height: 58px;
    font-size: 1.05rem;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
  }
  .topbar, .room-header, .hero-band, .room-actions { align-items: flex-start; flex-direction: column; }
  .grid.two, .settings-grid, .control-grid, .compact-controls { grid-template-columns: 1fr; }
  .dashboard { width: calc(100% - 24px); padding-top: 12px; }
  .hero-band { padding: 18px 0; }
  .control-grid .button { width: 100%; }
  .seek-row input, .seek-row .button { width: 100%; }
  .host-player { min-height: 190px; }
  .copy-row, .inline-form, .seek-row { flex-direction: column; align-items: stretch; }
  .host-link-form { grid-template-columns: 1fr; }
  .host-link-item .copy-row form, .host-link-item .copy-row .button { width: 100%; }
  .nav { flex-wrap: wrap; }
  .badge { white-space: normal; }
}
