/* ==========================================================================
   Clarity — Video Upscaler · RJ's Design Studio
   Concept: a darkroom console. The frame sits on an always-dark stage; the
   before/after seam is the hero. Brand gradient (cyan → violet → purple)
   is used like a light leak: thin, rare, deliberate.
   ========================================================================== */

@font-face { font-family: "Playfair Display"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/playfair-display-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 500; font-style: italic; font-display: swap; src: url("../fonts/playfair-display-latin-500-italic.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/playfair-display-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-style: italic; font-display: swap; src: url("../fonts/playfair-display-latin-600-italic.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 300; font-display: swap; src: url("../fonts/poppins-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("../fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("../fonts/poppins-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("../fonts/poppins-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("../fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root {
    /* Light: "gallery" — cool paper around a dark stage */
    --bg: #f3f4f9;
    --bg-glow: rgba(90, 84, 201, 0.10);
    --surface: #ffffff;
    --surface-2: #eef0f7;
    --surface-3: #e4e7f2;
    --line: rgba(17, 22, 48, 0.09);
    --line-strong: rgba(17, 22, 48, 0.18);
    --ink: #10152e;
    --ink-2: #47506f;
    --ink-3: #6f7896;
    --accent: #5a54c9;
    --accent-ink: #ffffff;
    --accent-soft: rgba(90, 84, 201, 0.10);
    --cyan: #3ec6f0;
    --violet: #5a54c9;
    --purple: #7d3fa8;
    --grad: linear-gradient(115deg, var(--cyan) 0%, var(--violet) 55%, var(--purple) 100%);
    --ok: #1d8f6a;
    --warn: #a86a12;
    --danger: #c03a48;
    --danger-soft: rgba(192, 58, 72, 0.09);
    --shadow: 0 1px 2px rgba(16, 21, 46, 0.05), 0 12px 32px -12px rgba(16, 21, 46, 0.16);
    --focus: 0 0 0 3px rgba(62, 198, 240, 0.55);

    /* The stage is a darkroom in both themes */
    --stage: #05070f;
    --stage-ink: #e9ecf8;
    --stage-ink-2: #9aa2c2;
    --stage-line: rgba(233, 236, 248, 0.12);

    --radius: 16px;
    --radius-sm: 10px;
    --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
    --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #070a18;
        --bg-glow: rgba(90, 84, 201, 0.16);
        --surface: #0d1228;
        --surface-2: #131a37;
        --surface-3: #1b2347;
        --line: rgba(233, 236, 248, 0.08);
        --line-strong: rgba(233, 236, 248, 0.17);
        --ink: #eef0fa;
        --ink-2: #aeb5d0;
        --ink-3: #7c84a5;
        --accent: #8a84ff;
        --accent-ink: #0b0e22;
        --accent-soft: rgba(138, 132, 255, 0.14);
        --ok: #4fd1a5;
        --warn: #f0b356;
        --danger: #ff7a87;
        --danger-soft: rgba(255, 122, 135, 0.10);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -18px rgba(0, 0, 0, 0.7);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #070a18;
    --bg-glow: rgba(90, 84, 201, 0.16);
    --surface: #0d1228;
    --surface-2: #131a37;
    --surface-3: #1b2347;
    --line: rgba(233, 236, 248, 0.08);
    --line-strong: rgba(233, 236, 248, 0.17);
    --ink: #eef0fa;
    --ink-2: #aeb5d0;
    --ink-3: #7c84a5;
    --accent: #8a84ff;
    --accent-ink: #0b0e22;
    --accent-soft: rgba(138, 132, 255, 0.14);
    --ok: #4fd1a5;
    --warn: #f0b356;
    --danger: #ff7a87;
    --danger-soft: rgba(255, 122, 135, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -18px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 85% -10%, var(--bg-glow), transparent 60%),
        var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

h1, h2, h3 { text-wrap: balance; line-height: 1.15; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.mono { font-family: var(--font-mono); font-feature-settings: "zero" 1; letter-spacing: -0.01em; }

.wrap {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 16px;
}
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar::after {
    content: "";
    position: absolute;
    inset: auto 0 -1px 0;
    height: 1px;
    background: var(--grad);
    opacity: 0.55;
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
    min-width: 0;
}
.brand img { width: 108px; height: auto; }
@media (max-width: 400px) {
    .brand img { width: 88px; }
    .brand-product { font-size: 18px; }
    .topbar-inner { gap: 10px; }
}
.brand-divider { width: 1px; height: 26px; background: var(--line-strong); }
.brand-product {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.brand-product em { font-style: italic; font-weight: 500; color: var(--ink-2); }
.topbar-spacer { flex: 1; }

.privacy-pill {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    color: var(--ink-2);
    font-size: 12.5px;
    white-space: nowrap;
}
.privacy-pill svg { color: var(--ok); }
@media (min-width: 1380px) { .privacy-pill { display: inline-flex; } }

/* Studio main menu: inline on wide screens, a drop panel below 1100px */
.main-nav ul {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    padding: 0;
}
.main-nav a {
    position: relative;
    display: block;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color .2s, background .2s;
}
.main-nav a:hover { color: var(--ink); background: var(--accent-soft); }
.main-nav a.is-current { color: var(--ink); }
.main-nav a.is-current::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background: var(--grad);
}
.icon-btn.menu-btn { display: none; }

@media (max-width: 1099px) {
    .icon-btn.menu-btn { display: inline-grid; }
    .main-nav {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        right: 16px;
        left: 16px;
        z-index: 40;
        padding: 8px;
        border-radius: 16px;
        background: var(--surface);
        border: 1px solid var(--line-strong);
        box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.45);
    }
    .main-nav.is-open { display: block; animation: toast-in .2s ease; }
    .main-nav ul { flex-direction: column; align-items: stretch; }
    .main-nav a { padding: 12px 14px; font-size: 15px; }
    .main-nav a.is-current::after { left: 14px; right: auto; width: 24px; bottom: 6px; }
}
@media (min-width: 600px) and (max-width: 1099px) {
    .main-nav { left: auto; width: 280px; }
}
.topbar-inner { position: relative; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    transition: color .2s, border-color .2s, background .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }


/* ---------- Buttons ---------- */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-weight: 500;
    font-size: 14.5px;
    text-decoration: none;
    transition: transform .15s ease, border-color .2s, background .2s, opacity .2s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    border: 0;
    color: #fff;
    background: var(--grad);
    background-size: 160% 100%;
    background-position: 0% 0;
    box-shadow: 0 10px 30px -12px rgba(90, 84, 201, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: background-position .5s ease, transform .15s ease, box-shadow .3s, opacity .2s;
}
.btn-primary:hover:not(:disabled) { background-position: 100% 0; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 15.5px; border-radius: 14px; }
.btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--ink-2);
    padding: 0 12px;
}
.btn-quiet:hover:not(:disabled) { color: var(--ink); border-color: var(--line-strong); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }

.btn-stack { display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.25; }
.btn-stack small { font-family: var(--font-mono); font-size: 11.5px; font-weight: 400; opacity: 0.85; }

/* ---------- Landing ---------- */

.landing { padding: 40px 0 72px; }
@media (min-width: 960px) { .landing { padding: 64px 0 96px; } }

.hero {
    display: grid;
    gap: 40px;
    align-items: center;
}
@media (min-width: 960px) {
    .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 56px; }
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-2);
}
.eyebrow::before {
    content: "";
    width: 28px;
    height: 2px;
    border-radius: 2px;
    background: var(--grad);
}

.hero h1 {
    margin-top: 18px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(38px, 6.4vw, 68px);
    letter-spacing: -0.015em;
    line-height: 1.04;
}
.hero h1 em {
    font-style: italic;
    font-weight: 500;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding-right: 0.06em;
}
.hero-lede {
    margin-top: 20px;
    max-width: 52ch;
    color: var(--ink-2);
    font-size: 16.5px;
    font-weight: 300;
}

/* Drop zone */
.dropzone {
    position: relative;
    margin-top: 32px;
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 34px 20px 28px;
    text-align: center;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    isolation: isolate;
    transition: transform .2s ease;
}
.dropzone::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(var(--line-strong), var(--line-strong));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: background .3s;
}
.dropzone.is-over { transform: scale(1.01); }
.dropzone.is-over::before,
.dropzone:focus-within::before { background: var(--grad); }
.dz-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent-soft);
    color: var(--accent);
}
.dz-title { font-weight: 500; font-size: 17px; }
.dz-sub { color: var(--ink-3); font-size: 13.5px; max-width: 46ch; }
.dz-formats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 11.5px;
}

/* Seam demo visual */
.seam-demo {
    position: relative;
    border-radius: 22px;
    overflow: hidden;
    background: var(--stage);
    aspect-ratio: 4 / 3;
    box-shadow: 0 40px 80px -40px rgba(20, 16, 70, 0.6);
    isolation: isolate;
}
.seam-demo::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid var(--stage-line);
    pointer-events: none;
}
.seam-demo canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.seam-demo .lowres { image-rendering: pixelated; }
.seam-demo .hires { clip-path: inset(0 0 0 var(--seam, 50%)); }
.seam-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--seam, 50%);
    width: 2px;
    margin-left: -1px;
    background: linear-gradient(var(--cyan), var(--violet), var(--purple));
    box-shadow: 0 0 24px rgba(62, 198, 240, 0.6);
}
.seam-label {
    position: absolute;
    top: 16px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(5, 7, 15, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--stage-ink);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--stage-line);
}
.seam-label.left { left: 16px; }
.seam-label.right { right: 16px; }
.seam-caption {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--stage-ink-2);
    font-family: var(--font-mono);
    font-size: 11.5px;
}

/* Feature + spec rows */
.features {
    margin-top: 64px;
    display: grid;
    gap: 1px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--line);
    border: 1px solid var(--line);
}
@media (min-width: 760px) { .features { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.feature {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 26px 24px 28px;
    background: var(--surface);
}
.feature-num {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-3);
}
.feature h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
}
.feature p { color: var(--ink-2); font-size: 14px; font-weight: 300; max-width: 42ch; }

.specs {
    margin-top: 28px;
    display: grid;
    gap: 12px 32px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.spec { display: grid; gap: 2px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.spec dt { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.spec dd { font-size: 14px; color: var(--ink); }

/* Unsupported browser */
.notice {
    display: grid;
    gap: 8px;
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    background: var(--danger-soft);
}
.notice strong { color: var(--danger); font-weight: 600; }
.notice p { color: var(--ink-2); font-size: 14px; }

/* ---------- Workspace ---------- */

.workspace { padding: 20px 0 64px; }
@media (min-width: 720px) { .workspace { padding: 28px 0 80px; } }

.ws-grid {
    display: grid;
    gap: 20px;
    align-items: start;
}
@media (min-width: 1040px) {
    .ws-grid { grid-template-columns: minmax(0, 1fr) 372px; gap: 24px; }
    .rail { position: sticky; top: 88px; }
}

.stage-card {
    display: grid;
    gap: 0;
    border-radius: 20px;
    overflow: hidden;
    background: var(--stage);
    color: var(--stage-ink);
    box-shadow: 0 30px 70px -40px rgba(10, 8, 40, 0.75);
    border: 1px solid var(--stage-line);
}

.stage {
    position: relative;
    width: 100%;
    aspect-ratio: var(--ar, 16 / 9);
    max-height: 68vh;
    overflow: hidden;
    touch-action: none;
    background:
        radial-gradient(circle at 50% 40%, #0d1124 0%, var(--stage) 70%);
    cursor: grab;
}
.stage.is-fit { cursor: default; }
.stage.is-panning { cursor: grabbing; }
.stage canvas,
.stage .stage-media {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    max-width: none;
}
.stage .stage-media { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; transform: none; }

.stage-label {
    position: absolute;
    top: 14px;
    z-index: 3;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(5, 7, 15, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--stage-line);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
}
.stage-label.left { left: 14px; color: var(--stage-ink-2); }
.stage-label.right { right: 14px; }
.stage-label.right b { font-weight: 500; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.split-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 44px;
    margin-left: -22px;
    display: grid;
    place-items: center;
    cursor: ew-resize;
    touch-action: none;
    background: none;
    border: 0;
    padding: 0;
}
.split-handle::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: linear-gradient(var(--cyan), var(--violet), var(--purple));
    box-shadow: 0 0 18px rgba(62, 198, 240, 0.55);
}
.split-knob {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(5, 7, 15, 0.82);
    border: 1.5px solid rgba(233, 236, 248, 0.85);
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.split-handle:focus-visible { box-shadow: none; }
.split-handle:focus-visible .split-knob { box-shadow: var(--focus); }

.stage-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 24px;
    text-align: center;
    background: rgba(5, 7, 15, 0.72);
    color: var(--stage-ink-2);
    font-size: 14px;
}
.stage-overlay[hidden] { display: none; }

.transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 14px;
    border-top: 1px solid var(--stage-line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent);
}
.t-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--stage-line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--stage-ink);
    flex: none;
}
.t-btn:hover { border-color: rgba(233, 236, 248, 0.35); }
.t-time {
    color: var(--stage-ink-2);
    font-size: 12.5px;
    white-space: nowrap;
}
.t-time b { color: var(--stage-ink); font-weight: 500; }
.scrub-wrap { position: relative; flex: 1 1 220px; min-width: 0; height: 40px; display: flex; align-items: center; }
.scrub-range {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 4px;
    pointer-events: none;
}
.scrub-range .track { position: absolute; inset: 0; background: rgba(233, 236, 248, 0.14); border-radius: inherit; }
.scrub-range .section {
    position: absolute;
    top: -2px;
    bottom: -2px;
    border-radius: 3px;
    background: rgba(138, 132, 255, 0.28);
    border-left: 2px solid var(--cyan);
    border-right: 2px solid var(--purple);
}
.scrub-range .played { position: absolute; left: 0; top: 0; bottom: 0; background: var(--grad); border-radius: inherit; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    height: 28px;
    margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: transparent; }
input[type="range"]::-moz-range-track { height: 4px; background: transparent; }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border-radius: 50%;
    background: #fff;
    border: 0;
    box-shadow: 0 0 0 4px rgba(138, 132, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 0;
    box-shadow: 0 0 0 4px rgba(138, 132, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
}
input[type="range"]:focus-visible { box-shadow: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--focus); }
.scrub-wrap input { position: relative; z-index: 1; }

.zoom-seg {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 11px;
    border: 1px solid var(--stage-line);
    background: rgba(255, 255, 255, 0.03);
    flex: none;
}
.zoom-seg button {
    min-width: 50px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--stage-ink-2);
    font-family: var(--font-mono);
    font-size: 12px;
}
.zoom-seg button[aria-pressed="true"] { background: rgba(233, 236, 248, 0.12); color: var(--stage-ink); }

.stage-hint {
    padding: 0 14px 12px;
    color: var(--stage-ink-2);
    font-size: 12.5px;
}

/* ---------- Rail ---------- */

.rail {
    display: grid;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.rail-section {
    display: grid;
    gap: 14px;
    padding: 20px 20px 22px;
    border-top: 1px solid var(--line);
}
.rail-section:first-child { border-top: 0; }
.rail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.rail-title {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.rail-aside { font-size: 12.5px; color: var(--ink-3); }

.file-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-thumb {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
}
.file-meta { min-width: 0; flex: 1; }
.file-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: 12.5px; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Output size options */
.size-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.size-opt {
    position: relative;
    display: grid;
    gap: 2px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    text-align: left;
    transition: border-color .2s, background .2s;
    min-width: 0;
}
.size-opt:hover:not(:disabled) { border-color: var(--accent); }
.size-opt[aria-checked="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.size-opt:disabled { cursor: not-allowed; opacity: 0.5; }
.size-name { font-weight: 500; font-size: 14px; }
.size-dims { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.size-x {
    position: absolute;
    top: 11px;
    right: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-3);
}

/* Presets */
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    transition: border-color .2s, background .2s, color .2s;
}
.chip-btn:hover { color: var(--ink); border-color: var(--accent); }
.chip-btn[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.slider { display: grid; gap: 4px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.slider-head label { font-weight: 500; font-size: 14px; }
.slider-head output { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }
.slider-help { font-size: 12.5px; color: var(--ink-3); }
.slider input[type="range"] {
    background: linear-gradient(var(--accent), var(--accent)) 0 50% / var(--fill, 50%) 4px no-repeat,
                linear-gradient(var(--surface-3), var(--surface-3)) 0 50% / 100% 4px no-repeat;
}

.seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding: 3px;
    gap: 3px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.seg button {
    min-height: 36px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-2);
    font-size: 13px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 21, 46, 0.12); font-weight: 500; }

.toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    cursor: pointer;
}
.toggle-text { display: grid; min-width: 0; }
.toggle-text span:first-child { font-weight: 500; font-size: 14px; }
.toggle-text span + span { font-size: 12.5px; color: var(--ink-3); }
.toggle input {
    -webkit-appearance: none;
    appearance: none;
    flex: none;
    position: relative;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    transition: background .2s;
    cursor: pointer;
}
.toggle input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform .2s;
}
.toggle input:checked { background: var(--accent); border-color: var(--accent); }
.toggle input:checked::after { transform: translateX(18px); }
.toggle input:disabled { opacity: 0.45; cursor: not-allowed; }
.toggle input:focus-visible { box-shadow: var(--focus); }

.section-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-row .btn { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.section-readout { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }

.cta-note { display: flex; gap: 8px; font-size: 12.5px; color: var(--ink-3); }
.cta-note svg { flex: none; margin-top: 2px; color: var(--ok); }

.inline-error {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--ink);
    font-size: 13.5px;
}
.inline-error strong { color: var(--danger); font-weight: 600; display: block; }
.inline-note { font-size: 12.5px; color: var(--warn); }

/* Progress */
.progress-big {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.progress-pct {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 54px;
    line-height: 1;
    font-variant-numeric: tabular-nums lining-nums;
}
.progress-pct small { font-size: 26px; color: var(--ink-3); }
.progress-phase { font-size: 13px; color: var(--ink-2); text-align: right; }
.bar {
    position: relative;
    height: 8px;
    border-radius: 8px;
    background: var(--surface-3);
    overflow: hidden;
}
.bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    border-radius: inherit;
    background: var(--grad);
    background-size: 200% 100%;
    animation: sheen 2.4s linear infinite;
    transition: width .3s ease;
}
@keyframes sheen { from { background-position: 0 0; } to { background-position: -200% 0; } }
.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--line);
    border: 1px solid var(--line);
}
.stat { display: grid; gap: 2px; padding: 12px 14px; background: var(--surface); min-width: 0; }
.stat dt { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.stat dd { font-family: var(--font-mono); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.done-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 30px;
}
.done-title em { font-style: italic; font-weight: 500; color: var(--ink-2); }
.done-sub { color: var(--ink-2); font-size: 14px; }
.btn-row { display: grid; gap: 8px; }

/* ---------- Footer ---------- */

.site-foot {
    border-top: 1px solid var(--line);
    padding: 24px 0 32px;
    color: var(--ink-3);
    font-size: 12.5px;
}
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-foot a { color: var(--ink-2); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* ---------- Toasts ---------- */

.toasts {
    position: fixed;
    z-index: 50;
    left: 16px;
    right: 16px;
    bottom: 16px;
    display: grid;
    justify-items: center;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 460px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--ink);
    color: var(--bg);
    box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
    font-size: 13.5px;
    pointer-events: auto;
    animation: toast-in .25s ease;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

[hidden] { display: none !important; }

/* Off-screen but still decoding, so preview frames keep arriving */
.probe-video {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 2px;
    height: 2px;
    opacity: 0.01;
    pointer-events: none;
    z-index: -1;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
