:root {
  --bg: #07070b;
  --bg2: #0d0d14;
  --panel: #13131c;
  --panel2: #1a1a26;
  --line: #262636;
  --text: #f1f0f6;
  --muted: #9a99ad;
  --blue: #33d1ff;
  --pink: #ff3d7f;
  --gold: #ffd34d;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 50% -200px, #1b1030 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  min-height: 100vh;
}
svg { display: block; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 11, .75); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo { width: 36px; height: 36px; filter: drop-shadow(0 0 10px rgba(51, 209, 255, .45)); }
.wordmark { font-family: "Bebas Neue", Impact, sans-serif; font-size: 32px; letter-spacing: 1.2px; line-height: 1; }
.w-robo { color: var(--blue); text-shadow: 0 0 14px rgba(51, 209, 255, .55); }
.w-comedian { color: var(--pink); text-shadow: 0 0 14px rgba(255, 61, 127, .55); }
.w-com { color: var(--gold); font-size: 22px; margin-left: 2px; }
.tagline { color: var(--muted); font-size: 14px; padding-left: 18px; border-left: 1px solid var(--line); }
.onair {
  margin-left: auto; font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.onair.on { color: #fff; background: #e0144f; border-color: #e0144f; box-shadow: 0 0 18px rgba(255, 61, 127, .6); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 4px rgba(255, 61, 127, .3); } }

/* ---- layout ---- */
.layout {
  max-width: 1440px; margin: 0 auto; padding: 22px 28px 10px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px;
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--muted); margin: 0 0 12px; font-weight: 600; }

/* ---- stage ---- */
.stage {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: #000; border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .02) inset;
}
#stage { width: 100%; height: 100%; display: block; }
.curtain {
  position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none;
  background: repeating-linear-gradient(90deg, #4a0716 0 14px, #6d0c22 14px 26px, #3b0511 26px 34px);
  box-shadow: inset -20px 0 40px rgba(0, 0, 0, .55);
}
.curtain.left { left: 0; border-radius: 0 0 60% 0 / 0 0 12% 0; }
.curtain.right { right: 0; transform: scaleX(-1); border-radius: 0 0 60% 0 / 0 0 12% 0; }
.valance {
  position: absolute; left: 0; right: 0; top: 0; height: 7%; pointer-events: none;
  background: repeating-linear-gradient(90deg, #5a0a1b 0 18px, #7a0f27 18px 30px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  border-bottom: 3px solid #b8892c;
}
.caption {
  position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%);
  max-width: 76%; padding: 10px 18px; border-radius: 12px; text-align: center;
  background: rgba(7, 7, 11, .78); backdrop-filter: blur(6px); border: 1px solid rgba(255, 255, 255, .08);
  font-size: clamp(14px, 1.5vw, 19px); line-height: 1.4; font-weight: 500;
}
.caption .who { display: block; font-family: "Bebas Neue", Impact, sans-serif; font-size: 1.05em; letter-spacing: 1.4px; margin-bottom: 2px; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
  background: var(--bg); font-size: 15px; letter-spacing: .5px;
}
.loading.done { opacity: 0; pointer-events: none; transition: opacity .6s; }

/* ---- controls ---- */
.controls { margin-top: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.row > * { flex-shrink: 0; }
.spacer { flex: 1 1 auto; }
input[type=text] {
  flex: 1 1 auto; min-width: 120px; height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; font-size: 15px;
}
input[type=text]:focus, select:focus { outline: 2px solid rgba(51, 209, 255, .5); outline-offset: 1px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; height: 44px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; height: 100%; padding: 0 14px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg input:checked + span { background: var(--panel2); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset; }
.seg input[value=adult]:checked + span { color: var(--pink); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .08s, filter .15s, background .15s;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #3fd8ff, #1aa9d6); color: #001520; box-shadow: 0 6px 20px rgba(51, 209, 255, .25); }
.btn.hot { background: linear-gradient(180deg, #ff5a92, #e0144f); color: #fff; box-shadow: 0 6px 20px rgba(255, 61, 127, .25); }
.btn.primary:hover:not(:disabled), .btn.hot:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--panel2); color: var(--text); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: #222232; }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); cursor: pointer; height: 44px; }
.toggle input { position: absolute; opacity: 0; }
.toggle .track { width: 38px; height: 22px; border-radius: 999px; background: #2a2a3a; position: relative; transition: background .2s; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .track { background: var(--blue); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid rgba(51, 209, 255, .6); outline-offset: 2px; }
.field { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); margin-left: 10px; height: 44px; }
select { height: 38px; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 14px; }

.heckle { margin-top: 12px; padding: 10px 10px 10px 16px; display: flex; gap: 10px; align-items: center; border-color: rgba(255, 61, 127, .25); }
.heckle input { background: transparent; border-color: transparent; min-width: 0; }
.show, .side { min-width: 0; }
.mic-icon { font-size: 20px; }
.mic-btn { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.mic-btn svg { width: 20px; height: 20px; }
.mic-btn.on { background: var(--pink); border-color: var(--pink); color: #fff; animation: micpulse 1.2s infinite; }
@keyframes micpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 61, 127, .6); } 50% { box-shadow: 0 0 0 8px rgba(255, 61, 127, 0); } }
.hint { color: var(--muted); font-size: 13px; margin: 10px 4px 0; }
#buffer { color: var(--blue); }

/* ---- side ---- */
.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.lineup { padding: 18px; }
.cast { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid transparent; transition: background .2s, border-color .2s; }
.cast + .cast { margin-top: 6px; }
.cast.talking { background: var(--panel2); border-color: var(--line); }
.cast .badge { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-family: "Bebas Neue", Impact, sans-serif; font-size: 22px; color: #07070b; }
.cast .name { font-family: "Bebas Neue", Impact, sans-serif; font-size: 22px; letter-spacing: 1.2px; line-height: 1; }
.cast .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.cast .info { min-width: 0; flex: 1 1 auto; }
.cast .story { font-size: 12px; color: #c9c8d8; margin-top: 4px; line-height: 1.35; }
.cast.busy .story { color: var(--blue); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.cast-actions { display: flex; flex-direction: column; gap: 6px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover:not(:disabled) { background: #26263a; border-color: currentColor; }
.icon-btn:disabled { opacity: .5; cursor: progress; }
.cast { align-items: flex-start; }
.cast .eq { margin-left: auto; align-self: center; display: flex; gap: 3px; align-items: flex-end; height: 18px; opacity: 0; transition: opacity .2s; }
.cast.talking .eq { opacity: 1; }
.cast .eq i { width: 3px; background: currentColor; border-radius: 2px; animation: eq .7s infinite ease-in-out; }
.cast .eq i:nth-child(2) { animation-delay: .15s; } .cast .eq i:nth-child(3) { animation-delay: .3s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }
.heckler-voice { font-size: 12px; color: var(--muted); margin-top: 10px; padding-left: 10px; }

.transcript { padding: 18px; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 300px; }
#log { overflow-y: auto; flex: 1 1 0; min-height: 0; max-height: 52vh; padding-right: 4px; }
#log .empty { color: var(--muted); font-size: 14px; }
.line { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.line b { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; letter-spacing: 1px; font-size: 16px; margin-right: 6px; }
.line.audience { color: #b7e4a0; font-style: italic; }
.line.audience b { color: #b7e4a0; font-style: normal; }
.line.sys { color: var(--muted); font-size: 13px; }

.foot { text-align: center; color: #5d5c70; font-size: 12px; padding: 18px; }

/* ---- smaller screens ---- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  #log { max-height: 40vh; }
}
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .tagline { display: none; }
  .layout { padding: 14px 16px; }
  .row { flex-wrap: wrap; }
  .row input[type=text] { flex-basis: 100%; }
  .spacer { display: none; }
  .field { margin-left: 0; }
  .heckle { padding-left: 10px; }
  .mic-icon { display: none; }
  .seg { flex: 1 1 100%; }
  .seg label { flex: 1; }
  .seg span { justify-content: center; }
}

/* ---- persona library ---- */
.pdialog { width: min(920px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 40px 120px rgba(0,0,0,.7); }
.pdialog::backdrop { background: rgba(4, 4, 8, .7); backdrop-filter: blur(4px); }
.pdialog[open] { display: flex; flex-direction: column; }
.pd-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.pd-head h2 { margin: 0; font-size: 13px; color: var(--text); }
.pd-sub { color: var(--muted); font-size: 13px; }
.pd-head .icon-btn { margin-left: auto; }
.pd-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; flex: 1 1 auto; }
.plist { overflow-y: auto; border-right: 1px solid var(--line); padding: 10px; max-height: 600px; }
.pitem { display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; color: var(--text); cursor: pointer; font: inherit; }
.pitem + .pitem { margin-top: 4px; }
.pitem:hover { background: var(--panel2); }
.pitem.sel { background: var(--panel2); border-color: rgba(51, 209, 255, .45); }
.ptag { display: block; font-weight: 600; font-size: 14px; line-height: 1.3; }
.pmeta { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.pdetail { padding: 20px 24px; overflow-y: auto; max-height: 600px; }
.pdetail h3 { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; font-size: 30px; letter-spacing: 1px; margin: 0 0 8px; line-height: 1.05; }
.pdetail h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }
.pdetail p { margin: 0; font-size: 14px; line-height: 1.55; color: #dcdbe8; }
.pdetail ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.6; color: #dcdbe8; }
.pd-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn.danger { color: #ff8fae; margin-left: auto; }
@media (max-width: 760px) {
  .pd-body { grid-template-columns: 1fr; }
  .plist { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .pd-sub { display: none; }
}

/* Collapsible side panels (lineup, transcript): collapsed by default, click the title to open. */
.fold { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; }
.fold::before { content: "\25B8"; font-size: .8em; transition: transform .15s; }
.panel:not(.collapsed) > .fold::before { transform: rotate(90deg); }
.panel.collapsed > :not(.fold) { display: none !important; }
.panel.collapsed > .fold { margin-bottom: 0; }
.transcript.collapsed { min-height: 0; flex: 0 0 auto; }

/* Event details panel (testing only) */
.context { padding: 18px; margin-top: 16px; }

.context label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.context input, .context textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: inherit; resize: vertical; }
.ctx-hint { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
#ctx-clear { margin-top: 12px; }
#ctx-clear.armed { background: var(--pink); color: #fff; }
.photos { display: grid; gap: 8px; margin: 6px 0 8px; }
.photo-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; }
.photo-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: rgba(0,0,0,.3); }
.photo-row button { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.photo-row button:hover { color: var(--pink); }
.photo-row input.need { border-color: var(--pink); }
.photo-msg { color: var(--pink); }
.char-count { font-size: 12px; color: var(--muted); text-align: right; min-height: 0; margin-top: 2px; }
.mic-btn[hidden], .mic-icon[hidden] { display: none; }

/* ---- click-a-robot color picker ---- */
#stage { cursor: pointer; }
.paint { position: absolute; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px;
  background: rgba(13, 13, 20, .92); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); transform: translate(-50%, -110%); }
.paint[hidden] { display: none; }
.paint-name { font-family: "Bebas Neue", Impact, sans-serif; letter-spacing: 1.2px; font-size: 18px; }
.paint input[type=color] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.paint .btn { padding: 6px 10px; font-size: 13px; }
.paint-x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 2px; }
