:root {
  --bg: #0b0d12; --panel: #12151c; --card: #171b24; --line: #252b38;
  --text: #eef1f6; --muted: #8b93a5; --accent: #fe2c55; --accent2: #25f4ee; --ok: #2ecc71;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#app { display: grid; grid-template-columns: 420px 1fr; height: 100vh; }

#panel { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 17px; margin: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #444; flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.card.grow { min-height: 220px; }
h2 { font-size: 13px; margin: 0 0 2px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > input { flex: 1; }
input, select, textarea, button { font: inherit; font-size: 13px; }
input, select, textarea { background: #0e1117; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; width: 100%; }
textarea { resize: vertical; margin-top: 6px; line-height: 1.4; }
input[type=range] { padding: 0; }
input[type=checkbox] { width: auto; flex: none; margin: 0; }
label.check { justify-content: flex-start; }
button { background: #232a38; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { filter: brightness(1.2); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; flex: 1; }
button.danger { background: #3a1820; border-color: #6b2232; }
button.ghost { background: transparent; }
button.small { padding: 5px 8px; font-size: 12px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }
.steps { padding-left: 18px; margin: 4px 0 0; line-height: 1.5; }
summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.pill { background: #232a38; border-radius: 99px; padding: 2px 8px; font-size: 11px; text-transform: none; letter-spacing: 0; }

#comments { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 300px; display: flex; flex-direction: column; gap: 6px; }
#comments li { background: #0e1117; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
#comments li .body { flex: 1; }
#comments li b { color: var(--accent2); font-weight: 600; }
#comments li.answered { opacity: .45; }
#comments li.blocked { opacity: .3; text-decoration: line-through; }
#comments li.queued { border-color: #3b4a66; }
#comments li.event b { color: #ffcc4d; }

/* ---------- Stage ---------- */
#stageWrap { display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at center, #141824, #07080b); }
#stage { position: relative; height: min(92vh, 1100px); aspect-ratio: 9 / 16; background: #000; border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#avatarVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
#placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); background: #07080b; }
#placeholder.hidden { display: none; }
.ring { width: 64px; height: 64px; border-radius: 50%; border: 3px solid #222; border-top-color: var(--accent); }
.ring.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.aiBadge { position: absolute; top: 14px; left: 14px; background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.25); padding: 5px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; backdrop-filter: blur(6px); }
.timer, .viewers { position: absolute; top: 14px; right: 14px; background: rgba(0,0,0,.55); padding: 5px 10px; border-radius: 99px; font-size: 13px; font-variant-numeric: tabular-nums; }
.viewers { top: 48px; }
.hidden { display: none !important; }

.onAir { position: absolute; left: 14px; right: 14px; top: 58%; background: rgba(255,255,255,.95); color: #111; border-radius: 14px; padding: 10px 14px; font-size: 17px; line-height: 1.3; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.onAir b { color: var(--accent); display: block; font-size: 13px; }
.caption { position: absolute; left: 16px; right: 16px; bottom: 8%; text-align: center; font-size: 22px; font-weight: 600; line-height: 1.3; text-shadow: 0 2px 6px #000, 0 0 2px #000; min-height: 1em; }
#toasts { position: absolute; left: 14px; bottom: 28%; display: flex; flex-direction: column; gap: 6px; }
.toast { background: rgba(254,44,85,.9); padding: 6px 12px; border-radius: 99px; font-size: 14px; font-weight: 600; animation: pop 5s forwards; }
@keyframes pop { 0% { opacity: 0; transform: translateY(8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* Stage-only view for clean window capture */
body.stageOnly #app { grid-template-columns: 1fr; }
body.stageOnly #panel { display: none; }
body.stageOnly #stageWrap { padding: 0; background: #000; }
body.stageOnly #stage { height: 100vh; border-radius: 0; box-shadow: none; }

.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(5,6,9,.92); }
.gate form { width: 320px; }

/* Emma mode: green overlay for OBS chroma key */
body.emma #stage { background: #00ff00; }
body.emma #avatarVideo, body.emma #placeholder, body.emma #timer, body.emma .caption { display: none !important; }
body.emma #nuancePanel { display: none; }
body.emma #steerCard { display: none; }
.levelBar { position: absolute; bottom: 10px; right: 14px; width: 80px; height: 6px; background: rgba(0,0,0,.4); border-radius: 3px; overflow: hidden; }
.levelBar i { display: block; height: 100%; width: 0; background: #fff; }
body.stageOnly .levelBar { display: none; }
