* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0c12;
  --bg2: #0f131c;
  --panel: #11151f;
  --panel2: #161b27;
  --line: #232a3a;
  --line2: #2e3850;
  --txt: #eef1f7;
  --muted: #8893a8;
  --faint: #5a6478;
  --accent: #00e5c7;       /* electric teal */
  --accent-dim: #0a8f80;
  --live: #ff5d73;         /* coral — speaking */
  --amber: #ffc24b;
  --glow: 0 0 0 1px rgba(0,229,199,.4), 0 0 24px rgba(0,229,199,.22);
  font-synthesis: none;
}

html, body {
  height: 100%;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(0,229,199,.08), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(255,93,115,.07), transparent 55%),
    var(--bg);
  color: var(--txt);
  font-family: 'Sora', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: 100vh;
  transition: grid-template-columns .45s cubic-bezier(.7,0,.2,1);
}

/* Presentation mode — Alice fills the whole viewport, keyboard-driven.
   stage-wrap becomes a fixed full-viewport overlay so grid/overflow can't offset it. */
#app.present { grid-template-columns: 1fr 0; }
#app.present #panel { opacity: 0; pointer-events: none; }
#app.present #stage-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 0;
  background: #000;
}
#app.present #stage {
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  border-radius: 0;
  box-shadow: none;
}
/* In present mode the on-stage chrome hides; the HUD takes over */
#app.present #status-chip,
#app.present #seg-counter,
#app.present #fs-btn { opacity: 0; pointer-events: none; }
#app.present #present-hud.show { opacity: 1; }

/* ── 9:16 broadcast stage ── */
#stage-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  min-width: 0;
  position: relative;
}

#stage {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(100%, calc(100vh - 56px));
  max-width: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(160deg, #11151f, #0a0c12);
  box-shadow:
    0 0 0 1px var(--line2),
    0 30px 80px -20px rgba(0,0,0,.8),
    inset 0 0 120px rgba(0,0,0,.4);
}

#avatar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;   /* June HR ships its own background — fill the 9:16 frame */
  opacity: 0;
  transition: opacity .6s ease;
}
#avatar-video.active { opacity: 1; }

#stage-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .3px;
}
#stage-placeholder.hidden { display: none; }

.loader {
  width: 38px; height: 38px;
  border: 2px solid var(--line2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#stage-top {
  position: absolute;
  top: 16px; left: 16px; right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 3;
}

#status-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  background: rgba(10,12,18,.6);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line2);
  border-radius: 100px;
  font-size: 12px;
  letter-spacing: .4px;
  text-transform: uppercase;
}
#status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
  transition: background .3s, box-shadow .3s;
}
#status-dot.ready { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
#status-dot.connecting { background: var(--amber); animation: blink 1.1s infinite; }
#status-dot.speaking { background: var(--live); box-shadow: 0 0 12px var(--live); animation: blink .8s infinite; }
#status-dot.listening { background: var(--accent); animation: blink .7s infinite; }
#status-dot.error { background: var(--live); }
@keyframes blink { 50% { opacity: .35; } }

#seg-counter {
  padding: 8px 14px;
  background: rgba(10,12,18,.6);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line2);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--accent);
}

#fs-btn {
  position: absolute;
  bottom: 16px; right: 16px; z-index: 3;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: rgba(10,12,18,.6);
  backdrop-filter: blur(14px);
  color: var(--txt);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
#fs-btn svg { width: 20px; height: 20px; }
#fs-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Full-screen HUD (present mode) ── */
#present-hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  padding: 60px 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(to top, rgba(0,0,0,.78), transparent);
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
#hud-now, #hud-next {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .2px;
  text-shadow: 0 2px 12px rgba(0,0,0,.7);
}
#hud-next { color: var(--muted); font-size: 15px; font-weight: 500; }
.hud-k {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-right: 8px;
  vertical-align: middle;
}
#hud-next .hud-k { color: var(--faint); }
#hud-keys {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: .6px;
  color: var(--faint);
  text-transform: uppercase;
}

/* ── Operator panel ── */
#panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-width: 0;
  transition: opacity .35s;
}

#panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}
#panel-head h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -.5px;
  display: flex; align-items: center; gap: 10px;
}
.tag {
  font-family: 'Sora', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 3px 8px;
  border-radius: 6px;
}
.panel-sub { color: var(--faint); font-size: 12px; margin-top: 4px; letter-spacing: .3px; }

#voice-toggle {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: var(--panel2);
  color: var(--muted);
  cursor: pointer;
  font-family: 'Sora', sans-serif;
  font-size: 10px;
  letter-spacing: .5px;
  text-transform: uppercase;
  transition: all .2s;
}
#voice-toggle svg { width: 18px; height: 18px; }
#voice-toggle:hover { border-color: var(--line2); color: var(--txt); }
#voice-toggle.voice-on {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--glow);
}

#voice-banner {
  margin: 12px 22px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(0,229,199,.08);
  border: 1px solid var(--accent-dim);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px;
}
#voice-banner.hidden { display: none; }
#voice-banner::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); animation: blink .7s infinite;
}

/* Segment list */
#seg-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seg {
  position: relative;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 14px;
  padding: 13px 15px 13px 16px;
  cursor: pointer;
  transition: all .18s;
  overflow: hidden;
}
.seg::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent;
  transition: background .18s;
}
.seg:hover { border-color: var(--line2); background: #1a2030; }

.seg-top { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.seg-num {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--faint);
  min-width: 22px;
}
.seg-slide {
  font-size: 10px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0,229,199,.08);
  padding: 2px 7px;
  border-radius: 5px;
}
.seg-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--txt);
  flex: 1;
}
.seg-preview {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.seg.current {
  border-color: var(--accent);
  background: linear-gradient(100deg, rgba(0,229,199,.10), rgba(0,229,199,.02));
  box-shadow: var(--glow);
}
.seg.current::before { background: var(--accent); }
.seg.current .seg-num { color: var(--accent); }

.seg.done { opacity: .55; }
.seg.done .seg-num::after { content: ' ✓'; color: var(--accent-dim); }

.seg.suggested {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(255,194,75,.4), 0 0 18px rgba(255,194,75,.18);
}
.seg.suggested::before { background: var(--amber); }

.seg.speaking .seg-num {
  color: var(--live);
}

/* Footer controls */
#panel-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.foot-row { display: flex; gap: 10px; }
.ctrl-sm {
  flex: 1;
  padding: 11px;
  border-radius: 11px;
  border: 1px solid var(--line2);
  background: var(--panel2);
  color: var(--muted);
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s;
}
.ctrl-sm:hover:not(:disabled) { color: var(--txt); border-color: var(--faint); }
.ctrl-sm:disabled { opacity: .4; cursor: not-allowed; }

.ctrl-next {
  padding: 17px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #04110f;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .2px;
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 10px 30px -8px rgba(0,229,199,.6);
}
.ctrl-next:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 36px -8px rgba(0,229,199,.75); }
.ctrl-next:active:not(:disabled) { transform: translateY(0); }
.ctrl-next:disabled { background: var(--panel2); color: var(--faint); box-shadow: none; cursor: not-allowed; }
.ctrl-next.speaking {
  background: var(--live);
  color: #fff;
  box-shadow: 0 10px 30px -8px rgba(255,93,115,.6);
}
.ctrl-next.finished { background: var(--panel2); color: var(--accent); border: 1px solid var(--accent-dim); box-shadow: none; }

/* ── Start overlay ── */
#start-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 600px at 70% 10%, rgba(0,229,199,.14), transparent 55%),
    radial-gradient(700px 500px at 20% 90%, rgba(255,93,115,.10), transparent 50%),
    var(--bg);
  transition: opacity .5s;
}
#start-overlay.hidden { opacity: 0; pointer-events: none; }
#start-content { text-align: center; padding: 40px; }

.brand-mark {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 6px;
  color: var(--accent);
  margin-bottom: 22px;
  opacity: 0;
  animation: rise .7s .05s forwards;
}
#start-content h1 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: clamp(38px, 7vw, 76px);
  line-height: .98;
  letter-spacing: -1.5px;
  margin-bottom: 18px;
  opacity: 0;
  animation: rise .7s .15s forwards;
}
.sub {
  font-size: 18px; color: var(--muted); letter-spacing: .3px; margin-bottom: 6px;
  opacity: 0; animation: rise .7s .28s forwards;
}
.sub .accent { color: var(--accent); font-weight: 600; }
.hint {
  font-size: 13px; color: var(--faint); letter-spacing: .5px; margin-bottom: 38px;
  opacity: 0; animation: rise .7s .38s forwards;
}
#start-btn {
  padding: 17px 52px;
  border: none; border-radius: 100px;
  background: var(--accent); color: #04110f;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 17px; font-weight: 800; letter-spacing: .3px;
  cursor: pointer;
  box-shadow: 0 14px 40px -10px rgba(0,229,199,.6);
  transition: transform .2s, box-shadow .2s;
  opacity: 0; animation: rise .7s .5s forwards;
}
#start-btn:hover { transform: translateY(-2px); box-shadow: 0 20px 50px -10px rgba(0,229,199,.8); }
.micnote {
  margin-top: 18px; font-size: 12px; color: var(--faint); letter-spacing: .3px;
  opacity: 0; animation: rise .7s .62s forwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(15,19,28,.96);
  border: 1px solid var(--line2);
  color: var(--txt);
  padding: 13px 22px; border-radius: 100px;
  font-size: 13px; letter-spacing: .3px;
  opacity: 0; transition: all .3s; pointer-events: none; z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }

@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr 360px; }
}
