/* =====================================================================
   Vullow Layers — warm "atelier" design, light + dark
   ===================================================================== */

:root {
    --bg: #f4f1eb;
    --bg-grain: #ede8df;
    --surface: #ffffff;
    --surface-2: #faf8f4;
    --surface-3: #f2eee7;
    --ink: #1d1a16;
    --ink-2: #5a534a;
    --ink-3: #8c8478;
    --line: #e6e0d5;
    --line-strong: #d7cfc2;
    --accent: #d9480f;
    --accent-hover: #c03f0c;
    --accent-ink: #ffffff;
    --accent-soft: #fbe7dc;
    --dark-btn: #1d1a16;
    --dark-btn-ink: #faf8f4;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --checker-a: #ffffff;
    --checker-b: #f1ede6;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(40, 30, 20, .06);
    --shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 6px 20px -6px rgba(40, 30, 20, .12);
    --shadow-lg: 0 24px 60px -12px rgba(30, 20, 10, .35);

    --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Fraunces", Georgia, serif;
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

    --sidebar-w: 372px;
    --topbar-h: 64px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12110f;
        --bg-grain: #171513;
        --surface: #1b1916;
        --surface-2: #211e1a;
        --surface-3: #2a2621;
        --ink: #f3eee6;
        --ink-2: #bdb4a6;
        --ink-3: #8a8174;
        --line: #2e2a24;
        --line-strong: #3b362f;
        --accent: #ff7a3d;
        --accent-hover: #ff8f5c;
        --accent-ink: #1a0f08;
        --accent-soft: rgba(255, 122, 61, .14);
        --dark-btn: #f3eee6;
        --dark-btn-ink: #1b1916;
        --danger: #ff8a7a;
        --danger-soft: rgba(255, 110, 90, .12);
        --checker-a: #24211d;
        --checker-b: #1e1b18;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .55);
        color-scheme: dark;
    }
}

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

html, body { margin: 0; }

body {
    font-family: var(--font-ui);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 85% -10%, var(--accent-soft), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1:focus { outline: none; }
code { font-family: var(--font-mono); font-size: .86em; }
img { display: block; max-width: 100%; }
a { color: inherit; }

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

/* ---------------------------------------------------------------- Topbar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.brand-name em { font-style: italic; color: var(--accent); font-weight: 500; }
.topbar-tag { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ---------------------------------------------------------------- Layout */

.workspace {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: 28px;
    padding: 24px 28px 48px;
    max-width: 1680px;
    margin: 0 auto;
}

.sidebar {
    position: sticky;
    top: calc(var(--topbar-h) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--topbar-h) - 48px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.sidebar-actions {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
}

.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--ink-3);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px;
    border-radius: 11px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
    position: relative;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-grow { flex: 1; }

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-dark { background: var(--dark-btn); color: var(--dark-btn-ink); }
.btn-dark:hover { opacity: .9; }

.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }

.btn .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent-ink);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-ink) 30%, transparent);
    animation: pulse 1.6s ease-in-out infinite;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-ink); }

.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--line-strong);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
    display: inline-block;
}
.spinner-light { border-color: color-mix(in srgb, var(--accent-ink) 35%, transparent); border-top-color: var(--accent-ink); }

/* ---------------------------------------------------------------- Upload */

.upload-card { position: relative; padding: 0; border: none; box-shadow: none; background: none; }

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 30px 18px 26px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--surface-3) 60%, transparent) 10px 11px),
        var(--surface-2);
    transition: border-color .15s, background-color .15s, transform .15s;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background-color: var(--accent-soft); }
.dropzone.is-dragging { transform: scale(1.01); }

.dropzone input[type=file], .photo input[type=file] {
    position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.photo input[type=file] { font-size: 0; z-index: 1; }

.dropzone-icon {
    width: 54px; height: 54px; display: grid; place-items: center;
    border-radius: 16px; background: var(--surface); color: var(--accent);
    box-shadow: var(--shadow); margin-bottom: 12px;
}
.dropzone-title { margin: 0; font-weight: 600; font-size: 15px; }
.dropzone-sub { margin: 4px 0 0; color: var(--ink-3); font-size: 12.5px; }
.link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.photo {
    position: relative;
    display: grid;
    grid-template-columns: 72px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    transition: border-color .15s, background-color .15s;
}
.photo.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.photo:hover .photo-replace { background: var(--surface-3); }
.photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.photo-meta { min-width: 0; }
.photo-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-sub { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-replace { pointer-events: none; }

.upload-busy {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    border-radius: var(--radius);
    font-weight: 500;
}

/* ---------------------------------------------------------------- Presets */

.presets { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    transition: all .15s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------------------------------------------------------------- Settings sections */

.sections { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.section + .section { border-top: 1px solid var(--line); }

.section summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background .15s;
}
.section summary::-webkit-details-marker { display: none; }
.section summary:hover { background: var(--surface-2); }
.section[open] summary { background: var(--surface-2); }

.section-icon {
    width: 32px; height: 32px; flex: none;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--surface-3);
    color: var(--ink-2);
}
.section[open] .section-icon { background: var(--accent-soft); color: var(--accent); }

.section-title { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; line-height: 1.25; }
.section-title small { font-weight: 400; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chevron { width: 18px; height: 18px; color: var(--ink-3); transition: transform .2s; flex: none; }
.section[open] .chevron { transform: rotate(180deg); }

.section-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 6px 16px 18px;
    background: var(--surface-2);
    transition: opacity .2s;
}
.section-body.is-off { opacity: .55; }

/* switch */
.switch { display: inline-flex; padding: 4px; margin: -4px; border-radius: 999px; cursor: pointer; }
.switch-track {
    width: 36px; height: 21px; border-radius: 999px;
    background: var(--line-strong);
    position: relative;
    transition: background .2s;
}
.switch-track.is-on { background: var(--accent); }
.switch-thumb {
    position: absolute; top: 2.5px; left: 2.5px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s cubic-bezier(.3, 1.4, .5, 1);
}
.switch-track.is-on .switch-thumb { transform: translateX(15px); }

/* fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.field.is-disabled { opacity: .45; pointer-events: none; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-head label, .field-label { font-weight: 500; font-size: 13.5px; }
.field-value {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    min-width: 42px;
    text-align: center;
}
.field-hint { margin: -2px 0 0; color: var(--ink-3); font-size: 12px; line-height: 1.45; }

.range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    cursor: pointer;
    margin: 0;
}
.range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--accent) 0 var(--fill, 0%), var(--line-strong) var(--fill, 0%) 100%);
}
.range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line-strong); }
.range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px; margin-top: -6px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
    transition: transform .12s;
}
.range::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-3);
    border: 1px solid var(--line);
}
.segment {
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: all .15s;
}
.segment:hover { color: var(--ink); }
.segment.is-selected { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ---------------------------------------------------------------- Alert / progress */

.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
    font-weight: 500;
}
.alert > div { flex: 1; }
.alert .icon-btn { background: transparent; border: none; color: inherit; }

.progress-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; animation: rise .3s ease-out; }
.progress-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.progress-msg { font-weight: 600; font-size: 16px; margin-top: 2px; }
.progress-pct { font-family: var(--font-display); font-size: 30px; font-weight: 600; color: var(--accent); line-height: 1; }
.progress-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar span {
    display: block; height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f2c9a0, var(--accent));
    transition: width .35s ease;
    position: relative;
    overflow: hidden;
}
.progress-bar span::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    animation: shimmer 1.4s linear infinite;
}
.progress-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.progress-log { list-style: none; margin: 0; padding: 0; color: var(--ink-3); font-size: 12.5px; font-family: var(--font-mono); }
.progress-log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-log li:last-child { color: var(--ink-2); }

/* ---------------------------------------------------------------- Empty state */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 56px 24px 64px;
    min-height: calc(100vh - var(--topbar-h) - 72px);
    justify-content: center;
}
.empty h1 {
    font-family: var(--font-display);
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1.08;
    max-width: 640px;
    letter-spacing: -.025em;
}
.empty h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.lead { max-width: 560px; color: var(--ink-2); font-size: 16px; margin: 16px 0 34px; }

.empty-art { position: relative; width: 220px; height: 170px; margin-bottom: 30px; }
.sheet {
    position: absolute;
    width: 140px; height: 105px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, .04);
    animation: float 6s ease-in-out infinite;
}
.sheet.s1 { left: 0; top: 0; background: #efe2d0; }
.sheet.s2 { left: 26px; top: 20px; background: #f2c9a0; animation-delay: -1.5s; }
.sheet.s3 { left: 52px; top: 40px; background: var(--accent); animation-delay: -3s; }
.sheet.s4 { left: 78px; top: 60px; background: #3b2a20; animation-delay: -4.5s; }

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    max-width: 820px;
    width: 100%;
    text-align: left;
}
.steps li {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink-2);
    font-size: 13.5px;
}
.steps li span {
    flex: none;
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
}
.steps strong { color: var(--ink); }

/* ---------------------------------------------------------------- Results */

.results { display: flex; flex-direction: column; gap: 18px; transition: opacity .3s, filter .3s; animation: rise .35s ease-out; }
.results.is-stale { opacity: .45; filter: saturate(.6); pointer-events: none; }

.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.results-head h2 { font-family: var(--font-display); font-size: 28px; letter-spacing: -.02em; word-break: break-word; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.meta span {
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-2);
}
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: 12px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    font: inherit; font-weight: 500; font-size: 13.5px;
    padding: 8px 14px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.tab.is-active .icon { color: var(--accent); }

/* layer grid */
.layer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.layer-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.layer-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-strong); }

.layer-thumb {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    border-bottom: 1px solid var(--line);
    background: #fff;
    cursor: zoom-in;
    overflow: hidden;
}
.layer-thumb img { width: 100%; height: 100%; object-fit: contain; transition: transform .35s ease; }
.layer-card:hover .layer-thumb img { transform: scale(1.03); }

.step-badge {
    position: absolute; top: 10px; left: 10px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    padding: 3px 7px;
    border-radius: 7px;
    background: rgba(20, 16, 12, .78);
    color: #fff;
    backdrop-filter: blur(6px);
}
.step-badge.static { position: static; }

.zoom {
    position: absolute; top: 10px; right: 10px;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    color: #1d1a16;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    opacity: 0;
    transform: translateY(-4px);
    transition: all .2s;
}
.layer-card:hover .zoom, .layer-thumb:focus-visible .zoom { opacity: 1; transform: none; }

.layer-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.layer-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.layer-title-row h3 { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kind {
    flex: none;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--ink-3);
}
.kind-ground { background: #e8efe6; color: #3f6b3a; }
.kind-hair { background: #efe6dc; color: #7a4f2a; }
.kind-detaillight, .kind-detaildark { background: #e6ebf3; color: #3d5a86; }
@media (prefers-color-scheme: dark) {
    .kind-ground { background: rgba(120, 180, 110, .14); color: #9ed493; }
    .kind-hair { background: rgba(200, 150, 100, .14); color: #e0b48a; }
    .kind-detaillight, .kind-detaildark { background: rgba(120, 160, 230, .14); color: #a9c3f0; }
}

.layer-color { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.hex {
    display: inline-flex; align-items: center; gap: 8px;
    font: inherit;
    padding: 4px 9px 4px 4px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.hex:hover { border-color: var(--line-strong); background: var(--surface-3); }
.hex .icon { color: var(--ink-3); }

.swatch {
    display: inline-block;
    width: 22px; height: 22px;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
    flex: none;
}

.coverage { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.coverage-bar { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.coverage-bar span { display: block; height: 100%; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }

/* build */
.build { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }

.build-stage { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.stack {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 330px);
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    background-color: var(--checker-a);
    background-image:
        linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%),
        linear-gradient(45deg, var(--checker-b) 25%, transparent 25%, transparent 75%, var(--checker-b) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    box-shadow: inset 0 0 0 1px var(--line);
}
.stack img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity .45s ease;
}
.stack img.is-visible { opacity: 1; }
.stack img.is-current { animation: reveal .6s ease; }
.stack-empty {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    color: var(--ink-3);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 20px;
}

.build-controls { display: flex; align-items: center; gap: 8px; }
.build-range { flex: 1; margin-left: 6px; }
.build-count { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); min-width: 48px; text-align: right; }

.build-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}
.build-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    font: inherit;
    text-align: left;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.build-item:hover { background: var(--surface-2); color: var(--ink); }
.build-item.is-done { color: var(--ink-2); }
.build-item.is-current { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.build-item .swatch { width: 18px; height: 18px; border-radius: 5px; }
.build-item:not(.is-done):not(.is-current) .swatch { opacity: .45; }
.build-num { font-family: var(--font-mono); font-size: 11.5px; width: 20px; color: var(--ink-3); }
.build-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-item code { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.build-caption { margin: -4px 0 0; color: var(--ink-2); }
.build-caption code { padding: 1px 6px; border-radius: 5px; background: var(--surface-3); }

/* compare */
.compare-card { padding: 16px; }
.compare {
    position: relative;
    max-height: calc(100vh - 290px);
    max-width: 100%;
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    user-select: none;
    background: #fff;
}
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.compare-b { clip-path: inset(0 0 0 var(--pos)); }
.compare-handle {
    position: absolute; top: 0; bottom: 0; left: var(--pos);
    width: 2px; margin-left: -1px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .15), 0 0 12px rgba(0, 0, 0, .25);
    pointer-events: none;
}
.compare-handle span {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    padding: 9px 6px;
    border-radius: 999px;
    background: #fff;
    color: #1d1a16;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.compare-label {
    position: absolute; top: 12px;
    font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
    padding: 4px 9px; border-radius: 7px;
    background: rgba(20, 16, 12, .72); color: #fff;
    backdrop-filter: blur(6px);
    pointer-events: none;
}
.compare-label.left { left: 12px; }
.compare-label.right { right: 12px; }
.compare-range {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    margin: 0;
    opacity: 0;
    cursor: ew-resize;
    -webkit-appearance: none;
    appearance: none;
}
.compare-range::-webkit-slider-thumb { -webkit-appearance: none; width: 40px; height: 100vh; }

/* palette */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.palette-swatch {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font: inherit;
    text-align: left;
    padding: 8px 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.palette-swatch:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.palette-color {
    position: relative;
    width: 100%;
    aspect-ratio: 1.15;
    border-radius: 9px;
    margin-bottom: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.palette-copy { position: absolute; right: 10px; bottom: 10px; opacity: 0; transition: opacity .15s; }
.palette-swatch:hover .palette-copy { opacity: .9; }
.palette-label { font-weight: 600; padding: 0 4px; }
.palette-swatch code { padding: 0 4px; color: var(--ink-2); }
.palette-rgb { padding: 0 4px; font-size: 11.5px; color: var(--ink-3); }
.palette-foot { display: flex; justify-content: flex-end; }

/* ---------------------------------------------------------------- Lightbox */

.lightbox {
    position: fixed; inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(14, 11, 8, .78);
    backdrop-filter: blur(8px);
    animation: fade .2s ease-out;
    outline: none;
}
.lightbox-inner {
    width: min(1200px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: pop .25s cubic-bezier(.2, 1.2, .4, 1);
}
.lightbox-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px 12px 18px;
    border-bottom: 1px solid var(--line);
}
.lightbox-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lightbox-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox-title code { color: var(--ink-2); }
.lightbox-actions { display: flex; gap: 8px; align-items: center; }
.lightbox-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 18px 64px;
    background: var(--surface-2);
}
.lightbox-stage img {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    object-fit: contain;
    border-radius: 6px;
    box-shadow: var(--shadow);
    background: #fff;
}
.nav-btn {
    position: absolute; top: 50%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background .15s, opacity .15s;
}
.nav-btn:hover:not(:disabled) { background: var(--surface-3); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.nav-btn.prev { left: 12px; }
.nav-btn.next { right: 12px; }
.lightbox-dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 12px; border-top: 1px solid var(--line); }
.dot-btn {
    width: 22px; height: 22px;
    border-radius: 6px;
    border: 2px solid transparent;
    background: var(--c);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
    cursor: pointer;
    transition: transform .15s;
}
.dot-btn:hover { transform: scale(1.1); }
.dot-btn.is-active { border-color: var(--surface); outline: 2px solid var(--accent); outline-offset: 0; }

/* ---------------------------------------------------------------- Toast */

.toast {
    position: fixed;
    left: 50%; bottom: 28px;
    transform: translateX(-50%);
    z-index: 200;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--dark-btn);
    color: var(--dark-btn-ink);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast .25s ease-out;
}
.toast .icon { color: var(--accent); }

/* ---------------------------------------------------------------- Animations */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .5; } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes reveal { from { opacity: 0; filter: blur(4px); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 1100px) {
    .build { grid-template-columns: 1fr; }
    .build-list { max-height: none; }
}

@media (max-width: 960px) {
    .workspace { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
    .sidebar { position: static; max-height: none; }
    .sidebar-actions { position: sticky; bottom: 0; z-index: 5; }
    .empty { min-height: 0; padding: 32px 8px 40px; }
    .steps { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .topbar-tag { display: none; }
    .stack, .compare { max-height: none; }
}

@media (max-width: 560px) {
    .lightbox { padding: 0; }
    .lightbox-inner { border-radius: 0; height: 100%; }
    .lightbox-stage { padding: 12px 8px 64px; }
    .nav-btn { top: auto; bottom: 10px; transform: none; }
    .layer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .results-actions { width: 100%; }
    .results-actions .btn { flex: 1; }
}

/* ---------------------------------------------------------------- Blazor */

#blazor-error-ui {
    display: none;
    position: fixed; left: 16px; right: 16px; bottom: 16px;
    z-index: 1000;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    box-shadow: var(--shadow-lg);
}
#blazor-error-ui .reload { font-weight: 600; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 14px; top: 10px; }

.blazor-error-boundary { padding: 1rem; border-radius: 12px; background: var(--danger-soft); color: var(--danger); }
.blazor-error-boundary::after { content: "Er is een fout opgetreden."; }
