/* Night School Live — the guest page. NS Player's own palette: warm near-black, one amber accent. */
:root {
  --bg: #0a0a0f; --surface: #111118; --surface-2: #17171f; --surface-3: #1f1f2a;
  --line: rgba(255,255,255,.07); --line-strong: rgba(255,255,255,.14);
  --text: #f3f0e8; --dim: #9a978d; --dim-2: #6b6960;
  --accent: #e8a838; --accent-hi: #f4bd55; --accent-soft: rgba(232,168,56,.14); --accent-ink: #1a1300;
  --live: #e0483f; --live-soft: rgba(224,72,63,.16); --ok: #35c46b;
  --bevel: inset 0 1px 0 rgba(255,255,255,.07), 0 1px 2px rgba(0,0,0,.55);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --bar: 56px; --ctl: 84px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; min-height: 100dvh; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.hidden { display: none !important; }
.mirror { transform: scaleX(-1); }
.eyebrow { margin: 0 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
h1 { font: 400 clamp(34px, 4.4vw, 48px)/1.04 var(--serif); letter-spacing: -.01em; margin: 0 0 14px; }
h1 em { font-style: italic; color: var(--accent-hi); }
.sub { color: var(--dim); margin: 0 0 22px; }

/* ---- brand bar --------------------------------------------------------------------------------- */
.brandbar { height: var(--bar); flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  padding-top: env(safe-area-inset-top); height: calc(var(--bar) + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font: 400 17px/1 var(--serif);
  color: var(--accent-ink); background: linear-gradient(160deg, var(--accent-hi), var(--accent)); box-shadow: var(--bevel); letter-spacing: .02em; }
.wordmark { font-weight: 650; font-size: 15.5px; letter-spacing: -.005em; white-space: nowrap; }
.wordmark .wm-b { font: italic 400 19px/1 var(--serif); color: var(--accent-hi); }
.bar-mid { flex: 1; display: flex; justify-content: center; }
.host-line { color: var(--dim); font-size: 13.5px; white-space: nowrap; }
.host-line b { color: var(--text); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 650;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim-2); }
.pill.on { background: var(--live); border-color: transparent; color: #fff; }
.pill.on .dot { background: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.screen { flex: 1 1 auto; min-height: 0; }

/* ---- setup ------------------------------------------------------------------------------------- */
.setup { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 44px; align-items: center;
  width: 100%; max-width: 1160px; margin: 0 auto; padding: 40px 32px; }
.preview { position: relative; aspect-ratio: 16 / 10; border-radius: 22px; overflow: hidden; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 30px 80px -30px rgba(0,0,0,.8); }
.preview video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.pv-off, .tile-off { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--dim);
  background: radial-gradient(120% 90% at 50% 30%, var(--surface-3), var(--surface)); }
.pv-off p { margin: 0; font-size: 14px; }
.initial { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font: 400 40px/1 var(--serif);
  color: var(--accent-ink); background: linear-gradient(160deg, var(--accent-hi), var(--accent)); }
.pv-msg { position: absolute; left: 16px; right: 16px; top: 16px; padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: rgba(20,12,10,.86); border: 1px solid rgba(224,72,63,.45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pv-tools { position: absolute; left: 0; right: 0; bottom: 20px; display: flex; justify-content: center; gap: 12px; }
.round { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.16);
  background: rgba(14,14,20,.55); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); color: #fff; }
.round:hover { background: rgba(30,30,40,.7); }
.round.off, .ctl.off { background: var(--live); border-color: transparent; color: #fff; }
.meter { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.06); }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), var(--accent-hi)); transform-origin: left; transform: scaleX(0); transition: transform .1s linear; }

.form-col h1 { margin-bottom: 26px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--dim); }
.field input, .field select { height: 50px; width: 100%; min-width: 0; padding: 0 14px; border-radius: 13px; background: var(--surface-2);
  border: 1px solid var(--line-strong); outline: none; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 36px; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 19px) 22px, calc(100% - 14px) 22px; background-size: 5px 5px; background-repeat: no-repeat; }
.field select:disabled { opacity: .75; cursor: default; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder { color: var(--dim-2); }
.nudge { animation: nudge .4s; border-color: var(--accent) !important; }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tip { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13.5px; margin: 4px 0 22px; }
.tip svg { width: 19px; height: 19px; color: var(--accent); }

.primary, .ghost, .danger { height: 48px; padding: 0 22px; border-radius: 14px; border: 1px solid transparent; font-weight: 650; font-size: 15.5px; }
.primary { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 24px -10px rgba(232,168,56,.6); }
.primary:hover { filter: brightness(1.05); }
.primary:disabled { opacity: .55; cursor: default; filter: none; }
.primary.big { width: 100%; height: 54px; font-size: 16.5px; }
.ghost { background: transparent; color: var(--dim); border-color: var(--line-strong); }
.ghost:hover { color: var(--text); background: rgba(255,255,255,.05); }
.danger { background: var(--live); color: #fff; }

/* ---- centred cards: home, waiting, end ---------------------------------------------------------- */
.card-screen { display: grid; place-items: center; padding: 32px 20px; }
.note-card { width: 100%; max-width: 470px; text-align: center; padding: 44px 36px; border-radius: 26px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 30px 80px -30px rgba(0,0,0,.8); }
.note-card .sub { margin-bottom: 26px; }
.note-card .sub:has(+ .hidden) { margin-bottom: 4px; }
.note-card h1 { font-size: clamp(32px, 4vw, 40px); }
.wait-face { position: relative; width: 120px; height: 120px; margin: 0 auto 26px; border-radius: 50%; }
.wait-face::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--accent); opacity: .6; animation: ring 2.2s ease-out infinite; }
@keyframes ring { from { transform: scale(.94); opacity: .7; } to { transform: scale(1.18); opacity: 0; } }
.wait-face video, .wait-face .initial { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.wait-face .initial { font-size: 52px; z-index: -0; }
.wait-face video { z-index: 1; background: #000; }
.dots { display: flex; gap: 7px; justify-content: center; margin: -6px 0 26px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* ---- the studio -------------------------------------------------------------------------------- */
.call { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; min-height: 0; height: calc(100dvh - var(--bar) - env(safe-area-inset-top)); }
.call-main { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 0; min-height: 0; }
.show { position: relative; flex: 1 1 auto; min-height: 0; border-radius: 18px; overflow: hidden; background: #050508; border: 1px solid var(--line); }
.show video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.show:not(.live) video { visibility: hidden; }
.show-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; color: var(--dim); }
.show-empty p:last-child { margin: 0; font: italic 400 24px/1.25 var(--serif); color: var(--text); max-width: 420px; }
.show.live .show-empty { display: none; }

.tiles { flex: 0 0 auto; height: 148px; display: flex; gap: 10px; justify-content: center; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tiles::-webkit-scrollbar { display: none; }
.tile { position: relative; flex: 0 0 auto; height: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--line); transition: box-shadow .2s; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .initial { width: 54px; height: 54px; font-size: 26px; }
.tile.talking { box-shadow: 0 0 0 2px var(--accent), 0 0 24px -4px rgba(232,168,56,.5); }
.tile .tag { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 5px; padding: 4px 9px;
  border-radius: 8px; font-size: 12.5px; font-weight: 600; background: rgba(8,8,12,.62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tile .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .muted-ico { width: 14px; height: 14px; color: #ff8b82; display: none; }
.tile.mic-off .muted-ico { display: block; }
.tile .on-show { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 750;
  letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--live); display: none; }
.tile.show-on .on-show { display: block; }

.controls { grid-column: 1; grid-row: 2; display: flex; justify-content: center; gap: 6px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.ctl { position: relative; width: 74px; height: 60px; display: grid; justify-items: center; align-content: center; gap: 4px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 11.5px; font-weight: 600; box-shadow: var(--bevel); }
.ctl:hover { background: var(--surface-3); }
.ctl.leave { color: #ff8b82; }
.ctl.leave:hover { background: var(--live-soft); }
.badge { position: absolute; top: 5px; right: 13px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-weight: 750; background: var(--accent); color: var(--accent-ink); }
body.chat-open #cChat { background: var(--accent-soft); border-color: rgba(232,168,56,.4); color: var(--accent-hi); }

/* backstage chat: a column on wide screens, a panel over the studio otherwise */
.chat { display: none; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
body.chat-open .chat { display: flex; }
.chat header { display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 18px; border-bottom: 1px solid var(--line); }
.chat header div { flex: 1; display: grid; }
.chat header small { color: var(--dim); font-size: 12px; }
.icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: none; border: 0; color: var(--dim); }
.icon:hover { background: rgba(255,255,255,.07); color: var(--text); }
.msgs { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.msgs-empty { color: var(--dim); font-size: 13.5px; text-align: center; margin: auto 10px; }
.msg { max-width: 86%; align-self: flex-start; margin-top: 10px; }
.msg.cont { margin-top: 2px; } .msg.cont .who { display: none; }
.msg .who { font-size: 12px; font-weight: 650; color: var(--dim); margin: 0 0 4px 4px; display: flex; align-items: center; gap: 6px; }
.msg .chip { font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent); border-radius: 5px; padding: 1px 5px; }
.msg .body { padding: 9px 13px; border-radius: 15px; background: var(--surface-3); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.msg.host .body { background: var(--accent-soft); border: 1px solid rgba(232,168,56,.25); }
.msg.mine { align-self: flex-end; }
.msg.mine .who { justify-content: flex-end; margin-right: 4px; }
.msg.mine .body { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); }
#chatForm { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
#chatIn { flex: 1; min-width: 0; height: 46px; padding: 0 15px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line-strong); outline: none; font-size: 16px; }
#chatIn:focus { border-color: var(--accent); }
.icon.send { width: 46px; height: 46px; background: var(--accent); color: var(--accent-ink); border-radius: 13px; }
.icon.send:hover { background: var(--accent-hi); color: var(--accent-ink); }

@media (min-width: 1100px) {
  body.chat-open .call { grid-template-columns: minmax(0, 1fr) 360px; }
  .chat { grid-column: 2; grid-row: 1 / 3; }
}
@media (max-width: 1099.98px) {
  .chat { position: fixed; z-index: 30; top: calc(var(--bar) + env(safe-area-inset-top)); right: 0; bottom: 0; width: min(380px, 100%); box-shadow: -30px 0 60px -20px rgba(0,0,0,.7); }
}

/* ---- sheets, toasts, sound gate ---------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet { width: 100%; max-width: 420px; padding: 26px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 40px 100px -20px rgba(0,0,0,.9); }
.sheet h2 { margin: 0 0 18px; font: 400 30px/1.1 var(--serif); }
.sheet .sub { margin-top: -8px; }
.sheet-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.toasts { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(var(--ctl) + 16px + env(safe-area-inset-bottom));
  display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
body:not([data-screen="scrCall"]) .toasts { bottom: 24px; }
.toast { pointer-events: auto; padding: 12px 16px; border-radius: 14px; font-size: 14px; background: rgba(24,24,32,.92); border: 1px solid var(--line-strong);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 16px 40px -14px rgba(0,0,0,.8); overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; animation: up .25s ease-out; transition: opacity .3s, transform .3s; }
.toast.tap { cursor: pointer; }
.toast.live { border-color: rgba(224,72,63,.6); background: rgba(60,16,14,.94); }
.toast.warn { border-color: rgba(232,168,56,.5); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }
.sound-gate { position: fixed; z-index: 45; top: calc(var(--bar) + 18px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 20px; border-radius: 999px; border: 0; font-weight: 700; background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 30px -8px rgba(232,168,56,.6); }

/* ---- phones ------------------------------------------------------------------------------------ */
@media (max-width: 760px) {
  :root { --bar: 52px; --ctl: 76px; }
  .brandbar { padding-left: 14px; padding-right: 14px; gap: 10px; }
  .host-line { display: none; }
  .bar-mid { justify-content: flex-end; }
  .setup { grid-template-columns: 1fr; gap: 22px; padding: 16px 16px 28px; align-items: start; }
  .preview { aspect-ratio: 4 / 3; border-radius: 18px; }
  h1 { font-size: 34px; }
  .form-col h1 { margin-bottom: 18px; }
  .note-card { padding: 34px 22px; }
  .call-main { padding: 10px 10px 0; gap: 10px; overflow-y: auto; }
  .show { flex: 0 0 auto; aspect-ratio: 16 / 9; border-radius: 14px; }
  .tiles { height: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; overflow: visible; padding-bottom: 10px; }
  .tiles[data-n="1"] { grid-template-columns: minmax(0, 60%); justify-content: center; }
  .tile { height: auto; aspect-ratio: 4 / 3; border-radius: 12px; }
  .controls { gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .ctl { width: auto; flex: 1 1 0; max-width: 72px; height: 56px; font-size: 10.5px; border-radius: 13px; }
  .chat { width: 100%; }
  .scrim { align-items: end; padding: 0; }
  .sheet { max-width: none; border-radius: 22px 22px 0 0; padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
}
/* phone on its side: the show fills, the guests in a column beside it */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --bar: 44px; --ctl: 62px; }
  .host-line { display: none; }
  .call-main { flex-direction: row; padding: 8px 8px 0; overflow: hidden; }
  .show { flex: 1 1 auto; aspect-ratio: auto; height: 100%; }
  .tiles { display: flex; flex-direction: column; width: 150px; height: 100%; overflow-y: auto; padding: 0; }
  .tile { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .controls { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .ctl { height: 46px; width: 64px; } .ctl span { display: none; }
  .setup { grid-template-columns: 1fr 1fr; gap: 20px; padding: 12px 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
