:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --fg: #e8e8e8;
  --muted: #9a9a9a;
  --accent: #7cf29a;
  --danger: #ff8a7a;
  --line: #2a2a2a;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--mono); }
a { color: var(--accent); }
.page { max-width: 1680px; margin: 0 auto; padding: 24px 24px 48px; }
.wordmark { font-size: 22px; margin: 0 0 16px; letter-spacing: 0.04em; }
.app { display: flex; flex-direction: column; gap: 12px; }

.url-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: 960px; }
.url-form label { width: 100%; color: var(--muted); font-size: 13px; }
.url-form input { flex: 1 1 320px; min-width: 0; padding: 10px 12px; font: inherit; color: var(--fg); background: #141414; border: 1px solid var(--line); border-radius: 6px; }
.url-form input[aria-invalid="true"] { border-color: var(--danger); }
button { font: inherit; color: var(--bg); background: var(--fg); border: 0; border-radius: 6px; padding: 9px 14px; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.url-error { margin: 0; color: var(--danger); }
.note { margin: 0; color: var(--muted); font-size: 13px; max-width: 960px; }

/*
 * Capture mode: the YouTube player and the ASCII view side by side (stacked when narrow). Nothing
 * overlaps the player. Each pane is at least 480 CSS px wide where there is room: YouTube picks the
 * rendition (and so 60 fps, which it serves only from 720p up) from the player's size.
 */
.stage { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 16px; align-items: start; }
.pane { margin: 0; min-width: 0; }
.pane-title { margin: 0 0 6px; font-size: 13px; font-weight: normal; color: var(--muted); }
/* Element Capture target: its own stacking context, flat (no 3D), holding only the iframe. */
.player-box { position: relative; aspect-ratio: 16 / 9; background: #000; isolation: isolate; transform-style: flat; }
.player-box .embed { display: block; width: 100%; height: 100%; border: 0; }
.placeholder { margin: 0; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); border: 1px dashed var(--line); }

/* The ASCII view (both modes): a screen box with a fixed aspect ratio. */
.screen { position: relative; width: 100%; aspect-ratio: var(--ar, 1.7778); background: #000; overflow: hidden; }
.screen > canvas { z-index: 2; }
.panel { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; background: #050505; border: 1px solid var(--line); }
.panel[hidden] { display: none; }
.panel-title { margin: 0; font-size: 16px; }
.panel-body { margin: 0; color: var(--muted); max-width: 60ch; }
.panel-actions { display: flex; gap: 8px; margin-top: 6px; }

/* Curated mode: our own <video> under an opaque backdrop, the ASCII canvas over it, a control bar. */
.player { display: flex; flex-direction: column; width: min(100%, 1280px, calc((100vh - 300px) * var(--ar, 1.7778))); min-width: min(100%, 480px); background: #000; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.source-video { position: absolute; inset: 0; width: 100%; height: 100%; }
.backdrop { position: absolute; inset: 0; z-index: 1; background: #000; }
.controls { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #111; border-top: 1px solid var(--line); }
.controls .control { padding: 6px 10px; font-size: 13px; background: #1e1e1e; color: var(--fg); border: 1px solid var(--line); white-space: nowrap; }
.controls .seek { flex: 1; min-width: 60px; accent-color: var(--accent); }
.controls .time { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.player:fullscreen { border: 0; border-radius: 0; width: 100vw; height: 100vh; max-width: none; }
.player:fullscreen .screen-area { container-type: size; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.player:fullscreen .screen { width: min(100cqw, calc(100cqh * var(--ar))); }
.picker { display: flex; gap: 8px; flex-wrap: wrap; }
.picker .pick { background: #1e1e1e; color: var(--fg); border: 1px solid var(--line); }
.picker .pick[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.credit { margin: 0; color: var(--muted); font-size: 13px; }
.extension { margin: 0; font-size: 13px; }
