/* Layout: one working screen — a large preview stage on the left, a narrow control column on the right; stacks on phones. */
:root {
  --bg: #0d0f13;
  --surface: #15181e;
  --raise: #1c2028;
  --line: #262b35;
  --fg: #e8eaef;
  --muted: #8a909e;
  --accent: #8fb3ff;
  --accent-ink: #0b1220;
  --ok: #6fd3a5;
  --warn: #f0b860;
  --danger: #ff8a80;
  --font-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f7; --surface: #ffffff; --raise: #eceef3; --line: #dcdfe6;
    --fg: #14171d; --muted: #646b79; --accent: #2f5fd0; --accent-ink: #ffffff;
    --ok: #17865a; --warn: #a8690c; --danger: #c2372c; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f4f7; --surface: #ffffff; --raise: #eceef3; --line: #dcdfe6;
  --fg: #14171d; --muted: #646b79; --accent: #2f5fd0; --accent-ink: #ffffff;
  --ok: #17865a; --warn: #a8690c; --danger: #c2372c; color-scheme: light;
}

[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
.app {
  min-height: 100%;
  display: flex; flex-direction: column; gap: 14px;
  padding-block: 14px 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-sizing: border-box;
}
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; font-size: 15px; }
.mark { width: 22px; height: 22px; border-radius: 6px; background:
  linear-gradient(135deg, var(--accent) 0 50%, transparent 50%), var(--raise);
  box-shadow: inset 0 0 0 1px var(--line); }
.brand { white-space: nowrap; }
.hint { color: var(--muted); font-size: 12.5px; text-align: right; }
@media (max-width: 520px) { .hint { display: none; } }
.hint b { color: var(--fg); font-weight: 500; }

main.upscale { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; min-height: 0; }
@media (max-width: 860px) { main.upscale { grid-template-columns: minmax(0, 1fr); } }

/* Stage */
.stage {
  position: relative; min-height: 360px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  display: grid; grid-template-rows: 1fr auto; overflow: hidden;
}
.viewport { position: relative; overflow: hidden; display: grid; place-items: center; min-height: 300px; cursor: zoom-in;
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 18px 18px; }
.viewport.zoomed { cursor: zoom-out; }
.frame { position: relative; transform-origin: 0 0; transition: transform .25s cubic-bezier(.2,.7,.2,1); }
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#origCanvas { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }
.divider { position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 0; pointer-events: none; }
.divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--fg); opacity: .85; }
.knob { position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%;
  background: var(--fg); color: var(--bg); display: grid; place-items: center; pointer-events: auto; cursor: ew-resize;
  box-shadow: 0 2px 12px rgb(0 0 0 / .35); }
.knob svg { width: 16px; height: 16px; }
.tag { position: absolute; top: 12px; font: 500 11px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 6px 8px; border-radius: 6px; background: rgb(0 0 0 / .55); color: #fff; pointer-events: none; }
.tag.l { left: 12px; } .tag.r { right: 12px; }

.bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.meta { font: 12px/1.3 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.meta b { color: var(--fg); font-weight: 500; }
.scrub { flex: 1 1 160px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.time { font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.drop {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(6px);
  border: 2px dashed var(--accent); border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity .15s;
  font-size: 15px; font-weight: 500;
}
.drop.on { opacity: 1; }
.sample-note { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 10px; align-items: center; padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--raise); border: 1px solid var(--line); white-space: nowrap; font-size: 13px; max-width: calc(100% - 24px); }
.sample-note span { overflow: hidden; text-overflow: ellipsis; }

/* Panel */
.panel { display: flex; flex-direction: column; gap: 18px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.group { display: flex; flex-direction: column; gap: 8px; }
.label { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.label .val { font: 12px var(--font-mono); letter-spacing: 0; text-transform: none; color: var(--fg); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--raise); border-radius: 8px; padding: 3px; gap: 3px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { text-align: center; padding: 7px 4px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--muted); transition: background .12s, color .12s; user-select: none; }
.seg label small { display: block; font: 10.5px var(--font-mono); color: inherit; opacity: .8; margin-top: 1px; font-weight: 400; }
.seg input:checked + label { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / .25), inset 0 0 0 1px var(--line); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg input:disabled + label { opacity: .35; cursor: not-allowed; }
.banner { padding: 10px 14px; border-radius: var(--r); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--fg); font-size: 13.5px; }
.note { color: var(--muted); font-size: 12.5px; }
.loading { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 70%, transparent); font-size: 13px; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.res label { padding: 10px 4px; font-size: 15px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p, 50%) 100% no-repeat, var(--line); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--fg); margin-top: -5px; border: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--fg); border: 0; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input[type="range"]:disabled { opacity: .4; }

.out { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font: 12px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.out b { color: var(--fg); font-weight: 500; text-align: right; }
.warn { color: var(--warn); font-size: 12.5px; }

.btn { appearance: none; border: 0; font: 600 14px var(--font-ui); border-radius: 8px; padding: 12px 14px; cursor: pointer; transition: filter .12s, transform .06s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--raise); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { filter: brightness(1.15); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 999px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.spacer { flex: 1; }

.progress { display: flex; flex-direction: column; gap: 8px; }
.track { height: 6px; background: var(--raise); border-radius: 3px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .2s linear; }
.stats { display: flex; justify-content: space-between; font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--fg); font-weight: 500; }
.result { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 8px; background: var(--raise); }
.result video { width: 100%; border-radius: 6px; background: #000; max-height: 180px; }
.result .ok { color: var(--ok); font-weight: 500; }
.err { color: var(--danger); font-size: 13px; }
.foot { color: var(--muted); font-size: 12px; line-height: 1.5; }

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

/* =====================================================================
   Shared chrome: header + tabs
   ===================================================================== */
a.brand { color: inherit; text-decoration: none; }
a.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.tabs { display: flex; gap: 2px; background: var(--raise); padding: 3px; border-radius: 9px; margin-right: auto; margin-left: 18px; }
.tabs a { padding: 6px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13.5px; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / .2), inset 0 0 0 1px var(--line); }
.tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.head-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 520px) { .tabs { margin-left: 10px; } .tabs a { padding: 6px 10px; } }
.sel { appearance: none; border: 0; background: var(--raise); color: var(--fg); font: 500 13px var(--font-ui); padding: 7px 26px 7px 10px; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--line); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px; background-repeat: no-repeat; }
.sel:disabled { opacity: .4; cursor: not-allowed; }
.sel:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kbd { font: 11px var(--font-mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.help { color: var(--muted); font-size: 12.5px; line-height: 1.6; }

/* =====================================================================
   Editor
   ===================================================================== */
.editor { flex: 1; display: grid; grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr); gap: 14px; min-height: 0; align-items: start; }
@media (max-width: 960px) { .editor { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }

.player-col { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@media (max-width: 960px) { .player-col { position: static; } }
.player-card { overflow: hidden; position: relative; }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; max-width: 100%; max-height: 62vh; margin-inline: auto; width: 100%; }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.player .msg { position: absolute; inset: auto 12px 12px; padding: 8px 12px; border-radius: 8px; background: rgb(0 0 0 / .65); color: #fff; font-size: 12.5px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; cursor: pointer; background: var(--surface); }
.empty .inner { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty .glyph { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--raise); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
.empty .glyph svg { width: 20px; height: 20px; }
.empty .big { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.empty .sub { color: var(--muted); font-size: 13px; max-width: 32ch; }
.empty:hover .glyph { color: var(--fg); }
.empty:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.transport { display: flex; align-items: center; gap: 12px; padding: 10px 12px 6px; flex-wrap: wrap; }
.play { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--fg); color: var(--bg); display: grid; place-items: center; cursor: pointer; flex: none; }
.play:disabled { opacity: .3; cursor: not-allowed; }
.play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.play svg { width: 13px; height: 13px; }
.clock { font: 13px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--fg); white-space: nowrap; }
.clock span { color: var(--muted); }
.chip { font: 11.5px var(--font-mono); padding: 3px 8px; border-radius: 999px; background: var(--raise); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.cutchip { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--raise)); }
.strip-wrap { padding: 4px 12px 12px; }
.strip { width: 100%; height: 40px; display: block; cursor: pointer; border-radius: 6px; touch-action: none; }
.filebar { display: flex; align-items: center; gap: 10px; padding: 0 4px; min-width: 0; }
.filebar .name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.filebar .name b { color: var(--fg); font-weight: 500; }
.linkbtn { appearance: none; border: 0; background: none; color: var(--accent); font: 500 13px var(--font-ui); cursor: pointer; padding: 4px 2px; white-space: nowrap; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn:disabled { color: var(--muted); cursor: not-allowed; text-decoration: none; }
.linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.script-card { display: flex; flex-direction: column; min-height: 520px; height: calc(100vh - 92px); overflow: hidden; }
@media (max-width: 960px) { .script-card { height: auto; min-height: 360px; max-height: 80vh; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tool { appearance: none; border: 0; background: transparent; color: var(--fg); font: 500 13px var(--font-ui); padding: 7px 10px; border-radius: 7px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tool:hover { background: var(--raise); }
.tool[aria-pressed="true"] { background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); }
.tool:disabled { opacity: .35; cursor: not-allowed; background: transparent; }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tool svg { width: 15px; height: 15px; flex: none; }
.tool-group { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 9px; box-shadow: inset 0 0 0 1px var(--line); }
.tool-group .sel { box-shadow: none; background-color: transparent; padding-block: 6px; }
.toolbar .spacer { flex: 1; }
.saved { font: 11.5px var(--font-mono); color: var(--muted); white-space: nowrap; transition: opacity .3s; }
.findbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.findbar input { flex: 1 1 160px; min-width: 0; appearance: none; border: 0; border-radius: 7px; background: var(--raise); color: var(--fg); font: 14px var(--font-ui); padding: 7px 10px; box-shadow: inset 0 0 0 1px var(--line); }
.findbar input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.findbar .count { font: 12px var(--font-mono); color: var(--muted); min-width: 6ch; text-align: right; font-variant-numeric: tabular-nums; }

.resume { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-size: 13px; flex-wrap: wrap; }

.script { flex: 1; overflow-y: auto; padding: 22px 26px 60px; font-size: 17px; line-height: 1.85; outline: none; overscroll-behavior: contain; }
.script p { margin: 0 0 16px; max-width: 66ch; }
.script .stamp { display: block; font: 11px var(--font-mono); color: var(--muted); margin-bottom: 2px; letter-spacing: .02em; user-select: none; cursor: pointer; width: max-content; }
.script .stamp:hover { color: var(--accent); }
.w { border-radius: 4px; padding: 1px 0; cursor: text; transition: background .1s, color .1s; }
.w:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.w.cut { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 2px; opacity: .5; }
.w.now { background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--fg); }
.w.cut.now { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.w.find { box-shadow: 0 0 0 1.5px var(--warn); }
.w.find.cur { background: color-mix(in srgb, var(--warn) 30%, transparent); }
.w[contenteditable="true"] { outline: 2px solid var(--accent); background: var(--raise); padding: 1px 3px; cursor: text; }
.gap { display: inline-block; font: 10.5px/1.6 var(--font-mono); padding: 0 6px; margin: 0 3px; border-radius: 999px; background: var(--raise); color: var(--muted); cursor: pointer; vertical-align: 2px; user-select: none; }
.gap:hover { color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.gap.cut { text-decoration: line-through; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--raise)); }
.livewords { color: var(--muted); }
.example-tag { display: inline-block; font: 500 10.5px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; margin-bottom: 14px; }

.setup { margin: auto; width: min(440px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 28px 20px; }
.setup h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; text-wrap: balance; }
.setup .lead { margin: -8px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.setup .row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.setup .row > .grow { flex: 1 1 220px; min-width: 0; }

.seltool { position: fixed; z-index: 30; display: flex; gap: 2px; padding: 4px; border-radius: 10px; background: var(--fg); box-shadow: 0 8px 28px rgb(0 0 0 / .28); transform: translate(-50%, calc(-100% - 10px)); }
.seltool button { appearance: none; border: 0; background: transparent; color: var(--bg); font: 600 12.5px var(--font-ui); padding: 6px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seltool button:hover, .seltool button:focus-visible { background: color-mix(in srgb, var(--bg) 18%, transparent); outline: none; }

/* Export dialog */
dialog.sheet { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--fg); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 80px rgb(0 0 0 / .35); }
dialog.sheet::backdrop { background: rgb(8 10 14 / .5); backdrop-filter: blur(3px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.sheet-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.sheet-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.xbtn { appearance: none; border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.xbtn:hover { background: var(--raise); color: var(--fg); }
.xbtn svg { width: 14px; height: 14px; }
.sheet .downloads { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet .downloads .btn { flex: 1 1 120px; }
.btn.exporting { background: var(--raise); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }

/* =====================================================================
   Home
   ===================================================================== */
.home { flex: 1; display: flex; flex-direction: column; gap: 88px; padding-block: 40px 24px; width: min(1120px, 100%); margin-inline: auto; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 48px; align-items: center; }
@media (max-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr); gap: 32px; } .home { gap: 64px; padding-block: 20px; } }
.eyebrow { font: 500 12px var(--font-mono); letter-spacing: .06em; color: var(--muted); text-transform: uppercase; display: inline-flex; gap: 8px; align-items: center; }
.eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.hero h1 { font-size: clamp(36px, 5.6vw, 62px); line-height: 1.02; letter-spacing: -0.035em; margin: 16px 0 18px; font-weight: 600; text-wrap: balance; }
.hero h1 s { text-decoration-color: var(--danger); text-decoration-thickness: 0.08em; color: var(--muted); }
.hero .lede { font-size: 17px; line-height: 1.6; color: var(--muted); max-width: 46ch; margin: 0 0 28px; }
.hero .lede b { color: var(--fg); font-weight: 500; }
.ctas { display: flex; gap: 10px; flex-wrap: wrap; }
.ctas .btn { text-decoration: none; padding: 13px 18px; }
.fine { margin-top: 14px; font-size: 12.5px; color: var(--muted); }

.demo { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.demo-top { display: flex; align-items: center; gap: 10px; font: 12px var(--font-mono); color: var(--muted); }
.demo-top .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.demo-top .rec { margin-left: auto; color: var(--fg); font-variant-numeric: tabular-nums; }
.demo-text { font-size: 18px; line-height: 1.85; margin: 0; }
.demo-text .x { position: relative; transition: color .3s; }
.demo-text .x::after { content: ""; position: absolute; left: 0; right: 0; top: 54%; height: 2px; background: var(--danger); transform: scaleX(0); transform-origin: left; animation: strike 9s infinite; }
.demo-text .x { animation: fade 9s infinite; }
.demo-text .p { display: inline-block; font: 10.5px/1.6 var(--font-mono); padding: 0 6px; border-radius: 999px; background: var(--raise); color: var(--muted); vertical-align: 2px; margin: 0 2px; animation: fade 9s infinite; }
.demo-text .d1, .demo-text .d1::after { animation-delay: .2s; }
.demo-text .d2, .demo-text .d2::after { animation-delay: .9s; }
.demo-text .d3, .demo-text .d3::after { animation-delay: 1.6s; }
.demo-text .d4, .demo-text .d4::after { animation-delay: 2.3s; }
@keyframes strike { 0%, 12% { transform: scaleX(0); } 20%, 88% { transform: scaleX(1); } 96%, 100% { transform: scaleX(0); } }
@keyframes fade { 0%, 14% { color: var(--fg); opacity: 1; } 22%, 88% { color: var(--muted); opacity: .55; } 96%, 100% { color: var(--fg); opacity: 1; } }
.demo-strip { display: flex; height: 34px; gap: 2px; border-radius: 6px; overflow: hidden; }
.demo-strip i { display: block; background: color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 2px; transition: flex .6s; }
.demo-strip i.c { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--danger) 55%, transparent) 0 2px, transparent 2px 6px); animation: shrink 9s infinite; }
@keyframes shrink { 0%, 22% { flex-grow: var(--g); } 34%, 86% { flex-grow: 0.0001; opacity: .2; } 98%, 100% { flex-grow: var(--g); opacity: 1; } }
.demo-foot { display: flex; justify-content: space-between; font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.demo-foot b { color: var(--fg); font-weight: 500; }
@media (prefers-reduced-motion: reduce) {
  .demo-text .x::after { animation: none; transform: scaleX(1); }
  .demo-text .x, .demo-text .p { animation: none; color: var(--muted); opacity: .55; }
  .demo-strip i.c { animation: none; flex-grow: 0.0001; opacity: .2; }
}

.section-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.section-head h2 { margin: 0; font-size: clamp(24px, 3vw, 32px); letter-spacing: -0.02em; font-weight: 600; text-wrap: balance; }
.section-head p { margin: 0; color: var(--muted); max-width: 60ch; line-height: 1.6; }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.tool-card { padding: 24px; display: flex; flex-direction: column; gap: 14px; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); transform: translateY(-2px); }
.tool-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool-card h3 { margin: 0; font-size: 19px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.tool-card h3 .kind { font: 500 10.5px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.tool-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.tool-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 14px; }
.tool-card li { display: flex; gap: 10px; align-items: baseline; }
.tool-card li::before { content: ""; flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); transform: translateY(-2px); }
.tool-card .go { margin-top: auto; color: var(--accent); font-weight: 500; font-size: 14px; }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 32px; }
.why h3 { margin: 0 0 8px; font-size: 15px; letter-spacing: -0.005em; }
.why p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14.5px; }
.why .ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--raise); color: var(--accent); margin-bottom: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.why .ico svg { width: 16px; height: 16px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; counter-reset: s; }
.step { padding: 20px; counter-increment: s; }
.step::before { content: counter(s); font: 500 12px var(--font-mono); color: var(--muted); display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); margin-bottom: 14px; }
.step h3 { margin: 0 0 6px; font-size: 15px; }
.step p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.foot a { color: inherit; }

/* ---------- captions ---------- */
.capcanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cap-card { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.cap-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cap-title { font-weight: 600; font-size: 14px; }
.cap-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .knob { width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(16px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .knob { opacity: .4; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cap-body { display: flex; flex-direction: column; gap: 14px; }
.cap-styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cap-styles input { position: absolute; opacity: 0; pointer-events: none; }
.cap-styles label { display: flex; flex-direction: column; gap: 6px; cursor: pointer; border-radius: 9px; padding: 4px; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .12s; }
.cap-styles label:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 50%, var(--line)); }
.cap-styles input:checked + label { box-shadow: inset 0 0 0 2px var(--accent); }
.cap-styles input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.cap-styles canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; display: block; background: #1b1f27; }
.cap-styles .cs-name { font-size: 12px; font-weight: 500; text-align: center; padding-bottom: 2px; color: var(--muted); }
.cap-styles input:checked + label .cs-name { color: var(--fg); }
.cap-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches label { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2); position: relative; }
.swatches input:checked + label { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatches input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 4px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.check .muted { color: var(--muted); }
.caphandle { position: absolute; border-radius: 8px; cursor: grab; touch-action: none; outline: 1.5px dashed transparent; outline-offset: 2px; transition: outline-color .12s; }
.player:hover .caphandle, .caphandle:focus-visible, .caphandle.dragging { outline-color: rgb(255 255 255 / .75); }
.caphandle.dragging { cursor: grabbing; }
.capguide { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; border-left: 1.5px dashed rgb(255 255 255 / .7); pointer-events: none; }
.cap-sync { grid-column: 1 / -1; }
.aud-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.aud-stats div { background: var(--raise); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.aud-stats span { display: block; font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.aud-stats b { display: block; font: 500 13px var(--font-mono); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#audCompare.held { background: var(--fg); color: var(--bg); }
