/* =====================================================================
 * styles.css — shared stylesheet for nano-key-ui
 *
 * Loaded by:
 *   • multi-chroma-key-setup.html    (full 7-step workflow)
 *   • multi-chroma-key-sample.html   (simplified sample page)
 *   • multi-chroma-key-player.html   (player)
 *   • setup.html                     (refresh setup page)
 *
 * Section tags in comments:
 *   [shared]      — used by both pages
 *   [setup only]  — only referenced by multi-chroma-key-setup.html
 *   [sample only] — only referenced by multi-chroma-key-sample.html
 *
 * Brand: nanocosmos demo tier (web.pages.gitlab.nanocosmos.cloud).
 *   Headings: Lexend Deca · Body: Source Sans 3
 *   Orange #F48220 · Navy #00486C · Light Blue #0F8DC8
 * ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');


/* ---------- Brand tokens ---------- */
:root {
    /* Brand core */
    --orange:        #F48220;
    --orange-dark:   #EF7D00;
    --blue:          #0F8DC8;
    --navy:          #00486C;
    --hero-navy:     #0A436A;

    /* Dark-UI surface scale derived from navy */
    --surface-0:     #0E2A3F;   /* page background */
    --surface-1:     #0A436A;   /* section panels */
    --surface-2:     #0F537F;   /* nested cards / table-row hover */
    --surface-3:     #14628F;   /* selected state */
    --surface-deep:  #061B29;   /* inputs, code, deepest */

    /* Text on dark — tuned for AA contrast on --surface-1/2 */
    --text:          #FFFFFF;
    --text-soft:     #E3EDF3;   /* AAA on all dark surfaces */
    --text-muted:    #B5C8D6;   /* AA on surface-1/2; use for body-meta */
    --text-faint:    #8FA8B8;   /* AA-large on surface-1/2; use for 11–12px hints only */

    /* Lines / dividers */
    --line-dark:     #1F5E85;
    --line-faint:    rgba(255, 255, 255, 0.08);

    /* Status colors (legible on navy) */
    --ok:            #4CAF50;
    --warn:          #F4A720;
    --err:           #F25C5C;

    /* Form-field text on white field bg */
    --ink-on-light:  #313131;

    /* Typography (demo tier: Lexend Deca + Source Sans 3 per brand guide) */
    --font-display:  'Lexend Deca', 'Source Sans 3', Helvetica, Arial, sans-serif;
    --font-body:     'Source Sans 3', 'Open Sans', Helvetica, Arial, sans-serif;
    --font-mono:     ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Geometry */
    --radius:        8px;
    --radius-sm:     4px;
    --shadow:        0 18px 50px rgba(0, 0, 0, 0.28);
}


/* ---------- Light theme overrides ----------
 * Activated by `<html data-theme="light">`. The pre-paint <script> in
 * multi-chroma-key-setup.html sets that attribute before styles.css is
 * applied to the body, so first paint is correct on reload.
 *
 * Strategy: only re-bind the existing tokens — every component already
 * reads var(--surface-*) / var(--text-*) etc., so flipping the values
 * here propagates everywhere without per-rule overrides. Keep brand
 * accent colors (--orange/--blue/--navy) untouched in both themes. */
:root[data-theme="light"] {
    --surface-0:     #F4F7FA;   /* page background */
    --surface-1:     #FFFFFF;   /* section panels */
    --surface-2:     #EFF3F7;   /* nested cards / table-row hover */
    --surface-3:     #E2EAF1;   /* selected state */
    --surface-deep:  #FFFFFF;   /* inputs, code */

    --text:          #1A2B3A;
    --text-soft:     #2A3E50;
    --text-muted:    #5A6E80;
    --text-faint:    #8095A6;

    --line-dark:     #C9D4DD;
    --line-faint:    rgba(0, 0, 0, 0.06);

    --shadow:        0 10px 28px rgba(20, 50, 80, 0.10);
}


/* ---------- Base / typography [shared] ---------- */
* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: 15px;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: var(--surface-0);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1 { color: var(--orange); font-family: var(--font-display); font-weight: 700; letter-spacing: -0.005em; line-height: 1.15; }
h3 { margin: 0 0 15px 0; color: var(--orange); font-family: var(--font-display); font-weight: 700; letter-spacing: 0; line-height: 1.2; }
h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em; line-height: 1.25; }

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-soft);
    letter-spacing: 0.01em;
}


/* ---------- Layout [shared] ---------- */
.section {
    background: var(--surface-1);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.hidden { display: none; }                  /* [sample only] historically; now also used by setup hide helpers */

/* Collapsible section: uses <details class="section collapsible"> with a
   <summary> replacing the <h3>. Summary mimics the h3 look and adds a caret.
   [setup only — used by Authenticate + Backgrounds] */
details.collapsible > summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
    color: var(--orange);
    font-weight: 700;
    font-size: 1.17em;        /* matches default h3 sizing */
    margin: 0 0 15px 0;
    padding-left: 30px;
    position: relative;
    outline: none;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before {
    content: '▸';
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    font-size: 1.4em;
    line-height: 1;
    color: var(--orange);
    transition: transform 0.15s;
}
details.collapsible[open] > summary::before { content: '▾'; }
details.collapsible:not([open]) > summary { margin-bottom: 0; }   /* tighter when closed */


/* ---------- Form elements [shared] ---------- */
input, select, textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--line-dark);
    border-radius: 4px;
    background: var(--surface-deep);
    color: var(--text);
    font-size: 14px;
}

textarea {                                  /* [setup only] — setup has <textarea> elements; sample does not */
    font-family: monospace;
    font-size: 12px;
    min-height: 120px;
    line-height: 1.5;
    resize: vertical;
}

/* Compact range sliders — override default input padding/border/margin. [shared] */
input[type="range"] {
    padding: 0;
    margin-bottom: 4px;
    border: 0;
    background: transparent;
    height: 14px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: #2a2a40; border-radius: 2px; }
input[type="range"]::-moz-range-track            { height: 3px; background: #2a2a40; border-radius: 2px; border: 0; }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--orange); margin-top: -4.5px; border: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
    width: 12px; height: 12px; border: 0; border-radius: 50%;
    background: var(--orange); box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
input[type="range"].red::-webkit-slider-thumb,   input[type="range"].red::-moz-range-thumb   { background: #ff4444; }
input[type="range"].green::-webkit-slider-thumb, input[type="range"].green::-moz-range-thumb { background: #44ff44; }
input[type="range"].blue::-webkit-slider-thumb,  input[type="range"].blue::-moz-range-thumb  { background: #4444ff; }


/* ---------- Buttons [shared] ---------- */
button {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--orange);
    color: #fff;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.015em;
    margin-right: 10px;
    transition: background 0.15s, transform 0.15s;
}
button:hover    { background: var(--orange-dark); }
button:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; opacity: 0.7; }


/* ---------- Result / info / status banners [shared] ---------- */
.result {
    background: var(--surface-deep);
    padding: 15px;
    border-radius: 4px;
    margin-top: 10px;
    font-family: monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}
.success { border-left: 4px solid var(--ok); }
.error   { border-left: 4px solid var(--err); }

.info {
    background: var(--surface-2);
    padding: 12px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 13px;
}
.info code {                                /* [sample only] — inline <code> inside .info */
    background: var(--surface-deep);
    padding: 2px 6px;
    border-radius: 3px;
    word-break: break-all;
}


/* ---------- Chroma color section wrapper [shared] ---------- */
.chroma-section {
    background: var(--surface-2);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 5px;
}
.chroma-section h4 {
    margin: 0 0 12px 0;
    color: var(--orange);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-subhead {                          /* [setup only] — stand-alone h4 "Stream Information" heading */
    margin: 20px 0 12px 0;
    color: var(--orange);
    font-size: 14px;
    text-transform: uppercase;
}


/* ---------- Compact color picker: preview + RGB [shared] ---------- */
.color-compact { display: grid; grid-template-columns: 80px 1fr; gap: 15px; align-items: start; }
.color-left    { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.color-right   { display: flex; flex-direction: column; gap: 10px; }
.color-preview-compact {
    width: 70px; height: 70px;
    border-radius: 10px; border: 3px solid var(--line-dark);
    background: #00FF00;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.eyedropper-compact {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--surface-3); color: #fff;
    border: none; border-radius: 4px;
    margin: 0; width: 100%;
    cursor: pointer; font-weight: 600;
}
.eyedropper-compact:hover { background: var(--blue); }

/* Inline R/G/B row (current layout) [shared] */
.rgb-inline              { display: flex; gap: 12px; align-items: center; }
.rgb-inline .rgb-channel { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.rgb-inline .rgb-label   { font-size: 12px; font-weight: bold; width: 14px; text-align: center; }
.rgb-inline .rgb-label.red   { color: #ff4444; }
.rgb-inline .rgb-label.green { color: #44ff44; }
.rgb-inline .rgb-label.blue  { color: #4444ff; }
.rgb-inline .rgb-slider { flex: 1; margin: 0; min-width: 0; }
.rgb-inline .rgb-value  {
    width: 48px; padding: 3px 4px; font-size: 12px; margin: 0;
    text-align: center; border-radius: 4px;
    background: var(--surface-deep); color: #fff; border: 1px solid var(--line-dark);
}

/* Legacy stacked R/G/B rows — no longer used in markup. Kept in case a future
   variant wants three stacked rows again. [shared, legacy] */
.rgb-row-compact { display: grid; grid-template-columns: 20px 1fr 50px; gap: 8px; align-items: center; height: 28px; }
.rgb-row-compact .rgb-label       { font-size: 12px; font-weight: bold; text-align: center; }
.rgb-row-compact .rgb-label.red   { color: #ff4444; }
.rgb-row-compact .rgb-label.green { color: #44ff44; }
.rgb-row-compact .rgb-label.blue  { color: #4444ff; }
.rgb-row-compact .rgb-slider { width: 100%; height: 6px; margin: 0; accent-color: var(--orange); }
.rgb-row-compact .rgb-value  {
    width: 100%; padding: 3px 6px; font-size: 12px; margin: 0;
    text-align: center; border-radius: 4px;
    background: var(--surface-deep); color: #fff; border: 1px solid var(--line-dark);
}

/* Hex input row under the RGB block [shared] */
.hex-row-compact {
    display: flex; align-items: center; gap: 6px;
    margin-top: 4px; padding-top: 10px;
    border-top: 1px solid var(--surface-3);
}
.hex-row-compact .hex-prefix { font-size: 14px; color: var(--text-muted); font-weight: bold; }
.hex-row-compact input {
    flex: 1; margin: 0; padding: 6px 10px;
    font-size: 13px; font-family: monospace;
    text-transform: uppercase; letter-spacing: 1px;
    background: var(--surface-deep); color: #fff; border: 1px solid var(--line-dark); border-radius: 4px;
}


/* ---------- Slider labels + editable value pills [shared] ---------- */
.slider-header       { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slider-header label { margin: 0; font-weight: 600; }

.value-badge {                              /* non-editable pill — kept for backward compat [shared] */
    background: var(--orange); color: #fff;
    padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: bold;
}
.value-input {                              /* editable number pill for Similarity/Blend [shared] */
    background: var(--orange); color: #fff;
    padding: 2px 6px;
    border: 1px solid var(--orange); border-radius: 12px;
    font-size: 12px; font-weight: bold; font-family: inherit;
    width: 62px; text-align: center; margin: 0;
    -moz-appearance: textfield;
}
.value-input::-webkit-outer-spin-button,
.value-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.value-input:focus { outline: 1px solid #fff; }

.param-slider { width: 100%; margin-bottom: 8px; accent-color: var(--orange); }
.help-text    { font-size: 12px; color: var(--text-muted); margin: 8px 0 0 0; line-height: 1.4; }


/* =====================================================================
 * [setup only] — rules referenced exclusively by multi-chroma-key-setup.html
 * ===================================================================== */

/* Legacy color-preview + eyedropper (pre-compact variant) [setup only] */
.color-preview-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.color-preview     { width: 50px; height: 50px; border-radius: 8px; border: 2px solid var(--line-dark); background: #00FF00; }
.eyedropper-btn        { margin: 0; padding: 8px 14px; font-size: 13px; background: var(--surface-3); }
.eyedropper-btn:hover  { background: var(--blue); }

/* Stacked rgb-sliders layout (legacy) [setup only] */
.rgb-sliders      { display: flex; flex-direction: column; gap: 8px; }
.rgb-row          { display: flex; align-items: center; gap: 8px; }
.rgb-label        { width: 20px; font-weight: bold; font-size: 12px; }
.rgb-label.red    { color: #ff4444; }
.rgb-label.green  { color: #44ff44; }
.rgb-label.blue   { color: #4444ff; }
.rgb-slider       { flex: 1; margin: 0; accent-color: var(--orange); }
.rgb-slider.red   { accent-color: #ff4444; }
.rgb-slider.green { accent-color: #44ff44; }
.rgb-slider.blue  { accent-color: #4444ff; }
.rgb-value        { width: 55px; text-align: center; padding: 5px; font-size: 13px; margin: 0; }
.hex-input-row    { display: flex; align-items: center; gap: 5px; }
.hex-prefix       { font-size: 16px; color: var(--text-muted); font-weight: bold; }
#hexInput         { font-family: monospace; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }

/* Color-picker input tabs (RGB / HEX switch) [setup only] */
.input-tabs         { display: flex; gap: 5px; margin-bottom: 12px; }
.tab-btn            { padding: 6px 14px; background: var(--surface-deep); border: 1px solid var(--line-dark); color: var(--text-muted); font-size: 12px; margin: 0; }
.tab-btn.active     { background: var(--orange); color: #fff; border-color: var(--orange); }
.tab-content        { display: none; }
.tab-content.active { display: block; }

/* ---------- Utility rows (form layouts, action rows) [setup only] ---------- */
.form-row                   { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.form-row.wrap              { flex-wrap: wrap; }
.form-row.tight             { gap: 6px; }
.form-row > label           { margin: 0; white-space: nowrap; flex-shrink: 0; }
.form-row > .grow           { flex: 1; min-width: 0; }
.form-row > input,
.form-row > select          { margin: 0; }

.action-row                 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.action-row > .grow         { flex: 1; min-width: 0; }

/* ---------- Compact button variants [setup only] ---------- */
.btn-sm                     { padding: 8px 18px; font-size: 13px; margin: 0; white-space: nowrap; }
.btn-xs                     { padding: 4px 10px; font-size: 11px; margin: 0; background: var(--surface-3); }
.btn-xs:hover               { background: var(--blue); }
.btn-secondary              { background: var(--surface-3); }
.btn-secondary:hover        { background: var(--blue); }

/* ---------- Text helpers [setup only] ---------- */
.text-muted                 { color: var(--text-muted); font-size: 12px; }
.text-muted-sm              { color: var(--text-muted); font-size: 11px; }
.text-hint                  { color: var(--text-muted); font-size: 12px; }

/* Compact variant of the existing .info banner [setup only] */
.info.sm                    { font-size: 12px; padding: 8px 12px; margin-bottom: 12px; }

/* Overlay centred inside a relative parent (e.g. player placeholder) [setup only] */
.overlay-center             { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* Hidden native <input type="color"> launcher — keeps the <label> chip clickable [setup only] */
.native-picker-hidden       { width: 0; height: 0; padding: 0; border: 0; opacity: 0; position: absolute; }

/* ---------- Preset colour / tab / toggle buttons [setup only] ----------
   .active drives visual state so JS only needs classList.toggle() (no more
   btn.style.background writes). */
.preset-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px; font-size: 13px;
    background: var(--surface-3); color: #fff;
    border: none; cursor: pointer; margin: 0;
}
.preset-btn.active                       { background: var(--orange); }
.preset-btn:hover:not(.active)           { background: var(--blue); }
.preset-btn .swatch                      { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 2px solid #fff; }
.preset-btn .swatch.green                { background: #00FF00; }
.preset-btn .swatch.blue                 { background: #0000FF; }
.preset-btn.picker-label                 { cursor: pointer; }    /* the <label> variant that wraps a hidden color input */

/* Key Color indicator row (swatch + hex + name) [setup only] */
.color-indicator                         { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; color: var(--text-soft); }
.color-indicator .swatch-box             { width: 24px; height: 24px; border-radius: 6px; background: #00FF00; border: 2px solid var(--line-dark); }

/* Two-column grid for the Similarity / Blend pair [setup only] */
.grid-2col                               { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Setup mode tabs (Create vs Reuse) [setup only] */
.mode-tab {
    flex: 1; padding: 12px 16px; font-size: 14px; font-weight: 600;
    border-radius: 6px 6px 0 0;
    cursor: pointer; transition: background 0.15s, color 0.15s;
    margin: 0;
}
.mode-tab:not(.active)                   { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--surface-3); border-bottom-color: var(--surface-3); }
.mode-tab.active                         { background: var(--orange); color: #fff; border: 1px solid var(--orange); border-bottom-color: var(--surface-1); }
.mode-tab:hover:not(.active)             { background: var(--surface-2); color: var(--text-soft); }
.mode-tab.left                           { margin: 0 2px -1px 0; }
.mode-tab.right                          { margin: 0 0 -1px 2px; }
.mode-tabs-row                           { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 1px solid var(--surface-3); }

/* Live Player block layout [setup only] */
.player-section                          { margin-top: 20px; }
.player-section h4                       { color: var(--orange); margin: 0; }
.player-header                           { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.player-tabs-row                         { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.player-stage                            { background: #000; border-radius: 8px; overflow: hidden; position: relative; aspect-ratio: 16/9; }
#playerDiv                               { width: 100%; height: 100%; }
.player-placeholder                      { color: var(--text-faint); font-size: 14px; }

/* Live Adjustment panel [setup only] */
.adjust-panel                            { margin-top: 20px; }
.adjust-panel > h4                       { color: var(--orange); margin: 0 0 12px 0; }

/* Section footer actions (e.g. "+ Create New Setup") [setup only] */
.section-actions                         { margin-top: 20px; }

/* Compact inline toggle (checkbox + label) for action rows [setup only] */
.switch-label                            { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text-soft); cursor: pointer; white-space: nowrap; font-weight: 600; }
.switch-label input[type="checkbox"]     { width: auto; margin: 0; accent-color: var(--orange); cursor: pointer; }

/* Per-stream player tabs (Native / Target N) [setup only] */
.player-tab {
    padding: 8px 16px; margin: 0;
    border: 2px solid var(--line-dark); border-radius: 6px;
    background: var(--surface-2); color: #fff;
    cursor: pointer; font-size: 13px; font-weight: 600;
}
.player-tab.active                       { background: var(--orange); border-color: var(--orange); }

/* Upload column: selected-files chip + progress wrapper [setup only] */
.upload-card-heading                     { background: var(--surface-1); padding: 8px 10px; border-radius: 4px; margin-bottom: 8px; font-size: 12px; }
.upload-card-heading ul                  { margin: 4px 0 0 0; padding-left: 18px; color: var(--text-soft); font-size: 11px; }
.upload-progress                         { margin-top: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 4px; font-size: 12px; }
.upload-progress .bar                    { background: var(--surface-deep); height: 6px; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.upload-progress .fill                   { background: var(--orange); height: 100%; width: 0%; transition: width 0.3s; }

/* Per-file validation items emitted by onFilesSelected templates [setup only] */
.validation-item                         { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); list-style: none; }
.validation-item .title                  { font-weight: 600; }
.validation-item .meta                   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.validation-item.ok                      { color: var(--ok); }
.validation-item.ok .meta                { color: var(--text-muted); }
.validation-item.warn                    { color: var(--warn); }
.validation-item.warn .meta              { color: #ffcc80; }
.validation-item.warn .meta.accent       { color: var(--warn); }
.validation-item.err                     { color: var(--err); }
.validation-item.err .meta               { color: #ff8888; }
.validation-loading                      { color: var(--text-muted); list-style: none; }

/* Background-select embedded in target rows [setup only] */
.bg-select                               { width: 100%; margin: 0; padding: 4px 6px; font-size: 12px; }

/* Stream-information table (Step 3) [setup only] */
.stream-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.stream-table      { width: 100%; border-collapse: collapse; font-size: 13px; }
.stream-table th, .stream-table td {
    text-align: left; padding: 6px 10px;
    border-bottom: 1px solid var(--surface-3);
    vertical-align: middle; white-space: nowrap;
}
.stream-table th {
    font-weight: 600; color: var(--orange); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px;
    background: var(--surface-2);
}
.stream-table tr:hover td        { background: var(--surface-2); }
.stream-table .mono              {
    font-family: monospace; font-size: 12px;
    display: inline-block;
    -webkit-user-select: all; user-select: all;
}
.stream-table a.mono             { color: var(--orange); text-decoration: none; }
.stream-table a.mono:hover       { text-decoration: underline; }
.stream-table .copyable          { cursor: pointer; color: var(--text-soft); }
.stream-table .copyable:hover    { color: #fff; }
.stream-table .muted             { color: var(--text-faint); }
.stream-table .copy-btn {                  /* scoped copy button used inside table cells [setup only] */
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    padding: 0 4px; font-size: 12px;
    margin: 0 0 0 4px; vertical-align: middle;
}
.stream-table .copy-btn:hover    { color: #fff; }
.stream-meta                     { font-size: 12px; color: var(--text-muted); margin: 4px 0 12px 0; }
.stream-meta code {
    background: var(--surface-deep); padding: 2px 6px; border-radius: 3px;
    color: var(--orange); font-family: monospace;
}

/* three-column uploader grid [setup only] */
.upload-grid {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(220px, 1.2fr) minmax(220px, 1.5fr);
    gap: 12px;
}
@media (max-width: 820px) {
    .upload-grid { grid-template-columns: 1fr; }
}
.upload-grid > div          { min-width: 0; }
.upload-col-title           { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.upload-col-title strong    { color: var(--orange); }
.upload-area                { border: 2px dashed #444; border-radius: 6px; text-align: center; cursor: pointer; background: var(--surface-0); color: var(--text); transition: border-color 0.15s; }
.upload-area.drag-over      { border-color: var(--orange); }
.upload-area.compact        { padding: 18px 10px; font-size: 12px; }
.upload-area.compact .drop-icon { font-size: 28px; margin-bottom: 4px; }
.file-list-empty            { color: var(--text-faint); font-size: 12px; padding: 14px 8px; text-align: center; }

/* Uploaded-files list + preview [setup only] */
.file-list-box              { background: var(--surface-deep); border-radius: 6px; padding: 4px; max-height: 260px; overflow-y: auto; }
.file-list-item {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 6px 10px; border-radius: 4px;
    cursor: pointer; font-size: 12px; color: var(--text-soft);
}
.file-list-item:hover       { background: var(--surface-2); color: #fff; }
.file-list-item.selected    { background: var(--surface-3); color: #fff; }
.file-list-item .fname      {
    font-family: monospace;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.file-list-item .fmeta      { color: var(--text-muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.preview-box {
    background: var(--surface-deep); border-radius: 6px; padding: 10px;
    min-height: 180px;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 8px;
}
.preview-box img, .preview-box video { max-width: 100%; max-height: 240px; border-radius: 4px; background: #000; }
.preview-box .placeholder   { color: var(--text-faint); font-size: 12px; text-align: center; }
.preview-box .fname-line    { font-family: monospace; font-size: 11px; color: var(--text-muted); word-break: break-all; text-align: center; margin: 0; }

/* Command / textarea row helper [setup only] */
.cmd-row          { display: flex; gap: 10px; align-items: flex-start; }
.cmd-row textarea { flex: 1; margin: 0; min-height: 60px; }
.cmd-row button   { margin: 0; white-space: nowrap; }
.cmd-label        { color: var(--text-muted); font-size: 12px; margin-bottom: 5px; }

/* Dashboard cards — old layout, superseded by .stream-table but retained for possible reuse [setup only] */
.dashboard-grid                     { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.dashboard-card {
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-deep) 100%);
    border: 1px solid var(--surface-3);
    border-radius: 10px; padding: 16px;
    position: relative; overflow: hidden;
}
.dashboard-card::before             { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.dashboard-card.ingest::before      { background: linear-gradient(90deg, var(--orange), #ff9900); }
.dashboard-card.target::before      { background: linear-gradient(90deg, #00c6ff, #0072ff); }
.dashboard-card.modifiy::before     { background: linear-gradient(90deg, #11998e, #38ef7d); }
.card-header                        { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.card-header .icon                  { font-size: 18px; }
.card-row                           {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 12px;
}
.card-row:last-child                { border-bottom: none; }
.card-row .label                    { color: var(--text-muted); }
.card-row .value                    { font-family: monospace; color: #fff; }
.card-row .value.clickable          { color: var(--orange); cursor: pointer; text-decoration: none; }
.card-row .value.clickable:hover    { text-decoration: underline; }
.card-actions                       { display: flex; gap: 8px; margin-top: 12px; }
.card-actions button                { flex: 1; padding: 8px; font-size: 12px; margin: 0; }
.modify-section                     { background: var(--surface-deep); border-radius: 8px; padding: 12px; margin-top: 15px; }
.modify-grid                        { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.modify-item                        { text-align: center; }
.modify-item .label                 { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.modify-item .value                 { font-family: monospace; font-size: 12px; color: #fff; }


/* =====================================================================
 * [sample only] — rules referenced exclusively by multi-chroma-key-sample.html
 * ===================================================================== */

/* Button-row helper (two buttons side by side in Sample page) [sample only] */
.btn-row        { display: flex; gap: 10px; margin-bottom: 15px; }
.btn-row button { flex: 1; }

/* Two-column grid + targets grid [sample only] */
.grid-2         { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.targets-grid   { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 10px; }

.target-card            { background: var(--surface-2); padding: 12px; border-radius: 6px; font-size: 13px; }
.target-card strong     { color: var(--orange); display: block; margin-bottom: 6px; }
.target-card a          { color: var(--orange); word-break: break-all; }

/* Hints under form inputs [sample only] */
.hint { font-size: 12px; color: var(--text-muted); margin-top: -10px; margin-bottom: 12px; }

/* Field rows with labels + copy buttons [sample only] */
.field-row                      { margin-bottom: 12px; }
.field-row .field-label         { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.field-row .field-value         { display: flex; align-items: center; gap: 8px; }
.field-row input[type=text] {
    flex: 1; margin: 0; padding: 7px 10px;
    font-family: monospace; font-size: 12px;
    background: var(--surface-deep); border: 1px solid var(--surface-3); border-radius: 4px;
    color: var(--text-soft); cursor: text;
}
.field-row a.field-link {
    flex: 1; padding: 7px 10px;
    font-family: monospace; font-size: 12px;
    background: var(--surface-deep); border: 1px solid var(--surface-3); border-radius: 4px;
    color: var(--orange); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: block; text-decoration: none;
}
.field-row a.field-link:hover   { text-decoration: underline; }

/* Stand-alone copy button (sample). Note: setup has a scoped .stream-table .copy-btn
   with different styling — the two do not collide because setup's version is
   nested under .stream-table. [sample only] */
.copy-btn {
    flex-shrink: 0; padding: 6px 10px;
    font-size: 11px; font-weight: 600;
    background: var(--surface-3); color: var(--text-soft);
    border-radius: 4px; white-space: nowrap;
}
.copy-btn:hover { background: var(--blue); color: #fff; }

/* One-line label + selector + custom-input row for the Backgrounds panel [sample only] */
.bg-row                         { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.bg-row label                   { display: inline-flex; align-items: center; margin: 0; padding: 0; font-size: 13px; color: var(--orange); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.bg-row select                  { flex: 1 1 auto; width: auto; margin: 0; min-width: 0; }
.bg-row input[type=text]        { flex: 1 1 auto; width: auto; margin: 0; min-width: 0; }
.bg-row input[type=text].hidden { display: none; }

/* Result / target card for sample's stream output [sample only] */
.stream-card                { background: var(--surface-2); border: 1px solid var(--surface-3); border-radius: 8px; padding: 14px; }
.stream-card .card-title    { font-size: 13px; font-weight: 700; color: var(--orange); margin-bottom: 12px; }
.player-btn {
    display: inline-block; margin-top: 10px;
    padding: 8px 14px;
    background: var(--orange); color: #fff;
    border-radius: 4px; font-size: 13px; font-weight: 600;
    text-decoration: none; cursor: pointer; border: none;
}
.player-btn:hover { background: var(--orange-dark); }

/* Site footer (version + copyright) */
.site-footer            { margin: 28px auto 12px; padding: 10px 16px; text-align: center; font-size: 11px; color: var(--text-muted); }
.site-footer a          { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover    { color: #fff; text-decoration: underline; }

/* =====================================================================
 * Setup refresh — clearer workspace styling for setup.html
 * Legacy token names aliased to brand tokens defined at top of file.
 * ===================================================================== */
:root {
    --page:           var(--surface-0);
    --surface:        var(--surface-1);
    --ink:            var(--text);
    --muted:          var(--text-muted);
    --subtle:         var(--text-faint);
    --border:         var(--line-dark);
    --border-strong:  #2A6E94;
    --accent:         var(--orange);
    --accent-strong:  var(--orange-dark);
    --cyan:           var(--blue);
    --green:          var(--ok);
    --red:            var(--err);
}

html {
    min-height: 100%;
    background: var(--page);
}

body {
    max-width: 1440px;
    min-height: 100%;
    padding: 28px clamp(16px, 3vw, 34px) 22px;
    background:
        linear-gradient(180deg, rgba(15, 141, 200, 0.08), transparent 260px),
        var(--page);
    color: var(--ink);
    line-height: 1.45;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin: 0 0 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4.6vw, 44px);
    line-height: 1.08;
    letter-spacing: -0.01em;
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.header-meta span {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 9px;
    background: rgba(255, 255, 255, 0.03);
}

/* Theme toggle pill in the header. Sits next to .header-meta chips and
   borrows the same chip styling so it doesn't draw extra attention. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 7px 3px 11px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}
.theme-toggle select {
    width: auto;
    min-height: 26px;
    margin: 0;
    padding: 2px 22px 2px 8px;
    border-radius: 999px;
    font-size: 12px;
}
:root[data-theme="light"] .header-meta span,
:root[data-theme="light"] .theme-toggle {
    background: rgba(0, 0, 0, 0.03);
}

/* Light-theme text-color overrides for rules that hardcode color: #fff
   on backgrounds that *do* flip with the theme (inputs, table hovers,
   selected rows, value pills). Keeping the dark-default `#fff` literal
   in those rules is intentional — it keeps text readable on the brand
   orange/blue accents and on the dark-mode surfaces — but in light mode
   the surface flips while the color doesn't, leaving white-on-white.
   These overrides re-bind those spots to var(--text). */
:root[data-theme="light"] .rgb-inline .rgb-value,
:root[data-theme="light"] .rgb-row-compact .rgb-value,
:root[data-theme="light"] .hex-row-compact input,
:root[data-theme="light"] .file-list-item:hover,
:root[data-theme="light"] .file-list-item.selected,
:root[data-theme="light"] .card-row .value,
:root[data-theme="light"] .modify-item .value,
:root[data-theme="light"] .stream-table .copyable:hover,
:root[data-theme="light"] .stream-table .copy-btn:hover {
    color: var(--text);
}

.section,
details.section {
    background: color-mix(in srgb, var(--surface) 88%, black);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section {
    padding: clamp(16px, 2vw, 22px);
    margin-bottom: 16px;
}

details.collapsible > summary {
    color: var(--ink);
    font-size: 15px;
    padding-left: 24px;
    margin-bottom: 16px;
}

details.collapsible > summary::before {
    color: var(--cyan);
    font-size: 17px;
}

h3,
.chroma-section h4,
.section-subhead,
.upload-col-title strong,
.player-section h4,
.adjust-panel > h4 {
    color: var(--ink);
    letter-spacing: 0;
}

.section-subhead,
.chroma-section h4,
.adjust-panel > h4 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-soft);
}

input,
select,
textarea {
    border-color: var(--border);
    border-radius: 7px;
    background: var(--surface-deep);
    color: var(--ink);
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    accent-color: var(--cyan);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.upload-area:focus-visible {
    outline: 2px solid rgba(73, 199, 216, 0.85);
    outline-offset: 2px;
}

button,
.btn-sm,
.btn-xs,
.player-btn {
    border-radius: 7px;
    background: var(--accent);
    color: #111;
    font-weight: 760;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

button:hover,
.player-btn:hover {
    background: var(--accent-strong);
    color: #fff;
}

button:active {
    transform: translateY(1px);
}

.btn-secondary,
.btn-xs,
.preset-btn:not(.active),
.player-tab {
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    color: var(--text-soft);
}

.btn-secondary:hover,
.btn-xs:hover,
.preset-btn:hover:not(.active),
.player-tab:hover {
    background: var(--surface-2);
}

.result,
.info,
.upload-progress,
.file-list-box,
.preview-box,
.stream-meta code {
    background: var(--surface-deep);
    border: 1px solid var(--border);
}

.success {
    border-left-color: var(--green);
}

.error {
    border-left-color: var(--red);
}

.info {
    color: #d8e8f0;
}

.chroma-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.upload-grid {
    grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1.1fr) minmax(300px, 1.35fr);
    gap: 14px;
}

.upload-area {
    border-color: var(--border-strong);
    background: var(--surface-deep);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--cyan);
    background: #121b25;
}

.upload-area.compact {
    min-height: 132px;
    display: grid;
    place-content: center;
    gap: 4px;
}

.upload-area.compact .drop-icon {
    width: 34px;
    height: 26px;
    margin: 0 auto 5px;
    border: 2px solid var(--cyan);
    border-top-width: 8px;
    border-radius: 5px;
    opacity: 0.95;
}

.file-list-box {
    max-height: 310px;
}

.file-list-item {
    border: 1px solid transparent;
}

.file-list-item:hover,
.file-list-item.selected,
.stream-table tr:hover td {
    background: var(--surface-3);
}

.file-list-item.selected {
    border-color: var(--cyan);
}

.preview-box {
    min-height: 230px;
}

.preview-box img,
.preview-box video {
    max-height: 280px;
}

.mode-tabs-row {
    border-bottom-color: var(--border);
    gap: 8px;
}

.mode-tab,
.mode-tab.left,
.mode-tab.right {
    margin: 0;
    border-radius: 7px;
}

.mode-tab:not(.active) {
    background: #111720;
    border-color: var(--border);
    color: var(--muted);
}

.mode-tab.active,
.preset-btn.active,
.player-tab.active,
.value-badge,
.value-input {
    background: var(--accent);
    border-color: var(--accent);
    color: #111;
}

.grid-2col {
    gap: 14px;
}

.tuning-layout {
    display: grid;
    grid-template-columns: minmax(440px, 0.82fr) minmax(560px, 1.18fr);
    align-items: start;
    gap: 16px;
    margin-top: 16px;
}

.tuning-controls,
.tuning-preview {
    min-width: 0;
}

.tuning-controls {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tuning-controls > .action-row {
    background: var(--surface-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0;
    margin-bottom: 12px;
    padding: 12px;
}

.tuning-preview {
    position: sticky;
    top: 18px;
}

.tuning-preview .player-section {
    margin-top: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.tuning-preview .player-header {
    margin-bottom: 8px;
}

.tuning-preview .player-tabs-row {
    min-height: 36px;
    margin-bottom: 10px;
}

.tuning-preview .player-stage {
    aspect-ratio: 16 / 9;
    min-height: 360px;
}

.tuning-preview .action-row {
    margin-top: 12px !important;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.despill-fields {
    display: grid;
    grid-template-columns: auto auto minmax(240px, 1fr);
    align-items: center;
    gap: 12px;
}

.despill-enable,
.despill-type,
.despill-mix,
.color-radio {
    display: flex;
    align-items: center;
}

.despill-enable {
    gap: 7px;
    margin: 0;
}

.despill-type {
    gap: 8px;
}

.color-radio {
    position: relative;
    gap: 7px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: var(--surface-deep);
    color: var(--text-soft);
    cursor: pointer;
}

.color-radio input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.color-radio-square {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.88);
    border-radius: 5px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.color-radio-green .color-radio-square {
    background: #00ff00;
}

.color-radio-blue .color-radio-square {
    background: #0057ff;
}

.color-radio:has(input:checked) {
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px rgba(73, 199, 216, 0.18);
    color: var(--ink);
}

.color-radio:has(input:checked) .color-radio-square {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.despill-mix {
    gap: 8px;
    min-width: 0;
}

.despill-mix label {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.despill-mix .param-slider {
    flex: 1 1 auto;
    min-width: 90px;
    margin: 0;
}

.despill-mix .value-input {
    width: 76px;
}

.stream-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stream-table th {
    background: var(--surface-deep);
    color: var(--cyan);
}

.stream-table th,
.stream-table td {
    border-bottom-color: var(--border);
}

.stream-table a.mono,
.stream-meta code,
.field-row a.field-link {
    color: var(--cyan);
}

.player-stage {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

#despillPreview,
#eqPreview {
    background: var(--surface-deep) !important;
    border-color: var(--border) !important;
    color: var(--muted) !important;
}

.text-muted,
.text-muted-sm,
.help-text,
.file-list-item .fmeta,
.site-footer,
.site-footer a {
    color: var(--muted);
}

.switch-label input[type="checkbox"] {
    accent-color: var(--cyan);
}

input[type="range"]::-webkit-slider-runnable-track {
    background: #394355;
}

input[type="range"]::-moz-range-track {
    background: #394355;
}

input[type="range"]::-webkit-slider-thumb,
input[type="range"]::-moz-range-thumb {
    background: var(--cyan);
}

@media (max-width: 900px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-meta {
        justify-content: flex-start;
    }

    .grid-2col,
    #eqFields,
    #despillAdvanced {
        grid-template-columns: 1fr !important;
    }

    .tuning-layout {
        grid-template-columns: 1fr;
    }

    .tuning-preview {
        position: static;
        order: -1;
    }

    .tuning-preview .player-stage {
        min-height: 0;
    }

    .despill-fields {
        grid-template-columns: 1fr;
    }

    .despill-type {
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    body {
        padding: 18px 12px;
    }

    .form-row,
    .action-row,
    .rgb-inline {
        align-items: stretch;
        flex-direction: column;
    }

    .form-row > label,
    .switch-label {
        white-space: normal;
    }

    .btn-sm,
    .btn-xs,
    button {
        width: 100%;
        margin-right: 0;
    }

    .mode-tabs-row {
        flex-direction: column;
    }

    .color-compact {
        grid-template-columns: 1fr;
    }
}

/* =====================================================================
 * Tuning workbench variant — preview-first UX
 * ===================================================================== */
body {
    max-width: 1680px;
}

.app-header h1 {
    max-width: 900px;
}

#configurationSection {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
}

#configurationSection > h3,
#configurationSection > .section-subhead,
#configurationSection > #targetCountRow,
#configurationSection > #streamInfo,
#configurationSection > #createPane,
#configurationSection > .mode-tabs-row,
#configurationSection > #reusePane {
    max-width: 1480px;
    margin-left: auto;
    margin-right: auto;
}

#configurationSection > h3 {
    font-size: 28px;
    line-height: 1.15;
    margin-bottom: 22px;
}

#configurationSection > .section-subhead {
    font-size: 16px;
    margin-top: 28px;
    margin-bottom: 14px;
}

#configurationSection .mode-tabs-row {
    margin-bottom: 26px;
}

#configurationSection .mode-tab {
    min-height: 62px;
    font-size: 17px;
}

#configurationSection #targetCountRow {
    gap: 18px;
    margin-bottom: 16px;
    font-size: 16px;
}

#configurationSection #targetCountRow label {
    font-size: 17px;
}

#configurationSection #targetCount {
    width: 78px !important;
    min-height: 48px;
    font-size: 17px;
    font-weight: 700;
}

#configurationSection #targetCountRow .text-muted {
    font-size: 15px;
}

#configurationSection .stream-table {
    font-size: 16px;
}

#configurationSection .stream-table th {
    font-size: 13px;
    padding: 12px 14px;
}

#configurationSection .stream-table td {
    padding: 12px 14px;
}

#configurationSection .stream-table .mono,
#configurationSection .bg-select {
    font-size: 15px;
}

#configurationSection .bg-select {
    min-height: 42px;
    padding: 8px 10px;
}

#configurationSection #createPane .btn-sm {
    min-width: 250px;
    min-height: 52px;
    font-size: 16px;
}

.workbench-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    max-width: 1640px;
    margin: 20px auto 12px;
    padding: 14px 16px;
    background: var(--surface-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.workbench-header h3 {
    margin: 0;
    color: var(--ink);
    font-size: 22px;
}

.workbench-status {
    color: var(--muted);
    font-size: 12px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
}

.workbench-layout {
    display: grid;
    grid-template-columns: minmax(620px, 1fr) minmax(540px, 620px);
    gap: 24px;
    align-items: start;
    max-width: 1640px;
    margin: 0 auto;
}

.workbench-preview,
.workbench-controls {
    min-width: 0;
}

.workbench-preview {
    position: sticky;
    top: 16px;
}

.workbench-preview .player-section {
    margin: 0;
    padding: 16px;
    background: var(--surface-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.workbench-preview .player-header {
    margin-bottom: 10px;
}

.workbench-preview .player-header h4 {
    font-size: 13px;
    color: var(--cyan);
}

.workbench-preview .player-tabs-row {
    min-height: 38px;
    margin-bottom: 12px;
}

.workbench-preview .player-stage {
    min-height: clamp(420px, 58vh, 780px);
    aspect-ratio: 16 / 9;
    background: #05070a;
    max-width: 100%;
    overflow: hidden;
}

.workbench-preview #playerDiv,
.workbench-preview #playerDiv > * {
    max-width: 100%;
}

.workbench-preview .action-row {
    margin-top: 12px !important;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.workbench-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 0 6px 0 0;
}

.workbench-controls .chroma-section {
    margin-bottom: 0;
    box-shadow: none;
}

.workbench-controls > .grid-2col {
    grid-template-columns: 1fr;
}

.workbench-controls #despillAdvanced,
.workbench-controls #eqFields {
    grid-template-columns: 1fr 1fr !important;
}

.workbench-controls .despill-fields {
    grid-template-columns: auto 1fr;
    gap: 14px;
}

.workbench-controls .despill-type {
    justify-content: end;
}

.workbench-controls .despill-mix {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) 76px;
    gap: 10px;
}

.workbench-controls .despill-fields > button {
    grid-column: 1 / -1;
    justify-self: start;
}

.workbench-controls > .action-row {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--surface-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0;
    padding: 12px;
    box-shadow: 0 -14px 32px rgba(11, 13, 18, 0.82);
}

.workbench-controls > .action-row:first-of-type {
    border-color: rgba(73, 199, 216, 0.45);
}

#adjustPanel {
    display: none;
}

#postCreateBlock .section-actions {
    max-width: 1640px;
    margin: 16px auto 0;
}

@media (max-width: 1180px) {
    .workbench-layout {
        grid-template-columns: 1fr;
    }

    .workbench-preview {
        position: static;
    }

    .workbench-controls {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .workbench-preview .player-stage {
        min-height: 0;
    }
}

@media (max-width: 720px) {
    .workbench-header {
        align-items: stretch;
        flex-direction: column;
    }

    .workbench-controls #despillAdvanced,
    .workbench-controls #eqFields {
        grid-template-columns: 1fr !important;
    }
}
