/* ── Reset & tokens ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0b10;
  --surface: #13131a;
  --surface-2: #1a1a24;
  --surface-3: #22222f;
  --border: #28283a;
  --border-2: #323248;
  --accent: #50c878;
  --accent-dim: rgba(80,200,120,.15);
  --accent-glow: rgba(80,200,120,.35);
  --text: #e2e2f0;
  --text-2: #9090b0;
  --text-3: #55556e;
  --danger: #ff4757;
  --danger-dim: rgba(255,71,87,.15);
  --warn: #ffaa33;
  --blue: #5b8ef0;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 32px;
  --r-pill: 9999px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
  --shadow: 0 4px 24px rgba(0,0,0,.6);
  --shadow-lg: 0 8px 48px rgba(0,0,0,.8);
  --glow: 0 0 24px var(--accent-glow);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(.16,1,.3,1);
}

html { font-family: var(--font); color: var(--text); background: var(--bg); }
body { min-height: 100vh; overflow: hidden; position: relative; user-select: none; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input { font-family: var(--font); }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 5px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border-2);
  font-size: .7em; font-family: var(--font); color: var(--text-2);
}

/* ── Custom cursor ───────────────────────────────────────────────────────── */
@media (pointer: fine) {
  body { cursor: none; }
  .custom-cursor {
    position: fixed; width: 14px; height: 14px; border-radius: 50%;
    background: var(--accent); mix-blend-mode: screen;
    pointer-events: none; z-index: 9999;
    transform: translate(-50%,-50%);
    transition: opacity .15s, transform .1s;
  }
  .cursor-trail {
    position: fixed; width: 32px; height: 32px; border-radius: 50%;
    border: 1.5px solid rgba(80,200,120,.4);
    pointer-events: none; z-index: 9998;
    transform: translate(-50%,-50%);
    transition: left .12s var(--ease-out), top .12s var(--ease-out);
  }
  .custom-cursor.clicking { transform: translate(-50%,-50%) scale(.7); }
}

/* ── Background canvas ───────────────────────────────────────────────────── */
.bg-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

/* ── Ripple effect ───────────────────────────────────────────────────────── */
.btn, .btn-icon { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%;
  transform: scale(0); opacity: .6;
  background: radial-gradient(circle, rgba(80,200,120,.5) 0%, transparent 70%);
  animation: ripple-anim .55s var(--ease-out) forwards;
  pointer-events: none; width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
}
@keyframes ripple-anim {
  to { transform: scale(30); opacity: 0; }
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--r-pill);
  font-size: .9rem; font-weight: 500; letter-spacing: .01em;
  transition: transform .1s, box-shadow .2s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; pointer-events: none; }

.btn-primary {
  background: var(--accent); color: #0b0b10;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 0 0 8px var(--accent-dim), var(--glow); }

.btn-ghost {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-2); }

.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { box-shadow: 0 0 0 8px var(--danger-dim); }

.btn-full { width: 100%; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); transition: background .15s, color .15s, border-color .15s, transform .1s, box-shadow .2s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }
.btn-icon:active { transform: scale(.9); }
.btn-icon.active {
  background: var(--accent-dim); color: var(--accent);
  border-color: rgba(80,200,120,.4); box-shadow: 0 0 0 4px var(--accent-dim);
}
.btn-icon.danger {
  background: var(--danger-dim); color: var(--danger);
  border-color: rgba(255,71,87,.3);
}

/* ── Viewer page layout ──────────────────────────────────────────────────── */
.page-viewer {
  display: flex; flex-direction: column; height: 100vh;
  overflow: hidden;
}

.viewer-header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,11,16,.7);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.logo {
  display: flex; align-items: center; gap: 10px;
}
.logo-mark {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--accent-dim); border: 1px solid rgba(80,200,120,.3);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.logo-text {
  font-size: .95rem; font-weight: 600; letter-spacing: -.01em;
  color: var(--text);
}

.live-badge {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: var(--r-pill);
  background: rgba(255,71,87,.12); border: 1px solid rgba(255,71,87,.3);
  color: #ff4757; font-size: .8rem; font-weight: 600; letter-spacing: .08em;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #ff4757; box-shadow: 0 0 0 3px rgba(255,71,87,.25);
  animation: pulse-dot 1.4s ease infinite;
}
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 3px rgba(255,71,87,.25); }
  50% { box-shadow: 0 0 0 6px rgba(255,71,87,.08); }
}

/* ── Standby view ────────────────────────────────────────────────────────── */
.standby-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}

.standby-center {
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  text-align: center;
}

.standby-orb {
  position: relative; width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
}
.orb-core {
  width: 80px; height: 80px; border-radius: var(--r-xl);
  background: var(--surface-2); border: 1px solid rgba(80,200,120,.25);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); box-shadow: 0 0 32px var(--accent-dim), inset 0 1px 0 rgba(255,255,255,.05);
  z-index: 2; position: relative;
}
.orb-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(80,200,120,.2); animation: orb-pulse 3s ease infinite;
}
.orb-ring.r1 { width: 100px; height: 100px; animation-delay: 0s; }
.orb-ring.r2 { width: 130px; height: 130px; animation-delay: .7s; }
.orb-ring.r3 { width: 160px; height: 160px; animation-delay: 1.4s; }
@keyframes orb-pulse {
  0% { transform: scale(.9); opacity: .6; }
  50% { transform: scale(1); opacity: .25; }
  100% { transform: scale(.9); opacity: .6; }
}

.standby-title {
  font-size: 2.4rem; font-weight: 300; letter-spacing: -.04em;
  color: var(--text); line-height: 1.1;
}
.standby-sub {
  font-size: 1rem; color: var(--text-2); font-weight: 400;
  margin-top: -18px;
}

.wave-container {
  margin-top: 8px;
}
.wave-canvas { display: block; opacity: .6; }

/* ── Live viewer grid ────────────────────────────────────────────────────── */
.live-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; z-index: 1;
}

.live-grid {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: center;
  max-width: 1400px; width: 100%;
}

/* ── Video tile ──────────────────────────────────────────────────────────── */
.video-tile {
  position: relative; border-radius: var(--r-lg);
  overflow: hidden; background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .2s var(--ease-out), box-shadow .2s;
  flex-shrink: 0;
}
.video-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.video-tile video {
  display: block; width: 100%; height: 100%;
  object-fit: cover; background: var(--surface);
}

.video-tile .tile-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 28px 14px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  display: flex; align-items: center; gap: 8px;
}
.tile-name {
  font-size: .82rem; font-weight: 500; color: #fff; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-role-badge {
  font-size: .68rem; font-weight: 600; letter-spacing: .06em; padding: 2px 7px;
  border-radius: var(--r-pill); text-transform: uppercase;
}
.tile-role-badge.host { background: rgba(80,200,120,.25); color: var(--accent); }
.tile-role-badge.guest { background: rgba(91,142,240,.25); color: var(--blue); }

.tile-no-video {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: var(--surface-2);
}
.tile-avatar {
  width: 64px; height: 64px; border-radius: var(--r);
  background: var(--surface-3); border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 600; color: var(--text-2);
}
.tile-muted-badge {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,71,87,.85); display: flex; align-items: center; justify-content: center;
}

/* ── Producer modal ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.75); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } }

.modal-card {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-xl); padding: 36px 32px 28px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 16px;
  position: relative;
  animation: slide-up .25s var(--ease-out);
}
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } }

.modal-close {
  position: absolute; top: 14px; right: 14px;
}

.modal-icon-wrap {
  width: 52px; height: 52px; border-radius: var(--r);
  background: var(--accent-dim); border: 1px solid rgba(80,200,120,.25);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}

.modal-title { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; }
.modal-desc { font-size: .85rem; color: var(--text-2); margin-top: -8px; }
.modal-hint { font-size: .75rem; color: var(--text-3); text-align: center; }
.modal-build { font-size: .7rem; color: var(--text-3); text-align: center; margin-top: -8px; letter-spacing: .05em; }

/* ── Form fields ─────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: .78rem; font-weight: 500; color: var(--text-2); letter-spacing: .02em; }
.field-wrap { position: relative; }
.field-input {
  width: 100%; padding: 11px 44px 11px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font-size: .9rem;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.field-input:focus {
  border-color: rgba(80,200,120,.5);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field-input.error { border-color: rgba(255,71,87,.5); }
.field-input.error:focus { box-shadow: 0 0 0 3px var(--danger-dim); }
.field-reveal {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; background: none; border: none;
}
.field-error {
  font-size: .78rem; color: var(--danger); padding: 0 2px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.viewer-footer {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 10px; flex-shrink: 0;
}
.footer-hint { font-size: .72rem; color: var(--text-3); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
