/* Layout: player and transcript side by side, controls under them, then a tabbed workbench.
   One dark "neon night" look by choice, matching the scenes on the canvas. */
:root {
  --night: #120d1f;
  --panel: #1d1530;
  --panel-2: #251b3d;
  --line: #3a2d57;
  --text: #f4eefc;
  --muted: #b3a6cc;
  --pink: #ff4fa3;
  --sun: #ffb347;
  --teal: #2fe0c8;
  --ok: #2ecc71;
  --warn: #f5b82e;
  --bad: #ff5a5a;
  --f-display: "Play", "Commissioner", system-ui, sans-serif;
  --f-body: "Commissioner", system-ui, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--night); color: var(--text); margin: 0; }
body { font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
a { color: var(--teal); }

.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-block: 24px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 16px;
}

.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
h1 {
  font-family: var(--f-display); font-weight: 700; margin: 0; line-height: 1.1;
  font-size: clamp(30px, 5vw, 46px); text-wrap: balance;
  background: linear-gradient(90deg, var(--pink), var(--sun));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2, h3 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .02em; }
.sub { margin: 4px 0 0; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

.player { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.stage { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; min-width: 0; }
.stage:fullscreen { border: 0; border-radius: 0; display: grid; place-items: center; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; max-width: 100%; cursor: pointer; }
.stage:fullscreen canvas { height: 100%; object-fit: contain; }

.transcript {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; max-height: 100%;
}
.transcript ol { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; overflow-y: auto; max-height: 420px; }
.transcript li button {
  width: 100%; text-align: left; border-radius: 8px; padding: 6px 8px; border: 1px solid transparent;
  background: transparent; font: 400 13px/1.4 var(--f-body); color: var(--muted); display: grid; gap: 2px;
}
.transcript li button:hover { background: var(--panel-2); border-color: var(--line); }
.transcript li button[aria-current="true"] { background: var(--panel-2); border-color: var(--sun); color: var(--text); }
.transcript .who { font-weight: 800; font-size: 12px; color: var(--sun); }
.transcript .who[data-slot="1"] { color: var(--pink); }

@media (max-width: 900px) {
  .player { grid-template-columns: 1fr; }
  .transcript ol { max-height: 240px; }
}

button, select, .file-btn {
  font: 600 14px var(--f-body); color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; cursor: pointer;
}
select { border-radius: 10px; padding: 7px 10px; }
button:hover, .file-btn:hover { border-color: var(--pink); }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, .file-btn:focus-within {
  outline: 2px solid var(--teal); outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--pink); border-color: var(--pink); color: #1a0716; min-width: 9.5em; }
button.rec { background: var(--bad); border-color: var(--bad); color: #1a0716; }

.controls, .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.field.block { display: block; margin-top: 8px; font-weight: 700; color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.status { margin: 0; color: var(--muted); font-size: 13px; min-height: 1.5em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.clip {
  text-align: left; border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; align-content: start;
  background: var(--panel); border: 1px solid var(--line); font-weight: 400;
}
.clip[aria-pressed="true"] { border-color: var(--sun); box-shadow: 0 0 0 1px var(--sun) inset; }
.clip .no { font: 700 12px var(--f-display); letter-spacing: .12em; color: var(--sun); text-transform: uppercase; }
.clip .ttl { font-weight: 800; font-size: 16px; }
.clip .pts { color: var(--muted); font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }

.workbench { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.tabs button { border-radius: 8px; background: transparent; border-color: transparent; }
.tabs button[aria-selected="true"] { background: var(--panel); border-color: var(--line); color: var(--sun); }
.panel {
  display: grid; gap: 10px; padding-block: 16px;
  padding-left: 16px; padding-right: 16px;
}
textarea {
  width: 100%; max-width: 100%; resize: vertical; font: 13px/1.6 var(--f-mono); color: var(--text);
  background: var(--night); border: 1px solid var(--line); border-radius: 10px; padding: 12px; tab-size: 2;
}
.panel > button { justify-self: start; }
.stats { color: var(--muted); font-size: 13px; margin-left: auto; }
.errors { display: grid; gap: 4px; font-size: 13px; }
.errors .ok { color: var(--ok); }
.errors ul { margin: 0; padding-left: 18px; color: var(--bad); }

.cast { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .cast { grid-template-columns: 1fr; } }
.cast fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: center; margin: 0; min-width: 0; }
.cast legend { font-weight: 800; padding: 0 6px; }
.cast label { color: var(--muted); font-size: 13px; }
.cast input[type="color"] { width: 48px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; }
.cast select { width: 100%; min-width: 0; }

.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.card video { width: 100%; max-width: 100%; border-radius: 8px; background: #000; }
.file-btn { display: inline-flex; justify-content: center; position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.help pre { margin: 0; background: var(--night); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font: 13px/1.6 var(--f-mono); }
.help h3 { margin-top: 6px; }
.help p { max-width: 68ch; margin: 0; color: var(--muted); }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.keys dd { margin: 0; color: var(--muted); }
kbd { font: 12px var(--f-mono); background: var(--night); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
.help > div { display: grid; gap: 10px; }

.lang { display: flex; gap: 4px; }
.lang button { padding: 6px 12px; }
.lang button[aria-pressed="true"] { border-color: var(--sun); color: var(--sun); }

footer { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 12px; }
footer p { margin: 0; max-width: 90ch; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
