:root {
    --bg: #1b1b1c;
    --chrome: #202021;
    --panel: #242425;
    --panel-raised: #2a2a2c;
    --workspace: #101011;
    --control: #303033;
    --control-hover: #39393d;
    --text: #f0f0f1;
    --muted: #aaaab0;
    --subtle: #74747b;
    --line: rgba(255, 255, 255, .09);
    --line-strong: rgba(255, 255, 255, .17);
    --accent: #c4814f;
    --accent-hover: #d28e59;
    --accent-soft: rgba(196, 129, 79, .16);
    --danger: #d36d67;
    --radius: 5px;
    --font-ui: "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", Inter, Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
    --accent-color: var(--accent);
}

body[data-theme="light"] {
    --bg: #f2f2f0;
    --chrome: #fafaf9;
    --panel: #ffffff;
    --panel-raised: #f6f6f4;
    --workspace: #dededb;
    --control: #ececea;
    --control-hover: #e2e2df;
    --text: #181819;
    --muted: #626267;
    --subtle: #939398;
    --line: rgba(20, 20, 22, .10);
    --line-strong: rgba(20, 20, 22, .18);
    --accent: #9b5e31;
    --accent-hover: #854d24;
    --accent-soft: rgba(155, 94, 49, .12);
    --danger: #a54f4a;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
    background: var(--bg) !important;
    color: var(--text) !important;
    font-family: var(--font-ui) !important;
    font-size: 13px;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { border: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, [contenteditable]:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
}
body .uppercase { text-transform: none !important; }
body .tracking-widest, body .tracking-wider, body [class*="tracking-["] { letter-spacing: 0 !important; }

/* Scrollbars */
.custom-scrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--muted) 38%, transparent);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 62%, transparent); background-clip: padding-box; }

/* Quiet application chrome */
#native-menu-bar {
    height: 28px !important;
    padding: 0 16px !important;
    gap: 18px !important;
    background: var(--chrome) !important;
    color: var(--muted) !important;
    border-bottom: 1px solid var(--line) !important;
    font-size: 12px !important;
}
#native-menu-bar > div:first-child {
    color: var(--text) !important;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .16em;
    text-transform: uppercase;
}
#native-menu-bar .group { padding: 4px 6px !important; border-radius: 3px; }
#native-menu-bar .group:hover { color: var(--text) !important; background: var(--control) !important; }
#native-menu-bar .group > div {
    padding: 4px !important;
    background: var(--panel) !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: 6px !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .22) !important;
}
#native-menu-bar .group > div > div { min-height: 30px; padding: 0 10px !important; border-radius: 3px; }
#native-menu-bar .group > div > div:hover { background: var(--control) !important; }
#theme-value { color: var(--accent) !important; font-size: 11px; font-weight: 600; }

body > header {
    height: 62px !important;
    padding: 0 22px !important;
    background: var(--chrome) !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
}
body > header > div:first-child { gap: 28px !important; }
body > header .text-\[14px\] {
    color: var(--text) !important;
    font-size: 13px !important;
    font-weight: 680 !important;
    letter-spacing: .14em !important;
}
body > header .text-\[14px\] span { color: var(--subtle) !important; font-size: 10px; letter-spacing: 0 !important; }
body > header .h-6 { display: none; }
body > header nav { height: 100% !important; align-items: stretch; gap: 24px !important; background: transparent !important; }
body > header nav button {
    height: 100% !important;
    padding: 1px 0 0 !important;
    color: var(--muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 0 !important;
    font-size: 13px !important;
    font-weight: 480 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
body > header nav button:hover { color: var(--text) !important; }
body > header nav button.border-zinc-100 {
    color: var(--text) !important;
    border-bottom-color: var(--accent) !important;
    box-shadow: none !important;
}
body > header > div:last-child { gap: 8px !important; }
body > header > div:last-child button {
    min-height: 32px;
    padding: 0 13px !important;
    border-radius: var(--radius) !important;
    border: 1px solid var(--line-strong) !important;
    background: transparent !important;
    color: var(--text) !important;
    font-size: 12px !important;
    font-weight: 540 !important;
    text-transform: none !important;
    box-shadow: none !important;
}
body > header > div:last-child button:hover { background: var(--control) !important; }
#btn-export-dialog { background: var(--text) !important; color: var(--chrome) !important; border-color: var(--text) !important; }
#btn-export-dialog:hover { background: var(--accent) !important; border-color: var(--accent) !important; color: #17110d !important; }

/* Views are one continuous workspace, not cards. */
#views {
    margin: 0;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--panel) !important;
    box-shadow: none !important;
}
#view-library, #view-history, #view-calibration, #view-develop, #view-documentation {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 0 !important;
    overflow: hidden;
}
#view-history > div:last-child,
#view-library > div:last-child,
#view-calibration > div:last-child,
#view-documentation > div:last-child,
#view-develop > div:first-child,
#view-develop > div:last-child { min-height: 0; }

/* Library */
#view-library > div:first-child,
#view-history > div:last-child > div:first-child {
    height: 54px !important;
    padding: 0 24px !important;
    background: var(--panel) !important;
    border-bottom: 1px solid var(--line) !important;
}
#view-library > div:first-child > div:first-child,
#history-view-title {
    color: var(--text) !important;
    font-size: 18px !important;
    font-weight: 620 !important;
    letter-spacing: -.015em !important;
    text-transform: none !important;
}
#view-library > div:nth-child(2), #view-history > div:last-child > div:nth-child(2) {
    padding: 24px !important;
    background: var(--panel) !important;
}
#library-selection-count { font-size: 12px !important; color: var(--muted) !important; }
#btn-select-all, #btn-deselect-all { min-height: auto !important; padding: 5px 0 !important; color: var(--muted) !important; background: none !important; }
#btn-select-all:hover, #btn-deselect-all:hover { color: var(--text) !important; }
#library-grid, #history-internal-grid {
    gap: 12px !important;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.library-item {
    aspect-ratio: 4 / 3 !important;
    border: 0 !important;
    border-radius: 3px !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: 1px solid transparent;
    outline-offset: 2px;
    transition: opacity .14s ease, outline-color .14s ease !important;
}
.library-item:hover { border: 0 !important; outline-color: var(--line-strong); box-shadow: none !important; }
.library-item.selected { border: 0 !important; outline: 2px solid var(--accent); box-shadow: none !important; }
.library-item img { transition: opacity .15s ease !important; }
.library-item:hover img { transform: none !important; opacity: .92; }
#library-empty, #history-empty { color: var(--subtle) !important; }
#library-empty svg, #history-empty svg { width: 44px; height: 44px; color: var(--muted) !important; opacity: .5 !important; }
#library-empty .text-sm, #history-empty .text-sm { color: var(--text) !important; font-size: 18px !important; font-weight: 600; letter-spacing: -.01em !important; }
#library-empty button, #history-empty button {
    min-height: 34px !important;
    padding: 0 14px !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--radius) !important;
    background: var(--control) !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

/* Archive */
#view-history > div:first-child {
    width: 224px !important;
    padding: 24px 18px !important;
    background: var(--panel-raised) !important;
    border-right: 1px solid var(--line) !important;
}
#view-history > div:first-child h2 {
    margin-bottom: 26px !important;
    color: var(--text) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
#view-history > div:first-child h3 {
    color: var(--muted) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
#view-history label { color: var(--muted) !important; font-size: 12px !important; }
#view-history .filter-checkbox { width: 13px; height: 13px; border-radius: 2px !important; accent-color: var(--accent); }
#view-history button {
    border-radius: var(--radius) !important;
    font-size: 12px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}
#delete-action-bar {
    border-radius: 6px !important;
    background: color-mix(in srgb, var(--danger) 90%, #1a1a1a) !important;
    pointer-events: auto;
}
#btn-confirm-delete:disabled { opacity: .45; cursor: not-allowed; }
#library-rolls-grid { gap: 0 !important; }
.roll-row {
    min-height: 176px;
    align-items: stretch;
    gap: 32px;
    padding: 20px 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    transition: background .14s ease;
}
.roll-row:first-child { border-top: 1px solid var(--line); }
.roll-row:hover { background: var(--panel-raised); }
.roll-row.delete-selected { box-shadow: inset 3px 0 var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.roll-summary { flex: 1; min-width: 0; padding: 8px 12px; display: flex; flex-direction: column; }
.roll-title { color: var(--text); font-size: 20px; font-weight: 620; letter-spacing: -.02em; line-height: 1.2; }
.roll-format { margin-top: 7px; color: var(--accent); font-size: 12px; font-weight: 540; }
.roll-meta { margin-top: auto; display: flex; gap: 24px; color: var(--muted); font-size: 12px; }
.roll-edit-action {
    align-self: flex-start;
    margin-top: 14px;
    padding: 4px 0 !important;
    color: var(--muted) !important;
    background: transparent !important;
}

#toast-container {
    top: 102px;
    right: 16px;
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100vh - 118px);
    overflow: hidden;
}
#toast-container > div {
    width: 100%;
    min-width: 0;
}
#toast-container > div span {
    min-width: 0;
    overflow-wrap: anywhere;
}
#btn-delete-rolls:disabled,
#btn-promote-roll:disabled,
#btn-edit-roll:disabled,
#btn-delete-roll-images:disabled,
#btn-delete-develop-image:disabled,
#btn-delete-library-images:disabled {
    opacity: .4 !important;
    cursor: not-allowed !important;
}
.roll-edit-action:hover { color: var(--text) !important; }
.roll-preview { width: min(42%, 520px); min-width: 280px; overflow: hidden; background: var(--workspace); }
.roll-preview img { display: block; opacity: .82; transition: opacity .15s ease; }
.roll-row:hover .roll-preview img { opacity: 1; }
.roll-preview-empty { width: 100%; height: 100%; background: var(--workspace); }

/* Develop workspace */
#view-develop > div:first-child { min-width: 0; background: var(--workspace) !important; }
#view-develop > div:first-child > div:first-child {
    height: 46px !important;
    padding: 0 14px !important;
    justify-content: flex-start !important;
    gap: 2px !important;
    background: var(--chrome) !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
}
#view-develop .w-px { height: 16px !important; margin: 0 6px; background: var(--line-strong) !important; }
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 28px;
    padding: 0 9px !important;
    border: 0 !important;
    border-radius: 4px !important;
    background: transparent !important;
    color: var(--muted) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
.toolbar-btn:hover:not(:disabled) { color: var(--text) !important; background: var(--control) !important; }
.toolbar-btn.active { color: var(--accent) !important; background: var(--accent-soft) !important; }
.toolbar-btn:disabled { opacity: .38; cursor: not-allowed; }
#view-develop > div:first-child > div:nth-child(2) {
    padding: 24px !important;
    background: var(--workspace) !important;
    background-image: none !important;
}
#canvas-wrapper { border-radius: 0 !important; box-shadow: 0 12px 36px rgba(0, 0, 0, .3); }
#crop-overlay { touch-action: none; }
#crop-mask { fill: rgba(0, 0, 0, .68); }
#crop-box {
    stroke: rgba(255, 255, 255, .98);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, .95));
}
.toolbar-icon {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
    stroke: var(--accent);
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.toolbar-btn:hover:not(:disabled) .toolbar-icon,
.toolbar-btn.active .toolbar-icon { stroke-width: 1.85; }
#crop-grid-lines {
    fill: none;
    stroke: rgba(255, 255, 255, .52);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}
.crop-handle {
    fill: #fff;
    stroke: #111;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .7));
}
#crop-overlay.is-dragging #crop-grid { opacity: 1 !important; }
#crop-overlay.is-dragging #crop-box { stroke: var(--accent); }
#perspective-overlay path {
    fill: none;
    stroke: rgba(255, 255, 255, .48);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}
#perspective-overlay .perspective-grid-major {
    stroke: color-mix(in srgb, var(--accent) 78%, white);
    stroke-width: 1.5;
}
#filmstrip-container {
    height: 104px !important;
    padding: 12px 16px !important;
    gap: 8px !important;
    background: var(--chrome) !important;
    border-top: 1px solid var(--line) !important;
}
.film-item {
    position: relative;
    width: 108px !important;
    height: 72px !important;
    border: 0 !important;
    border-radius: 3px !important;
    background: var(--workspace) !important;
    opacity: .58 !important;
    outline: 1px solid transparent;
    outline-offset: 2px;
    transition: opacity .14s ease, outline-color .14s ease !important;
}
.film-item:hover { opacity: .9 !important; transform: none !important; }
.film-item.active { opacity: 1 !important; border: 0 !important; outline: 2px solid var(--accent); box-shadow: none; }
.film-item.settings-updated::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    border: 1px solid var(--chrome);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
    pointer-events: none;
}

/* Develop inspector */
#view-develop > div:last-child {
    width: 360px !important;
    background: var(--panel) !important;
    border-left: 1px solid var(--line) !important;
    box-shadow: none !important;
}
#develop-inspector.calibration-locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none;
}
.perspective-panel {
    position: absolute;
    inset: 0;
    z-index: 46;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background: var(--panel);
    color: var(--text);
}
.perspective-panel.hidden { display: none; }
.perspective-panel-header {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}
.perspective-panel-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0;
}
.perspective-panel-header span {
    display: block;
    margin-top: 3px;
    color: var(--subtle);
    font-size: 10px;
}
.perspective-icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    font-weight: 300;
    line-height: 26px;
}
.perspective-icon-btn:hover { border-color: var(--line); background: var(--control); color: var(--text); }
.perspective-panel-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 23px;
    overflow-y: auto;
    padding: 22px 20px;
}
.perspective-control > div {
    display: flex;
    min-height: 22px;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 7px;
}
.perspective-control label,
.perspective-toggle strong { color: var(--text); font-size: 12px; font-weight: 540; }
.perspective-control output {
    min-width: 52px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10px;
    text-align: right;
}
.perspective-toggle {
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 11px 0 0;
    border-top: 1px solid var(--line);
    cursor: pointer;
}
.perspective-toggle span { display: grid; gap: 3px; }
.perspective-toggle small { color: var(--subtle); font-size: 10px; line-height: 1.4; }
.perspective-toggle input {
    appearance: none;
    width: 32px;
    height: 18px;
    flex: 0 0 auto;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--control);
    transition: background .14s ease;
}
.perspective-toggle input::after {
    content: "";
    display: block;
    width: 12px;
    height: 12px;
    margin: 2px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .14s ease, background .14s ease;
}
.perspective-toggle input:checked { background: var(--accent); border-color: var(--accent); }
.perspective-toggle input:checked::after { background: #17110d; transform: translateX(14px); }
.perspective-panel-footer { padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.perspective-panel-footer button {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--control);
    color: var(--text);
    font-size: 11px;
    font-weight: 540;
}
.perspective-panel-footer button:hover:not(:disabled) { background: var(--control-hover); }
.perspective-panel button:disabled, .perspective-panel input:disabled { cursor: not-allowed; opacity: .38; }
.crop-aspect-control { display: grid; gap: 8px; }
.crop-aspect-control label { color: var(--text); font-size: 12px; font-weight: 540; }
.crop-aspect-control select {
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--control);
    color: var(--text);
    font-size: 12px;
}
.crop-rotation-control { padding-top: 4px; border-top: 1px solid var(--line); }
.crop-angle-field {
    display: inline-flex !important;
    min-width: 86px;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    color: var(--muted) !important;
    font-size: 11px !important;
}
.crop-angle-field input {
    width: 64px;
    min-height: 30px;
    padding: 0 7px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--control);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    text-align: right;
}
#view-develop > div:last-child > div:nth-of-type(2) {
    padding: 18px 20px !important;
    background: var(--panel) !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
}
#view-develop > div:last-child > div:nth-of-type(2) .w-full {
    height: 116px !important;
    background: var(--workspace) !important;
    border: 1px solid var(--line) !important;
    border-radius: 3px !important;
    box-shadow: none !important;
}
#viz-title { color: var(--text) !important; font-size: 12px !important; font-weight: 600 !important; letter-spacing: 0 !important; text-transform: none !important; }
.viz-mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 168px;
    min-width: 0;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--workspace);
}
.viz-mode-tab {
    min-width: 0;
    min-height: 26px;
    padding: 0 7px !important;
    border: 1px solid transparent !important;
    border-radius: 3px !important;
    background: transparent !important;
    color: var(--muted) !important;
    font-size: 11px !important;
    font-weight: 520 !important;
    text-transform: none !important;
    white-space: nowrap;
}
.viz-mode-tab:hover:not(.active) { color: var(--text) !important; background: var(--control) !important; }
.viz-mode-tab.active {
    border-color: var(--line-strong) !important;
    background: var(--panel-raised) !important;
    color: var(--text) !important;
}
#view-develop > div:last-child > div:last-child { padding: 18px 20px !important; gap: 22px !important; background: var(--panel) !important; }
.control-group { border-color: var(--line) !important; }
.control-group h3 {
    margin-bottom: 18px !important;
    color: var(--text) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
.control-group h3 svg { color: var(--subtle); }
.control-group label { color: var(--muted) !important; font-size: 12px !important; font-weight: 450 !important; letter-spacing: 0 !important; }
.control-group [class*="bg-\[\#121214\]"] { background: transparent !important; border-color: var(--line) !important; }
.control-group button:not(.toolbar-btn), #btn-copy-settings, #btn-paste-settings {
    min-height: 30px;
    border: 1px solid var(--line) !important;
    border-radius: 4px !important;
    background: var(--control) !important;
    color: var(--text) !important;
    box-shadow: none !important;
    font-size: 11px !important;
    font-weight: 520 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
.control-group button:not(.toolbar-btn):hover, #btn-copy-settings:hover, #btn-paste-settings:hover { background: var(--control-hover) !important; }
.control-group button#btn-auto-color,
.control-group button#btn-auto-color-roll { background: var(--accent) !important; border-color: var(--accent) !important; color: #17110d !important; }
.control-group button#btn-auto-color:hover,
.control-group button#btn-auto-color-roll:hover { background: var(--accent-hover) !important; }
.control-group select, #view-develop select {
    min-height: 30px;
    padding: 0 8px !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: 4px !important;
    background: var(--control) !important;
    color: var(--text) !important;
    font-size: 12px !important;
}
#btn-mode-color, #btn-mode-bw { min-height: 28px; border-radius: 3px !important; }
#right-panel-blocker { background: color-mix(in srgb, var(--panel) 92%, transparent) !important; }
#right-panel-blocker h3 { color: var(--text) !important; font-size: 15px !important; text-transform: none !important; }
.film-area-description {
    max-width: 290px;
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}
.film-area-actions {
    display: grid;
    width: min(100%, 290px);
    gap: 10px;
}
.film-area-action {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--control);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    transition: background .14s ease, border-color .14s ease, opacity .14s ease;
    pointer-events: auto;
}
.film-area-action:hover:not(:disabled) { background: var(--control-hover); border-color: var(--subtle); }
.film-area-action:disabled { cursor: not-allowed; opacity: .42; }
.film-area-action-primary,
#btn-confirm-calibration {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #17110d !important;
}
.film-area-action-primary:hover { background: var(--accent-hover) !important; }
.batch-apply-hint {
    margin: -2px 2px 0;
    color: var(--subtle);
    font-size: 11px;
    line-height: 1.5;
    text-align: left;
}
.calib-edge-handle { pointer-events: stroke; touch-action: none; }
.calib-edge-horizontal { cursor: ns-resize; }
.calib-edge-vertical { cursor: ew-resize; }
.calib-edge-dot {
    fill: var(--panel);
    pointer-events: none;
    stroke: #f97316;
    stroke-width: 1.5;
}
.calib-dot { pointer-events: none; }
.calib-handle { touch-action: none; }

/* Precision sliders */
.custom-range, .slider {
    --val: 50%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    margin: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    outline: none;
}
.silver-track { --track-fill: var(--accent); }
.red-track { --track-fill: #c96868; }
.green-track { --track-fill: #55a780; }
.blue-track { --track-fill: #648fc7; }
.color-balance-group {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: color-mix(in srgb, var(--control) 68%, transparent);
}
.color-balance-title {
    color: var(--subtle);
    font-size: 9px;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0;
    text-transform: uppercase;
}
.custom-range::-webkit-slider-runnable-track, .slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    border-radius: 0;
    background: linear-gradient(to right, var(--track-fill, var(--accent)) 0%, var(--track-fill, var(--accent)) var(--val), color-mix(in srgb, var(--muted) 35%, transparent) var(--val), color-mix(in srgb, var(--muted) 35%, transparent) 100%);
}
.custom-range::-webkit-slider-thumb, .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 11px;
    height: 11px;
    margin-top: -4.5px;
    border: 1px solid color-mix(in srgb, var(--text) 40%, transparent);
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .34);
    transition: transform .08s ease;
}
.custom-range:hover::-webkit-slider-thumb, .slider:hover::-webkit-slider-thumb { transform: scale(1.08); }
.custom-range:active::-webkit-slider-thumb, .slider:active::-webkit-slider-thumb { transform: scale(1.18); }
.temperature-track::-webkit-slider-runnable-track {
    height: 6px;
    border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
    border-radius: 3px;
    background: linear-gradient(to right, #3976d2 0%, #80b9e8 28%, #d2d3cf 50%, #efb35d 74%, #d9682f 100%);
}
.tint-track::-webkit-slider-runnable-track {
    height: 6px;
    border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
    border-radius: 3px;
    background: linear-gradient(to right, #36a565 0%, #8bc79e 28%, #d2d3cf 50%, #b989c8 74%, #874ca2 100%);
}
.temperature-track::-webkit-slider-thumb,
.tint-track::-webkit-slider-thumb { margin-top: -3.5px; }
.custom-range:disabled, .slider:disabled { cursor: not-allowed; opacity: .35; }
.custom-range:disabled::-webkit-slider-runnable-track, .slider:disabled::-webkit-slider-runnable-track { background: var(--line-strong); }
.slider-track { display: none; }
.slider-container { min-height: 31px; }
.slider-value {
    display: inline-flex;
    min-width: 48px;
    min-height: 22px;
    align-items: center;
    justify-content: flex-end;
    padding: 2px 5px;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--muted) !important;
    background: transparent;
    font-family: var(--font-mono) !important;
    font-size: 10px !important;
    line-height: 16px;
    text-align: right;
    cursor: text;
}
.slider-value:hover { border-color: var(--line); background: var(--control); color: var(--text) !important; }
.slider-value:focus { border-color: var(--accent); background: var(--control); color: var(--text) !important; }

/* Modals are the only intentionally framed surfaces. */
[id$="-modal"] { background: rgba(0, 0, 0, .58) !important; backdrop-filter: blur(8px) !important; }
[id$="-content"] {
    width: min(460px, calc(100vw - 32px)) !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: 7px !important;
    background: var(--panel) !important;
    color: var(--text) !important;
    box-shadow: 0 18px 46px rgba(0, 0, 0, .3) !important;
}
[id$="-content"] > div:first-child { padding: 18px 20px !important; border-color: var(--line) !important; }
[id$="-content"] > div:last-child { padding: 20px !important; }
[id$="-content"] h2 { color: var(--text) !important; font-size: 17px !important; font-weight: 620 !important; letter-spacing: -.01em !important; text-transform: none !important; }
[id$="-content"] label { color: var(--muted) !important; font-size: 12px !important; text-transform: none !important; }
[id$="-content"] input, [id$="-content"] select {
    min-height: 32px;
    border: 1px solid var(--line-strong) !important;
    border-radius: 4px !important;
    background: var(--control) !important;
    color: var(--text) !important;
}
[id$="-content"] button { min-height: 32px; border-radius: 4px !important; text-transform: none !important; letter-spacing: 0 !important; }
[id$="-content"] button[id*="confirm"] { background: var(--text) !important; color: var(--panel) !important; }
#import-choice-content button { background: transparent !important; border-color: var(--line) !important; box-shadow: none !important; }
#import-choice-content button:hover { background: var(--panel-raised) !important; }

.sponsor-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, .58) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    backdrop-filter: blur(10px) !important;
    transition: opacity .18s ease, visibility .18s ease;
}
.library-item, .film-item, .roll-row {
    -webkit-user-select: none;
    user-select: none;
}
.sponsor-modal.is-open { visibility: visible; opacity: 1; pointer-events: auto; }
#sponsor-modal-content.sponsor-card {
    width: min(860px, calc(100vw - 48px)) !important;
    max-height: calc(100vh - 48px);
    overflow: auto;
    border: 1px solid var(--line-strong) !important;
    border-radius: 7px !important;
    background: var(--panel) !important;
    color: var(--text) !important;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .38) !important;
    transform: translateY(8px) scale(.98);
    transition: transform .18s ease;
}
.sponsor-modal.is-open .sponsor-card { transform: translateY(0) scale(1); }
.sponsor-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}
.sponsor-card-kicker {
    margin-bottom: 4px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .12em;
    text-transform: uppercase;
}
#sponsor-modal-title { margin: 0; color: var(--text); font-size: 17px; font-weight: 620; }
.sponsor-close-button {
    display: grid;
    flex: 0 0 32px;
    width: 32px;
    min-height: 32px;
    place-items: center;
    border: 1px solid transparent !important;
    border-radius: 4px !important;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.sponsor-close-button:hover { border-color: var(--line) !important; background: var(--control); color: var(--text); }
.sponsor-close-button svg { width: 18px; height: 18px; }
.sponsor-card-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 22px !important;
}
.sponsor-intro {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}
.sponsor-intro section { display: grid; align-content: start; }
.sponsor-intro section + section { padding-left: 20px; border-left: 1px solid var(--line); }
.sponsor-intro p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.sponsor-qr-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}
.sponsor-person { display: grid; justify-items: center; gap: 10px; margin: 0; min-width: 0; }
.sponsor-person figcaption { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.sponsor-person figcaption strong { color: var(--text); font-size: 12px; font-weight: 700; }
.sponsor-person figcaption span { color: var(--accent); font-size: 12px; font-weight: 600; }
.sponsor-qr-frame {
    width: min(250px, 100%);
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: #fff;
}
.sponsor-qr-frame img { display: block; width: 100%; height: auto; }
.sponsor-contacts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.sponsor-contacts > div { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; min-width: 0; }
.sponsor-contacts strong { width: 100%; color: var(--text); font-size: 11px; font-weight: 700; }
.sponsor-contacts span { color: var(--muted); font-size: 11px; }
.sponsor-contacts a { color: var(--accent); font-size: 11px; text-decoration: none; overflow-wrap: anywhere; }
.sponsor-contacts a:hover { text-decoration: underline; }

.batch-target-options { display: grid; gap: 8px; }
.batch-target-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    min-height: 42px;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--panel-raised);
    cursor: pointer;
}
.batch-target-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.batch-target-option input { width: 14px; min-height: 14px; accent-color: var(--accent); }
.batch-target-count { min-width: 24px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; text-align: right; }

#toast-container > div {
    border: 1px solid var(--line-strong) !important;
    border-left: 2px solid var(--accent) !important;
    border-radius: 4px !important;
    background: var(--panel) !important;
    color: var(--text) !important;
    box-shadow: 0 12px 26px rgba(0, 0, 0, .24) !important;
}
#drag-overlay { background: color-mix(in srgb, var(--accent) 12%, transparent) !important; border-color: var(--accent) !important; }
#drag-overlay > div { border: 1px solid var(--line-strong); border-radius: 6px !important; background: var(--panel) !important; }

/* Export workflow */
#export-modal {
    padding: 16px;
    background: rgba(0, 0, 0, .46) !important;
}
#export-modal-content.export-dialog {
    --panel: #fff;
    --panel-raised: #fff;
    --workspace: #dadada;
    --control: #e3e3e3;
    --control-hover: #d2d2d2;
    --text: #3b3b3b;
    --muted: #8f8f94;
    --subtle: #8f8f94;
    --line: rgba(20, 20, 22, .10);
    --line-strong: rgba(20, 20, 22, .18);
    --accent: #0a5aa8;
    --accent-hover: #074e91;
    display: flex;
    flex-direction: column;
    width: min(754px, calc(100vw - 32px)) !important;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 18px !important;
    background: var(--panel) !important;
    box-shadow: 0 18px 54px rgba(0, 0, 0, .24);
}
.export-dialog-header,
.export-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 14px 20px 10px;
}
.export-dialog-header h2 { margin: 0; color: var(--accent) !important; font-size: 17px !important; font-weight: 700 !important; letter-spacing: 0; }
.export-dialog-header p { margin: 3px 0 0; color: var(--text); font-size: 12px; }
.export-icon-button {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid transparent !important;
    border-radius: 4px !important;
    background: transparent !important;
    color: var(--muted);
}
.export-icon-button:hover { border-color: var(--line) !important; background: var(--control) !important; color: var(--text); }
.export-icon-button svg { width: 26px; height: 26px; }
.export-dialog-body { min-height: 0; overflow: auto; padding: 0 10px 10px; }
.export-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    padding: 10px 32px;
    border: 0;
    border-radius: 10px;
    background: var(--panel-raised);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18) !important;
}
.export-summary-bar > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.export-summary-label { color: var(--subtle); font-size: 10px; font-weight: 600; }
.export-summary-bar strong { color: var(--text); font-size: 13px; font-weight: 700; }
.export-summary-detail { max-width: 56%; color: var(--muted); font-size: 12px; line-height: 1.4; text-align: right; }
.export-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.export-settings-section { min-width: 0; padding: 16px 20px; border-radius: 10px; background: var(--workspace); }
.export-file-section { grid-column: 1 / -1; }
.export-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.export-section-heading h3 { margin: 0; color: var(--accent); font-size: 17px; font-weight: 700; }
.export-section-heading span { color: var(--subtle); font-size: 10px; }
.export-field { display: grid; grid-template-columns: minmax(112px, 1fr) minmax(0, 1.08fr); align-items: center; gap: 12px; min-height: 34px; margin-bottom: 8px; }
.export-file-section > .export-field { grid-template-columns: minmax(180px, 1fr) minmax(0, 1fr); }
.export-field > span:first-child, .export-field-row > span, .export-preview-row > span { color: var(--text); font-size: 12px; font-weight: 600; }
.export-field select, .export-field input, .export-destination-row input {
    width: 100%;
    min-width: 0;
    min-height: 30px;
    padding: 0 7px;
    border: 0 !important;
    border-radius: 11px !important;
    outline: 0;
    background: var(--panel-raised) !important;
    color: var(--text) !important;
    font-size: 12px;
}
.export-field select:focus, .export-field input:focus, .export-destination-row input:focus { border-color: var(--accent) !important; }
/* Export dropdowns are drawn here instead of by the platform, exactly like the
 * Develop inspector: the native macOS pop-up button paints its own gradient
 * body and stepper, which never matches the flat Windows/Chromium rendering of
 * the same dialog. */
#export-modal-content .export-field select {
    appearance: none !important;
    -webkit-appearance: none !important;
    padding: 0 32px 0 12px !important;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) !important;
    background-position:
        calc(100% - 17px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px) !important;
    background-size: 5px 5px !important;
    background-repeat: no-repeat !important;
    background-color: var(--panel-raised) !important;
    color: var(--text) !important;
    text-overflow: ellipsis;
    box-shadow: none !important;
}
#export-modal-content .export-field select:disabled {
    color: var(--muted) !important;
    cursor: not-allowed;
}
.export-field-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.export-field output { color: var(--text); font-family: var(--font-mono); font-size: 11px; }
#export-quality-group { display: block; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--panel-raised) 76%, transparent); }
#export-quality { width: 100%; min-height: 20px; accent-color: var(--accent); }
.export-range-labels { display: flex; justify-content: space-between; color: var(--subtle); font-size: 10px; }
.export-field.is-disabled { opacity: .45; }
.export-check-row.is-disabled { opacity: .45; }
.export-check-row { display: flex; align-items: flex-start; gap: 9px; margin: 14px 0 10px calc(50% + 6px); cursor: pointer; }
.export-check-row input { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 1px; accent-color: var(--accent); }
.export-check-row span { display: flex; flex-direction: column; gap: 3px; }
.export-check-row strong { color: var(--text); font-size: 12px; font-weight: 560; }
.export-check-row small { color: var(--subtle); font-size: 10px; line-height: 1.4; }
.export-info-note { color: var(--subtle); font-size: 10px; line-height: 1.45; }
.export-info-note.is-accent { color: var(--text); }
.export-token-hint { margin: -2px 0 10px 50%; padding-left: 6px; color: var(--subtle); font-size: 10px; line-height: 1.6; }
.export-token-hint code { color: var(--accent); font-family: var(--font-mono); }
.export-preview-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 1fr); align-items: center; gap: 12px; min-height: 30px; margin: 0 0 8px; padding: 0 10px; border-radius: 10px; background: var(--panel-raised); }
.export-preview-row code { overflow: hidden; color: var(--text); font-family: var(--font-mono); font-size: 11px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.export-inline-check { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 6px 10px; border-radius: 10px; background: var(--panel-raised); color: var(--text) !important; cursor: pointer; }
.export-inline-check input { width: 14px; min-height: 14px; padding: 0; accent-color: var(--accent); }
.export-inline-check span { min-width: 0; font-size: 11px; font-weight: 500; }
.export-destination-field { margin-bottom: 0; }
.export-destination-row { display: flex; align-items: center; gap: 10px; }
.export-destination-row input { flex: 1 1 auto; color: var(--muted) !important; }
.export-destination-row button {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 11px;
    border: 0 !important;
    border-radius: 10px !important;
    background: var(--panel-raised);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}
.export-destination-row button:hover { background: var(--control-hover); }
.export-dialog-footer { justify-content: flex-end; gap: 10px; padding: 0 10px 10px; }
.export-dialog-footer button { min-height: 35px; padding: 0 20px; border: 0 !important; border-radius: 10px !important; background: var(--control); color: var(--text); font-size: 12px; font-weight: 700; }
.export-dialog-footer button:hover { background: var(--control); color: var(--text); }
.export-dialog-footer #btn-confirm-export { min-width: 133px; background: var(--accent); color: #fff; }
.export-dialog-footer #btn-confirm-export:hover { background: var(--accent-hover); color: #fff; }
.export-dialog-footer #btn-confirm-export:disabled { cursor: not-allowed; opacity: .42; }

/* Neutralize legacy Tailwind colors in light mode. */
body[data-theme="light"] [class*="bg-\[\#1C1C1E\]"],
body[data-theme="light"] [class*="bg-\[\#171719\]"],
body[data-theme="light"] [class*="bg-\[\#1a1a1e"] { background: var(--panel) !important; }
body[data-theme="light"] [class*="bg-\[\#121214\]"] { background: var(--panel-raised) !important; }
body[data-theme="light"] [class*="border-\[\#28282c\]"] { border-color: var(--line) !important; }
body[data-theme="light"] .text-zinc-100,
body[data-theme="light"] .text-zinc-200,
body[data-theme="light"] .text-zinc-300 { color: var(--text) !important; }
body[data-theme="light"] .text-zinc-400,
body[data-theme="light"] .text-zinc-500,
body[data-theme="light"] .text-zinc-600 { color: var(--muted) !important; }
body[data-theme="light"] .bg-zinc-800, body[data-theme="light"] .bg-zinc-900 { background: var(--control) !important; }
/* Batch and export progress fills are zinc-200, which is invisible on the
   light theme's gray track. Paint them with the text colour instead, so the
   bar shows the same progress in both themes. */
body[data-theme="light"] .bg-zinc-200 { background: var(--text) !important; }
body[data-theme="light"] [id$="-modal"] { background: rgba(30, 30, 28, .24) !important; }
body[data-theme="light"] .sponsor-modal { background: rgba(30, 30, 28, .24) !important; }

@media (max-width: 1050px) {
    #view-develop > div:last-child { width: 320px !important; }
    #view-history > div:first-child { width: 200px !important; }
    #library-grid, #history-internal-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .roll-preview { min-width: 240px; }
}

@media (max-width: 780px) {
    body > header { padding: 0 14px !important; }
    body > header > div:first-child { gap: 14px !important; }
    body > header nav { gap: 12px !important; }
    #btn-export-dialog { display: none; }
    #view-history > div:first-child { display: none; }
    #view-develop > div:last-child { width: 286px !important; }
    #view-library > div:nth-child(2), #view-history > div:last-child > div:nth-child(2) { padding: 16px !important; }
    .roll-row { gap: 16px; }
    .roll-preview { width: 44%; min-width: 180px; }
}


@media (max-width: 1050px) {
    .toolbar-btn {
        width: 30px;
        padding: 0 !important;
    }
    .toolbar-btn > span { display: none; }
}

/* Dark reference: the geometry above remains identical; only the surface
 * tokens and control fills change to the exported Develop_dark palette. */
body[data-theme="dark"] {
    --figma-blue: #4893dd;
    --figma-stone: #1f1f1f;
    --figma-workspace: #0e0e0e;
    --figma-control: #3b3b3b;
    --figma-text: #e3e3f1;
    --figma-muted: #8d8d8d;
    --figma-line: rgba(226, 226, 244, .10);
    --bg: #2b2b2b;
    --chrome: #1f1f1f;
    --panel: #2b2b2b;
    --panel-raised: #3b3b3b;
    --workspace: #0e0e0e;
    --control: #3b3b3b;
    --control-hover: #444;
    --text: #e3e3f1;
    --muted: #8d8d8d;
    --subtle: #8d8d8d;
    --line: rgba(226, 226, 244, .10);
    --line-strong: rgba(226, 226, 244, .18);
    --accent: #4893dd;
    --accent-hover: #5aa0e7;
    --accent-soft: rgba(72, 147, 221, .18);
}
body[data-theme="dark"] {
    background: #2b2b2b !important;
    color: var(--figma-text) !important;
}
body[data-theme="dark"] #native-menu-bar {
    background: #282828 !important;
    color: #8d8d8d !important;
    border-bottom-color: rgba(226, 226, 244, .10) !important;
}
body[data-theme="dark"] > header { background: #282828 !important; }
body[data-theme="dark"] > header .brand-mark {
    content: url("assets/design-reference/nexfilm-logo-dark.svg") !important;
    filter: none !important;
}
body[data-theme="dark"] > header nav button { color: #e3e3f1 !important; }
body[data-theme="dark"] > header nav button:hover { background: #303030 !important; }
body[data-theme="dark"] > header nav button.border-zinc-100 {
    background: #0e0e0e !important;
    border-bottom-color: #0e0e0e !important;
    color: #4893dd !important;
}
body[data-theme="dark"] > header > div:last-child { background: #4893dd !important; }
body[data-theme="dark"] > header > div:last-child button {
    background: #1f1f1f !important;
    color: #e3e3f1 !important;
    box-shadow: inset 0 0 0 3px #4893dd !important;
}
body[data-theme="dark"] > header > div:last-child button:hover:not(:disabled) { background: #303030 !important; }
body[data-theme="dark"] #btn-export-dialog { background: #4893dd !important; color: #1f1f1f !important; box-shadow: none !important; }
body[data-theme="dark"] #btn-delete-develop-image {
    background: #2b2b2b !important;
    color: #e3e3f1 !important;
    box-shadow: inset 0 0 0 1px #7f4242 !important;
}
body[data-theme="dark"] #views { background: #2b2b2b !important; }
body[data-theme="dark"] #view-develop > div:first-child > div:first-child {
    background: #1f1f1f !important;
    box-shadow: none !important;
}
body[data-theme="dark"] #view-develop > div:first-child > div:first-child > div:first-child { background: #1f1f1f !important; }
body[data-theme="dark"] #view-develop > div:first-child > div:first-child > div:first-child #btn-crop-mode { background: #1f1f1f !important; color: #e3e3f1 !important; }
body[data-theme="dark"] #view-develop > div:first-child > div:first-child > div:first-child #btn-reset-crop { background: #8d8d8d !important; color: #1f1f1f !important; }
body[data-theme="dark"] #view-develop > div:first-child > div:nth-child(2) { background: #0e0e0e !important; }
body[data-theme="dark"] #filmstrip-container { background: #1f1f1f !important; box-shadow: none !important; }
body[data-theme="dark"] .film-item { background: #1f1f1f !important; }
body[data-theme="dark"] #view-develop > div:last-child > div:nth-of-type(2),
body[data-theme="dark"] #view-develop > div:last-child > div:last-child { background: #2b2b2b !important; box-shadow: none !important; }
body[data-theme="dark"] #view-develop > div:last-child > div:nth-of-type(2) .w-full { background: #0e0e0e !important; }
body[data-theme="dark"] .viz-mode-tab { color: #e3e3f1 !important; }
body[data-theme="dark"] .viz-mode-tab.active { color: #4893dd !important; background: #2b2b2b !important; }
body[data-theme="dark"] #btn-copy-settings,
body[data-theme="dark"] #btn-paste-settings,
body[data-theme="dark"] .control-group button:not(.toolbar-btn) {
    background: #3b3b3b !important;
    color: #e3e3f1 !important;
}
body[data-theme="dark"] .control-group button#btn-auto-color,
body[data-theme="dark"] .control-group button#btn-auto-color-roll { background: #4893dd !important; color: #1f1f1f !important; }
body[data-theme="dark"] .control-group #btn-reset-color { background: #2b2b2b !important; color: #e3e3f1 !important; box-shadow: inset 0 0 0 2px #4893dd !important; }
body[data-theme="dark"] .control-group > .flex.items-center.justify-between,
body[data-theme="dark"] .control-group .bg-\[\#121214\],
body[data-theme="dark"] .color-balance-group { background: #2b2b2b !important; border-color: #3b3b3b !important; }
body[data-theme="dark"] #btn-mode-color { background: #2b2b2b !important; color: #e3e3f1 !important; }
body[data-theme="dark"] #btn-mode-bw { background: #4a4a4a !important; color: #e3e3f1 !important; }
body[data-theme="dark"] .control-group h3,
body[data-theme="dark"] .color-balance-title { color: #8d8d8d !important; }
body[data-theme="dark"] .control-group label { color: #e3e3f1 !important; }
body[data-theme="dark"] .control-group [class*="text-zinc-400"],
body[data-theme="dark"] .control-group [class*="text-zinc-500"] { color: #8d8d8d !important; }
body[data-theme="dark"] .control-group [class*="text-red-400"] { color: #b75858 !important; }
body[data-theme="dark"] .control-group [class*="text-emerald-400"] { color: #3f8f67 !important; }
body[data-theme="dark"] .control-group [class*="text-blue-400"] { color: #4d75ad !important; }
body[data-theme="dark"] .custom-range::-webkit-slider-runnable-track,
body[data-theme="dark"] .slider::-webkit-slider-runnable-track,
body[data-theme="dark"] .custom-range:disabled::-webkit-slider-runnable-track,
body[data-theme="dark"] .slider:disabled::-webkit-slider-runnable-track {
    background: linear-gradient(to right, var(--track-fill, #4893dd) 0%, var(--track-fill, #4893dd) var(--val), #5a5a5a var(--val), #5a5a5a 100%) !important;
}
body[data-theme="dark"] .custom-range::-webkit-slider-thumb,
body[data-theme="dark"] .slider::-webkit-slider-thumb { background: #4893dd !important; }
body[data-theme="dark"] #right-panel-blocker { background: rgba(43, 43, 43, .96) !important; }

/* Micro-details from Frame 53 and the exported slider cards. */
body[data-theme="light"] #view-develop > div:last-child > div:last-child,
body[data-theme="light"] #view-develop > div:last-child > div:nth-of-type(2) { border-radius: 10px !important; }
body[data-theme="light"] #btn-copy-settings,
body[data-theme="light"] #btn-paste-settings,
body[data-theme="light"] .control-group button:not(.toolbar-btn),
body[data-theme="light"] .control-group > .flex.items-center.justify-between,
body[data-theme="light"] .control-group .bg-\[\#121214\],
body[data-theme="light"] .color-balance-group,
body[data-theme="light"] .control-group select {
    background: #ececea !important;
    border-color: transparent !important;
}
body[data-theme="light"] #btn-mode-color { background: #fff !important; }
body[data-theme="light"] #btn-mode-bw { background: #d4d4d4 !important; }
body[data-theme="light"] .control-group .h-px { background: #d0d0d0 !important; }
body[data-theme="light"] .control-group { border-top-color: #ececea !important; }
body[data-theme="light"] .control-group label[class*="text-red-400"],
body[data-theme="light"] .control-group label[class*="text-emerald-400"],
body[data-theme="light"] .control-group label[class*="text-blue-400"] { color: var(--figma-text) !important; }
body[data-theme="light"] .temperature-track::-webkit-slider-runnable-track {
    height: 8px !important;
    margin-top: -2px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: linear-gradient(to right, #4893dd 0%, #8ebfe6 28%, #d4d4d4 50%, #efb35d 74%, #d9682f 100%) !important;
}
body[data-theme="light"] .tint-track::-webkit-slider-runnable-track {
    height: 8px !important;
    margin-top: -2px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: linear-gradient(to right, #3f8f67 0%, #8bc79e 28%, #d4d4d4 50%, #b989c8 74%, #874ca2 100%) !important;
}
body[data-theme="light"] .temperature-track::-webkit-slider-thumb,
body[data-theme="light"] .tint-track::-webkit-slider-thumb {
    width: 8px !important;
    height: 20px !important;
    margin-top: -6px !important;
    border-radius: 2px !important;
    background: #3f3f46 !important;
}
body[data-theme="dark"] #btn-copy-settings,
body[data-theme="dark"] #btn-paste-settings,
body[data-theme="dark"] .control-group button:not(.toolbar-btn),
body[data-theme="dark"] .control-group > .flex.items-center.justify-between,
body[data-theme="dark"] .control-group .bg-\[\#121214\],
body[data-theme="dark"] .color-balance-group,
body[data-theme="dark"] .control-group select { border-radius: 10px !important; }
body[data-theme="dark"] .control-group { border-top-color: #3b3b3b !important; }
body[data-theme="dark"] .control-group label[class*="text-red-400"],
body[data-theme="dark"] .control-group label[class*="text-emerald-400"],
body[data-theme="dark"] .control-group label[class*="text-blue-400"] { color: var(--figma-text) !important; }
body[data-theme="dark"] .temperature-track::-webkit-slider-runnable-track {
    height: 8px !important;
    margin-top: -2px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: linear-gradient(to right, #4893dd 0%, #8ebfe6 28%, #3b3b3b 50%, #efb35d 74%, #d9682f 100%) !important;
}
body[data-theme="dark"] .tint-track::-webkit-slider-runnable-track {
    height: 8px !important;
    margin-top: -2px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: linear-gradient(to right, #3f8f67 0%, #8bc79e 28%, #3b3b3b 50%, #b989c8 74%, #874ca2 100%) !important;
}
body[data-theme="dark"] .temperature-track::-webkit-slider-thumb,
body[data-theme="dark"] .tint-track::-webkit-slider-thumb {
    width: 8px !important;
    height: 20px !important;
    margin-top: -6px !important;
    border-radius: 2px !important;
    background: #3f3f46 !important;
}

body[data-theme="light"] #develop-inspector input.custom-range:not(.temperature-track):not(.tint-track),
body[data-theme="light"] #develop-inspector input.slider {
    background-image:
        repeating-linear-gradient(to right, transparent 0, transparent calc(10% - 1px), rgba(20, 20, 22, .18) calc(10% - 1px), rgba(20, 20, 22, .18) 10%),
        linear-gradient(to right, var(--track-fill, #0a5aa8) 0%, var(--track-fill, #0a5aa8) var(--val), #d4d4d4 var(--val), #d4d4d4 100%) !important;
    background-size: 100% 7px, 100% 4px !important;
    background-position: center top, center center !important;
    background-repeat: no-repeat !important;
}
body[data-theme="dark"] #develop-inspector input.custom-range:not(.temperature-track):not(.tint-track),
body[data-theme="dark"] #develop-inspector input.slider {
    background-image:
        repeating-linear-gradient(to right, transparent 0, transparent calc(10% - 1px), rgba(226, 226, 244, .18) calc(10% - 1px), rgba(226, 226, 244, .18) 10%),
        linear-gradient(to right, var(--track-fill, #4893dd) 0%, var(--track-fill, #4893dd) var(--val), #5a5a5a var(--val), #5a5a5a 100%) !important;
    background-size: 100% 7px, 100% 4px !important;
    background-position: center top, center center !important;
    background-repeat: no-repeat !important;
}
body[data-theme="light"] #develop-inspector input.custom-range:not(.temperature-track):not(.tint-track)::-webkit-slider-runnable-track,
body[data-theme="light"] #develop-inspector input.slider::-webkit-slider-runnable-track,
body[data-theme="dark"] #develop-inspector input.custom-range:not(.temperature-track):not(.tint-track)::-webkit-slider-runnable-track,
body[data-theme="dark"] #develop-inspector input.slider::-webkit-slider-runnable-track { background: transparent !important; }

@media (max-width: 640px) {
    #export-modal { padding: 16px; }
    #export-modal-content.export-dialog { width: calc(100vw - 32px) !important; max-height: calc(100vh - 32px); }
    .export-dialog-header, .export-dialog-footer { padding-left: 16px; padding-right: 16px; }
    .export-dialog-body { padding: 12px 16px 16px; }
    .export-settings-grid { grid-template-columns: 1fr; }
    .export-file-section { grid-column: auto; }
    .export-summary-bar { align-items: flex-start; flex-direction: column; gap: 4px; }
    .export-summary-detail { max-width: none; text-align: left; }
    .export-check-row, .export-token-hint { margin-left: 0; }
    .export-field { grid-template-columns: 1fr; gap: 5px; align-items: start; }
    .export-file-section > .export-field { grid-template-columns: 1fr; }
    .export-preview-row { grid-template-columns: 1fr; gap: 5px; }
    .export-destination-row { align-items: stretch; flex-direction: column; }
    .export-destination-row button { width: 100%; }
    .sponsor-modal { padding: 16px; }
    #sponsor-modal-content.sponsor-card { width: calc(100vw - 32px) !important; max-height: calc(100vh - 32px); }
    .sponsor-card-body { padding: 18px !important; }
    .sponsor-intro,
    .sponsor-qr-grid,
    .sponsor-contacts { grid-template-columns: minmax(0, 1fr); }
    .sponsor-intro section + section { padding: 16px 0 0; border-top: 1px solid var(--line); border-left: 0; }
    .sponsor-qr-frame { width: min(240px, 100%); margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .sponsor-modal, .sponsor-card { transition: none !important; }
}

/* -------------------------------------------------------------------------
   NEXFILM / Figma visual system
   ------------------------------------------------------------------------- */
:root {
    --bg: #25272a;
    --chrome: #1d1f22;
    --panel: #2b2d30;
    --panel-raised: #32353a;
    --workspace: #111315;
    --control: #3a3d42;
    --control-hover: #454950;
    --text: #f4f6f8;
    --muted: #aeb5bf;
    --subtle: #737b86;
    --line: rgba(255, 255, 255, .11);
    --line-strong: rgba(255, 255, 255, .2);
    --accent: #2388ff;
    --accent-hover: #4b9eff;
    --accent-soft: rgba(35, 136, 255, .18);
    --danger: #e26f73;
    --radius: 4px;
    --motion-fast: 140ms;
    --motion-base: 190ms;
    --ease-standard: cubic-bezier(.2, .7, .2, 1);
    --ease-emphasized: cubic-bezier(.22, 1, .36, 1);
}

body[data-theme="light"] {
    --bg: #e7e9ec;
    --chrome: #f7f8fa;
    --panel: #f4f5f6;
    --panel-raised: #ffffff;
    --workspace: #d9dde2;
    --control: #e5e8ec;
    --control-hover: #d9dde3;
    --text: #1d2228;
    --muted: #69727d;
    --subtle: #929aa5;
    --line: rgba(22, 30, 40, .13);
    --line-strong: rgba(22, 30, 40, .22);
    --accent: #1677e8;
    --accent-hover: #0d63c9;
    --accent-soft: rgba(22, 119, 232, .12);
    --danger: #be5258;
}

html, body { background: var(--bg) !important; }
body { color: var(--text) !important; }

/* The reference uses compact desktop chrome and restrained separators. */
#native-menu-bar {
    height: 30px !important;
    background: var(--chrome) !important;
    border-bottom-color: var(--line) !important;
}
#native-menu-bar > div:first-child { color: var(--text) !important; }
body > header {
    height: 58px !important;
    padding: 0 18px !important;
    background: var(--chrome) !important;
}
body > header > div:first-child { gap: 24px !important; }
body > header .text-\[14px\] {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px !important;
    letter-spacing: .12em !important;
}
body > header .brand-mark { width: 24px; height: 18px; flex: 0 0 auto; object-fit: contain; }
body > header .brand-name { color: var(--text); }
body > header nav { gap: 4px !important; }
body > header nav button {
    min-width: 72px;
    height: 32px !important;
    align-self: center;
    padding: 0 12px !important;
    border: 1px solid transparent !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    color: var(--muted) !important;
    transition: color var(--motion-fast) var(--ease-standard),
        background var(--motion-fast) var(--ease-standard),
        border-color var(--motion-fast) var(--ease-standard);
}
body > header nav button:hover { background: var(--control); color: var(--text) !important; }
body > header nav button.border-zinc-100 {
    color: var(--text) !important;
    background: var(--accent-soft) !important;
    border-color: color-mix(in srgb, var(--accent) 55%, transparent) !important;
}
body > header > div:last-child { gap: 6px !important; }
body > header > div:last-child button {
    min-height: 30px;
    padding: 0 11px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    transition: color var(--motion-fast) var(--ease-standard),
        background var(--motion-fast) var(--ease-standard),
        border-color var(--motion-fast) var(--ease-standard),
        transform var(--motion-fast) var(--ease-standard);
}
body > header > div:last-child button:hover { transform: translateY(-1px); }
#btn-import { color: var(--text) !important; border-color: var(--line-strong) !important; }
#btn-export-dialog { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
#btn-export-dialog:hover { background: var(--accent-hover) !important; border-color: var(--accent-hover) !important; color: #fff !important; }

/* Views fade and lift together instead of popping between display states. */
#views > [id^="view-"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity var(--motion-base) var(--ease-standard),
        transform var(--motion-base) var(--ease-emphasized),
        visibility 0s linear var(--motion-base);
}
#views > [id^="view-"].is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
    z-index: 30;
}
#views > [id^="view-"].is-leaving {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
}

/* Library and Rolls share the light, gallery-like spacing from the reference. */
#view-library > div:first-child,
#view-history > div:last-child > div:first-child {
    height: 52px !important;
    padding: 0 20px !important;
    background: var(--panel) !important;
}
#view-library > div:first-child > div:first-child,
#history-view-title {
    font-size: 14px !important;
    font-weight: 620 !important;
    letter-spacing: .01em !important;
}
#view-library > div:nth-child(2), #view-history > div:last-child > div:nth-child(2) {
    padding: 20px !important;
    background: var(--panel) !important;
}
#library-grid, #history-internal-grid { gap: 10px !important; }
.library-item {
    aspect-ratio: 4 / 3 !important;
    background: color-mix(in srgb, var(--panel-raised) 76%, var(--workspace)) !important;
    outline: 1px solid transparent;
    outline-offset: 2px;
    transition: opacity var(--motion-fast) var(--ease-standard),
        outline-color var(--motion-fast) var(--ease-standard),
        transform var(--motion-fast) var(--ease-emphasized);
    animation: nexfilm-item-in 220ms var(--ease-emphasized) both;
}
.library-item:hover { outline-color: var(--line-strong); transform: translateY(-2px); }
.library-item.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.library-item img { transition: opacity var(--motion-base) var(--ease-standard), transform var(--motion-base) var(--ease-emphasized); }
.library-item:hover img { opacity: .96; transform: scale(1.015); }
#library-empty svg, #history-empty svg { color: var(--accent) !important; }
#library-empty button, #history-empty button { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
#library-empty button:hover, #history-empty button:hover { background: var(--accent-hover) !important; }

#view-history > div:first-child {
    width: 216px !important;
    padding: 20px 16px !important;
    background: var(--panel-raised) !important;
}
#view-history > div:first-child h2 { margin-bottom: 20px !important; font-size: 13px !important; }
#view-history > div:first-child h3 { margin-bottom: 10px !important; font-size: 11px !important; }
#view-history label { min-height: 25px; align-items: center; border-radius: 3px; transition: background var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard); }
#view-history label:hover { background: var(--control); color: var(--text) !important; }
.roll-row { min-height: 156px; gap: 24px; padding: 16px 0; transition: background var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-emphasized); animation: nexfilm-item-in 220ms var(--ease-emphasized) both; }
.roll-row:hover { transform: translateX(2px); }
.roll-title { font-size: 17px; }
.roll-format { color: var(--accent); }
.roll-preview { width: min(38%, 460px); min-width: 240px; }

/* Develop keeps the image dominant and the inspector dense. */
#view-develop > div:first-child { background: var(--workspace) !important; }
#view-develop > div:first-child > div:first-child {
    height: 44px !important;
    padding: 0 12px !important;
    background: var(--chrome) !important;
}
.toolbar-btn { min-height: 28px; padding: 0 8px !important; border-radius: 3px !important; color: var(--muted) !important; }
.toolbar-btn:hover:not(:disabled) { background: var(--control) !important; color: var(--text) !important; }
.toolbar-btn.active { background: var(--accent-soft) !important; color: var(--accent) !important; }
#view-develop > div:first-child > div:nth-child(2) { padding: 20px !important; background: var(--workspace) !important; }
#canvas-wrapper { box-shadow: 0 16px 40px rgba(0, 0, 0, .34); transition: opacity var(--motion-base) var(--ease-standard); }
#filmstrip-container { height: 98px !important; padding: 10px 14px !important; gap: 8px !important; background: var(--chrome) !important; }
.film-item { width: 96px !important; height: 66px !important; border-radius: 3px !important; outline: 1px solid transparent; outline-offset: 2px; transition: opacity var(--motion-fast) var(--ease-standard), outline-color var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-emphasized); animation: nexfilm-item-in 180ms var(--ease-emphasized) both; }
.film-item:hover { transform: translateY(-2px) !important; }
.film-item.active { outline: 2px solid var(--accent); outline-offset: 2px; }
#view-develop > div:last-child { width: 328px !important; background: var(--panel) !important; }
#view-develop > div:last-child > div:nth-of-type(2) { padding: 16px 18px !important; }
#view-develop > div:last-child > div:nth-of-type(2) .w-full { height: 108px !important; }
#view-develop > div:last-child > div:last-child { padding: 16px 18px !important; gap: 19px !important; }
.control-group { padding-top: 18px !important; }
.control-group h3 { margin-bottom: 14px !important; font-size: 11px !important; }
.control-group label { font-size: 11px !important; }
.control-group button:not(.toolbar-btn), #btn-copy-settings, #btn-paste-settings { min-height: 29px; }
#btn-auto-color,
#btn-auto-color-roll { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
#btn-auto-color:hover,
#btn-auto-color-roll:hover { background: var(--accent-hover) !important; }
#right-panel-blocker h3 { color: var(--accent) !important; }
.calib-edge-dot { stroke: var(--accent) !important; }
.calib-dot { fill: var(--accent) !important; }
#calibration-polygon { fill: var(--accent-soft) !important; stroke: var(--accent) !important; }
#calibration-grid { stroke: color-mix(in srgb, var(--accent) 52%, transparent) !important; }

/* Inputs, notices and modal surfaces use the same blue focus language. */
input[type="range"]::-webkit-slider-thumb { border-color: var(--accent) !important; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }
select:focus, input:focus { border-color: var(--accent) !important; }
#toast-container > div { border-left-color: var(--accent) !important; }
#drag-overlay { border-color: var(--accent) !important; }

@keyframes nexfilm-item-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 780px) {
    body > header { padding: 0 10px !important; }
    body > header > div:first-child { gap: 10px !important; }
    body > header nav button { min-width: 58px; padding: 0 8px !important; }
    body > header > div:last-child button { padding: 0 8px !important; }
    #view-develop > div:last-child { width: 286px !important; }
}

@media (prefers-reduced-motion: reduce) {
    #views > [id^="view-"], .library-item, .film-item, .roll-row, #canvas-wrapper, button, img { animation: none !important; transition-duration: 1ms !important; }
}

/*
 * Figma Light desktop reference.  These rules deliberately live last: the
 * application markup keeps Tailwind utility classes for behavior, while this
 * layer makes the shared chrome and Develop workspace follow the source file.
 */
:root,
body[data-theme="light"],
body[data-theme="dark"] {
    --figma-blue: #0a5aa8;
    --figma-stone: #fafaf9;
    --figma-workspace: #dadada;
    --figma-control: #ececea;
    --figma-text: #3b3b3b;
    --figma-muted: #939398;
    --figma-line: rgba(20, 20, 22, .101961);
    --bg: #fff;
    --chrome: #fff;
    --panel: #fff;
    --panel-raised: #fff;
    --workspace: var(--figma-workspace);
    --control: var(--figma-control);
    --control-hover: #d4d4d4;
    --text: var(--figma-text);
    --muted: var(--figma-muted);
    --subtle: var(--figma-muted);
    --line: var(--figma-line);
    --line-strong: rgba(23, 23, 23, .18);
    --accent: var(--figma-blue);
    --accent-hover: #074e91;
    --accent-soft: rgba(10, 90, 168, .13);
    --font-ui: Montserrat, "Segoe UI", Arial, sans-serif;
    --font-mono: Montserrat, "Segoe UI", Arial, sans-serif;
}

body {
    background: #fff !important;
    color: var(--figma-text) !important;
    font-family: Montserrat, "Segoe UI", Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 500;
}
body .uppercase { text-transform: none !important; }
body .tracking-widest,
body .tracking-wider,
body [class*="tracking-["] { letter-spacing: 0 !important; }
button,
input,
select { font-family: inherit !important; }
button:focus-visible,
input:focus-visible,
select:focus-visible { outline: 2px solid var(--figma-blue) !important; outline-offset: 2px !important; }

/* Figma top menu and application navigation. */
#native-menu-bar {
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 32px !important;
    gap: 40px !important;
    background: var(--figma-stone) !important;
    color: var(--figma-muted) !important;
    border: 0 !important;
    border-bottom: 2px solid var(--figma-line) !important;
    border-radius: 0 0 20px 20px !important;
    box-shadow: none !important;
    font-size: 10px !important;
    font-weight: 500 !important;
}
#native-menu-bar > div:first-child {
    color: var(--figma-blue) !important;
    font-size: 10px !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
    text-transform: uppercase !important;
}
#native-menu-bar > div:not(:first-child) { padding: 4px 0 !important; }
#native-menu-bar > div:hover { color: var(--figma-text) !important; background: transparent !important; }
#native-menu-bar .group > div {
    border: 1px solid var(--figma-line) !important;
    border-radius: 8px !important;
    background: #fff !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .12) !important;
}
#native-menu-bar .group > div > div:hover { background: var(--figma-control) !important; }
#theme-value { color: var(--figma-blue) !important; }

body > header {
    height: 58px !important;
    min-height: 58px !important;
    padding: 0 32px !important;
    background: #fff !important;
    border: 0 !important;
    box-shadow: none !important;
}
body > header > div:first-child { height: 100% !important; gap: 40px !important; }
body > header .text-\[14px\] {
    display: flex !important;
    align-items: center !important;
    width: 56px !important;
    height: 36px !important;
    color: transparent !important;
    font-size: 0 !important;
    letter-spacing: 0 !important;
}
body > header .brand-mark {
    display: block !important;
    width: 56px !important;
    height: 36px !important;
    object-fit: contain !important;
}
body > header .brand-name,
body > header .brand-mark + span,
body > header .text-\[14px\] > span { display: none !important; }
body > header .h-6 { display: none !important; }
body > header nav {
    height: 100% !important;
    align-items: flex-end !important;
    gap: 39px !important;
}
body > header nav button {
    height: 50px !important;
    min-width: 76px;
    padding: 0 10px !important;
    border: 0 !important;
    border-bottom: 8px solid transparent !important;
    border-radius: 20px 20px 0 0 !important;
    background: transparent !important;
    color: var(--figma-text) !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: 42px !important;
    text-transform: none !important;
}
body > header nav button:hover { background: #f3f3f3 !important; color: var(--figma-text) !important; }
body > header nav button.border-zinc-100 {
    border-bottom-color: var(--figma-workspace) !important;
    background: var(--figma-workspace) !important;
    color: var(--figma-blue) !important;
    font-weight: 700 !important;
}
body > header nav button:focus-visible { outline: none !important; }
body > header > div:last-child {
    width: 320px !important;
    flex: 0 0 320px !important;
    height: 32px !important;
    gap: 10px !important;
    overflow: visible !important;
    border-radius: 10px !important;
    background: var(--figma-blue) !important;
}
body > header > div:last-child button {
    width: 100px !important;
    min-width: 100px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 10px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #fff !important;
    color: #18181b !important;
    box-shadow: inset 0 0 0 3px var(--figma-blue) !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    white-space: nowrap;
}
body > header > div:last-child button:hover:not(:disabled) { background: #f4f4f4 !important; transform: none !important; }
#btn-export-dialog { min-width: 100px !important; }
#btn-export-dialog {
    background: var(--figma-blue) !important;
    color: #fff !important;
    box-shadow: none !important;
}
#btn-export-dialog:hover:not(:disabled) { background: #074e91 !important; color: #fff !important; }
#btn-delete-develop-image {
    position: absolute;
    right: 338px;
    background: #fff !important;
    color: #b91c1c !important;
    box-shadow: inset 0 0 0 1px #fecaca !important;
}

/* Main canvas, transform bar and filmstrip. */
#views {
    background: var(--figma-workspace) !important;
    border-radius: 20px 20px 0 0 !important;
    overflow: hidden !important;
}
#views > [id^="view-"] { border-radius: 20px 20px 0 0 !important; }
#view-develop { padding: 10px !important; gap: 10px !important; }
#view-develop > div:first-child {
    min-width: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
}
#view-develop > div:first-child > div:first-child {
    height: 46px !important;
    min-height: 46px !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 0 14px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: var(--figma-control) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25) !important;
}
#view-develop > div:first-child > div:first-child > div:first-child {
    gap: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}
#view-develop > div:first-child > div:first-child > div:first-child #btn-crop-mode {
    padding-right: 8px !important;
    border-radius: 3px !important;
    background: #fff !important;
}
#view-develop > div:first-child > div:first-child > div:first-child #btn-reset-crop {
    border-radius: 3px !important;
    background: #a1a1aa !important;
    color: #fff !important;
}
#view-develop > div:first-child > div:first-child > div:first-child #btn-reset-crop .toolbar-icon { stroke: #fff !important; }
#view-develop > div:first-child > div:first-child > div:first-child #btn-perspective-mode { order: 4; margin-left: 2px; }
#view-develop > div:first-child > div:first-child > div:first-child #btn-recalibrate { order: 3; }
#view-develop .w-px {
    width: 1px !important;
    height: 20px !important;
    margin: 0 2px !important;
    background: var(--figma-line) !important;
}
.toolbar-btn {
    min-height: 28px !important;
    padding: 0 8px !important;
    border-radius: 3px !important;
    background: transparent !important;
    color: var(--figma-text) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}
.toolbar-btn:hover:not(:disabled),
.toolbar-btn.active { background: rgba(255, 255, 255, .72) !important; color: var(--figma-blue) !important; }
.toolbar-btn:disabled { opacity: 1 !important; color: var(--figma-text) !important; }
.toolbar-icon { width: 11px !important; height: 11px !important; color: var(--figma-blue) !important; stroke: var(--figma-blue) !important; stroke-width: 1.8 !important; }
#btn-flip-h .toolbar-icon { width: 10px !important; }
#btn-flip-v .toolbar-icon { width: 12px !important; }
#btn-crop-mode .toolbar-icon,
#btn-reset-crop .toolbar-icon,
#btn-recalibrate .toolbar-icon,
#btn-perspective-mode .toolbar-icon { display: none !important; }
#view-develop > div:first-child > div:nth-child(2) {
    padding: 20px !important;
    border-radius: 10px !important;
    background: var(--figma-workspace) !important;
}
#canvas-wrapper { box-shadow: 0 14px 28px rgba(0, 0, 0, .24) !important; }
#missing-file-ui { background: var(--figma-workspace) !important; }
#filmstrip-container {
    height: 104px !important;
    min-height: 104px !important;
    margin-top: 10px !important;
    padding: 16px !important;
    gap: 8px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: var(--figma-stone) !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, .25) !important;
}
.film-item {
    width: 108px !important;
    height: 72px !important;
    border-radius: 3px !important;
    background: var(--figma-control) !important;
    opacity: 1 !important;
}
.film-item.active { outline: 3px solid var(--figma-blue) !important; outline-offset: 0 !important; }

/* Inspector: discrete cards and compact Figma controls. */
#view-develop > div:last-child,
#develop-inspector {
    width: 360px !important;
    min-width: 360px !important;
    gap: 10px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow-y: auto !important;
}
#develop-inspector::-webkit-scrollbar {
    width: 0;
    height: 0;
}
#view-develop > div:last-child > div:nth-of-type(2),
#view-develop > div:last-child > div:last-child {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #fff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25) !important;
}
#view-develop > div:last-child > div:nth-of-type(2) {
    position: static !important;
    padding: 24px !important;
}
#view-develop > div:last-child > div:nth-of-type(2) > div:first-child { margin-bottom: 0 !important; }
#viz-title { display: none !important; }
#viz-mode-tabs {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}
.viz-mode-tab {
    flex: 0 0 84px;
    width: 84px !important;
    min-height: 29px !important;
    padding: 0 8px !important;
    border: 0 !important;
    border-radius: 5px 5px 0 0 !important;
    background: transparent !important;
    color: var(--figma-text) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}
.viz-mode-tab.active {
    background: var(--figma-workspace) !important;
    color: var(--figma-blue) !important;
    font-weight: 700 !important;
}
#view-develop > div:last-child > div:nth-of-type(2) .w-full {
    height: 116px !important;
    border: 0 !important;
    border-radius: 5px !important;
    background: var(--figma-workspace) !important;
}
#view-develop > div:last-child > div:last-child {
    padding: 24px 24px 28px !important;
    gap: 18px !important;
}
#view-develop > div:last-child > div:last-child > .flex:first-child { gap: 12px !important; }
#btn-copy-settings,
#btn-paste-settings {
    height: 30px !important;
    min-height: 30px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: rgba(23, 23, 23, .10) !important;
    color: #18181b !important;
    box-shadow: none !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}
.control-group {
    padding-top: 18px !important;
    border-color: var(--figma-line) !important;
    border-top-width: 3px !important;
}
.control-group h3 {
    margin-bottom: 16px !important;
    color: var(--figma-muted) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}
.control-group h3 svg { color: var(--figma-muted) !important; }
.control-group label { color: var(--figma-text) !important; font-size: 12px !important; font-weight: 500 !important; }
.control-group [class*="text-zinc-400"],
.control-group [class*="text-zinc-500"] { color: var(--figma-muted) !important; }
.control-group button:not(.toolbar-btn),
#btn-mode-color,
#btn-mode-bw {
    min-height: 32px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: rgba(23, 23, 23, .10) !important;
    color: var(--figma-text) !important;
    box-shadow: none !important;
    font-size: 12px !important;
    font-weight: 600 !important;
}
.control-group button#btn-auto-color,
.control-group button#btn-auto-color-roll {
    background: var(--figma-blue) !important;
    color: #fff !important;
    box-shadow: none !important;
}
#develop-inspector button:disabled,
#develop-inspector input:disabled,
#develop-inspector select:disabled { opacity: 1 !important; }
.control-group #btn-reset-color { background: #fff !important; box-shadow: inset 0 0 0 2px var(--figma-blue) !important; }
.control-group > .flex.items-center.justify-between {
    padding: 3px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: rgba(23, 23, 23, .10) !important;
}
#btn-mode-color,
#btn-mode-bw { min-height: 28px !important; background: transparent !important; }
#btn-mode-color { background: #fff !important; }
.control-group .bg-\[\#121214\] {
    border: 0 !important;
    border-radius: 10px !important;
    background: rgba(23, 23, 23, .10) !important;
}
#select-colorspace {
    width: 122px !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 26px 0 8px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #fff !important;
    color: #939398 !important;
    font-size: 12px !important;
    font-weight: 400 !important;
}
#select-colorspace:hover { background: var(--figma-control) !important; }
.control-group .h-px { background: rgba(23, 23, 23, .45) !important; }
.control-group [class*="text-red-400"] { color: #ef4444 !important; }
.control-group [class*="text-emerald-400"] { color: #16a34a !important; }
.control-group [class*="text-blue-400"] { color: #64748b !important; }
.color-balance-group {
    gap: 14px !important;
    padding: 10px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: rgba(23, 23, 23, .10) !important;
}
.color-balance-title { color: var(--figma-muted) !important; font-size: 10px !important; font-weight: 500 !important; text-transform: none !important; }
.custom-range,
.slider { height: 18px !important; opacity: 1 !important; }
.custom-range:disabled,
.slider:disabled { cursor: default !important; opacity: 1 !important; }
.custom-range::-webkit-slider-runnable-track,
.slider::-webkit-slider-runnable-track,
.custom-range:disabled::-webkit-slider-runnable-track,
.slider:disabled::-webkit-slider-runnable-track {
    height: 4px !important;
    background: linear-gradient(to right, var(--track-fill, var(--figma-blue)) 0%, var(--track-fill, var(--figma-blue)) var(--val), #d4d4d4 var(--val), #d4d4d4 100%) !important;
}
.custom-range::-webkit-slider-thumb,
.slider::-webkit-slider-thumb {
    width: 6px !important;
    height: 20px !important;
    margin-top: -8px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: var(--figma-blue) !important;
    box-shadow: none !important;
}
.red-track { --track-fill: #c96565; }
.green-track { --track-fill: #4c9a78; }
.blue-track { --track-fill: #668bd4; }
.temperature-track::-webkit-slider-runnable-track,
.tint-track::-webkit-slider-runnable-track { height: 5px !important; border: 0 !important; }
.temperature-track::-webkit-slider-thumb,
.tint-track::-webkit-slider-thumb { background: #3f3f46 !important; }
#right-panel-blocker { border-radius: 10px !important; background: rgba(255, 255, 255, .94) !important; }

@media (max-width: 1100px) {
    body > header { padding: 0 16px !important; }
    body > header > div:first-child { gap: 18px !important; }
    body > header nav { gap: 4px !important; }
    body > header nav button { min-width: 64px; font-size: 14px !important; }
    #view-develop > div:last-child,
    #develop-inspector { width: 320px !important; min-width: 320px !important; }
    .toolbar-btn { padding: 0 6px !important; }
}

@media (max-width: 780px) {
    #native-menu-bar { padding: 0 16px !important; gap: 18px !important; }
    body > header > div:last-child button { min-width: 32px !important; font-size: 0 !important; }
    body > header > div:last-child button::first-letter { font-size: 12px !important; }
    #view-develop { padding: 6px !important; gap: 6px !important; }
    #view-develop > div:last-child,
    #develop-inspector { width: 286px !important; min-width: 286px !important; }
    .toolbar-btn > span { display: none; }
}

/* Dark uses the same Figma geometry as Light; only the reference palette changes. */
body[data-theme="dark"] {
    --figma-blue: #4893dd;
    --figma-stone: #282828;
    --figma-workspace: #0e0e0e;
    --figma-control: #1f1f1f;
    --figma-text: #e3e3f1;
    --figma-muted: #8d8d8d;
    --figma-line: rgba(226, 226, 244, .10);
    --bg: #282828;
    --chrome: #282828;
    --panel: #2b2b2b;
    --panel-raised: #2b2b2b;
    --workspace: #0e0e0e;
    --control: #3b3b3b;
    --control-hover: #4a4a4a;
    --text: #e3e3f1;
    --muted: #8d8d8d;
    --subtle: #8d8d8d;
    --line: rgba(226, 226, 244, .10);
    --line-strong: rgba(226, 226, 244, .18);
    --accent: #4893dd;
    --accent-hover: #68a8e7;
    --accent-soft: rgba(72, 147, 221, .18);
    background: #282828 !important;
    color: #e3e3f1 !important;
}
body[data-theme="dark"] #native-menu-bar,
body[data-theme="dark"] > header { background: #282828 !important; }
body[data-theme="dark"] #native-menu-bar .group > div {
    border-color: rgba(226, 226, 244, .10) !important;
    background: #2b2b2b !important;
}
body[data-theme="dark"] #native-menu-bar .group > div > div:hover,
body[data-theme="dark"] > header nav button:hover { background: #303030 !important; }
body[data-theme="dark"] > header .brand-mark {
    content: url("assets/design-reference/nexfilm-logo-dark.svg") !important;
}
body[data-theme="dark"] > header nav button { color: #e3e3f1 !important; }
body[data-theme="dark"] > header nav button.border-zinc-100 {
    border-bottom-color: #0e0e0e !important;
    background: #0e0e0e !important;
    color: #4893dd !important;
}
body[data-theme="dark"] > header > div:last-child { background: #4893dd !important; }
body[data-theme="dark"] > header > div:last-child button {
    background: #1f1f1f !important;
    color: #e3e3f1 !important;
    box-shadow: inset 0 0 0 3px #4893dd !important;
}
body[data-theme="dark"] > header > div:last-child button:hover:not(:disabled) { background: #303030 !important; }
body[data-theme="dark"] #btn-export-dialog { background: #4893dd !important; color: #1f1f1f !important; box-shadow: none !important; }
body[data-theme="dark"] #btn-delete-develop-image {
    background: #2b2b2b !important;
    color: #e3e3f1 !important;
    box-shadow: inset 0 0 0 1px #7f4242 !important;
}
body[data-theme="dark"] #views { background: #2b2b2b !important; }
body[data-theme="dark"] #view-develop > div:first-child > div:first-child,
body[data-theme="dark"] #filmstrip-container {
    background: #1f1f1f !important;
    box-shadow: none !important;
}
body[data-theme="dark"] #view-develop > div:first-child > div:first-child > div:first-child { background: transparent !important; }
body[data-theme="dark"] #view-develop > div:first-child > div:first-child > div:first-child #btn-crop-mode {
    background: #1f1f1f !important;
    color: #e3e3f1 !important;
}
body[data-theme="dark"] #view-develop > div:first-child > div:first-child > div:first-child #btn-reset-crop {
    background: #8d8d8d !important;
    color: #1f1f1f !important;
}
body[data-theme="dark"] #view-develop > div:first-child > div:nth-child(2),
body[data-theme="dark"] #missing-file-ui { background: #0e0e0e !important; }
body[data-theme="dark"] .film-item { background: #1f1f1f !important; }
body[data-theme="dark"] #view-develop > div:last-child > div:nth-of-type(2),
body[data-theme="dark"] #view-develop > div:last-child > div:last-child {
    background: #2b2b2b !important;
    box-shadow: none !important;
}
body[data-theme="dark"] .viz-mode-tab { color: #e3e3f1 !important; }
body[data-theme="dark"] .viz-mode-tab.active { background: #2b2b2b !important; color: #4893dd !important; }
body[data-theme="dark"] #view-develop > div:last-child > div:nth-of-type(2) .w-full { background: #0e0e0e !important; }
body[data-theme="dark"] #btn-copy-settings,
body[data-theme="dark"] #btn-paste-settings,
body[data-theme="dark"] .control-group button:not(.toolbar-btn),
body[data-theme="dark"] .control-group > .flex.items-center.justify-between,
body[data-theme="dark"] .control-group .bg-\[\#121214\],
body[data-theme="dark"] .color-balance-group,
body[data-theme="dark"] .control-group select {
    border-color: transparent !important;
    background: #3b3b3b !important;
    color: #e3e3f1 !important;
}
body[data-theme="dark"] .control-group button#btn-auto-color,
body[data-theme="dark"] .control-group button#btn-auto-color-roll { background: #4893dd !important; color: #1f1f1f !important; }
body[data-theme="dark"] .control-group #btn-reset-color,
body[data-theme="dark"] #btn-mode-color { background: #2b2b2b !important; color: #e3e3f1 !important; }
body[data-theme="dark"] .control-group #btn-reset-color { box-shadow: inset 0 0 0 2px #4893dd !important; }
body[data-theme="dark"] #btn-mode-bw { background: #4a4a4a !important; color: #e3e3f1 !important; }
body[data-theme="dark"] .control-group { border-top-color: #3b3b3b !important; }
body[data-theme="dark"] .control-group h3,
body[data-theme="dark"] .color-balance-title,
body[data-theme="dark"] .control-group [class*="text-zinc-400"],
body[data-theme="dark"] .control-group [class*="text-zinc-500"] { color: #8d8d8d !important; }
body[data-theme="dark"] .control-group label { color: #e3e3f1 !important; }
body[data-theme="dark"] #right-panel-blocker { background: rgba(43, 43, 43, .96) !important; }
body[data-theme="dark"] #select-colorspace {
    background: #3b3b3b !important;
    color: #8d8d8d !important;
}

/* Keep the Frame 54/55 color-balance swatches above the generic range rules. */
body[data-theme="light"] #develop-inspector .temperature-track::-webkit-slider-runnable-track,
body[data-theme="dark"] #develop-inspector .temperature-track::-webkit-slider-runnable-track {
    height: 8px !important;
    margin-top: -2px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: linear-gradient(to right, #407acb 0%, #86b8e2 25%, #c9cbc6 50%, #e3a862 75%, #ce6e3e 100%) !important;
}
body[data-theme="light"] #develop-inspector .tint-track::-webkit-slider-runnable-track,
body[data-theme="dark"] #develop-inspector .tint-track::-webkit-slider-runnable-track {
    height: 8px !important;
    margin-top: -2px !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: linear-gradient(to right, #54a06b 0%, #93c29f 25%, #c9cbc6 50%, #a983bd 75%, #80539e 100%) !important;
}
body[data-theme="light"] #develop-inspector .temperature-track::-webkit-slider-thumb,
body[data-theme="light"] #develop-inspector .tint-track::-webkit-slider-thumb,
body[data-theme="dark"] #develop-inspector .temperature-track::-webkit-slider-thumb,
body[data-theme="dark"] #develop-inspector .tint-track::-webkit-slider-thumb {
    width: 6px !important;
    height: 20px !important;
    margin-top: -6px !important;
    border-radius: 2px !important;
    background: #3f3f46 !important;
}

/* Final geometry pass: the inspector rail and adjacent action control are
 * structural UI, so keep them independent from the older utility overrides. */
body.font-sans,
body.font-sans button,
body.font-sans input,
body.font-sans select,
body.font-sans textarea {
    font-family: "Montserrat", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif !important;
}
:lang(zh-CN),
:lang(zh-CN) button,
:lang(zh-CN) input,
:lang(zh-CN) select,
:lang(zh-CN) textarea,
body[data-locale="zh-CN"],
body[data-locale="zh-CN"] button,
body[data-locale="zh-CN"] input,
body[data-locale="zh-CN"] select,
body[data-locale="zh-CN"] textarea {
    font-family: "Montserrat", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif !important;
}

#develop-module-nav {
    flex: 0 0 18px;
    width: 18px;
    min-width: 18px;
    align-self: stretch;
    margin: 10px 0;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 8px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
    z-index: 12;
}
.module-nav-btn {
    position: relative;
    flex: 1 1 0;
    width: 10px;
    min-height: 18px;
    margin: 0 auto;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    transition: background-color 140ms ease, transform 140ms ease;
}
.module-nav-btn::before {
    content: "";
    position: absolute;
    inset: 50% 2px auto;
    height: 2px;
    border-radius: 2px;
    background: #c9c9c9;
    transform: translateY(-50%);
    transition: background-color 140ms ease, height 140ms ease, box-shadow 140ms ease;
}
.module-nav-btn:hover,
.module-nav-btn:focus-visible { background: rgba(10, 90, 168, .10); outline: none; }
.module-nav-btn:hover::before,
.module-nav-btn:focus-visible::before { background: var(--figma-blue); }
.module-nav-btn.is-active::before {
    inset: 50% 0 auto;
    height: 5px;
    background: var(--figma-blue);
    box-shadow: 0 0 4px rgba(10, 90, 168, .45);
}

#develop-inspector {
    scroll-padding-top: 12px;
    overscroll-behavior: contain;
}
#develop-inspector > #inspector-scopes,
#develop-inspector > div:last-child {
    border: 0 !important;
}
.inspector-action-segment {
    display: grid !important;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.2fr) minmax(0, 0.75fr);
    gap: 0 !important;
    overflow: hidden;
    border-radius: 10px;
    background: var(--figma-blue);
    outline: none !important;
    box-shadow: inset 0 0 0 2px var(--figma-blue) !important;
}
.inspector-action-segment #btn-auto-color,
.inspector-action-segment #btn-auto-color-roll,
.inspector-action-segment #btn-reset-color {
    min-width: 0;
    border: 0 !important;
    border-radius: 0 !important;
    outline: none !important;
    margin: 0 !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    white-space: nowrap;
    overflow: hidden;
}
.inspector-action-segment #btn-auto-color { border-radius: 10px 0 0 10px !important; }
.inspector-action-segment #btn-auto-color-roll { border-radius: 0 !important; }
.inspector-action-segment #btn-reset-color {
    border-radius: 0 10px 10px 0 !important;
    box-shadow: none !important;
}

body[data-theme="light"] #develop-module-nav { background: #fff; }
body[data-theme="dark"] #develop-module-nav {
    background: #282828;
    box-shadow: none;
}
body[data-theme="dark"] .module-nav-btn::before { background: #5a5a5a; }
body[data-theme="dark"] .module-nav-btn:hover,
body[data-theme="dark"] .module-nav-btn:focus-visible { background: rgba(72, 147, 221, .14); }
body[data-theme="dark"] .inspector-action-segment { background: #4893dd; box-shadow: inset 0 0 0 2px #4893dd !important; }
body[data-theme="dark"] .inspector-action-segment #btn-reset-color { background: #2b2b2b !important; color: #e3e3f1 !important; }

/* Keep the scope card pinned while the inspector content scrolls. Older
 * structural rules set this block to static; this is the final layout rule. */
#develop-inspector > #inspector-scopes {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
    flex: 0 0 auto !important;
    background: var(--panel) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .14) !important;
}

/* Figma's active top-level tab has two 20px corner pieces that continue the
 * grey tab into the header baseline. */
body > header nav { position: relative; gap: 39px !important; overflow: visible !important; }
body > header nav button.border-zinc-100 {
    position: relative !important;
    overflow: visible !important;
    border-bottom-width: 8px !important;
    border-bottom-color: var(--figma-workspace) !important;
    border-radius: 20px 20px 0 0 !important;
}
body > header nav button.border-zinc-100::before,
body > header nav button.border-zinc-100::after {
    content: "";
    position: absolute;
    bottom: -8px;
    width: 20px;
    height: 20px;
    background: var(--figma-workspace);
    pointer-events: none;
}
body > header nav button.border-zinc-100::before {
    left: -20px;
    border-top-right-radius: 20px;
}
body > header nav button.border-zinc-100::after {
    right: -20px;
    border-top-left-radius: 20px;
}
body[data-theme="dark"] > header nav button.border-zinc-100::before,
body[data-theme="dark"] > header nav button.border-zinc-100::after { background: #282828; }

@media (max-width: 780px) {
    body > header > div:last-child {
        width: auto !important;
        flex-basis: auto !important;
        gap: 4px !important;
        background: transparent !important;
    }
    body > header > div:last-child button { width: 32px !important; }
    #develop-module-nav { flex-basis: 16px; width: 16px; min-width: 16px; padding-inline: 3px; }
    #view-develop { gap: 6px !important; }
}

/* Scope enhancements stay inside the existing histogram frame. */
.scope-canvas-frame {
    position: relative;
    width: 100%;
    height: 116px;
    overflow: hidden;
    border: 0;
    border-radius: 5px;
    background: var(--figma-workspace);
    box-shadow: none;
}
.scope-canvas-frame canvas {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.scope-canvas-frame canvas.hidden { display: none; }
.scope-channel-tabs {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 3px;
    background: rgba(28, 28, 30, .72);
    backdrop-filter: blur(4px);
}
.scope-channel-btn {
    min-width: 20px;
    height: 18px;
    padding: 0 4px;
    border: 0;
    border-radius: 2px;
    background: transparent;
    color: rgba(255, 255, 255, .62);
    font-size: 9px;
    font-weight: 600;
    line-height: 18px;
    cursor: pointer;
}
.scope-clipping-toggle {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 2px;
    background: transparent;
    color: rgba(255, 255, 255, .7);
    font-size: 11px;
    font-weight: 800;
    line-height: 16px;
    cursor: pointer;
}
.scope-clipping-toggle:hover,
.scope-clipping-toggle:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    outline: none;
}
.scope-clipping-toggle.active {
    border-color: #ff7068;
    background: rgba(255, 75, 65, .28);
    color: #fff;
}
.scope-channel-btn:hover,
.scope-channel-btn:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    outline: none;
}
.scope-channel-btn.active {
    color: #fff;
    background: rgba(255, 255, 255, .20);
}
.scope-channel-tabs.waveform-mode .scope-channel-btn { display: none; }
.scope-channel-red { color: #ff7770; }
.scope-channel-green { color: #6ce98a; }
.scope-channel-blue { color: #78a0ff; }
.scope-threshold-handle {
    position: absolute;
    bottom: 0;
    z-index: 4;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    transform: translateX(-50%);
    cursor: ew-resize;
    touch-action: none;
}
.scope-threshold-handle::before {
    content: "";
    position: absolute;
    left: 3px;
    bottom: 2px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 9px solid rgba(225, 225, 228, .92);
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, .9));
}
.scope-threshold-handle:hover::before,
.scope-threshold-handle:focus-visible::before { border-bottom-color: #fff; }
.scope-threshold-handle:focus-visible { outline: none; }
.scope-threshold-shadow.active::before { border-bottom-color: #4f83ff; }
.scope-threshold-highlight.active::before { border-bottom-color: #ff554c; }
body[data-theme="light"] .scope-channel-tabs { background: rgba(42, 42, 44, .72); }

.library-toolbar-button {
    min-height: 30px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-raised);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.library-toolbar-button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.library-toolbar-button:disabled { opacity: .42; cursor: not-allowed; }
.library-toolbar-button-danger { color: #d74848; }
.library-toolbar-button-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.library-toolbar-button-primary:hover:not(:disabled),
.library-toolbar-button-primary.is-selecting { background: var(--accent-hover, #1f5fa7); color: #fff; }
.density-reference-selection .library-item { cursor: pointer; }

.density-calibration-modal {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: center;
    padding: 24px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(10px);
    transition: opacity .18s ease, visibility .18s ease;
}
.density-calibration-modal.is-open { visibility: visible; opacity: 1; pointer-events: auto; }
#density-calibration-content.density-calibration-dialog {
    width: min(920px, calc(100vw - 48px)) !important;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
}
.density-calibration-header, .density-calibration-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 17px 20px;
}
.density-calibration-header { border-bottom: 1px solid var(--line); }
.density-calibration-header h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: 0; }
.density-calibration-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 11px; }
.density-calibration-close, .density-eyedropper {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-raised);
    color: var(--text-muted);
}
.density-calibration-close svg, .density-eyedropper svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.7; }
.density-eyedropper:hover, .density-eyedropper.is-active { border-color: var(--accent); color: var(--accent); }
.density-calibration-body { min-height: 420px; display: grid; grid-template-columns: minmax(0, 1fr) 270px; }
.density-calibration-preview {
    position: relative;
    min-width: 0;
    min-height: 420px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--panel-raised);
}
.density-calibration-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    user-select: none;
}
.density-calibration-preview.is-sampling img { cursor: crosshair; }
.density-calibration-controls { padding: 20px; border-left: 1px solid var(--line); }
.density-calibration-sources { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.density-calibration-sources > strong { display: block; margin-bottom: 9px; color: var(--text-muted); font-size: 10px; font-weight: 650; }
.density-calibration-source-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; max-height: 148px; overflow-y: auto; }
.density-calibration-source { aspect-ratio: 1; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-raised); color: var(--text-muted); }
.density-calibration-source:hover { border-color: var(--line-strong); }
.density-calibration-source.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.density-calibration-source img { width: 100%; height: 100%; object-fit: cover; }
.density-reference-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.density-reference-row:first-child { padding-top: 0; }
.density-reference-row strong, .density-reference-row span { display: block; letter-spacing: 0; }
.density-reference-row strong { font-size: 12px; font-weight: 650; }
.density-reference-row span { margin-top: 5px; color: var(--text-muted); font-size: 11px; }
.density-reference-row span.is-sampled { color: #2f9d67; }
.density-calibration-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 7px 10px; border-radius: 4px; background: rgba(15, 15, 16, .84); color: #fff; font-size: 10px; white-space: nowrap; }
.density-sample-marker { position: absolute; width: 24px; height: 24px; border: 2px solid #fff; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px rgba(0, 0, 0, .65); pointer-events: none; }
.density-sample-marker::before, .density-sample-marker::after { content: ""; position: absolute; background: #fff; }
.density-sample-marker::before { width: 1px; height: 32px; left: 10px; top: -6px; }
.density-sample-marker::after { width: 32px; height: 1px; left: -6px; top: 10px; }
.density-sample-marker-base { border-color: #4fa3ff; }
.density-sample-marker-full { border-color: #f0b447; }
.density-calibration-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.density-calibration-footer button { min-width: 92px; height: 34px; padding: 0 16px; border-radius: 5px; font-size: 11px; font-weight: 650; letter-spacing: 0; }
.density-calibration-secondary { border: 1px solid var(--line); background: var(--panel-raised); color: var(--text-muted); }
.density-calibration-primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.density-calibration-primary:disabled { opacity: .42; cursor: not-allowed; }
@media (max-width: 760px) {
    .density-calibration-body { grid-template-columns: 1fr; }
    .density-calibration-controls { border-left: 0; border-top: 1px solid var(--line); }
    .density-calibration-preview { min-height: 280px; }
}

.perspective-control output.slider-value,
#export-quality-val.slider-value {
    min-width: 42px;
    padding: 1px 4px;
    text-align: right;
}

/* Calibration Config Profiles */
.calibration-workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel);
    color: var(--text);
}
.calibration-toolbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex: 0 0 auto;
    padding: 13px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.calibration-toolbar h1,
.calibration-toolbar p,
.calibration-detail-header h2,
.calibration-detail-header p,
.calibration-empty-state h2,
.calibration-empty-state p { margin: 0; letter-spacing: 0; }
.calibration-toolbar h1 { font-size: 18px; font-weight: 640; }
.calibration-toolbar p { margin-top: 4px; color: var(--muted); font-size: 11px; }
.calibration-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 14px;
    flex: 1 1 auto;
    padding: 14px;
    background: var(--workspace);
}
.calibration-profile-panel,
.calibration-detail-panel {
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
}
.calibration-profile-panel { display: flex; flex-direction: column; }
.calibration-panel-heading {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
}
.calibration-panel-heading h2,
.calibration-section-heading h3 {
    margin: 0;
    color: var(--text);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0;
}
.calibration-panel-heading span {
    color: var(--subtle);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.calibration-profile-list {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    padding: 8px;
}
.calibration-profile-list-empty {
    padding: 28px 14px;
    color: var(--subtle);
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
}
.calibration-profile-item {
    width: 100%;
    min-height: 58px;
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text);
    text-align: left;
}
.calibration-profile-item:hover { background: var(--control); }
.calibration-profile-item.is-active {
    border-color: var(--line-strong);
    background: var(--control);
}
.calibration-profile-item-dot,
.calibration-stage-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--subtle);
}
.calibration-profile-item-dot.is-available,
.calibration-stage-dot.is-configured { background: #38a169; }
.calibration-profile-item-dot.is-warning { background: #d39a42; }
.calibration-profile-item strong,
.calibration-profile-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calibration-profile-item strong { font-size: 12px; font-weight: 620; letter-spacing: 0; }
.calibration-profile-item small { margin-top: 4px; color: var(--subtle); font-size: 10px; }
.calibration-detail-panel { position: relative; }
.calibration-empty-state {
    width: 100%;
    height: 100%;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: var(--subtle);
    text-align: center;
}
.calibration-empty-state.hidden,
.calibration-profile-detail.hidden {
    display: none;
}
.calibration-empty-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    margin-bottom: 4px;
    color: var(--muted);
}
.calibration-empty-icon svg { width: 42px; height: 42px; stroke: currentColor; stroke-width: 1.1; }
.calibration-empty-state h2 { color: var(--text); font-size: 17px; font-weight: 620; }
.calibration-empty-state p { max-width: 440px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.calibration-empty-state button { margin-top: 8px; }
.calibration-profile-detail {
    height: 100%;
    overflow-y: auto;
    padding: 22px;
}
.calibration-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.calibration-detail-header h2 { margin-top: 8px; font-size: 22px; font-weight: 650; }
.calibration-detail-header p { margin-top: 5px; color: var(--subtle); font-size: 10px; }
.calibration-detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.calibration-detail-badges span {
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--muted);
    background: var(--panel-raised);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}
.calibration-detail-badges span.is-warning { border-color: rgba(211, 154, 66, .5); color: #d39a42; }
.calibration-detail-badges span.is-available { border-color: rgba(56, 161, 105, .45); color: #38a169; }
.calibration-detail-actions { display: flex; align-items: center; gap: 8px; }
.calibration-primary-button,
.calibration-secondary-button,
.calibration-danger-button {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0;
}
.calibration-primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.calibration-primary-button:hover { background: var(--accent-hover); }
.calibration-primary-button:disabled { opacity: .45; cursor: not-allowed; }
.calibration-secondary-button { border: 1px solid var(--line); background: var(--panel-raised); color: var(--text); }
.calibration-secondary-button:hover { border-color: var(--line-strong); }
.calibration-danger-button {
    width: 32px;
    padding: 0;
    border: 1px solid rgba(211, 109, 103, .34);
    background: transparent;
    color: var(--danger);
    font-size: 19px;
    line-height: 1;
}
.calibration-metadata-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin: 18px 0 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: var(--line);
}
.calibration-metadata-grid div { min-width: 0; padding: 11px 12px; background: var(--panel-raised); }
.calibration-metadata-grid dt { color: var(--subtle); font-size: 9px; font-weight: 650; text-transform: uppercase; }
.calibration-metadata-grid dd { margin: 5px 0 0; overflow: hidden; color: var(--text); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.calibration-detail-warnings {
    margin-top: 12px;
    padding: 9px 10px;
    border: 1px solid rgba(211, 154, 66, .35);
    border-radius: 5px;
    background: rgba(211, 154, 66, .08);
    color: color-mix(in srgb, #d39a42 82%, var(--text));
    font-size: 10px;
    line-height: 1.5;
}
.calibration-detail-warnings p { margin: 0; }
.calibration-detail-warnings p + p { margin-top: 4px; }
.calibration-pipeline-section,
.calibration-reference-section { margin-top: 24px; }
.calibration-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 13px;
}
.calibration-section-heading span { color: var(--subtle); font-size: 10px; line-height: 1.45; text-align: right; }
.calibration-pipeline { position: relative; padding-left: 2px; }
.calibration-stage {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 51px;
    padding-bottom: 12px;
}
.calibration-stage:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 13px;
    bottom: -2px;
    width: 1px;
    background: var(--line-strong);
}
.calibration-stage-dot { position: relative; z-index: 1; margin-top: 4px; }
.calibration-stage strong,
.calibration-stage small { display: block; letter-spacing: 0; }
.calibration-stage strong { color: var(--text); font-size: 11px; font-weight: 620; }
.calibration-stage small { margin-top: 4px; color: var(--subtle); font-size: 10px; }
.calibration-stage-status { color: var(--subtle); font-size: 10px; white-space: nowrap; }
.calibration-stage-status.is-configured { color: #38a169; }
.calibration-reference-list { display: flex; flex-direction: column; gap: 6px; }
.calibration-reference-item {
    min-height: 42px;
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-raised);
}
.calibration-reference-item strong { color: var(--muted); font-size: 10px; font-weight: 650; }
.calibration-reference-item span { overflow: hidden; color: var(--text); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.calibration-reference-empty { padding: 12px 0; color: var(--subtle); font-size: 10px; }

/* Profile editor */
.calibration-profile-modal {
    position: fixed;
    inset: 0;
    z-index: 115;
    display: grid;
    place-items: center;
    padding: 24px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(9px);
    transition: opacity .16s ease, visibility .16s ease;
}
.calibration-profile-modal.is-open { visibility: visible; opacity: 1; pointer-events: auto; }
.calibration-profile-dialog {
    width: min(780px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
}
.calibration-confirm-dialog {
    width: min(480px, calc(100vw - 48px));
}
.calibration-confirm-body {
    padding: 20px 19px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}
.calibration-confirm-body p { margin: 0; }
.calibration-delete-confirm {
    border-color: var(--danger);
    background: var(--danger);
}
.calibration-delete-confirm:hover {
    background: color-mix(in srgb, var(--danger) 86%, #000);
}
.calibration-profile-dialog-header,
.calibration-profile-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex: 0 0 auto;
    padding: 16px 19px;
}
.calibration-profile-dialog-header { border-bottom: 1px solid var(--line); }
.calibration-profile-dialog-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.calibration-profile-dialog-header h2,
.calibration-profile-dialog-header p { margin: 0; letter-spacing: 0; }
.calibration-profile-dialog-header h2 { font-size: 15px; font-weight: 650; }
.calibration-profile-dialog-header p { margin-top: 4px; color: var(--muted); font-size: 10px; }
.calibration-dialog-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-raised);
    color: var(--muted);
    font-size: 19px;
}
.calibration-profile-dialog-body { min-height: 0; overflow-y: auto; padding: 19px; }
.calibration-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.calibration-form-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.calibration-form-field-wide { grid-column: 1 / -1; }
.calibration-form-field > span { color: var(--muted); font-size: 10px; font-weight: 650; }
.calibration-form-field input,
.calibration-form-field select,
.calibration-form-field textarea,
.develop-calibration-profile select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--control);
    color: var(--text);
    font-size: 11px;
    letter-spacing: 0;
    outline: none;
}
.calibration-form-field input,
.calibration-form-field select { height: 34px; padding: 0 10px; }
.calibration-form-field textarea { min-height: 64px; resize: vertical; padding: 8px 10px; line-height: 1.5; }
/* Same drawn dropdown as the Develop inspector and the export dialog. */
.calibration-form-field select {
    appearance: none !important;
    -webkit-appearance: none !important;
    padding: 0 32px 0 12px !important;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) !important;
    background-position:
        calc(100% - 17px) calc(50% - 2px),
        calc(100% - 12px) calc(50% - 2px) !important;
    background-size: 5px 5px !important;
    background-repeat: no-repeat !important;
    text-overflow: ellipsis;
}
.calibration-form-field input:focus,
.calibration-form-field select:focus,
.calibration-form-field textarea:focus,
.develop-calibration-profile select:focus { border-color: var(--accent); }
.calibration-editor-references { margin-top: 22px; }
.calibration-reference-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.calibration-reference-editor-row {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-raised);
}
.calibration-reference-editor-row strong,
.calibration-reference-editor-row small { display: block; overflow: hidden; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.calibration-reference-editor-row strong { color: var(--text); font-size: 10px; font-weight: 650; }
.calibration-reference-editor-row small { margin-top: 4px; color: var(--subtle); font-size: 9px; }
.calibration-reference-actions { display: flex; gap: 5px; }
.calibration-reference-actions button {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--control);
    color: var(--muted);
    font-size: 10px;
}
.calibration-reference-actions button:hover { color: var(--text); border-color: var(--line-strong); }
.calibration-reference-actions button.is-remove { width: 28px; padding: 0; color: var(--danger); }

/* Develop Roll Profile selector */
.develop-calibration-profile { display: flex; flex-direction: column; gap: 9px; }
.develop-profile-heading label { color: var(--figma-muted) !important; font-size: 11px; font-weight: 650; letter-spacing: 0; }
.develop-calibration-profile select { height: 32px; padding: 0 8px; }
.develop-calibration-profile select:disabled { opacity: .48; cursor: not-allowed; }

@media (max-width: 920px) {
    .calibration-layout { grid-template-columns: 210px minmax(0, 1fr); }
    .calibration-metadata-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calibration-reference-editor { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .calibration-toolbar { align-items: flex-start; }
    .calibration-layout { grid-template-columns: 1fr; grid-template-rows: 180px minmax(0, 1fr); }
    .calibration-form-grid { grid-template-columns: 1fr; }
    .calibration-form-field-wide { grid-column: auto; }
    .calibration-profile-dialog { width: min(100%, calc(100vw - 24px)); }
}

/* ==========================================================================
   Documentation Workspace
   ========================================================================== */
/* Documentation-only tokens. Everything else comes from the shared --ui-* set. */
:root,
body[data-theme="light"] {
    --doc-warning: #b45309;
    --doc-mark-bg: #fde68a;
}

body[data-theme="dark"] {
    --doc-warning: #f0a44a;
    --doc-mark-bg: rgba(250, 204, 21, 0.26);
}

.documentation-workspace {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    color: var(--ui-text);
}

.documentation-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 0 0 auto;
}

.documentation-toolbar-lead {
    min-width: 0;
}

.documentation-toolbar-lead h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
    color: var(--ui-brand);
}

.documentation-toolbar-lead p {
    margin: 2px 0 0;
    color: var(--ui-muted);
    font-size: 11px;
}

.documentation-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.documentation-search-input {
    width: 220px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--ui-line);
    border-radius: 6px;
    background: var(--ui-surface);
    color: var(--ui-text);
    font-size: 12px;
    outline: none;
    transition: border-color .15s ease, width .2s ease;
}

.documentation-search-input:focus {
    border-color: var(--ui-brand);
    width: 260px;
}

.documentation-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
    gap: var(--ui-gap);
    flex: 1 1 auto;
    padding: 0;
    background: transparent;
}

.documentation-nav-panel,
.documentation-content-panel {
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
}

.documentation-nav-panel {
    display: flex;
    flex-direction: column;
}

.documentation-panel-heading {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    border-bottom: 1px solid var(--ui-line);
}

.documentation-panel-heading h2 {
    margin: 0;
    color: var(--ui-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

.documentation-panel-heading span {
    color: var(--ui-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.documentation-nav-list {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    padding: 8px;
}

.documentation-nav-group-header {
    padding: 8px 10px 4px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.documentation-nav-group-header:not(:first-child) {
    margin-top: 6px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.documentation-nav-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.documentation-nav-item:hover {
    background: var(--ui-surface-soft);
}

.documentation-nav-item.is-active {
    background: var(--ui-surface-soft);
    border-color: var(--ui-line);
    box-shadow: inset 3px 0 0 var(--ui-brand);
}

.documentation-nav-index {
    flex: 0 0 auto;
    min-width: 18px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--ui-brand);
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
}

.documentation-nav-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
}

.documentation-nav-title {
    flex: 1 1 auto;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ui-text);
}

.documentation-nav-meta {
    padding-left: 26px;
    font-size: 11px;
    color: var(--ui-muted);
    line-height: 1.3;
}

.documentation-nav-crumb {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--ui-brand);
}

.documentation-nav-result .documentation-nav-title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.documentation-nav-result .documentation-nav-title mark {
    background: transparent;
    color: var(--ui-brand);
}

.documentation-nav-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--ui-muted);
    font-size: 12px;
}

.documentation-content-panel {
    overflow-y: auto;
    padding: 28px clamp(20px, 3vw, 44px) 56px;
}

.documentation-article {
    max-width: 820px;
    margin: 0 auto;
}

.documentation-article-header {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--ui-line);
    margin-bottom: 26px;
}

.documentation-article-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ui-brand);
    margin-bottom: 8px;
}

.documentation-article-title {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--ui-text);
    letter-spacing: -0.015em;
    line-height: 1.3;
}

.documentation-article-subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ui-muted);
}

.documentation-article-meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--ui-muted);
    font-variant-numeric: tabular-nums;
}

/* On-this-page index */
.documentation-toc {
    margin-top: 18px;
    padding: 12px 14px;
    border: 1px solid var(--ui-line);
    border-radius: 6px;
    background: var(--ui-surface-soft);
}

.documentation-toc-title {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ui-muted);
    margin-bottom: 8px;
}

.doc-toc-item {
    display: block;
    width: 100%;
    padding: 4px 0;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--ui-text);
    cursor: pointer;
}

.doc-toc-item:hover {
    color: var(--ui-brand);
}

.doc-toc-item.is-active {
    color: var(--ui-brand);
    font-weight: 700;
}

.documentation-article-section {
    margin-bottom: 32px;
}

.documentation-section-heading {
    margin: 0 0 14px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ui-text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ui-line);
    scroll-margin-top: 12px;
}

.documentation-anchor {
    float: left;
    margin-left: -18px;
    padding-right: 6px;
    color: var(--ui-muted);
    text-decoration: none;
    opacity: 0;
    transition: opacity .12s ease, color .12s ease;
}

.documentation-section-heading:hover .documentation-anchor,
.documentation-anchor:focus-visible {
    opacity: 1;
}

.documentation-anchor:hover {
    color: var(--ui-brand);
}

.documentation-section-body {
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--ui-text);
}

.documentation-section-body svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 16px 0;
}

.documentation-section-body p {
    margin: 0 0 14px 0;
    color: inherit;
}

.documentation-section-body ul,
.documentation-section-body ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
    color: inherit;
}

.documentation-section-body ul {
    list-style: disc outside;
}

.documentation-section-body ol {
    list-style: decimal outside;
}

.documentation-section-body ul ul {
    list-style: circle outside;
    margin-top: 6px;
}

.documentation-section-body li {
    margin-bottom: 6px;
    color: inherit;
}

.documentation-section-body li::marker {
    color: var(--ui-muted);
}

.documentation-section-body ol > li::marker {
    font-variant-numeric: tabular-nums;
}

.documentation-section-body strong {
    color: var(--ui-text);
    font-weight: 700;
}

.documentation-section-body code {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--ui-surface-soft);
    color: var(--ui-brand);
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    border: 1px solid var(--ui-line);
}

.documentation-section-body kbd {
    display: inline-block;
    min-width: 18px;
    padding: 1px 5px;
    border: 1px solid var(--ui-line);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--ui-surface-soft);
    color: var(--ui-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.5;
    text-align: center;
}

/* Callouts */
.doc-callout {
    margin: 18px 0;
    padding: 14px 18px;
    border-radius: 6px;
    border: 1px solid var(--ui-line);
    border-left: 4px solid var(--ui-brand);
    background: var(--ui-surface-soft);
}

.doc-callout-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ui-brand);
    margin-bottom: 6px;
}

.doc-callout-body {
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--ui-text);
}

.doc-callout-warn {
    border-left-color: var(--doc-warning);
}

.doc-callout-warn .doc-callout-title {
    color: var(--doc-warning);
}

/* Tables */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 12.5px;
    border: 1px solid var(--ui-line);
}

.doc-table th,
.doc-table td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid var(--ui-line);
    line-height: 1.55;
    vertical-align: top;
}

.doc-table th {
    color: var(--ui-text);
    font-weight: 700;
    background: var(--ui-surface-soft);
}

.doc-table td {
    color: var(--ui-text);
    background: var(--ui-surface);
}

.doc-table tr:hover td {
    background: var(--ui-surface-soft);
}

/* Code block */
.doc-code-block {
    position: relative;
    margin: 16px 0;
    padding: 14px 16px 14px;
    border-radius: 6px;
    background: var(--ui-surface-soft);
    border: 1px solid var(--ui-line);
    overflow-x: auto;
}

.doc-code-block code {
    background: transparent !important;
    padding: 0 !important;
    font-size: 12px;
    color: var(--ui-brand) !important;
    border: 0 !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.doc-copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border: 1px solid var(--ui-line);
    border-radius: 4px;
    background: var(--ui-surface);
    color: var(--ui-muted);
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
}

.doc-copy-button:hover {
    color: var(--ui-text);
    border-color: var(--ui-brand);
}

/* Search highlight */
mark.doc-mark {
    padding: 0 1px;
    border-radius: 2px;
    background: var(--doc-mark-bg);
    color: inherit;
}

/* Chapter pager */
.documentation-article-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--ui-line);
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
}

.doc-pager-button {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 48%;
    padding: 10px 14px;
    border: 1px solid var(--ui-line);
    border-radius: 6px;
    background: var(--ui-surface);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.doc-pager-button:hover {
    border-color: var(--ui-brand);
    background: var(--ui-surface-soft);
}

.doc-pager-next {
    text-align: right;
    align-items: flex-end;
}

.doc-pager-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ui-muted);
}

.doc-pager-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ui-text);
}
