/*
 * Tailwind's preflight reset (v4.3.3, MIT), kept from when these styles
 * went through a build. It sits in a layer so every rule below outranks it
 * regardless of specificity — and it carries the rule that keeps [hidden]
 * elements hidden even when a class gives them a display.
 */
@layer base {
    *,
    ::after,
    ::before,
    ::backdrop,
    ::file-selector-button {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
        border: 0 solid;
    }

    html,
    :host {
        line-height: 1.5;
        -webkit-text-size-adjust: 100%;
        tab-size: 4;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
        font-feature-settings: normal;
        font-variation-settings: normal;
        -webkit-tap-highlight-color: transparent;
    }

    hr {
        height: 0;
        color: inherit;
        border-top-width: 1px;
    }

    abbr:where([title]) {
        -webkit-text-decoration: underline dotted;
        text-decoration: underline dotted;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        font-size: inherit;
        font-weight: inherit;
    }

    a {
        color: inherit;
        -webkit-text-decoration: inherit;
        text-decoration: inherit;
    }

    b,
    strong {
        font-weight: bolder;
    }

    code,
    kbd,
    samp,
    pre {
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
        font-feature-settings: normal;
        font-variation-settings: normal;
        font-size: 1em;
    }

    small {
        font-size: 80%;
    }

    sub,
    sup {
        font-size: 75%;
        line-height: 0;
        position: relative;
        vertical-align: baseline;
    }

    sub {
        bottom: -0.25em;
    }

    sup {
        top: -0.5em;
    }

    table {
        text-indent: 0;
        border-color: inherit;
        border-collapse: collapse;
    }

    :-moz-focusring:where(:not(iframe)) {
        outline: auto;
    }

    progress {
        vertical-align: baseline;
    }

    summary {
        display: list-item;
    }

    ol,
    ul,
    menu {
        list-style: none;
    }

    img,
    svg,
    video,
    canvas,
    audio,
    iframe,
    embed,
    object {
        display: block;
        vertical-align: middle;
    }

    img,
    video {
        max-width: 100%;
        height: auto;
    }

    button,
    input,
    select,
    optgroup,
    textarea,
    ::file-selector-button {
        font: inherit;
        font-feature-settings: inherit;
        font-variation-settings: inherit;
        letter-spacing: inherit;
        color: inherit;
        border-radius: 0;
        background-color: transparent;
        opacity: 1;
    }

    :where(select:is([multiple], [size])) optgroup {
        font-weight: bolder;
    }

    :where(select:is([multiple], [size])) optgroup option {
        padding-inline-start: 20px;
    }

    ::file-selector-button {
        margin-inline-end: 4px;
    }

    ::placeholder {
        opacity: 1;
    }

    @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {
        ::placeholder {
            color: color-mix(in oklab, currentcolor 50%, transparent);
        }
    }

    textarea {
        resize: vertical;
    }

    ::-webkit-search-decoration {
        -webkit-appearance: none;
    }

    ::-webkit-date-and-time-value {
        min-height: 1lh;
        text-align: inherit;
    }

    ::-webkit-datetime-edit {
        display: inline-flex;
    }

    ::-webkit-datetime-edit-fields-wrapper {
        padding: 0;
    }

    ::-webkit-datetime-edit,
    ::-webkit-datetime-edit-year-field,
    ::-webkit-datetime-edit-month-field,
    ::-webkit-datetime-edit-day-field,
    ::-webkit-datetime-edit-hour-field,
    ::-webkit-datetime-edit-minute-field,
    ::-webkit-datetime-edit-second-field,
    ::-webkit-datetime-edit-millisecond-field,
    ::-webkit-datetime-edit-meridiem-field {
        padding-block: 0;
    }

    ::-webkit-calendar-picker-indicator {
        line-height: 1;
    }

    :-moz-ui-invalid {
        box-shadow: none;
    }

    button,
    input:where([type='button'], [type='reset'], [type='submit']),
    ::file-selector-button {
        appearance: button;
    }

    ::-webkit-inner-spin-button,
    ::-webkit-outer-spin-button {
        height: auto;
    }

    [hidden]:where(:not([hidden='until-found'])) {
        display: none !important;
    }
}

/*
 * Chakra Petch, IBM Plex Mono and Inter, latin subset, served from this host
 * so a page load asks nothing of a third party.
 */
@font-face {
    font-family: "Chakra Petch";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/chakra-petch-500.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "Chakra Petch";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/chakra-petch-600.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "Chakra Petch";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/chakra-petch-700.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-500.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/inter-400.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/inter-500.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/inter-600.woff2") format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/*
 * QUANTIZE — instrument panel for an image encoder.
 *
 * The console language is carried over from ai-news-gathering, and so is its
 * one rule: colour is data, never decoration. Three roles are reserved and
 * never borrowed from each other.
 *
 *   accent  the instrument itself — chrome, rules, focus, live state
 *   gain    how much a file shrank, and only that
 *   amber   a caveat the numbers do not say
 *
 * A saturated accent at full strength on a near-black ground is tiring to read
 * for long stretches, so accent marks structure and state. Figures wear text
 * tokens unless the figure's colour is itself the information — which, on this
 * screen, means the savings ramp and nothing else.
 */

:root {
    /* Instrument-panel base: blue-black, the colour of a darkened CRT. */
    --p0: #070a0f;
    --p1: #0b0f16;
    --p2: #10161f;
    --p3: #151d28;
    --grid: #16202b;
    --rule: #1e2937;
    --rule-hi: #2b3a4c;

    /*
     * Chrome accent. Saturated enough to carry the brand, which is exactly why
     * the rule above matters: it marks structure and state, and never a figure
     * whose colour is not itself the information.
     *
     * "hi" lifts it for hover and for text that has to hold its own against a
     * near-black ground; "dim" drops it to the weight a corner bracket or a
     * micro-label wants, where full strength would shout.
     */
    --accent: #1786f9;
    --accent-hi: #5aa8fb;
    --accent-dim: #1a5892;

    --text: #dde5ef;
    --text-mid: #8fa0b4;
    --text-low: #5b6b7f;

    --amber: #f0b429;
    --danger: #f2555a;

    /*
     * Savings ramp — reserved, and the only sequential colour on the screen.
     * Read as: how much smaller the file got. The bottom of the ramp is a real
     * outcome, not an error state: re-encoding an already-optimised image can
     * genuinely make it bigger, and saying so plainly beats a flat zero.
     */
    --gain-4: #4bbf7b;
    --gain-3: #8fd06a;
    --gain-2: #e8c33c;
    --gain-1: #f08c3c;
    --gain-0: #f2555a;

    --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --hud: 'Chakra Petch', 'Inter', system-ui, sans-serif;
    --body: 'Inter', system-ui, -apple-system, sans-serif;

    --rail-w: 232px;
    --ad-rail-w: 176px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

    --measure: clamp(640px, 100%, 980px);
}

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

body {
    margin: 0;
    min-height: 100vh;
    background: var(--p0);
    color: var(--text);
    font: 400 13.5px/1.55 var(--body);
    -webkit-font-smoothing: antialiased;
}

/* Scope graticule — texture, not pattern. Fixed so it reads as the surface. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 44px 44px;
    opacity: 0.28;
    -webkit-mask-image: radial-gradient(ellipse 100% 75% at 50% 0%, #000 15%, transparent 78%);
    mask-image: radial-gradient(ellipse 100% 75% at 50% 0%, #000 15%, transparent 78%);
}

:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

button,
input,
select,
label {
    font-family: inherit;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
::-webkit-scrollbar-track {
    background: var(--p1);
}
::-webkit-scrollbar-thumb {
    background: var(--rule);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--rule-hi);
}

.shell {
    position: relative;
    z-index: 1;
}

/* ── Status strip ────────────────────────────────────────────────── */

.statusbar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 46px;
    padding: 0 16px;
    background: var(--p1);
    border-bottom: 1px solid var(--rule);
    font-family: var(--hud);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: none;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.16em;
    white-space: nowrap;
    text-decoration: none;
    color: inherit;
}
/* No glow: a text-shadow halo on a saturated mark is the first thing that makes
   a dark console tiring to sit in front of. */
.brand .logo {
    display: block;
    flex: none;
    color: var(--accent);
}
.brand .wordmark {
    color: var(--text);
}
.brand .sub {
    align-self: center;
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: 0.2em;
    color: var(--text-low);
    text-transform: uppercase;
}

.live {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--text-mid);
    text-transform: uppercase;
}
.live .pip {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
/* The pulse is only honest while an encode is actually outstanding. */
.live.is-working .pip {
    animation: sweep 1.4s var(--ease) infinite;
}

@keyframes sweep {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
    }
    70% {
        box-shadow: 0 0 0 7px transparent;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.readouts {
    display: flex;
    gap: 16px;
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10.5px;
}
.readout {
    display: flex;
    align-items: baseline;
    gap: 5px;
}
.readout .k {
    color: var(--text-low);
    letter-spacing: 0.13em;
    text-transform: uppercase;
    font-size: 9px;
}
.readout .v {
    color: var(--text);
    font-weight: 500;
}
/* Carries the savings ramp like the rows do, so a batch that came out bigger
   cannot report itself in green. */
.readout .v.is-gain {
    color: var(--gain, var(--gain-4));
}

/* ── Frame ───────────────────────────────────────────────────────── */

.workspace {
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    align-items: start;
    gap: 0;
}

.rail {
    background: var(--p1);
    border-right: 1px solid var(--rule);
    padding: 14px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 46px;
    max-height: calc(100vh - 46px);
    overflow-y: auto;
}

.rail-group > h2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 14px 8px;
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--text-low);
}
.rail-group > h2 .scope {
    letter-spacing: 0.1em;
    color: var(--accent-dim);
}

/* A rail, not tabs: modes are meant to grow past this list. */
.mode {
    display: grid;
    grid-template-columns: 5px 1fr;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    padding: 8px 14px 8px 0;
    background: none;
    border: 0;
    color: var(--text-mid);
    text-align: left;
    cursor: pointer;
    transition:
        background 0.15s var(--ease),
        color 0.15s var(--ease);
}
.mode .bar {
    background: var(--rule-hi);
    opacity: 0.55;
    transition:
        opacity 0.15s var(--ease),
        background 0.15s var(--ease);
}
.mode:hover {
    background: var(--p2);
    color: var(--text);
}
.mode:hover .bar {
    opacity: 0.75;
}
.mode[aria-pressed='true'] {
    background: var(--p3);
    color: var(--text);
}
.mode[aria-pressed='true'] .bar {
    background: var(--accent);
    opacity: 1;
}
.mode .mode-name {
    font-family: var(--hud);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.25;
}
.mode .mode-note {
    display: block;
    margin-top: 3px;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-low);
}
.mode[aria-pressed='true'] .mode-note {
    color: var(--accent-dim);
}

/* Batch totals on the download screen, where the rail has no modes to carry. */
.tally {
    display: grid;
    gap: 1px;
    padding: 0 14px;
}
.tally-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    font-family: var(--mono);
    font-size: 11px;
}
.tally-row .k {
    color: var(--text-low);
    letter-spacing: 0.13em;
    text-transform: uppercase;
    font-size: 9px;
}
.tally-row .v {
    color: var(--text-mid);
}
.tally-row.is-total {
    margin-top: 5px;
    padding-top: 10px;
    border-top: 1px solid var(--rule);
}
.tally-row.is-total .v {
    font-family: var(--hud);
    font-size: 17px;
    font-weight: 700;
    color: var(--gain, var(--gain-4));
}

.main {
    min-width: 0;
    padding: 16px max(18px, calc((100% - var(--measure)) / 2)) 72px;
    display: grid;
    gap: 12px;
    align-content: start;
}

.ad-rail {
    position: sticky;
    top: 46px;
    padding: 16px 8px;
    display: flex;
    justify-content: center;
    border-left: 1px solid var(--rule);
    min-height: calc(100vh - 46px);
}

/* ── HUD panel ───────────────────────────────────────────────────── */
/*
 * Corner brackets rather than a full border: the frame marks a panel's extent
 * without drawing four heavy lines around every block.
 */
.panel {
    position: relative;
    background: var(--p1);
    border: 1px solid var(--rule);
    padding: 14px 16px;
}
.panel::before,
.panel::after {
    content: '';
    position: absolute;
    width: 9px;
    height: 9px;
    border: 1px solid var(--accent-dim);
    pointer-events: none;
}
.panel::before {
    top: -1px;
    left: -1px;
    border-right: 0;
    border-bottom: 0;
}
.panel::after {
    bottom: -1px;
    right: -1px;
    border-left: 0;
    border-top: 0;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-family: var(--hud);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
}
.panel-head .meta {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.08em;
    color: var(--text-low);
    text-transform: none;
}

/* ── Drop zone ───────────────────────────────────────────────────── */

.dropzone {
    position: relative;
    display: grid;
    place-items: center;
    gap: 14px;
    padding: 42px 20px;
    border: 1px dashed var(--rule-hi);
    background:
        radial-gradient(ellipse 70% 100% at 50% 0%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 70%),
        var(--p0);
    text-align: center;
    transition:
        border-color 0.16s var(--ease),
        background-color 0.16s var(--ease);
}
.dropzone.is-over {
    border-color: var(--accent);
    background-color: var(--p2);
}
.dropzone-title {
    font-family: var(--hud);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text);
}
.dropzone-sub {
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-low);
}
.dropzone input[type='file'] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--p1);
    border: 1px solid var(--rule);
    color: var(--text-mid);
    font-family: var(--hud);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition:
        background 0.14s var(--ease),
        border-color 0.14s var(--ease),
        color 0.14s var(--ease);
}
.btn:hover {
    background: var(--p2);
    border-color: var(--rule-hi);
    color: var(--text);
}
.btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--p0);
}
.btn-primary:hover {
    background: var(--accent-hi);
    border-color: var(--accent-hi);
    color: var(--p0);
}
.btn-ghost {
    background: none;
    padding: 7px 11px;
    font-size: 10.5px;
    letter-spacing: 0.12em;
}
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.btn-row .spacer {
    margin-left: auto;
}

/* ── Settings ────────────────────────────────────────────────────── */

.settings > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 16px;
    font-family: var(--hud);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
}
.settings > summary::-webkit-details-marker {
    display: none;
}
.settings > summary .chev {
    margin-left: auto;
    color: var(--text-low);
    transition: transform 0.18s var(--ease);
}
.settings[open] > summary .chev {
    transform: rotate(180deg);
}
.settings > summary .active-mode {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.1em;
    color: var(--text-low);
    text-transform: none;
}
.settings-body {
    padding: 4px 16px 16px;
    display: grid;
    gap: 2px;
    border-top: 1px solid var(--rule);
    margin-top: 2px;
    padding-top: 14px;
}

.field {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 11px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent);
}
.field:last-child {
    border-bottom: 0;
}
.field > .lab {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--text-mid);
    padding-top: 7px;
}
.field .hint {
    display: block;
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-low);
}
.field.is-disabled {
    opacity: 0.45;
}

.control {
    min-width: 0;
}

select,
input[type='number'],
input[type='text'] {
    width: 100%;
    padding: 8px 10px;
    background: var(--p0);
    border: 1px solid var(--rule);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
}
select:hover,
input[type='number']:hover,
input[type='text']:hover {
    border-color: var(--rule-hi);
}
select:disabled,
input:disabled {
    cursor: not-allowed;
}

.dims {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
}
.dims .x {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-low);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding-top: 7px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
.check input {
    accent-color: var(--accent);
    margin: 1px 0 0;
    cursor: pointer;
    flex: none;
}
.check .txt {
    font-size: 12.5px;
    color: var(--text-mid);
}
.check:hover .txt {
    color: var(--text);
}

/* Slider: the value rides above the thumb rather than sitting in a box beside
   it, so the number and the position it names are never read apart. */
.slider {
    display: grid;
    gap: 8px;
    padding-top: 4px;
}
.slider-track {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
}
.slider-track .end {
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: 0.1em;
    color: var(--text-low);
    text-transform: uppercase;
}
.slider-value {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-family: var(--hud);
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.slider-value .unit {
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-low);
}
.slider-value.is-auto {
    font-size: 12.5px;
    color: var(--accent);
    letter-spacing: 0.06em;
}

input[type='range'] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: none;
    cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
    height: 2px;
    background: var(--rule);
}
input[type='range']::-moz-range-track {
    height: 2px;
    background: var(--rule);
}
input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    margin-top: -5.5px;
    background: var(--accent);
    border: 0;
    border-radius: 50%;
}
input[type='range']::-moz-range-thumb {
    width: 13px;
    height: 13px;
    background: var(--accent);
    border: 0;
    border-radius: 50%;
}
input[type='range']:disabled::-webkit-slider-thumb {
    background: var(--text-low);
}
input[type='range']:disabled::-moz-range-thumb {
    background: var(--text-low);
}

/* ── File rows ───────────────────────────────────────────────────── */

.files {
    display: grid;
    gap: 5px;
}

.file {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 11px 13px 11px 16px;
    background: var(--p1);
    border: 1px solid var(--rule);
    border-left: 0;
}
.file::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--state, var(--rule-hi));
}
.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 5px;
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text-low);
}
.file-meta .sep::before {
    content: '·';
}
.file-meta .to {
    color: var(--text-mid);
}
.file-meta .note {
    color: var(--amber);
}
.file-meta .err {
    color: var(--danger);
}

.file-gain {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex: none;
}
.file-gain .pct {
    font-family: var(--hud);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: var(--gain, var(--text-mid));
}
.file-gain .cap {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-low);
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

/* The bar is the only progress signal; it is removed the moment it is done, so
   a finished row never carries a full bar that reads as still running. */
.file-progress {
    position: absolute;
    left: 0;
    bottom: -1px;
    height: 1px;
    background: var(--accent);
    transition: width 0.2s linear;
}

/* ── Info ────────────────────────────────────────────────────────── */

.prose {
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-mid);
}
.prose p {
    margin: 0 0 10px;
}
.prose p:last-child {
    margin-bottom: 0;
}
.prose strong {
    color: var(--text);
    font-weight: 600;
}
.prose code {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--accent);
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.step .n {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-dim);
}
.step h4 {
    margin: 6px 0 5px;
    font-family: var(--hud);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.step p {
    margin: 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-low);
}

.notice {
    display: flex;
    gap: 9px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--amber) 8%, var(--p1));
    border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
    font-size: 12.5px;
    color: var(--text-mid);
}
.notice .mark {
    color: var(--amber);
    flex: none;
    font-family: var(--mono);
}

.empty {
    padding: 18px 0 4px;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-low);
    text-align: center;
}

.footer-link {
    color: var(--text-mid);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-dim);
    padding-bottom: 1px;
    transition:
        color 0.14s var(--ease),
        border-color 0.14s var(--ease);
}
.footer-link:hover {
    color: var(--accent-hi);
    border-color: var(--accent);
}

.footer {
    padding: 20px max(18px, calc((100% - var(--measure)) / 2));
    border-top: 1px solid var(--rule);
    background: var(--p1);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-low);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ── Ads ─────────────────────────────────────────────────────────── */
/*
 * Every slot reserves its full size whether or not a unit fills it, so turning
 * a provider on later cannot move the interface underneath the reader.
 */
.ad {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: var(--ad-w);
    min-height: var(--ad-h);
    margin-inline: auto;
}
.ad-leaderboard {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule);
    background: var(--p1);
    max-width: none;
}
.ad-leaderboard > * {
    max-width: var(--ad-w);
}
.ad-pair {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule);
    background: var(--p1);
}
.ad-pair .ad {
    width: auto;
    flex: 0 1 var(--ad-w);
    margin-inline: 0;
}
.ad-rail .ad {
    position: sticky;
    top: 62px;
}

.ad-placeholder {
    display: grid;
    place-items: center;
    gap: 4px;
    width: 100%;
    max-width: var(--ad-w);
    min-height: var(--ad-h);
    border: 1px dashed var(--rule);
    color: var(--text-low);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}
.ad-placeholder .dim {
    color: color-mix(in srgb, var(--text-low) 60%, transparent);
    letter-spacing: 0.1em;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: var(--rail-w) minmax(0, 1fr);
    }
    .ad-rail {
        display: none;
    }
}

@media (max-width: 860px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }
    .rail {
        position: static;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--rule);
        padding-bottom: 14px;
    }
    /* The mode list becomes a horizontal shelf rather than stacking six tall
       rows above the drop zone, which would push the tool off the screen. */
    .rail-group.modes .mode-list {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 0 14px 4px;
        scrollbar-width: thin;
    }
    .rail-group.modes .mode {
        flex: none;
        width: 190px;
        padding: 8px 12px;
        border: 1px solid var(--rule);
        grid-template-columns: 3px 1fr;
    }
    .rail .ad {
        display: none;
    }
    .readouts .readout.optional {
        display: none;
    }
    .field {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }
    .field > .lab {
        padding-top: 0;
    }
    .steps {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .brand .sub {
        display: none;
    }
    .file {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }
    .file-gain {
        flex-direction: row;
        align-items: baseline;
        justify-content: flex-start;
        gap: 8px;
    }
}

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