:root {
    color-scheme: dark;

    --bg: #181b21;
    --bg-elevated: #1f232b;
    --panel: #252a33;
    --panel-hover: #2a303a;
    --panel-soft: rgba(255, 255, 255, 0.025);
    --text: #edf1f7;
    --muted: #aeb8c9;
    --muted-strong: #c7cfdb;
    --border: rgba(126, 146, 190, 0.18);
    --border-strong: rgba(126, 146, 190, 0.38);
    --accent: #7ea7ff;
    --accent-strong: #9c7cff;
    --accent-soft: rgba(126, 167, 255, 0.12);
    --success: #69e0a5;
    --success-soft: rgba(105, 224, 165, 0.1);
    --warning: #e1ad61;
    --warning-soft: rgba(225, 173, 97, 0.1);
    --danger: #ef7474;
    --radius-small: 10px;
    --radius: 16px;
    --radius-large: 22px;
    --shadow-panel: 0 14px 36px rgba(0, 0, 0, 0.18);
    --shadow-floating: 0 18px 50px rgba(0, 0, 0, 0.36);
    --panel-2: var(--bg-elevated);
    --accent-hover: #9cbdff;
    --good: var(--success);
    --warn: var(--warning);
    --bad: var(--danger);
    --shadow: var(--shadow-panel);
}


/* ============================================================
   BASE
   ============================================================ */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;

    min-height: 100vh;

    position: relative;

    background: radial-gradient(circle at 50% -200px, rgba(126, 167, 255, 0.08), transparent 480px), var(--bg);

    color: var(--text);

    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;

    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;

    background-image:
        linear-gradient(
            rgba(12, 16, 24, 0.72),
            rgba(12, 16, 24, 0.72)
        ),
        url("./data/chunli-bg.webp");

    background-size: cover;
    background-position: center right;
    background-repeat: no-repeat;

    pointer-events: none;
    z-index: -1;
}

body::after {
    content: "";
    position: fixed;
    inset: -20px;

    backdrop-filter: blur(2px);

    pointer-events: none;
    z-index: -1;
}

@media (max-width: 900px) {
    body::before {
        background-position: 65% center;
    }
}

button,
input,
select {
    font: inherit;
}

code,
pre {
    font-family:
        "Cascadia Code",
        "Cascadia Mono",
        Consolas,
        monospace;
}


/* ============================================================
   LAYOUT
   ============================================================ */

.page-width {
    width: min(
        1100px,
        calc(100% - 32px)
    );

    margin-inline: auto;
}


/* ============================================================
   HEADER
   ============================================================ */

.site-header {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.site-header-content {
    padding-top: 46px;
    padding-bottom: 38px;
}

.site-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.site-kicker {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(2.6rem, 6vw, 4.5rem);
    line-height: 0.98;
    letter-spacing: -0.045em;
}

.site-header h1 span {
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.reference-viewer {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: inline-block;
}

.reference-viewer-image-wrap {
    position: relative;
    width: min(230px, 45vw);
    max-height: 70vh;
    border-radius: 28px;
    border: 1px solid #46506a;
    overflow: hidden;
    background: #11151d;
}

.reference-viewer-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;

    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.reference-viewer-controls,
.reference-viewer-arrow,
.reference-viewer-caption { opacity: 0; pointer-events: none; transition: opacity 0.18s ease, background 0.18s ease; }
.reference-viewer:hover .reference-viewer-controls,
.reference-viewer:hover .reference-viewer-arrow,
.reference-viewer:hover .reference-viewer-caption { opacity: 1; pointer-events: auto; }
.reference-viewer-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 6;
}

.reference-viewer-control {
    width: 22px;
    height: 18;
    border-radius: 10px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    opacity: 0.85;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.reference-viewer-control:hover {
    opacity: 1;
}

.reference-viewer-arrow {
    position: absolute;
    top: 50%;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.reference-viewer-image-wrap:hover .reference-viewer-arrow {
    opacity: 1;
}

.reference-viewer-arrow:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-50%) !important;
}

.reference-viewer-arrow:active {
    transform: translateY(-50%) !important;
}

.reference-viewer-prev {
    left: 8px;
}

.reference-viewer-next {
    right: 8px;
}
.reference-viewer-caption { position: absolute; left: 8px; right: 8px; bottom: 8px; min-height: 30px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(8, 10, 16, 0.68); color: #e8edf7; font-size: 0.85rem; }
.reference-viewer-restore { position: fixed; top: 18px; right: 18px; z-index: 1000; min-height: 40px; }

#reference-image-input,
#file-input {
    display: none;
}

@media (max-width: 700px) {
    .reference-viewer { top: 10px; right: 10px; width: calc(100vw - 20px); }
}

@media (max-width: 1200px) {
    .reference-viewer {
        position: static;
        width: 100%;
        max-width: 520px;
        margin: 0 auto 24px;
    }
}

.subtitle {
    margin:
        0
        0
        12px;

    color:
        var(--muted);

    font-size:
        1.05rem;
}

.header-notices {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.privacy-note,
.release-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
}

.privacy-note {
    border: 1px solid rgba(105, 224, 165, 0.32);
    background: var(--success-soft);
    color: var(--success);
}

.privacy-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.008)), var(--panel);
    box-shadow: var(--shadow-panel);
}

.section-title {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.section-title h2 {
    margin: 0;
}

.section-number,
.section-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 1px solid rgba(126, 167, 255, 0.4);
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 800;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 36px;
    margin-bottom: 36px;
}

.info-card {
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.008)), var(--panel);
    box-shadow: var(--shadow-panel);
}

.info-card-wide {
    grid-column: 1 / -1;
}

.info-card h2 {
    margin-top: 4px;
}

.info-eyebrow {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.instruction-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 22px;
}

.instruction-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.instruction-step > span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
}

.instruction-step p {
    margin: 5px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.feature-guide-callout {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: linear-gradient(120deg, var(--panel-2), var(--panel-soft));
    color: var(--text);
    text-decoration: none;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.feature-guide-callout:hover {
    border-color: var(--accent);
    background: var(--panel-2);
    transform: translateY(-1px);
}

.feature-guide-callout-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 800;
}

.feature-guide-callout strong,
.feature-guide-callout small {
    display: block;
}

.feature-guide-callout small {
    margin-top: 2px;
    color: var(--muted);
}

.support-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
}

.support-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    color: white;
    font-size: clamp(0.78rem, 1.25vw, 0.96rem);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.support-button .brand-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

.patreon-button {
    order: 2;
    background: #111318;
}

.patreon-button:hover {
    background: #1d222a;
}

.patreon-button .brand-icon {
    display: none;
}

.patreon-button::before {
    content: "";
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    background: center / contain no-repeat url("./data/patreon-symbol-black.svg");
    filter: invert(1);
}

.support-community-copy {
    margin-top: 14px;
    color: var(--muted);
}

.discord-button {
    order: 3;
    background: #4752c4;
}

.discord-button:hover { background: #3e47aa; }

/* Use the maintained Discord brand mark rather than the fallback inline path. */
.discord-button .brand-icon {
    display: none;
}

.discord-button::before {
    content: "";
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    background: center / contain no-repeat url("./data/discord-symbol-white.svg");
}

.github-star-button {
    order: 1;
    background: #3b424a;
}

.github-star-button:hover {
    background: #4a535d;
}

.github-star-button .brand-icon {
    display: none;
}

.github-star-button::before {
    content: "";
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    background: center / contain no-repeat url("./data/github-invertocat-white.svg");
}


.credits-list {
    display: grid;
    gap: 12px;
}

.credits-list > div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.credits-list dt { color: var(--muted); }
.credits-list dd { margin: 0; font-weight: 600; }

.credits-list a {
    color: var(--accent);
    text-decoration: none;
}

.credits-list a:hover {
    text-decoration: underline;
}

.site-footer {
    margin-top: 54px;
    padding: 32px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 30px;
}

.footer-content strong { color: var(--text); }
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-meta { text-align: right; }

@media (max-width: 900px) {
    .about-grid { grid-template-columns: 1fr; }
    .info-card-wide { grid-column: auto; }
    .instruction-list { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
    .footer-content { grid-template-columns: 1fr; }
    .footer-meta { text-align: left; }
}


/* ============================================================
   MAIN
   ============================================================ */

main {
    padding:
        30px
        0
        60px;
}


/* ============================================================
   PANELS
   ============================================================ */

.panel {
    margin-bottom:
        22px;

    padding:
        24px;

    border:
        1px solid
        var(--border);

    border-radius:
        var(--radius);

    background:
        var(--panel);

    box-shadow:
        var(--shadow);
}

.panel h2 {
    margin:
        0
        0
        10px;

    font-size:
        1.3rem;
}

.panel h3 {
    margin:
        20px
        0
        8px;

    font-size:
        1rem;
}


/* ============================================================
   DROP ZONE
   ============================================================ */

.drop-zone {
    display:
        flex;

    flex-direction:
        column;

    align-items:
        center;

    justify-content:
        center;

    gap:
        6px;

    min-height:
        170px;

    margin-top:
        18px;

    padding:
        28px;

    border:
        2px dashed
        var(--border-strong);

    border-radius:
        var(--radius);

    background:
        var(--panel-2);

    color:
        var(--muted);

    text-align:
        center;

    cursor:
        pointer;

    transition:
        border-color 120ms ease,
        background 120ms ease,
        color 120ms ease,
        transform 120ms ease;
}

.drop-zone strong {
    color:
        var(--text);

    font-size:
        1.05rem;
}

.drop-zone:hover,
.drop-zone:focus-visible {
    border-color:
        var(--accent);

    color:
        var(--text);

    outline: none;
}

.drop-zone.drag-over {
    border-color:
        var(--accent);

    background:
        rgba(
            122,
            162,
            255,
            0.08
        );

    transform:
        translateY(-1px);
}


/* ============================================================
   FILE SUMMARY
   ============================================================ */

.file-summary {
    margin-top:
        20px;
}

#detected-character {
    margin-bottom:
        12px;

    color:
        var(--muted);
}

#file-list {
    display:
        grid;

    gap:
        8px;
}

.file-row {
    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    gap:
        12px;

    padding:
        10px
        12px;

    border:
        1px solid
        var(--border);

    border-radius:
        8px;

    background:
        var(--panel-2);
}

.file-row-name {
    overflow-wrap:
        anywhere;
}

.file-row-meta {
    color:
        var(--muted);

    font-size:
        0.9rem;

    white-space:
        nowrap;
}


/* ============================================================
   FORMS
   ============================================================ */

.form-grid {
    display:
        grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(
                230px,
                1fr
            )
        );

    gap:
        16px;

    margin-top:
        18px;
}

label {
    display:
        grid;

    gap:
        7px;
}

label > span {
    color:
        var(--muted);

    font-size:
        0.9rem;
}

input[type="text"],
input[type="number"],
select {
    width:
        100%;

    min-height: 44px;
    padding: 0 13px;

    border:
        1px solid
        var(--border-strong);

    border-radius: 12px;

    background: rgba(15, 18, 24, 0.35);

    color:
        var(--text);

    outline:
        none;

    font: inherit;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color:
        var(--accent);

    box-shadow:
        0 0 0 3px
        rgba(126, 167, 255, 0.14);

    background: rgba(15, 18, 24, 0.5);
}


/* ============================================================
   TARGET SLOT SELECTOR
   ============================================================ */

.slot-fieldset {
    margin:
        22px
        0
        0;

    padding:
        16px;

    border:
        1px solid
        var(--border);

    border-radius:
        8px;
}

.slot-fieldset legend {
    padding:
        0
        8px;

    color:
        var(--muted);
}

#target-slots {
    display:
        grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(
                180px,
                1fr
            )
        );

    gap:
        10px;
}

.slot-option {
    display:
        flex;

    align-items:
        center;

    gap:
        9px;

    padding:
        9px
        10px;

    border:
        1px solid
        var(--border);

    border-radius:
        8px;

    background:
        var(--panel-2);
}

.slot-option input {
    margin: 0;
}


/* ============================================================
   CHECKBOX ROW
   ============================================================ */

.checkbox-row {
    display:
        flex;

    align-items:
        center;

    gap:
        9px;

    margin-top:
        18px;

    cursor:
        pointer;
}

.checkbox-row input {
    margin: 0;
}


/* ============================================================
   BUTTONS
   ============================================================ */

button {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)), var(--panel-hover);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(126, 167, 255, 0.7);
    background: linear-gradient(180deg, rgba(126, 167, 255, 0.12), rgba(126, 167, 255, 0.05)), var(--panel-hover);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity:
        0.45;

    cursor:
        not-allowed;
}


/* ============================================================
   STATUS
   ============================================================ */

.status-box {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--muted-strong);
}

.status-box.good {
    border-color: rgba(105, 224, 165, 0.3);
    background: var(--success-soft);
    color: var(--success);
}

.status-box.warn {
    border-color: rgba(225, 173, 97, 0.32);
    background: var(--warning-soft);
    color: var(--warning);
}

.status-box.bad {
    border-color: rgba(239, 116, 116, 0.35);
    background: rgba(239, 116, 116, 0.08);
    color: var(--danger);
}

#apply-working-copy,
#build-button {
    border-color: rgba(126, 167, 255, 0.65);
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #11141b;
    box-shadow: 0 8px 24px rgba(126, 167, 255, 0.18);
}

#apply-working-copy:hover:not(:disabled),
#build-button:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.5);
    background: linear-gradient(135deg, #91b5ff, #ad8dff);
    box-shadow: 0 10px 28px rgba(126, 167, 255, 0.26);
}

.secondary-button,
#export-cmd-button,
#revert-all-changes,
.current-change-revert {
    background: rgba(255, 255, 255, 0.035);
}


/* ============================================================
   CLUSTER INSPECTOR
   ============================================================ */

.cluster-group-heading {
    margin: 18px 2px 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.cluster-group-heading.is-custom {
    margin-top: 12px;
    color: var(--accent);
}

.cluster-card {
    margin-top:
        14px;

    border:
        1px solid
        var(--border);

    border-radius:
        8px;

    overflow:
        hidden;
}

.cluster-card-header {
    padding:
        10px
        12px;

    background:
        var(--panel-2);

    font-weight:
        700;
}

.cluster-slot-list {
    display:
        grid;
}

.cluster-slot-row {
    display:
        grid;

    grid-template-columns:
        minmax(
            150px,
            1fr
        )
        minmax(
            90px,
            0.6fr
        )
        minmax(
            170px,
            1fr
        );

    gap:
        12px;

    padding:
        9px
        12px;

    border-top:
        1px solid
        var(--border);

    font-size:
        0.92rem;
}

.slot-disabled {
    color:
        var(--muted);

    opacity:
        0.72;
}


/* ============================================================
   DEBUG
   ============================================================ */

details summary {
    cursor:
        pointer;

    color:
        var(--muted);
}

#debug-output {
    max-height:
        420px;

    margin:
        16px
        0
        0;

    padding:
        14px;

    overflow:
        auto;

    border:
        1px solid
        var(--border);

    border-radius:
        8px;

    background:
        #0c0e12;

    color:
        #cbd3df;

    font-size:
        0.85rem;

    line-height:
        1.45;
}


/* ============================================================
   INLINE CODE
   ============================================================ */

p code,
label code {
    padding:
        2px
        5px;

    border-radius:
        5px;

    background:
        rgba(
            255,
            255,
            255,
            0.06
        );
}


/* ============================================================
   UTILITY
   ============================================================ */

.hidden {
    display:
        none !important;
}


/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
    padding:
        24px
        0
        36px;

    border-top:
        1px solid
        var(--border);

    color:
        var(--muted);

    font-size:
        0.88rem;
}

.site-footer p {
    margin:
        3px
        0;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (
    max-width: 650px
) {
    .page-width {
        width:
            min(
                100% - 20px,
                1100px
            );
    }

    .site-header {
        padding-top:
            34px;
    }

    .panel {
        padding:
            18px;
    }

    .cluster-slot-row {
        grid-template-columns:
            1fr;

        gap:
            3px;
    }

    .file-row {
        align-items:
            flex-start;

        flex-direction:
            column;
    }
}

.color-slot-name {
    font-weight: 600;
    min-width: 140px;
    white-space: nowrap;
}

.color-state {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}

.color-state.enabled {
    background: rgba(80, 180, 110, 0.18);
}

.color-state.disabled {
    background: rgba(180, 180, 180, 0.12);
    opacity: 0.75;
}

.color-picker {
    width: 32px;
    height: 26px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    flex: 0 0 auto;
}

.color-hex-input {
    width: 105px;
    min-width: 105px;
    font-family: monospace;
    text-transform: uppercase;
    padding: 0.35rem 0.45rem;
}

.color-hex-input.invalid {
    outline: 2px solid currentColor;
}

.color-byte-meta {
    margin-left: auto;
    font-family: monospace;
    font-size: 0.7rem;
    opacity: 0.65;
    white-space: nowrap;
}

.cluster-slot-list {
    display: flex;
    flex-direction: column;
}

.cluster-slot-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    padding: 0.55rem 0.75rem;
    min-height: 42px;
}

.cluster-slot-row + .cluster-slot-row {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.cluster-card-header {
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
}

.cluster-card {
    margin-bottom: 0.75rem;
}

@media (max-width: 1050px) {
    .cluster-slot-row {
        flex-wrap: wrap;
    }

    .color-byte-meta {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 700px) {
    .color-slot-name {
        min-width: 100%;
        width: 100%;
    }

    .color-byte-meta {
        white-space: normal;
        word-break: break-all;
    }
}

.screenshot-drop-zone {
    margin-top: 1rem;
    min-height: 120px;
    border: 1px dashed rgba(150, 180, 230, 0.55);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.screenshot-drop-zone:hover,
.screenshot-drop-zone.drag-over {
    border-color: currentColor;
    background: rgba(255, 255, 255, 0.035);
}

.screenshot-preview-wrap {
    width: 140px;
    height: 88px;
    flex: 0 0 140px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.18);
}

.screenshot-preview {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.screenshot-drop-content {
    min-width: 0;
}

.screenshot-drop-title {
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.screenshot-drop-status {
    font-size: 0.9rem;
    opacity: 0.75;
    word-break: break-word;
}

@media (max-width: 700px) {
    .screenshot-drop-zone {
        align-items: stretch;
        flex-direction: column;
    }

    .screenshot-preview-wrap {
        width: 100%;
        height: 160px;
        flex-basis: auto;
    }
}

.inspector-toolbar {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    margin-bottom: 10px;
}

.inspector-toolbar button {
    margin-top: 0;
    padding: 7px 11px;
    font-size: 0.85rem;
}

.cmd-inspector-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 18px 0 18px;
    padding: 16px 18px;
    border: 1px solid rgba(120, 146, 202, 0.22);
    border-radius: 16px;
    background: rgba(18, 24, 36, 0.42);
}

.cmd-inspector-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 260px;
}

.cmd-inspector-picker > span {
    font-size: 0.95rem;
    color: #bfc8d8;
    font-weight: 600;
}

.cmd-inspector-picker select {
    min-width: 260px;
}

.cmd-inspector-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.cmd-inspector-dirty-indicator {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    background: rgba(255, 181, 72, 0.14);
    border: 1px solid rgba(255, 181, 72, 0.28);
    color: #ffbf66;
    font-weight: 600;
}

.cmd-inspector-controls.hidden {
    display: none;
}

.secondary-button {
    background: var(--panel-2);
    color: var(--text);
    border-color: var(--border-strong);
}

.secondary-button:hover:not(:disabled) {
    background: var(--border);
}

details.cluster-card {
    overflow: hidden;
}

details.cluster-card > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

details.cluster-card > summary::-webkit-details-marker {
    display: none;
}

details.cluster-card > summary::before {
    content: "▶";
    display: inline-block;
    margin-right: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    transition: transform 120ms ease;
}

details.cluster-card[open] > summary::before {
    transform: rotate(90deg);
}
.source-color-editor {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.source-color-picker {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.source-color-hex {
    flex: 1;
    min-width: 0;
    height: 42px;
    font-family: monospace;
    text-transform: uppercase;
}

.source-color-hex.invalid {
    border-color: var(--bad);
}

#source-slot {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    color: inherit;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.custom-select-trigger:hover,
.custom-select-trigger.open {
    border-color: #7ea7ff;
    background: rgba(126, 167, 255, 0.06);
}

.custom-select-trigger .cs-swatch {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.custom-select-trigger .cs-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.custom-select-trigger .cs-arrow {
    flex: 0 0 auto;
    opacity: 0.7;
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}

.custom-select-trigger.open .cs-arrow {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    z-index: 50;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 10px;
    background: #1b1f27;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
    max-height: 280px;
    overflow-y: auto;
}

.custom-select-dropdown.hidden {
    display: none;
}

.custom-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.custom-select-option:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(106, 124, 176, 0.3);
}

.custom-select-option.selected {
    background: rgba(126, 167, 255, 0.09);
    border-color: rgba(126, 167, 255, 0.45);
}

.custom-select-option .cs-swatch {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.custom-select-option .cs-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.custom-select-option .cs-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    opacity: 0.7;
    flex: 0 0 auto;
}

.color-picker,
.source-color-picker,
.current-change-picker {
    width: 56px;
    height: 56px;
    border: 1px solid rgba(120, 145, 210, 0.45);
    border-radius: 16px;
    background: #222735;
    cursor: pointer;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.04),
        0 8px 24px rgba(0, 0, 0, 0.22);
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease,
        border-color 0.16s ease,
        opacity 0.16s ease;
    appearance: none;
    padding: 0;
}

.color-picker:hover,
.source-color-picker:hover,
.current-change-picker:hover {
    transform: translateY(-1px);
    border-color: rgba(129, 170, 255, 0.75);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.06),
        0 10px 28px rgba(0, 0, 0, 0.3);
}

.color-picker:focus-visible,
.source-color-picker:focus-visible,
.current-change-picker:focus-visible {
    outline: none;
    border-color: #7ea7ff;
    box-shadow: 0 0 0 3px rgba(126, 167, 255, 0.22), 0 10px 28px rgba(0, 0, 0, 0.3);
}

.color-picker:disabled,
.source-color-picker:disabled,
.current-change-picker:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.source-slot-visual-picker {
    position: relative;
    width: 100%;
    margin-top: 8px;
}

.source-slot-visual-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 10px 14px;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.source-slot-visual-trigger:hover,
.source-slot-visual-trigger.open {
    border-color: #7ea7ff;
    background: rgba(126, 167, 255, 0.06);
}

.source-slot-trigger-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.source-slot-trigger-arrow {
    flex: 0 0 auto;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.source-slot-visual-trigger.open .source-slot-trigger-arrow {
    transform: rotate(180deg);
}

.source-slot-visual-list {
    position: absolute;
    z-index: 50;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
    max-height: 320px;
    overflow-y: auto;
}

.source-slot-chip {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.source-slot-chip:hover,
.source-slot-chip.selected {
    background: rgba(126, 167, 255, 0.09);
    border-color: rgba(126, 167, 255, 0.45);
}

.source-slot-chip-swatch {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.source-slot-chip-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.source-slot-chip-title {
    font-weight: 600;
    line-height: 1.2;
}

.source-slot-chip-value {
    font-size: 0.95rem;
    opacity: 0.75;
    margin-top: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.panel-heading > div p {
    margin-top: 10px;
    opacity: 0.82;
}

#revert-all-changes {
    flex: 0 0 auto;
    margin-top: 4px;
}

.color-state-actions {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.color-state-actions .secondary-button {
    min-height: 38px;
    padding: 0 14px;
}

.color-state-actions #revert-all-changes {
    margin-top: 0;
}

#color-state-status:not(.hidden) {
    margin-bottom: 1rem;
}

.current-changes-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.current-change-file {
    border: 1px solid rgba(106, 124, 176, 0.28);
    border-radius: 24px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.018);
}

.current-change-file-header {
    padding: 24px 28px;
}

.current-change-row {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 0.8fr) minmax(220px, 1fr) auto;
    gap: 22px;
    align-items: center;
    padding: 20px 28px;
    border-top: 1px solid rgba(106, 124, 176, 0.14);
}

.current-change-column-header {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 0.8fr) minmax(220px, 1fr) auto;
    gap: 22px;
    padding: 12px 28px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(106, 124, 176, 0.12);
}

.current-change-color-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.current-change-color-group .current-change-hex-input {
    width: 160px;
}

.current-change-file > summary {
    list-style: none;
    cursor: pointer;
}

.current-change-file > summary::-webkit-details-marker {
    display: none;
}

.current-change-file-header::after {
    content: "▾";
    margin-left: 12px;
    opacity: 0.65;
    transition: transform 0.16s ease;
}

.current-change-file:not([open]) .current-change-file-header::after {
    transform: rotate(-90deg);
}

.current-change-row:first-of-type {
    border-top: 0;
}

.current-change-identity {
    min-width: 0;
    font-size: 1.05rem;
}

.current-change-colors {
    gap: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.current-change-swatch {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.current-change-hex-input {
    min-width: 180px;
    max-width: 220px;
}

.current-change-revert {
    white-space: nowrap;
    align-self: center;
}

@media (max-width: 1100px) {
    .current-change-column-header {
        display: none;
    }

    .current-change-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .current-change-color-group::before {
        width: 72px;
        flex: 0 0 72px;
        color: var(--muted);
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .current-change-color-group:nth-child(2)::before {
        content: "Original";
    }

    .current-change-color-group:nth-child(3)::before {
        content: "Current";
    }

    .current-change-revert {
        justify-self: start;
    }
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#target-slots {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.target-slot-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 90px;
    padding: 14px;
    min-width: 0;
    border: 1px solid rgba(106, 124, 176, 0.35);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.target-slot-card:hover {
    transform: translateY(-1px);
    border-color: rgba(129, 170, 255, 0.65);
    background: rgba(255, 255, 255, 0.045);
}

.target-slot-card.selected {
    border-color: #7ea7ff;
    background: rgba(126, 167, 255, 0.11);
    box-shadow: 0 0 0 2px rgba(126, 167, 255, 0.18);
}

.target-slot-card.selected::after {
    content: "✓";
    position: absolute;
    top: 12px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #7ea7ff;
    color: #111827;
    font-size: 0.8rem;
    font-weight: 800;
}

.target-slot-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.target-slot-swatch {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.target-slot-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.target-slot-title {
    font-weight: 600;
    line-height: 1.2;
}

.target-slot-value {
    margin-top: 4px;
    font-size: 0.9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    opacity: 0.72;
}

.target-slot-card.slot-disabled {
    opacity: 0.45;
}

.target-slot-card.slot-disabled .target-slot-title {
    font-weight: 500;
}

.target-slot-card.slot-disabled.selected {
    opacity: 1;
}

#apply-sync-button,
#apply-color-sync,
#apply-pattern-sync,
#apply-duplicate-palette {
    margin-top: 20px;
}

#duplicate-palette-pane .sync-target-section + .sync-target-section {
    margin-top: 18px;
}

.duplicate-scope-body {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
}

.duplicate-scope-body .slot-picker-list {
    margin-top: 4px;
    max-height: 280px;
}

.duplicate-palette-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.duplicate-palette-actions > button {
    margin-top: 0;
}

#apply-duplicate-palette,
#undo-duplicate-palette {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    min-height: 46px;
    padding: 0 20px;
    width: auto;
    max-width: 100%;
}

.sync-empty-note {
    margin: 10px 12px;
}

.sync-mode-tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 18px;
    flex-wrap: wrap;
}

.sync-mode-tab {
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid rgba(106, 124, 176, 0.4);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted-strong);
    cursor: pointer;
}

.sync-mode-tab.active {
    color: var(--text);
    border-color: rgba(126, 167, 255, 0.7);
    background: rgba(126, 167, 255, 0.12);
}

.sync-active-line {
    margin: 0 0 16px;
    color: var(--muted-strong);
}

.release-note {
    border: 1px solid rgba(126, 167, 255, 0.34);
    background: var(--accent-soft);
    color: var(--muted-strong);
    text-decoration: none;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.release-note strong,
.release-note:hover {
    color: var(--accent);
}

.release-note:hover,
.release-note:focus-visible {
    border-color: rgba(126, 167, 255, 0.62);
    background: rgba(126, 167, 255, 0.17);
    outline: none;
}

.release-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.sync-active-cmd-picker {
    display: block;
    max-width: 460px;
    margin: 0 0 16px;
}

.sync-active-cmd-picker > span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted-strong);
    font-size: 0.9rem;
    font-weight: 650;
}

.sync-active-cmd-picker select {
    width: 100%;
    min-height: 42px;
}

/* Keep every active-color selector visually and behaviorally identical. */
.active-cmd-stepper {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.active-cmd-stepper .active-cmd-select {
    min-width: 0;
}

.active-cmd-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    min-height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--muted-strong);
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.active-cmd-step:hover:not(:disabled),
.active-cmd-step:focus-visible {
    border-color: #7ea7ff;
    background: rgba(126, 167, 255, 0.08);
    color: var(--text);
    outline: none;
}

.active-cmd-step:active:not(:disabled) {
    transform: scale(0.96);
}

.active-cmd-step:disabled {
    opacity: 0.32;
    cursor: default;
}

.active-cmd-step svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.active-cmd-step path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sync-active-cmd-picker .active-cmd-select {
    width: 100%;
}

.sync-active-cmd-picker .active-cmd-select .custom-select-trigger {
    width: 100%;
    min-height: 42px;
}

.muted-inline {
    color: var(--muted);
    font-size: 0.92rem;
}

.target-slot-item,
.target-cmd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}

.target-slot-item:hover,
.target-cmd-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(106, 124, 176, 0.25);
}

.target-slot-item.disabled-slot {
    opacity: 0.55;
}

.target-slot-swatch,
.swatch-inline,
.cs-swatch {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.swatch-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    vertical-align: -2px;
    margin-right: 6px;
}

.color-inline {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.color-inline em {
    font-style: normal;
    opacity: 0.7;
    margin-left: 4px;
}

.target-slot-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.target-slot-text small {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.custom-select-option.disabled-slot,
.custom-select-trigger.disabled-slot {
    opacity: 0.55;
}

.cluster-slot-row {
    display: grid;
    grid-template-columns: 56px minmax(120px, 1fr) minmax(90px, 0.8fr) minmax(120px, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.cluster-slot-friendly {
    color: var(--muted-strong);
    text-transform: lowercase;
}

.cluster-slot-flags {
    color: var(--warning);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cluster-slot-row.disabled-slot {
    opacity: 0.7;
}

.current-change-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(126, 146, 190, 0.12);
}

.current-change-hexes {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

.file-list-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(126, 146, 190, 0.12);
}

.file-list-item.rejected {
    color: var(--danger);
}

.drop-zone.dragover,
.screenshot-drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

#custom-color-picker {
    position: fixed;
    z-index: 1000;
}

#color-panel .form-grid {
    grid-template-columns: 1fr 1fr;
}

.sync-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sync-target-section {
    border: 1px solid rgba(106, 124, 176, 0.35);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.015);
    overflow: hidden;
}

.sync-target-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(106, 124, 176, 0.2);
    background: rgba(255, 255, 255, 0.02);
}

.sync-target-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #d7deef;
}

.sync-target-toggles {
    display: flex;
    gap: 6px;
}

.small-button {
    padding: 3px 10px;
    font-size: 0.8rem;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: #aeb8c9;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.small-button:hover {
    background: rgba(126, 167, 255, 0.12);
    border-color: #7ea7ff;
}

.sync-target-grid {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.sync-target-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.sync-target-card:hover {
    background: rgba(255, 255, 255, 0.025);
    border-color: rgba(106, 124, 176, 0.3);
}

.sync-target-card.selected {
    background: rgba(126, 167, 255, 0.08);
    border-color: #7ea7ff;
}

.sync-target-card.slot-disabled {
    opacity: 0.45;
}

.sync-target-checkbox {
    margin: 0;
    flex: 0 0 auto;
    accent-color: #7ea7ff;
}

.sync-target-swatch {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.sync-target-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.sync-target-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
}

.sync-target-value {
    margin-top: 3px;
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    opacity: 0.7;
}
.source-palette-colors {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.source-palette-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.85rem;
}

.source-palette-swatch {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
}

.current-changes-list {
    display: grid;
    gap: 14px;
}

.current-change-file {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.current-change-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.current-change-file-header span {
    color: var(--muted);
    font-size: 0.85rem;
}

.current-change-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.current-change-row:last-child {
    border-bottom: 0;
}

.current-change-identity {
    min-width: 0;
    font-size: 0.9rem;
}

.current-change-colors {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    font-family: monospace;
    font-size: 0.85rem;
}

.current-change-swatch {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
}

.current-change-arrow {
    color: var(--muted);
    padding: 0 3px;
}

@media (max-width: 700px) {
    .current-change-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

.current-change-hex-input {
    width: 100px;
    padding: 6px 8px;
    font-family: monospace;
}

.current-change-picker {
    width: 34px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    cursor: pointer;
}

.current-change-revert {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 0.8rem;
}

.current-change-hex-input.invalid {
    border-color: #d85c5c;
}

@media (max-width: 700px) {
    .current-change-row {
        align-items: stretch;
    }

    .current-change-colors {
        flex-wrap: wrap;
    }

    .current-change-revert {
        align-self: flex-start;
    }
}
.section-description {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.5;
}
.custom-color-picker {
    position: fixed;
    z-index: 1000;
    width: 300px;
    padding: 14px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 14px 40px rgb(0 0 0 / 35%);
}

.color-picker-sv {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 8px;
    cursor: crosshair;
    background:
        linear-gradient(
            to top,
            #000,
            transparent
        ),
        linear-gradient(
            to right,
            #fff,
            transparent
        ),
        red;
}

.color-picker-sv-cursor {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow:
        0 0 0 1px rgb(0 0 0 / 70%);
    pointer-events: none;
}

.color-picker-hue {
    width: 100%;
    margin: 12px 0;
    appearance: none;
    height: 14px;
    border-radius: 999px;
    background:
        linear-gradient(
            to right,
            #f00,
            #ff0,
            #0f0,
            #0ff,
            #00f,
            #f0f,
            #f00
        );
}

.color-picker-hue::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid white;
    border-radius: 50%;
    background: transparent;
    box-shadow:
        0 0 0 1px rgb(0 0 0 / 60%);
    cursor: pointer;
}

.color-picker-preview-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-preview {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
}

.color-picker-hex {
    flex: 1;
    font-family: monospace;
}

.color-picker-rgba {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.color-picker-rgba label {
    display: grid;
    gap: 4px;
}

.color-picker-rgba span {
    color: var(--muted);
    font-size: 0.75rem;
}

.color-picker-rgba input {
    width: 100%;
}

/* ============================================================
   COLOR TOOL MODE TOGGLE
   ============================================================ */

.mode-toggle {
    display: inline-flex;
    gap: 8px;
    padding: 4px;
    margin-bottom: 18px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.mode-toggle-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 7px;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.mode-toggle-option:hover {
    color: var(--text);
}

.mode-toggle-option input {
    accent-color: var(--accent);
}

.mode-toggle-option:has(input:checked) {
    background: var(--accent-soft);
    color: var(--text);
}

/* ============================================================
   PATTERN SYNC
   ============================================================ */

.pattern-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.pattern-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--muted-strong);
}

.pattern-block-actions {
    display: inline-flex;
    gap: 6px;
}

.pattern-block-actions .secondary-button {
    padding: 3px 10px;
    font-size: 0.75rem;
}

.pattern-list {
    display: grid;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.pattern-empty {
    color: var(--muted);
    font-size: 0.85rem;
    padding: 8px 2px;
}

.pattern-slot-row,
.pattern-target-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.pattern-slot-row:hover,
.pattern-target-row:hover {
    background: var(--panel-hover);
}

.pattern-slot-row input,
.pattern-target-row input {
    accent-color: var(--accent);
    flex: 0 0 auto;
}

.pattern-slot-swatch {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
}

.pattern-slot-name {
    font-weight: 600;
    color: var(--text);
}

.pattern-slot-hex {
    margin-left: auto;
    font-family: monospace;
    color: var(--muted);
}

.pattern-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

#pattern-apply-button {
    flex: 1;
}

#pattern-preview-button {
    flex: 0 0 auto;
}

/* ============================================================
   COLOR REPLACE
   ============================================================ */

.replace-results {
    display: grid;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
}

.replace-result-row {
    padding: 7px 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: monospace;
    color: var(--muted-strong);
}

/* ============================================================
   DIRECT COLOR EDITOR + DIVIDER
   ============================================================ */

.direct-editor {
    display: grid;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 6px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.direct-editor > label {
    display: grid;
    gap: 8px;
}

.tool-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 22px 0;
}

/* ============================================================
   UI POLISH PASS (overrides conflicting legacy rules)
   ============================================================ */

#color-panel .form-grid,
#color-replace-panel .form-grid,
#output-panel .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 28px;
    align-items: start;
}

@media (max-width: 860px) {
    #color-panel .form-grid,
    #color-replace-panel .form-grid,
    #output-panel .form-grid {
        grid-template-columns: 1fr;
    }
}

.sync-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.sync-column > label,
.form-grid > label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted-strong);
}

.sync-column > label > span,
.form-grid > label > span {
    font-weight: 600;
    color: var(--muted-strong);
}

.sync-column select,
.form-grid select,
.form-grid input[type="text"],
.sync-column input[type="text"],
.cmd-inspector-picker select {
    width: 100%;
    min-height: 42px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid rgba(106, 124, 176, 0.45);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text);
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.form-grid input[type="text"],
.sync-column input[type="text"].source-color-hex {
    background-image: none;
    padding-right: 12px;
}

.custom-select-trigger,
.source-color-editor {
    min-height: 42px;
}

.source-color-editor {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

#color-panel .source-color-picker,
#color-panel .source-color-hex {
    width: auto;
    height: 42px;
}

#color-panel .source-color-picker {
    width: 42px;
    min-width: 42px;
    border-radius: 10px;
    flex: 0 0 42px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#color-panel .source-color-hex {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-transform: uppercase;
}

.sync-mode-tabs {
    display: flex;
    gap: 10px;
    margin: 4px 0 18px;
}

.sync-mode-tab {
    min-height: 40px;
    padding: 8px 18px;
    border-radius: 999px;
    line-height: 1.2;
}

.sync-active-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    margin: 0 0 18px;
    padding: 10px 12px;
    border: 1px solid rgba(126, 146, 190, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.sync-target-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sync-target-header {
    min-height: 46px;
    padding: 8px 12px;
    gap: 12px;
}

.sync-target-toggles {
    display: flex;
    align-items: center;
    gap: 8px;
}

.small-button {
    min-height: 30px;
    padding: 4px 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sync-target-grid {
    padding: 8px;
    gap: 6px;
    max-height: 280px;
}

.target-slot-item,
.target-cmd-item {
    min-height: 44px;
    padding: 8px 10px;
    gap: 12px;
    border: 1px solid rgba(106, 124, 176, 0.14);
    background: rgba(255, 255, 255, 0.015);
}

.target-slot-item input,
.target-cmd-item input {
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 auto;
}

.target-slot-swatch {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border-radius: 6px;
}

.target-slot-text strong {
    display: block;
    line-height: 1.2;
}

.target-slot-text small {
    display: block;
    margin-top: 2px;
    line-height: 1.2;
}

#apply-color-sync,
#apply-pattern-sync,
#replace-color-button,
#build-button,
#export-cmd-button,
#export-colors-zip-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 20px;
    width: auto;
    max-width: 100%;
}

#apply-color-sync,
#apply-pattern-sync {
    margin-top: 18px;
}

#export-cmd-button {
    margin-top: 12px;
}

#apply-status,
#build-status,
#export-cmd-status,
#replace-color-status {
    margin-top: 14px;
}

/* Inspector cluster rows */
#cluster-inspector .cluster-card {
    margin-bottom: 10px;
    border: 1px solid rgba(126, 146, 190, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

#cluster-inspector .cluster-card > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 650;
    color: var(--text);
    background: rgba(255, 255, 255, 0.02);
}

#cluster-inspector .cluster-card > summary::-webkit-details-marker {
    display: none;
}

#cluster-inspector .cluster-slot-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#cluster-inspector .cluster-slot-row {
    display: grid !important;
    grid-template-columns:
        34px
        minmax(140px, 0.9fr)
        minmax(90px, 0.7fr)
        minmax(130px, 1fr)
        auto !important;
    align-items: center;
    gap: 12px !important;
    min-height: 48px;
    padding: 8px 14px !important;
    border-top: 1px solid rgba(126, 146, 190, 0.12);
    flex-wrap: nowrap;
}

#cluster-inspector .cluster-slot-row .color-picker,
#cluster-inspector .color-picker {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: none !important;
    padding: 0 !important;
}

#cluster-inspector .cluster-slot-name {
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cluster-inspector .cluster-slot-friendly {
    color: var(--muted);
    text-transform: lowercase;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cluster-inspector .source-color-hex,
#cluster-inspector input[type="text"] {
    width: 100%;
    min-width: 0;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88rem;
    text-transform: uppercase;
}

#cluster-inspector .cluster-slot-flags:empty {
    display: none;
}

#cluster-inspector .cluster-slot-flags:not(:empty) {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--warning);
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--warning-soft);
    white-space: nowrap;
}

.inspector-toolbar,
.cmd-inspector-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin: 12px 0 14px;
}

.cmd-inspector-controls {
    justify-content: space-between;
}

.cmd-inspector-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: min(360px, 100%);
}

.cmd-inspector-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cmd-inspector-actions .secondary-button,
.inspector-toolbar .secondary-button {
    min-height: 38px;
    padding: 0 14px;
}

.cmd-inspector-actions .secondary-button,
.cmd-inspector-dirty-indicator {
    min-height: 38px;
    border-radius: 10px;
    font-size: 0.92rem;
}

.current-changes-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.current-changes-group h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.current-change-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
}

.current-change-picker {
    width: 42px !important;
    height: 42px !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.panel + .panel {
    margin-top: 18px;
}

.custom-select-trigger .cs-swatch,
.custom-select-option .cs-swatch {
    width: 22px;
    height: 22px;
    border-radius: 6px;
}

.custom-select-option {
    min-height: 40px;
}

.custom-select-option .cs-value {
    opacity: 0.65;
}

#custom-color-picker:not(.hidden) {
    display: grid;
    gap: 12px;
    width: min(300px, calc(100vw - 24px));
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    padding: 14px;
    padding-bottom: 20px;
    border: 1px solid rgba(126, 146, 190, 0.35);
    border-radius: 16px;
    background: #1b1f27;
    box-shadow: var(--shadow-floating);
    cursor: grab;
    overflow: auto;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#custom-color-picker::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

#custom-color-picker.is-dragging {
    cursor: grabbing;
    user-select: none;
}

#custom-color-picker.is-resizing {
    user-select: none;
}

#custom-color-picker input,
#custom-color-picker button,
#custom-color-picker .color-picker-sv {
    cursor: auto;
}

#custom-color-picker .color-picker-sv {
    cursor: crosshair;
}

.color-picker-sv {
    position: relative;
    width: 100%;
    height: 150px;
    border-radius: 12px;
    cursor: crosshair;
    overflow: hidden;
}

.color-picker-sv-cursor {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.color-picker-preview-row {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 10px;
    align-items: center;
}

.color-picker-preview {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.color-picker-rgba {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.color-picker-rgba label {
    display: grid;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--muted);
}

.color-picker-rgba input,
.color-picker-hex {
    width: 100%;
    min-height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(106, 124, 176, 0.4);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    padding: 0 8px;
}

.file-list-item {
    gap: 4px;
    padding: 12px 0;
}

.file-list-item span {
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 720px) {
    #cluster-inspector .cluster-slot-row {
        grid-template-columns: 28px 1fr !important;
        grid-template-areas:
            "swatch name"
            "swatch friendly"
            "hex hex"
            "flags flags";
        gap: 6px 10px !important;
    }

    #cluster-inspector .cluster-slot-row .color-picker { grid-area: swatch; }
    #cluster-inspector .cluster-slot-name { grid-area: name; }
    #cluster-inspector .cluster-slot-friendly { grid-area: friendly; }
    #cluster-inspector .source-color-hex,
    #cluster-inspector input[type="text"] { grid-area: hex; }
    #cluster-inspector .cluster-slot-flags { grid-area: flags; }

    .current-change-row {
        grid-template-columns: 1fr auto;
    }
}

/* ============================================================
   REPLACE COLOR EVERYWHERE
   ============================================================ */

.replace-color-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.replace-color-label {
    font-weight: 600;
    color: var(--muted-strong);
    font-size: 0.9rem;
}

.replace-color-editor {
    margin-top: 0;
}

.replace-color-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: lowercase;
}

.replace-color-meta .swatch-inline {
    width: 16px;
    height: 16px;
}

.replace-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 120px;
    max-height: 360px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid rgba(126, 146, 190, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
}

.replace-empty,
.replace-results-header {
    color: var(--muted-strong);
    font-size: 0.92rem;
    line-height: 1.45;
}

.replace-result-group h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}

.replace-result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(126, 146, 190, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.015);
    font-size: 0.9rem;
}

.replace-result-row + .replace-result-row {
    margin-top: 6px;
}
/* ============================================================
   EXPORT / JUMP / COLLAPSE / REFERENCE POLISH
   ============================================================ */

.export-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

#cluster-inspector .cluster-card > summary::before {
    flex: 0 0 auto;
    margin-right: 0;
}

.cluster-card-title {
    min-width: 0;
    flex: 1 1 auto;
}

.cluster-card-actions {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 5px;
}

#cluster-inspector details.cluster-card:not([open]) .cluster-card-actions {
    display: none;
}

.cluster-surprise-button,
.cluster-surprise-discard {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.cluster-surprise-button {
    border-color: rgba(156, 124, 255, 0.3);
    background: rgba(156, 124, 255, 0.09);
    color: var(--accent-hover);
}

.cluster-surprise-button:hover:not(:disabled),
.cluster-surprise-button:focus-visible {
    border-color: rgba(156, 124, 255, 0.56);
    background: rgba(156, 124, 255, 0.16);
}

.cluster-surprise-discard {
    border-color: rgba(154, 169, 200, 0.2);
    background: rgba(154, 169, 200, 0.045);
    color: var(--text-muted);
}

.cluster-surprise-discard:hover,
.cluster-surprise-discard:focus-visible {
    border-color: rgba(154, 169, 200, 0.4);
    background: rgba(154, 169, 200, 0.1);
    color: var(--text);
}

.modder-files-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 2px 14px;
    color: var(--warning);
    font-size: 0.9rem;
    line-height: 1.45;
}

.modder-files-notice-icon {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex: 0 0 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.zip-import-progress {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(126, 164, 255, 0.28);
    border-radius: var(--radius-small);
    background: rgba(126, 164, 255, 0.08);
}

.color-library-picker {
    display: block;
    margin-top: 10px;
}

label.color-library-picker > span {
    display: block;
    margin-bottom: 5px;
    font-weight: 650;
}

#color-library-drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(126, 164, 255, 0.1);
}

#color-library-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 170px;
    gap: 8px;
}

.color-library-download {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.color-library-download a {
    color: var(--accent);
    font-weight: 650;
    text-decoration: none;
    text-underline-offset: 3px;
}

.color-library-download a:hover,
.color-library-download a:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Keep the homepage support links on the site's blue accent palette. */
.info-card p a[href*="nexusmods.com/streetfighter6/mods/3837"],
.info-card p a[href="https://github.com/ZZtaii/colorsync-sf6"],
.info-card p a[href="https://www.patreon.com/ZZtai/posts/buy-me-coffee-167011360"] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(126, 167, 255, 0.55);
  text-underline-offset: 3px;
}

.info-card p a[href*="nexusmods.com/streetfighter6/mods/3837"]:hover,
.info-card p a[href*="nexusmods.com/streetfighter6/mods/3837"]:focus-visible,
.info-card p a[href="https://github.com/ZZtaii/colorsync-sf6"]:hover,
.info-card p a[href="https://github.com/ZZtaii/colorsync-sf6"]:focus-visible,
.info-card p a[href="https://www.patreon.com/ZZtai/posts/buy-me-coffee-167011360"]:hover,
.info-card p a[href="https://www.patreon.com/ZZtai/posts/buy-me-coffee-167011360"]:focus-visible {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

#remember-color-library-field {
    width: fit-content;
    margin-top: 10px;
}

#forget-color-library {
    margin-top: 8px;
}

.zip-import-progress-label {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.zip-import-progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
}

.zip-import-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 120ms ease;
}

.zip-import-progress-bar.is-indeterminate {
    width: 36%;
    animation: zip-import-progress-slide 1.1s ease-in-out infinite;
}

@keyframes zip-import-progress-slide {
    from { transform: translateX(-120%); }
    to { transform: translateX(340%); }
}

.export-actions #build-button,
.export-actions #export-cmd-button,
.export-actions #export-colors-zip-button {
    margin-top: 0;
}

.export-destinations {
    margin-top: 16px;
}

.export-destinations[open] .collapsible-section-body {
    display: grid;
    gap: 8px;
}

.export-destination-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.export-destination-row > div {
    display: grid;
    gap: 3px;
    flex: 1;
}

.export-destination-row span,
.export-destination-hint {
    color: var(--muted);
    font-size: 0.86rem;
}

.export-destination-hint {
    margin: 0;
}

.export-duplicate-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    cursor: pointer;
    font-weight: 600;
}

.export-duplicate-option input {
    width: 17px;
    height: 17px;
}

.export-duplicate-hint {
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.file-list-item {
    flex-direction: row;
    align-items: center;
}

.file-unload-button {
    margin-left: auto;
    flex: 0 0 auto;
}

#unload-all-cmds {
    margin: 0 0 8px;
}

@media (max-width: 720px) {
    .export-destination-row { flex-wrap: wrap; }

    .support-buttons {
        grid-template-columns: 1fr;
    }
}

.section-jump {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid transparent;
}

.section-jump:hover {
    border-bottom-color: rgba(126, 167, 255, 0.7);
}

.section-flash {
    animation: section-flash 1.1s ease;
}

@keyframes section-flash {
    0% { box-shadow: 0 0 0 0 rgba(126, 167, 255, 0.0); }
    25% { box-shadow: 0 0 0 3px rgba(126, 167, 255, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(126, 167, 255, 0.0); }
}

.collapsible-section {
    margin-top: 14px;
    border: 1px solid rgba(126, 146, 190, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.collapsible-section-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    font-weight: 650;
    color: var(--text);
    background: rgba(255, 255, 255, 0.02);
}

.collapsible-section-summary::-webkit-details-marker {
    display: none;
}

.collapsible-section-hint {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.collapsible-section-body {
    padding: 4px 12px 12px;
    border-top: 1px solid rgba(126, 146, 190, 0.12);
}

.replace-active-line {
    margin-top: 0;
}

/* Reference viewer redesign */
.reference-viewer {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    display: block;
    width: auto;
}

.reference-viewer-shell {
    position: relative;
    width: min(260px, 42vw);
    min-width: 180px;
    max-width: min(640px, calc(100vw - 24px));
    border-radius: 18px;
    border: 1px solid rgba(126, 146, 190, 0.35);
    background: rgba(16, 19, 27, 0.94);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.reference-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px 8px 12px;
    border-bottom: 1px solid rgba(126, 146, 190, 0.16);
    background: rgba(255, 255, 255, 0.03);
}

.reference-viewer-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.reference-viewer-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
    font-weight: 650;
    color: #edf1f7;
}

.reference-viewer-count {
    flex: 0 0 auto;
    font-size: 0.78rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.reference-viewer-controls {
    position: static;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 1;
    pointer-events: auto;
}

.reference-viewer-control {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(126, 146, 190, 0.28);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.04);
    color: #dce4f5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.reference-viewer-control:hover {
    background: rgba(126, 167, 255, 0.14);
    border-color: rgba(126, 167, 255, 0.55);
    color: #fff;
}

.reference-viewer-control.hidden {
    display: none;
}

.reference-viewer-image-wrap {
    position: relative;
    width: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    overflow: hidden;
    background: #0d1016;
}

.reference-viewer-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(70vh, 720px);
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.reference-viewer-resize {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nesw-resize;
    background:
        linear-gradient(135deg, transparent 55%, rgba(190, 205, 235, 0.75) 55%, rgba(190, 205, 235, 0.75) 62%, transparent 62%),
        linear-gradient(135deg, transparent 70%, rgba(190, 205, 235, 0.55) 70%, rgba(190, 205, 235, 0.55) 78%, transparent 78%);
    opacity: 0.55;
}

.reference-viewer-resize:hover,
body.is-resizing-reference .reference-viewer-resize {
    opacity: 1;
}

body.is-resizing-reference {
    cursor: nesw-resize !important;
    user-select: none !important;
}

.reference-viewer-restore {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(126, 146, 190, 0.35);
    background: rgba(16, 19, 27, 0.94);
    color: var(--text);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.reference-viewer-restore-icon {
    opacity: 0.8;
}

/* (removed old rule that forced arrows/caption permanently hidden) */

@media (max-width: 1200px) {
    .reference-viewer {
        position: fixed;
        top: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        margin: 0;
    }
}

@media (max-width: 700px) {
    .reference-viewer {
        top: 10px;
        right: 10px;
        left: auto;
        width: auto;
    }

    .reference-viewer-shell {
        width: min(240px, calc(100vw - 20px));
    }
}
/* ============================================================
   REFERENCE VIEWER: hover chrome + compact pretty controls
   ============================================================ */

.reference-viewer {
    position: fixed !important;
    top: 18px !important;
    right: 18px !important;
    left: auto !important;
    z-index: 1000 !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
}

.reference-viewer.hidden,
.reference-viewer-restore.hidden {
    display: none !important;
}

.reference-viewer-shell {
    position: relative;
    width: min(240px, 42vw);
    min-width: 170px;
    max-width: min(560px, calc(100vw - 24px));
    border-radius: 22px;
    border: 1px solid rgba(90, 104, 138, 0.55);
    background: #11151d;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
    overflow: hidden;
}

.reference-viewer-image-wrap {
    position: relative !important;
    width: 100% !important;
    max-height: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: #11151d !important;
}

.reference-viewer-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(68vh, 680px);
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Hide chrome until hover (original behavior) */
.reference-viewer-controls,
.reference-viewer-arrow,
.reference-viewer-caption,
.reference-viewer-resize {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease !important;
}

.reference-viewer:hover .reference-viewer-controls,
.reference-viewer:hover .reference-viewer-arrow,
.reference-viewer:hover .reference-viewer-caption,
.reference-viewer:hover .reference-viewer-resize,
.reference-viewer:focus-within .reference-viewer-controls,
.reference-viewer:focus-within .reference-viewer-arrow,
.reference-viewer:focus-within .reference-viewer-caption,
.reference-viewer:focus-within .reference-viewer-resize {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.reference-viewer-controls {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    left: auto !important;
    display: flex !important;
    gap: 5px !important;
    z-index: 6 !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
}

.reference-viewer-control,
.reference-viewer-arrow {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 999px !important;
    background: rgba(12, 15, 22, 0.62) !important;
    color: #e8edf7 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28) !important;
    backdrop-filter: blur(8px);
    cursor: pointer !important;
}

.reference-viewer-control:hover,
.reference-viewer-arrow:hover {
    background: rgba(20, 26, 38, 0.82) !important;
    border-color: rgba(126, 167, 255, 0.45) !important;
    color: #fff !important;
}

.reference-viewer-arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 8 !important;
}

.reference-viewer-prev { left: 8px !important; right: auto !important; }
.reference-viewer-next { right: 8px !important; left: auto !important; }

.reference-viewer-arrow.hidden,
.reference-viewer-control.hidden {
    display: none !important;
}

.reference-viewer-caption {
    position: absolute !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    min-height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    padding: 5px 9px !important;
    border-radius: 999px !important;
    background: rgba(8, 10, 16, 0.66) !important;
    color: #e8edf7 !important;
    font-size: 0.8rem !important;
    line-height: 1.2 !important;
    backdrop-filter: blur(8px);
    z-index: 7 !important;
}

.reference-viewer-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.reference-viewer-count {
    flex: 0 0 auto;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

.reference-viewer-resize {
    position: absolute !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 16px !important;
    height: 16px !important;
    cursor: nesw-resize !important;
    z-index: 9 !important;
    background:
        linear-gradient(135deg, transparent 52%, rgba(200, 214, 240, 0.75) 52%, rgba(200, 214, 240, 0.75) 60%, transparent 60%),
        linear-gradient(135deg, transparent 68%, rgba(200, 214, 240, 0.5) 68%, rgba(200, 214, 240, 0.5) 76%, transparent 76%) !important;
}

.reference-viewer-restore {
    position: fixed !important;
    top: 18px !important;
    right: 18px !important;
    z-index: 1000 !important;
    min-height: 34px !important;
    padding: 0 12px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(126, 146, 190, 0.35) !important;
    background: rgba(16, 19, 27, 0.94) !important;
    color: var(--text) !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3) !important;
    font-size: 0.86rem !important;
}

/* ============================================================
   INSPECTOR SLOT SYMMETRY + INACTIVE BADGE + SWATCH SIZE
   ============================================================ */

#cluster-inspector .cluster-slot-row {
    display: grid !important;
    grid-template-columns:
        42px
        minmax(150px, 1.1fr)
        minmax(110px, 0.9fr)
        minmax(140px, 1.1fr)
        96px !important;
    align-items: center !important;
    gap: 12px !important;
    min-height: 56px !important;
    padding: 8px 14px !important;
}

#cluster-inspector .cluster-slot-row .color-picker,
#cluster-inspector .cluster-slot-swatch,
#cluster-inspector .color-picker {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    border-radius: 10px !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04) !important;
    padding: 0 !important;
    justify-self: start;
}

#cluster-inspector .cluster-slot-hex,
#cluster-inspector .source-color-hex,
#cluster-inspector input[type="text"] {
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 12px !important;
    border-radius: 10px !important;
    font-size: 0.9rem !important;
}

#cluster-inspector .cluster-slot-flags {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 96px !important;
    min-width: 96px !important;
    height: 26px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    border-radius: 999px !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
    white-space: nowrap !important;
    justify-self: end;
}

#cluster-inspector .cluster-slot-flags.is-inactive {
    color: var(--warning) !important;
    background: var(--warning-soft) !important;
    opacity: 1 !important;
}

/* Reserve space always; hide active label visually without layout shift */
#cluster-inspector .cluster-slot-flags.is-active {
    color: transparent !important;
    background: transparent !important;
    border: 1px solid transparent !important;
}

#cluster-inspector .cluster-slot-row.inactive-slot {
    opacity: 0.78;
}

.custom-select-option.inactive-slot,
.custom-select-trigger.inactive-slot,
.target-slot-item.inactive-slot {
    opacity: 0.55;
}

/* Keep source picker/hex aligned at 42px */
#color-panel .source-color-picker,
#color-panel .source-color-hex,
.replace-color-editor .source-color-picker,
.replace-color-editor .source-color-hex {
    height: 42px !important;
    min-height: 42px !important;
}

#color-panel .source-color-picker,
.replace-color-editor .source-color-picker {
    width: 42px !important;
    min-width: 42px !important;
    border-radius: 10px !important;
}

/* Hover-only native paste affordance for editable hex fields. */
.hex-input-control {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.hex-input-control .source-color-hex {
    width: 100% !important;
    padding-right: 42px !important;
}

.hex-action-buttons {
    position: absolute;
    z-index: 1;
    top: 50%;
    right: 5px;
    display: flex;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%);
    transition: opacity 120ms ease;
}

.hex-action-button {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 7px;
    color: var(--muted-strong);
    background: transparent;
    box-shadow: none !important;
    transform: none !important;
}

.hex-action-button svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.hex-input-control:hover .hex-action-buttons,
.hex-input-control:focus-within .hex-action-buttons {
    opacity: 1;
    pointer-events: auto;
}

.hex-action-button:hover,
.hex-action-button:focus-visible {
    color: var(--text);
    background: rgba(126, 167, 255, 0.14);
    outline: none;
}

#cluster-inspector .hex-input-control {
    min-width: 0;
}

/* Color is data, not a disabled-state indicator. Keep every swatch literal. */
.color-picker,
.source-color-picker,
.current-change-picker,
.cs-swatch,
.target-slot-swatch,
.swatch-inline {
    filter: none !important;
}

.color-picker:disabled,
.source-color-picker:disabled,
.current-change-picker:disabled {
    opacity: 1 !important;
}

.target-slot-item.disabled-slot,
.target-slot-item.inactive-slot,
.custom-select-option.disabled-slot,
.custom-select-option.inactive-slot,
.custom-select-trigger.disabled-slot,
.custom-select-trigger.inactive-slot,
#cluster-inspector .cluster-slot-row.inactive-slot,
#cluster-inspector .cluster-slot-row.disabled-slot,
.target-slot-card.slot-disabled,
.sync-target-card.slot-disabled {
    opacity: 1 !important;
}

.target-slot-item.disabled-slot .target-slot-text,
.target-slot-item.inactive-slot .target-slot-text,
.custom-select-option.disabled-slot .cs-text,
.custom-select-option.disabled-slot .cs-value,
.custom-select-option.inactive-slot .cs-text,
.custom-select-option.inactive-slot .cs-value,
.custom-select-trigger.disabled-slot .cs-text,
.custom-select-trigger.disabled-slot .cs-arrow,
.custom-select-trigger.inactive-slot .cs-text,
.custom-select-trigger.inactive-slot .cs-arrow,
#cluster-inspector .cluster-slot-row.inactive-slot .cluster-slot-name,
#cluster-inspector .cluster-slot-row.inactive-slot .cluster-slot-friendly,
#cluster-inspector .cluster-slot-row.inactive-slot .hex-input-control,
.target-slot-card.slot-disabled .target-slot-title,
.sync-target-card.slot-disabled .target-slot-title {
    opacity: 0.55;
}

@media (max-width: 720px) {
    #cluster-inspector .cluster-slot-row {
        grid-template-columns: 42px 1fr 96px !important;
        grid-template-areas:
            "swatch name flags"
            "swatch friendly flags"
            "hex hex hex" !important;
        gap: 8px 10px !important;
    }

    #cluster-inspector .cluster-slot-row .color-picker { grid-area: swatch; }
    #cluster-inspector .cluster-slot-name { grid-area: name; }
    #cluster-inspector .cluster-slot-friendly { grid-area: friendly; }
    #cluster-inspector .cluster-slot-hex,
    #cluster-inspector input[type="text"] { grid-area: hex; }
    #cluster-inspector .cluster-slot-flags { grid-area: flags; }
}

@media (max-width: 1200px) {
    .reference-viewer {
        position: fixed !important;
        top: 12px !important;
        right: 12px !important;
        width: auto !important;
        margin: 0 !important;
    }
}
/* Chevron arrows for reference viewer */
.reference-viewer-arrow svg {
    width: 13px;
    height: 13px;
    display: block;
}

.reference-viewer-arrow {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
    border-radius: 999px !important;
    background: rgba(10, 13, 20, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28) !important;
}

.reference-viewer-arrow:hover {
    background: rgba(18, 24, 36, 0.82) !important;
    border-color: rgba(126, 167, 255, 0.5) !important;
    transform: translateY(-50%) scale(1.04) !important;
}

.reference-viewer-arrow:active {
    transform: translateY(-50%) scale(0.98) !important;
}
/* Ensure reference arrows are visible on hover */
.reference-viewer-arrow {
    display: inline-flex !important;
}

.reference-viewer-caption {
    display: flex !important;
}

.reference-viewer-arrow.hidden {
    display: none !important;
}
/* Arrow visibility fix */
.reference-viewer-arrow {
    display: inline-flex !important;
    opacity: 0 !important;
    pointer-events: none !important;
    color: #f3f6ff !important;
    background: rgba(8, 11, 18, 0.72) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
}

.reference-viewer:hover .reference-viewer-arrow,
.reference-viewer:focus-within .reference-viewer-arrow,
.reference-viewer-image-wrap:hover .reference-viewer-arrow {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.reference-viewer-arrow:disabled {
    opacity: 0.35 !important;
    cursor: default !important;
}

.reference-viewer-arrow svg {
    width: 14px !important;
    height: 14px !important;
    stroke: currentColor !important;
}

.reference-viewer-arrow svg path {
    stroke: currentColor !important;
    fill: none !important;
}
/* Final: arrows only on hover (disabled included) */
.reference-viewer-arrow,
.reference-viewer-arrow:disabled {
    opacity: 0 !important;
    pointer-events: none !important;
}

.reference-viewer:hover .reference-viewer-arrow,
.reference-viewer-image-wrap:hover .reference-viewer-arrow {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.reference-viewer:hover .reference-viewer-arrow:disabled,
.reference-viewer-image-wrap:hover .reference-viewer-arrow:disabled {
    opacity: 0.35 !important;
    pointer-events: none !important;
}
/* ============================================================
   COMMON COLOR PALETTE (active CMD)
   ============================================================ */

.common-palette {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid rgba(126, 146, 190, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.common-palette-label {
    flex: 0 0 auto;
    font-size: 0.86rem;
    font-weight: 650;
    color: var(--muted-strong);
}

.common-palette-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 28px;
}

.common-palette-empty {
    color: var(--muted);
    font-size: 0.86rem;
}

.common-palette-swatch {
    position: relative;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    cursor: pointer;
    appearance: none;
    background: transparent;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.common-palette-swatch:hover {
    transform: translateY(-1px);
    border-color: rgba(126, 167, 255, 0.7);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.06),
        0 6px 14px rgba(0, 0, 0, 0.28);
}

.common-palette-swatch:focus-visible {
    outline: none;
    border-color: #7ea7ff;
    box-shadow: 0 0 0 3px rgba(126, 167, 255, 0.22);
}

.common-palette-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(2px);
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(12, 15, 22, 0.94);
    border: 1px solid rgba(126, 146, 190, 0.35);
    color: #edf1f7;
    font-size: 0.72rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 5;
}

.common-palette-swatch:hover .common-palette-tooltip,
.common-palette-swatch:focus-visible .common-palette-tooltip,
.common-palette-swatch.copied .common-palette-tooltip,
.common-palette-swatch.copy-failed .common-palette-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.common-palette-swatch.copied {
    border-color: rgba(80, 200, 120, 0.8);
}

.common-palette-swatch.copy-failed {
    border-color: rgba(220, 90, 90, 0.8);
}

/* Reference arrows: clickable on hover (never steal-proof / never stuck disabled) */
#reference-viewer .reference-viewer-arrow {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 50% !important;
    z-index: 20 !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 999px !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    background: rgba(8, 11, 18, 0.72) !important;
    color: #f3f6ff !important;
    opacity: 0 !important;
    pointer-events: none !important;
    cursor: pointer !important;
    transform: translateY(-50%) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28) !important;
}

#reference-viewer .reference-viewer-prev {
    left: 8px !important;
    right: auto !important;
}

#reference-viewer .reference-viewer-next {
    right: 8px !important;
    left: auto !important;
}

#reference-viewer:hover .reference-viewer-arrow,
#reference-viewer:focus-within .reference-viewer-arrow,
#reference-viewer .reference-viewer-image-wrap:hover .reference-viewer-arrow {
    opacity: 1 !important;
    pointer-events: auto !important;
}

#reference-viewer .reference-viewer-arrow:hover {
    background: rgba(18, 24, 36, 0.9) !important;
    border-color: rgba(126, 167, 255, 0.55) !important;
    transform: translateY(-50%) scale(1.05) !important;
}

#reference-viewer .reference-viewer-arrow:active {
    transform: translateY(-50%) scale(0.97) !important;
}

#reference-viewer .reference-viewer-arrow:disabled {
    opacity: 0 !important;
    pointer-events: none !important;
    cursor: default !important;
}

#reference-viewer:hover .reference-viewer-arrow:disabled {
    opacity: 0.35 !important;
    pointer-events: none !important;
}

/* Center the smaller official credit against the larger caption title. */
#reference-viewer .reference-viewer-caption {
    align-items: center !important;
}

#reference-viewer .reference-viewer-arrow svg {
    width: 14px !important;
    height: 14px !important;
    pointer-events: none !important;
}

#reference-viewer .reference-viewer-controls {
    z-index: 21 !important;
}

/* Remote reference image URL popover */
#reference-viewer .reference-viewer-control svg {
    width: 13px;
    height: 13px;
    pointer-events: none;
}

#reference-viewer .reference-viewer-url-form {
    position: absolute;
    top: 40px;
    right: 8px;
    z-index: 22;
    display: grid;
    gap: 6px;
    width: min(330px, calc(100% - 16px));
    padding: 10px;
    border: 1px solid rgba(126, 167, 255, 0.42);
    border-radius: 12px;
    background: rgba(15, 19, 28, 0.96);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(10px);
}

#reference-viewer .reference-viewer-url-form.hidden {
    display: none;
}

#reference-viewer .reference-viewer-url-form label {
    color: #edf1f7;
    font-size: 0.72rem;
    font-weight: 700;
}

#reference-viewer .reference-viewer-url-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
}

#reference-viewer .reference-viewer-url-row input {
    min-width: 0;
    height: 32px;
    padding: 0 9px;
    border: 1px solid rgba(126, 146, 190, 0.35);
    border-radius: 8px;
    background: #10141d;
    color: #edf1f7;
    font-size: 0.75rem;
}

#reference-viewer .reference-viewer-url-row button {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 0.75rem;
}

#reference-viewer .reference-viewer-url-status {
    min-height: 1em;
    color: rgba(232, 237, 247, 0.68);
    font-size: 0.68rem;
    line-height: 1.3;
}

#reference-viewer .reference-viewer-url-status.bad {
    color: #ff9c9c;
}

#reference-viewer .reference-viewer-caption {
    z-index: 15 !important;
    pointer-events: none !important;
}

#reference-viewer:hover .reference-viewer-caption {
    pointer-events: none !important;
}

/* Official reference credit: aligned to the caption title at a quieter scale. */
#reference-viewer .reference-viewer-credit {
    flex: 0 0 auto;
    align-self: center;
    color: rgba(232, 237, 247, 0.56);
    font-size: 0.48rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    pointer-events: none;
}

#reference-viewer .reference-viewer-credit[hidden] {
    display: none !important;
}

/* Reference position: a quiet top-left overlay, separate from the attribution bar. */
#reference-viewer .reference-viewer-count {
    position: absolute !important;
    top: 10px !important;
    left: 12px !important;
    z-index: 9 !important;
    display: block !important;
    color: rgba(240, 244, 252, 0.72) !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0 !important;
    pointer-events: none !important;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.72);
    transition: opacity 0.16s ease !important;
}

#reference-viewer:hover .reference-viewer-count,
#reference-viewer:focus-within .reference-viewer-count {
    opacity: 1 !important;
}

/* Keep editing tools in their intended workflow order. */
main.page-width {
    display: flex;
    flex-direction: column;
}

#file-panel { order: 1; }
#parser-panel { order: 2; }
#color-replace-panel { order: 3; }
#color-panel { order: 4; }
#current-changes-panel { order: 5; }
#output-panel { order: 6; }
#about-tool { order: 7; }

/* Keep visual editing primary; expose decoded runtime values as context. */
.color-picker-space-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.color-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#custom-color-picker .color-picker-reset-layout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    cursor: pointer;
}

#custom-color-picker .color-picker-reset-layout:hover,
#custom-color-picker .color-picker-reset-layout:focus-visible {
    border-color: rgba(126, 167, 255, 0.55);
    background: rgba(126, 167, 255, 0.08);
    color: var(--text);
    outline: none;
}

.color-picker-reset-layout svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
}

.color-picker-reset-layout path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#custom-color-picker .color-picker-resize {
    position: absolute;
    right: 3px;
    bottom: 3px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: rgba(166, 180, 214, 0.62);
    box-shadow: none;
    cursor: nwse-resize;
    touch-action: none;
}

#custom-color-picker .color-picker-resize:hover,
#custom-color-picker .color-picker-resize:focus-visible {
    background: rgba(126, 167, 255, 0.1);
    color: var(--text);
    outline: none;
}

.color-picker-resize svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
}

.color-picker-resize path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
}

.color-picker-runtime-readout {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-areas:
        "label label action"
        "swatch hex action"
        "swatch name action";
    gap: 3px 9px;
    padding: 10px;
    border: 1px solid rgba(126, 146, 190, 0.24);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.035);
}

.color-picker-runtime-label {
    grid-area: label;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
}

.color-picker-runtime-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 1px solid rgba(126, 146, 190, 0.55);
    border-radius: 999px;
    color: var(--muted);
    font-family: serif;
    font-size: 0.68rem;
    font-style: italic;
    line-height: 1;
    cursor: help;
}

.color-picker-runtime-info:hover,
.color-picker-runtime-info:focus-visible {
    border-color: rgba(126, 167, 255, 0.8);
    color: var(--text);
    outline: none;
}

.color-picker-runtime-tooltip {
    position: fixed;
    z-index: 2500;
    width: min(240px, calc(100vw - 16px));
    padding: 9px 10px;
    border: 1px solid rgba(126, 146, 190, 0.4);
    border-radius: 8px;
    background: #1b1f27;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    color: var(--text);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s linear 0.12s;
}

.color-picker-runtime-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s;
}

.color-picker-runtime-lock {
    grid-area: lock;
    align-self: center;
    color: var(--muted);
    font-size: 0.62rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.color-picker-runtime-swatch {
    grid-area: swatch;
    width: 36px;
    height: 36px;
    align-self: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.color-picker-runtime-hex {
    grid-area: hex;
    align-self: end;
    color: var(--text);
    font-family: monospace;
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.color-picker-runtime-name {
    grid-area: name;
    align-self: start;
    color: var(--muted);
    font-size: 0.72rem;
}


.color-picker-original-readout {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-areas:
        "label label action"
        "swatch hex action"
        "swatch name action";
    gap: 3px 9px;
    padding: 10px;
    border: 1px solid rgba(126, 146, 190, 0.24);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.035);
}

.color-picker-original-label {
    grid-area: label;
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
}

.color-picker-original-swatch {
    grid-area: swatch;
    width: 36px;
    height: 36px;
    align-self: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.color-picker-original-hex {
    grid-area: hex;
    align-self: end;
    color: var(--text);
    font-family: monospace;
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.color-picker-original-name {
    grid-area: name;
    align-self: start;
    color: var(--muted);
    font-size: 0.72rem;
}

.color-picker-original-restore {
    grid-area: action;
    align-self: center;
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.72rem;
}

/* ============================================================
   COLOR PICKER REFERENCE ROWS + RUNTIME PASTE CONVERSION
   ============================================================ */

#custom-color-picker .color-picker-reference-card {
    gap: 5px 10px;
    padding: 11px;
    border-color: rgba(126, 146, 190, 0.3);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

#custom-color-picker .color-picker-original-readout,
#custom-color-picker .color-picker-runtime-readout {
    grid-template-columns: 42px minmax(0, 1fr) auto;
}

#custom-color-picker .color-picker-original-label,
#custom-color-picker .color-picker-runtime-label {
    font-size: 0.74rem;
    letter-spacing: 0.01em;
}

#custom-color-picker .color-picker-original-swatch,
#custom-color-picker .color-picker-runtime-swatch {
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

#custom-color-picker .color-picker-original-hex {
    align-self: center;
    font-size: 0.8rem;
}

#custom-color-picker .color-picker-runtime-hex {
    align-self: end;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

#custom-color-picker .color-picker-original-name,
#custom-color-picker .color-picker-runtime-name {
    font-size: 0.7rem;
}

#custom-color-picker .color-picker-original-restore,
#custom-color-picker .color-picker-runtime-paste {
    min-height: 30px;
    border-radius: 8px;
}

#custom-color-picker .color-picker-runtime-paste {
    grid-area: action;
    align-self: center;
    padding: 0 10px;
    font-size: 0.72rem;
}

#custom-color-picker .color-picker-runtime-paste.paste-succeeded {
    border-color: rgba(80, 200, 120, 0.8);
}

#custom-color-picker .color-picker-runtime-paste.paste-failed {
    border-color: rgba(220, 90, 90, 0.8);
}

/* DX palettes can be inspected and edited, but are not guaranteed game-active. */
.file-list-item.dx-reference {
    padding-left: 10px;
    border-left: 3px solid rgba(245, 184, 76, 0.72);
}

.file-list-item .dx-reference-note {
    color: var(--warning, #f5b84c);
    font-size: 0.78rem;
    font-weight: 700;
}

/* Restore snapshots embedded in Color Sync mod ZIPs. */
.color-backup-panel {
    margin-top: 20px;
}

.color-backup-description {
    margin: 10px 2px 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.color-backup-list {
    display: grid;
    gap: 8px;
    max-height: 460px;
    margin-top: 12px;
    overflow: auto;
}

.color-backup-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--panel-soft);
}

.color-backup-copy {
    min-width: 0;
}

.color-backup-copy > strong,
.color-backup-copy > span {
    display: block;
}

.color-backup-copy > span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.color-backup-restore {
    flex: 0 0 auto;
}

.color-backup-changes {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.8rem;
}

.color-backup-changes summary {
    cursor: pointer;
    color: var(--accent);
}

.color-backup-changes pre {
    max-height: 220px;
    margin: 8px 0 0;
    padding: 10px;
    overflow: auto;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text);
    font: 0.75rem/1.5 monospace;
    white-space: pre-wrap;
}

#color-backup-status {
    margin-top: 12px;
}

@media (max-width: 720px) {
    .color-backup-item {
        align-items: stretch;
        flex-direction: column;
    }

    .color-backup-restore {
        width: 100%;
    }
}

/* ============================================================
   SECTION RAIL + NUMBER SHORTCUTS
   ============================================================ */

.section-rail {
    position: fixed;
    top: 50%;
    left: max(8px, calc((100vw - 1100px) / 2 - 82px));
    z-index: 850;
    display: flex;
    flex-direction: column-reverse;
    gap: 4px;
    width: 52px;
    opacity: 0.56;
    transform: translateY(-50%);
    transition: opacity 180ms ease;
}

.section-rail:hover,
.section-rail:focus-within {
    opacity: 0.96;
}

.section-rail-link {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 52px;
    min-height: 82px;
    padding: 7px 5px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--muted-strong);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease, opacity 150ms ease;
}

.section-rail-number {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--panel-soft);
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.section-rail-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.section-rail-link:hover,
.section-rail-link:focus-visible,
.section-rail-link.is-active {
    border-color: rgba(126, 167, 255, 0.22);
    background: rgba(126, 167, 255, 0.08);
    color: var(--text);
    outline: none;
}

.section-rail-link.is-active .section-rail-number {
    border-color: rgba(126, 167, 255, 0.52);
    background: rgba(126, 167, 255, 0.12);
}

.section-rail-link.is-disabled {
    pointer-events: none;
    opacity: 0.34;
}

@media (min-width: 901px) and (max-width: 1340px) {
    .page-width {
        width: min(1100px, calc(100% - 110px));
        margin-right: 18px;
        margin-left: 92px;
    }

    .section-rail {
        left: 8px;
    }
}

@media (max-width: 900px) {
    .section-rail {
        display: none;
    }
}

/* Keep the ZIP-import-only export action aligned with the row's far edge. */
.export-actions #export-colors-zip-button {
    margin-left: auto;
}

@media (max-width: 720px) {
    .export-actions #export-colors-zip-button {
        margin-left: 0;
    }
}

.export-backup-option {
    margin-top: 18px;
}

.export-backup-hint,
.export-unedited-hint {
    margin-left: 25px;
}

.export-unedited-option {
    margin-top: 12px;
}

/* ============================================================
   MOD ZIP EDITING TARGET PICKER
   ============================================================ */

.mod-target-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 32px));
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.mod-target-dialog::backdrop {
    background: rgba(7, 9, 14, 0.78);
    backdrop-filter: blur(5px);
}

.mod-target-dialog-card {
    display: grid;
    gap: 18px;
    padding: 24px;
}

.mod-target-dialog-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.mod-target-dialog-heading h2,
.mod-target-dialog-heading p {
    margin: 0;
}

.mod-target-dialog-heading p {
    margin-top: 6px;
    color: var(--muted);
}

.mod-target-list {
    display: grid;
    gap: 18px;
    overflow: auto;
    max-height: min(570px, calc(100vh - 190px));
    padding-right: 4px;
}

.mod-target-group {
    display: grid;
    gap: 8px;
}

.mod-target-group-title {
    margin: 0;
    color: var(--accent);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mod-target-option {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 16px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.mod-target-option:hover,
.mod-target-option:focus-visible {
    border-color: rgba(126, 167, 255, 0.55);
    background: rgba(126, 167, 255, 0.1);
    outline: none;
}

.mod-target-option-name {
    font-weight: 750;
}

.mod-target-option-root {
    grid-column: 1 / -1;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mod-target-option-count {
    color: var(--muted-strong);
    font-size: 0.82rem;
    white-space: nowrap;
}

.zip-target-reminder {
    display: block;
    margin-top: 7px;
    color: var(--muted-strong);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
}

/* Surprise Me split button and floating settings menu */
.cluster-surprise-group {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: stretch;
}

.cluster-surprise-group .cluster-surprise-button {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cluster-surprise-settings {
    display: inline-grid;
    place-items: center;
    width: 30px;
    min-height: 32px;
    padding: 0;
    border: 1px solid rgba(156, 124, 255, 0.3);
    border-left: 0;
    border-radius: 0 9px 9px 0;
    background: rgba(156, 124, 255, 0.09);
    color: var(--accent-hover);
    cursor: pointer;
}

.cluster-surprise-settings:hover,
.cluster-surprise-settings:focus-visible,
.cluster-surprise-settings[aria-expanded="true"] {
    border-color: rgba(156, 124, 255, 0.56);
    background: rgba(156, 124, 255, 0.16);
    outline: none;
}

.surprise-menu:not(.hidden) {
    position: fixed;
    z-index: 1200;
    display: grid;
    gap: 14px;
    width: min(390px, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    padding: 16px;
    overflow: auto;
    border: 1px solid rgba(126, 146, 190, 0.38);
    border-radius: 16px;
    background: #1b1f27;
    box-shadow: var(--shadow-floating);
}

.surprise-menu-header,
.surprise-target-picker-header,
.surprise-intensity-field > .surprise-menu-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.surprise-menu-header {
    padding-right: 28px;
}

.surprise-menu-header strong {
    display: block;
    font-size: 1rem;
}

.surprise-menu-summary,
.surprise-target-summary,
.slot-picker-summary {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.78rem;
}

.surprise-menu .surprise-menu-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    display: inline-grid !important;
    place-items: center !important;
    width: 28px;
    height: 28px;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 4px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.surprise-menu .surprise-menu-close:hover {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--accent-hover);
}

.surprise-menu .surprise-menu-close:focus-visible {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--text);
    outline: 2px solid rgba(156, 124, 255, 0.72);
    outline-offset: 2px;
}

.surprise-menu-section,
.surprise-intensity-field {
    display: grid;
    gap: 8px;
}

.surprise-menu-label {
    color: var(--muted-strong);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.surprise-preset-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.surprise-preset-button {
    min-height: 34px;
    padding: 5px 7px;
    border: 1px solid rgba(126, 146, 190, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    font-size: 0.78rem;
    cursor: pointer;
}

.surprise-preset-button:hover,
.surprise-preset-button:focus-visible,
.surprise-preset-button.is-selected {
    border-color: rgba(156, 124, 255, 0.65);
    background: rgba(156, 124, 255, 0.16);
    color: var(--accent-hover);
    outline: none;
}

.surprise-intensity-field input[type="range"] {
    width: 100%;
    accent-color: var(--accent-hover);
}

.surprise-intensity-scale {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.72rem;
}

.surprise-radio-option,
.slot-picker-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    color: var(--text);
    font-size: 0.88rem;
    cursor: pointer;
}

.surprise-radio-option input,
.slot-picker-radio input {
    margin: 0;
    accent-color: var(--accent-hover);
}

.surprise-edit-targets {
    justify-self: start;
    min-height: 34px;
    padding: 0 11px;
    font-size: 0.8rem;
}

.surprise-target-picker {
    display: grid;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(126, 146, 190, 0.16);
}

.surprise-target-picker-actions {
    display: flex;
    gap: 5px;
}

.surprise-target-list-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: var(--muted-strong);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
}

.surprise-target-list-toggle:hover,
.surprise-target-list-toggle:focus-visible {
    color: var(--accent-hover);
    outline: none;
}

.surprise-target-list-toggle span {
    width: 12px;
    color: var(--accent-hover);
    text-align: center;
}

/* Keep the Active slots disclosure looking like a section heading, not a full app button. */
.surprise-menu .surprise-target-list-toggle,
.surprise-menu .surprise-target-list-toggle:hover:not(:disabled),
.surprise-menu .surprise-target-list-toggle:focus-visible {
    min-height: 28px;
    padding: 2px 4px 2px 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    transform: none;
}

.surprise-menu .surprise-target-list-toggle:focus-visible {
    outline: 2px solid rgba(156, 124, 255, 0.64);
    outline-offset: 2px;
}

.slot-picker-list {
    display: grid;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 3px;
}

.slot-picker-material {
    display: grid;
    gap: 4px;
    padding: 2px 0;
}

.slot-picker-material-header {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    min-height: 36px;
    border-radius: 8px;
}

.slot-picker-material-header:hover {
    background: rgba(255, 255, 255, 0.035);
}

.slot-picker-material-toggle {
    display: grid;
    place-items: center;
    width: 24px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-strong);
    cursor: pointer;
}

.slot-picker-material-toggle:hover,
.slot-picker-material-toggle:focus-visible {
    background: rgba(156, 124, 255, 0.14);
    color: var(--accent-hover);
    outline: none;
}

.slot-picker-material-select {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 4px 7px 4px 2px;
    cursor: pointer;
}

.slot-picker-material-select input {
    margin: 0;
    accent-color: var(--accent-hover);
}

.slot-picker-material-select:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.48;
}

.slot-picker-material-name {
    overflow: hidden;
    color: var(--accent-hover);
    font-size: 0.78rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-picker-material-select small {
    color: var(--muted);
    font-size: 0.68rem;
    white-space: nowrap;
}

.slot-picker-material-slots {
    display: grid;
    gap: 4px;
    margin-left: 28px;
    padding: 2px 0 6px 6px;
    border-left: 1px solid rgba(126, 146, 190, 0.18);
}

.slot-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.slot-picker-item:hover {
    border-color: rgba(126, 146, 190, 0.24);
    background: rgba(255, 255, 255, 0.035);
}

.slot-picker-item.inactive-slot {
    opacity: 0.45;
    cursor: not-allowed;
}

.slot-picker-item input {
    margin: 0;
    accent-color: var(--accent-hover);
}

.slot-picker-item .target-slot-swatch {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
    border-radius: 6px;
}

.slot-picker-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.slot-picker-item-text strong {
    font-size: 0.8rem;
}

.slot-picker-item-text small {
    overflow: hidden;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.surprise-menu-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(126, 146, 190, 0.16);
}

.surprise-apply-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(156, 124, 255, 0.3);
    border-radius: 9px;
    background: rgba(156, 124, 255, 0.09);
    color: var(--accent-hover);
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: none;
}

.surprise-apply-button:hover:not(:disabled),
.surprise-apply-button:focus-visible:not(:disabled) {
    border-color: rgba(156, 124, 255, 0.56);
    background: rgba(156, 124, 255, 0.16);
    outline: none;
}

.surprise-apply-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.surprise-menu-reset-actions {
    display: contents;
}

.surprise-reset-group {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}

.surprise-reset-group.has-more #surprise-reset-colors {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.surprise-reset-more {
    display: inline-grid;
    place-items: center;
    width: 26px;
    min-width: 26px;
    min-height: 34px;
    padding: 0;
    border: 1px solid rgba(126, 146, 190, 0.26);
    border-left: 0;
    border-radius: 0 9px 9px 0;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted-strong);
    cursor: pointer;
}

.surprise-reset-more:hover,
.surprise-reset-more:focus-visible,
.surprise-reset-more[aria-expanded="true"] {
    border-color: rgba(156, 124, 255, 0.48);
    background: rgba(156, 124, 255, 0.12);
    color: var(--accent-hover);
    outline: none;
}

.surprise-reset-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 2;
    width: max-content;
    min-width: 190px;
    padding: 5px;
    border: 1px solid rgba(126, 146, 190, 0.34);
    border-radius: 10px;
    background: #20252e;
    box-shadow: var(--shadow-floating);
}

.surprise-reset-menu button {
    width: 100%;
    min-height: 32px;
    padding: 5px 9px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 0.76rem;
    text-align: left;
    cursor: pointer;
}

.surprise-reset-menu button:hover,
.surprise-reset-menu button:focus-visible {
    background: rgba(156, 124, 255, 0.13);
    color: var(--accent-hover);
    outline: none;
}

.surprise-menu-reset-actions .secondary-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.78rem;
}

@media (max-width: 560px) {
    .surprise-preset-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .slot-picker-material-select {
        grid-template-columns: 18px minmax(0, 1fr);
    }

    .slot-picker-material-select small {
        grid-column: 2;
    }
}

/* Freecam / EMV bulk color import */
.freecam-import-panel { margin: 18px 0; }
.freecam-import-panel .collapsible-section-body { display: grid; gap: 14px; }
.freecam-import-panel p { margin: 0; line-height: 1.6; }
.freecam-setup-link { font-size: 0.85rem; color: var(--muted); }
.freecam-import-panel a { color: var(--accent-hover); }
#freecam-color-text {
    box-sizing: border-box;
    width: 100%; min-height: 110px; padding: 12px; resize: vertical;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--input-bg, rgba(0, 0, 0, 0.16)); color: var(--text);
    font: 0.85rem/1.5 ui-monospace, Consolas, monospace;
}
.freecam-import-actions { display: flex; flex-wrap: wrap; gap: 10px; }
#freecam-color-preview { display: grid; gap: 12px; min-width: 0; }
.freecam-preview-heading { font-weight: 600; overflow-wrap: anywhere; }
.freecam-preview-scroll { overflow: auto; max-height: 360px; border: 1px solid var(--border); border-radius: 10px; }
.freecam-preview-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.freecam-preview-table th, .freecam-preview-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.freecam-preview-table th { position: sticky; top: 0; background: #292e39; }
.freecam-preview-table td { overflow-wrap: anywhere; min-width: 170px; }
.freecam-preview-table .swatch-inline { margin-right: 7px; vertical-align: middle; }
#freecam-color-preview details { overflow-wrap: anywhere; }
#freecam-color-preview ul { max-height: 220px; overflow: auto; padding-left: 24px; }
.freecam-doc { max-width: 900px; margin: 40px auto; padding: 24px; }
.freecam-doc .panel { margin: 20px 0; }
.freecam-doc li { margin: 10px 0; line-height: 1.6; }
@media (max-width: 560px) {
    .freecam-import-actions button { flex: 1 1 100%; }
    .freecam-import-panel .collapsible-section-summary { flex-wrap: wrap; gap: 6px; }
}

/* Active CMD clipboard export, beside the Freecam color importer */
.color-string-export-panel { margin: 18px 0; }
.color-string-export-panel .collapsible-section-body { display: grid; gap: 14px; min-width: 0; }
.color-string-export-panel p { margin: 0; line-height: 1.6; }
#color-string-output {
    box-sizing: border-box;
    width: 100%; min-height: 110px; padding: 12px; resize: vertical;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--input-bg, rgba(0, 0, 0, 0.16)); color: var(--text);
    font: 0.85rem/1.5 ui-monospace, Consolas, monospace;
}
@media (max-width: 560px) {
    .color-string-export-panel .collapsible-section-summary { flex-wrap: wrap; gap: 6px; }
}

/* Keep setup links and game paths readable on narrow screens */
.freecam-doc { min-width: 0; }
.freecam-doc code { white-space: normal; overflow-wrap: anywhere; }

/* REFramework exporter screenshot in the setup guide */
.freecam-setup-screenshot {
    margin: 24px 0; overflow: hidden;
    border: 1px solid var(--border); border-radius: 12px;
    background: rgba(0, 0, 0, 0.16);
}
.freecam-setup-screenshot img { display: block; width: 100%; height: auto; }
.freecam-setup-screenshot figcaption {
    padding: 12px 15px; border-top: 1px solid var(--border);
    color: var(--muted); font-size: 0.85rem; line-height: 1.6;
}
.material-default-notice,
.material-default-scope {
    margin: 0;
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
}

.material-default-notice {
    border-left: 2px solid var(--accent);
    margin-bottom: 0.35rem;
}

.material-default-blocked {
    border-left-color: var(--muted);
}

/* Place the wrapped hex editor in the mobile row's full-width color field. */
@media (max-width: 720px) {
    #cluster-inspector .cluster-slot-row > .hex-input-control {
        grid-area: hex !important;
    }

    #cluster-inspector .cluster-slot-name {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* Material-state bridge: diagnostic colors, never a claim of rendered pixels. */
.preview-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.preview-toolbar input { flex: 1; min-width: 12rem; }
.preview-material-list { max-height: 32rem; overflow: auto; }
.preview-material { border: 1px solid #ffffff24; border-radius: .5rem; padding: .75rem; margin: .65rem 0; }
.preview-material h4 { margin: 0 0 .4rem; overflow-wrap: anywhere; }
.preview-slot { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; padding: .4rem; border-radius: .3rem; }
.preview-provenance { font-size: .85rem; opacity: .8; overflow-wrap: anywhere; }
.preview-swatch { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }
.preview-swatch::before { content: ''; width: 1.25rem; height: 1.25rem; border: 1px solid #888; border-radius: .2rem; background: var(--preview-color, repeating-conic-gradient(#888 0% 25%, #333 0% 50%) 50% / 8px 8px); }
.preview-slot.is-selected, .preview-located { outline: 2px solid #82c9ff; outline-offset: -2px; }
.preview-camera { display:flex; flex-wrap:wrap; gap:.8rem; padding:.8rem; margin:.8rem 0; }
.preview-camera label { display:flex; align-items:center; gap:.4rem; }
.preview-camera select { max-width:100%; }
.preview-binding-list { max-height:22rem; overflow:auto; }
.preview-binding-row { display:flex; flex-wrap:wrap; gap:.5rem; margin:.5rem 0; overflow-wrap:anywhere; }
.preview-binding-row select { flex:1; min-width:12rem; max-width:100%; }
.reasy-viewport { max-width:640px; min-height:12rem; border:1px solid #ffffff24; background:#202020; border-radius:.6rem; padding:.5rem; }
.reasy-viewport img { width:100%; height:auto; display:block; cursor:crosshair; }
.reasy-viewport img[hidden] { display:none; }
.reasy-viewport p { padding:.5rem; font-size:.85rem; }
.preview-diagnostics { font-size:.85rem; overflow-wrap:anywhere; }

/* Browser 3D preview panel */
.bp { display: grid; gap: 12px; container-type: inline-size; }
.bp-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.bp-icon .f { fill: currentColor; }
/* The site gives every button a 42px minimum height; the preview's compact controls opt out. */
.bp-icon-btn, .bp-chip, .bp-dot, .bp-game, .bp-help, .bp-swatch, .bp-slot-mask, .bp-material-pick { min-height: 0; box-sizing: border-box; }

/* Icon buttons and their hover labels */
.bp-icon-btn {
    position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; flex: none;
    border-radius: 9px; cursor: pointer; color: var(--muted-strong); background: transparent; border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
}
.bp-icon-btn:hover:not(:disabled) { background: var(--panel-hover); color: var(--text); }
.bp-icon-btn[aria-pressed="true"], .bp-icon-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.bp-icon-btn:disabled { opacity: .4; cursor: default; }
.bp-icon-btn:focus-visible, .bp-chip:focus-visible, .bp-dot:focus-visible, .bp-game:focus-visible, .bp-help:focus-visible, .bp-slot-mask:focus-visible, .bp-stage canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bp [data-tip]::after {
    content: attr(data-tip); position: absolute; top: calc(100% + 7px); left: 50%; transform: translate(-50%, -3px); z-index: 6;
    padding: 5px 8px; border-radius: 7px; background: #0b0d12; color: #e8ecf3; border: 1px solid rgba(255, 255, 255, .14);
    font-size: 0.72rem; font-weight: 400; line-height: 1.25; white-space: nowrap; opacity: 0; pointer-events: none;
    transition: opacity .12s, transform .12s;
}
.bp [data-tip]:hover::after, .bp [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .3s; }
.bp [data-tip][data-tip-align="start"]::after { left: 0; transform: translate(0, -3px); }
.bp [data-tip][data-tip-align="end"]::after { left: auto; right: 0; transform: translate(0, -3px); }
.bp [data-tip][data-tip-align="start"]:hover::after, .bp [data-tip][data-tip-align="start"]:focus-visible::after,
.bp [data-tip][data-tip-align="end"]:hover::after, .bp [data-tip][data-tip-align="end"]:focus-visible::after { transform: none; }

/* Top row: model parts on the left, game folder and unload on the right */
.bp-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.bp-toolbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.bp-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.bp-chips[hidden] { display: none; }
.bp-chip {
    display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 0.8rem; line-height: 1; padding: 6px 11px 6px 8px;
    border-radius: 999px; cursor: pointer; color: var(--muted); background: transparent; border: 1px solid var(--border);
    transition: background .12s, border-color .12s, color .12s;
}
.bp-chip .bp-icon { width: 15px; height: 15px; }
.bp-chip:hover { border-color: var(--border-strong); color: var(--text); }
.bp-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.bp-chip.is-stock { border-style: dashed; }
.bp-chip-tag { font-size: 0.68rem; padding: 2px 5px; border-radius: 5px; background: rgba(255, 255, 255, .08); color: var(--muted); }
.bp-game {
    display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px 0 10px; border-radius: 10px; cursor: pointer;
    font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text); background: var(--accent-soft); border: 1px solid var(--accent);
    transition: background .12s, border-color .12s, color .12s;
}
.bp-game[hidden] { display: none; }
.bp-game:hover { background: rgba(126, 167, 255, .22); }
.bp-game.is-on { width: 34px; padding: 0; justify-content: center; background: transparent; border-color: rgba(105, 224, 165, .45); color: var(--success); }
.bp-game.is-on:hover { background: rgba(105, 224, 165, .1); }
.bp-game.is-on .bp-game-label { display: none; }

/* Before a model is loaded the stage carries the only connect button, so the top row stays out of the way. */
.bp-toolbar .bp-icon-btn:disabled { display: none; }
.bp:has(.bp-stage:not(.has-model)) .bp-toolbar .bp-game:not(.is-on) { display: none; }
.bp:has(.bp-stage:not(.has-model)):not(:has(.bp-chips:not([hidden]))):not(:has(.bp-toolbar .bp-game.is-on)) .bp-toolbar { display: none; }

.bp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 12px; align-items: stretch; }
.bp-layout:has(.bp-side[hidden]) { grid-template-columns: minmax(0, 1fr); }
@container (max-width: 760px) { .bp-layout { grid-template-columns: minmax(0, 1fr); } }

/* Stage */
.bp-stage.browser-preview-viewport {
    position: relative; max-width: none; aspect-ratio: 5 / 6; max-height: min(80vh, 820px); min-height: 280px; width: 100%;
    background: #0e0e11; border: 1px solid var(--border); border-radius: var(--radius-small); overflow: hidden;
    container: bp-stage / inline-size;
}
.bp-stage.browser-preview-viewport:not(.has-model) { aspect-ratio: auto; height: 320px; }
.bp-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; visibility: hidden; }
.bp-stage.has-model canvas { visibility: visible; }
.bp-stage.is-dragging canvas { cursor: grabbing; }
.bp-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; text-align: center; color: var(--muted); font-size: 0.86rem; }
.bp-empty > .bp-icon { width: 46px; height: 46px; stroke-width: 1.2; opacity: .55; margin-bottom: 2px; }
.bp-empty strong { color: var(--muted-strong); font-size: 1rem; }
.bp-empty > span { max-width: 36ch; line-height: 1.45; }
.bp-empty .bp-game { margin-top: 8px; }
.bp-stage.has-model .bp-empty, .bp-stage.is-busy .bp-empty { display: none; }

.bp-tools { position: absolute; top: 8px; left: 8px; right: 8px; display: none; flex-wrap: wrap; align-items: flex-start; gap: 6px; pointer-events: none; }
.bp-stage.has-model .bp-tools { display: flex; }
.bp-spacer { flex: 1 1 0; }
.bp-group {
    display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; pointer-events: auto;
    background: rgba(18, 20, 26, .74); border: 1px solid rgba(255, 255, 255, .09); box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.bp-group .bp-icon-btn { width: 30px; height: 30px; color: #cfd6e2; }
.bp-group .bp-icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .13); color: #fff; }
.bp-group .bp-icon-btn[aria-pressed="true"] { background: rgba(126, 167, 255, .3); border-color: transparent; color: #fff; }
.bp-sep { width: 1px; height: 18px; margin: 0 3px; background: rgba(255, 255, 255, .15); }
.bp-dots { display: flex; align-items: center; gap: 6px; padding: 0 7px 0 4px; }
.bp-dot { position: relative; width: 16px; height: 16px; padding: 0; border-radius: 50%; cursor: pointer; background: var(--dot); border: 1.5px solid rgba(255, 255, 255, .38); transition: transform .1s, box-shadow .1s; }
.bp-dot:hover { transform: scale(1.15); }
.bp-dot[aria-checked="true"] { box-shadow: 0 0 0 2px rgba(18, 20, 26, .95), 0 0 0 3.5px var(--accent); }

.bp-help {
    position: absolute; left: 8px; bottom: 8px; display: none; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; cursor: pointer;
    color: #cfd6e2; background: rgba(18, 20, 26, .74); border: 1px solid rgba(255, 255, 255, .09); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    transition: background .12s, color .12s;
}
.bp-help .bp-icon { width: 16px; height: 16px; }
.bp-help:hover, .bp-help[aria-pressed="true"] { color: #fff; background: rgba(60, 76, 120, .85); }
.bp-stage.has-model .bp-help { display: grid; }
.bp-hint {
    position: absolute; left: 44px; bottom: 8px; margin: 0; max-width: calc(100% - 52px); display: none; flex-wrap: wrap; gap: 4px 12px; padding: 6px 11px; border-radius: 14px;
    font-size: 0.74rem; line-height: 1.3; color: #d5dbe6; background: rgba(18, 20, 26, .82); border: 1px solid rgba(255, 255, 255, .09);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none;
}
.bp-hint kbd { font: inherit; font-weight: 600; color: #fff; }
.bp-stage.has-model.show-hint .bp-hint, .bp-stage.has-model .bp-help:hover + .bp-hint, .bp-stage.has-model .bp-help:focus-visible + .bp-hint { display: flex; }
.bp-busy {
    position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: none; align-items: center; gap: 9px; max-width: calc(100% - 24px);
    padding: 7px 13px 7px 10px; border-radius: 999px; font-size: 0.78rem; color: #e3e8f0; background: rgba(18, 20, 26, .86);
    border: 1px solid rgba(255, 255, 255, .1); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none;
}
.bp-busy-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-stage.is-busy .bp-busy { display: flex; }
.bp-stage.is-busy .bp-hint, .bp-stage.is-busy .bp-help { display: none; }
.bp-stage.is-busy:not(.has-model) .bp-busy { bottom: 50%; transform: translate(-50%, 50%); }
.bp-spinner { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .22); border-top-color: var(--accent); animation: bp-spin .8s linear infinite; }
@keyframes bp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bp-spinner { animation-duration: 3s; } }
@container bp-stage (max-width: 330px) { .bp-group-display .bp-sep, .bp-dots { display: none; } }

/* Side panel: selected part, then the material list */
.bp-side { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--panel-soft); overflow: hidden; }
.bp-side[hidden] { display: none; }
.bp-side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 12px 6px; }
.bp-side-head h4 { margin: 0; font-size: 0.9rem; }
.bp-count { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.bp-materials { list-style: none; margin: 0; padding: 0 6px 6px; overflow: auto; flex: 1 1 0; min-height: 140px; max-height: 560px; }
@container (max-width: 760px) { .bp-materials { flex: none; max-height: 260px; } }
.bp-material {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; align-items: center; width: 100%; min-height: 34px;
    border: 1px solid transparent; border-radius: 8px; padding: 3px 8px 3px 6px; cursor: pointer;
}
.bp-material:hover { background: var(--panel-hover); }
.bp-material.is-selected { background: var(--accent-soft); border-color: var(--accent); }
.bp-state { display: grid; place-items: center; width: 20px; height: 20px; color: var(--muted); }
.bp-state .bp-icon { width: 15px; height: 15px; }
[data-status="colors"] > .bp-state { color: var(--success); }
[data-status="unresolved"] > .bp-state { color: var(--warning); }
[data-status="hidden"] > .bp-state { opacity: .6; }
.bp-material-pick { display: block; min-width: 0; text-align: left; font: inherit; color: var(--text); background: none; border: 0; border-radius: 6px; padding: 4px 0; cursor: pointer; }
.bp-material-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bp-material-name { display: block; font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-material[data-status="hidden"] .bp-material-name, .bp-material[data-status="base"] .bp-material-name { color: var(--muted); }
/* Up to four swatches per line, so a material with eight slots keeps room for its name. */
.bp-swatches { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 84px; }
.bp-swatch { width: 18px; height: 18px; padding: 0; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .32); cursor: pointer; transition: transform .1s, box-shadow .1s; }
.bp-swatch:hover:not(:disabled) { transform: scale(1.18); box-shadow: 0 0 0 2px var(--accent); }
.bp-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bp-swatch:disabled { cursor: default; opacity: .75; border-style: dashed; }

.bp-detail { display: grid; gap: 10px; padding: 8px 8px 12px 12px; border-bottom: 1px solid var(--border); background: var(--accent-soft); }
.bp-detail[hidden] { display: none; }
.bp-detail-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.bp-detail-name { flex: 1 1 auto; min-width: 0; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-detail-actions { display: flex; gap: 2px; flex: none; }
.bp-detail-actions .bp-icon-btn { width: 30px; height: 30px; }
.bp-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.bp-slot { display: grid; justify-items: center; gap: 4px; }
.bp-slot .bp-swatch { width: 34px; height: 34px; border-radius: 9px; }
.bp-slot-mask {
    position: relative; display: grid; place-items: center; width: 34px; height: 20px; padding: 0; border-radius: 7px; cursor: pointer;
    color: var(--muted); background: transparent; border: 1px solid transparent; transition: background .12s, color .12s;
}
.bp-slot-mask .bp-icon { width: 14px; height: 14px; }
.bp-slot-mask:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.bp-slot-mask[aria-pressed="true"] { background: var(--accent); color: #0d1220; }

/* Footer: status line plus the folded panels */
.bp-footer { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.bp-footer-actions { display: flex; gap: 4px; flex: none; }
.bp-status { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 0.82rem; line-height: 1.4; color: var(--muted-strong); }
.bp-status.is-error { color: var(--danger); }
.bp-panel { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--panel-soft); }
.bp-panel[hidden] { display: none; }
.bp-panel h5 { margin: 6px 0 0; font-size: 0.82rem; }
.bp-panel h5:first-child { margin-top: 0; }
.bp-panel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bp-fineprint { margin: 0; font-size: 0.76rem; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.bp-about { margin-top: -6px; }
.bp-about a { color: var(--accent); text-underline-offset: 2px; }
.bp-panel .preview-binding-row { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); align-items: center; gap: 10px; margin: 4px 0; font-size: 0.8rem; color: var(--muted-strong); }
.bp-panel .preview-binding-row select { min-width: 0; width: 100%; }
@container (max-width: 560px) { .bp-panel .preview-binding-row { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.bp-field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted-strong); }
.bp-field select { max-width: 100%; }

/* Floating in the corner while editing */
.bp-stage.browser-preview-viewport.is-pinned {
    position: fixed; bottom: 1rem; right: 1rem; width: min(34vw, 380px); min-height: 0; z-index: 1200;
    border-color: var(--border-strong); box-shadow: var(--shadow-floating);
}
/* Moved or resized by the user: the panel script keeps the rectangle in these variables. */
.bp-stage.browser-preview-viewport.is-pinned.is-placed {
    left: var(--bp-float-left); top: var(--bp-float-top); right: auto; bottom: auto;
    width: var(--bp-float-width); height: var(--bp-float-height); aspect-ratio: auto; max-height: none;
}
/* Floating: the buttons stay out of the picture until the pointer is over the window (or a key
   reaches one of them). Touch screens have no hover, so there they stay visible. */
.bp-stage.is-pinned .bp-tools, .bp-stage.is-pinned .bp-help, .bp-stage.is-pinned .bp-resize[data-dir="se"]::after { transition: opacity .18s; }
@media (hover: hover) {
    .bp-stage.is-pinned:not(:hover):not(:focus-within):not(.is-resizing) .bp-tools,
    .bp-stage.is-pinned:not(:hover):not(:focus-within):not(.show-hint) .bp-help,
    .bp-stage.is-pinned:not(:hover):not(.is-resizing) .bp-resize[data-dir="se"]::after { opacity: 0; }
    .bp-stage.is-pinned.is-moving .bp-tools, .bp-stage.is-pinned.is-moving .bp-help { opacity: 0; }
}

/* Full screen: the panel covers the window; the model takes the room the materials do not need. */
html.bp-full-open { overflow: hidden; }
.bp.is-full {
    position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; gap: 10px;
    padding: 12px; background: var(--bg, #0d0f14); overflow: hidden;
}
.bp.is-full .bp-layout { flex: 1 1 0; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
.bp.is-full .bp-layout:has(.bp-side[hidden]) { grid-template-columns: minmax(0, 1fr); }
.bp.is-full .bp-stage.browser-preview-viewport { aspect-ratio: auto; height: 100%; max-height: none; min-height: 0; }
.bp.is-full .bp-materials { max-height: none; min-height: 0; }
.bp.is-full .bp-about, .bp.is-full .bp-panel, .bp.is-full .bp-footer-actions { display: none; }
.bp.is-full .bp-footer { min-height: 0; }
.bp.is-full .bp-icon-btn[aria-label^="Float"] { display: none; }
@media (max-width: 760px) {
    .bp.is-full { padding: 8px; gap: 8px; }
    .bp.is-full .bp-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 42%); }
    .bp.is-full .bp-materials { flex: 1 1 0; }
}
/* The editor's color box and menus open above the full screen preview. */
html.bp-full-open #custom-color-picker, html.bp-full-open .surprise-menu { z-index: 2100 !important; }
html.bp-full-open .color-picker-runtime-tooltip { z-index: 2600; }

/* Palette tabs (full screen only) */
.bp-palettes { display: flex; gap: 4px; padding: 8px 8px 6px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.bp-palettes[hidden] { display: none; }
.bp-palette {
    flex: none; min-width: 30px; min-height: 0; height: 28px; padding: 0 8px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 0.8rem;
    font-variant-numeric: tabular-nums; color: var(--muted-strong); background: transparent; border: 1px solid var(--border);
}
.bp-palette:hover { background: var(--panel-hover); color: var(--text); }
.bp-palette[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.bp-palette:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* A plain drag moves the floating window; Shift or the middle button moves the model. */
.bp-stage.is-pinned canvas { cursor: move; }
.bp-stage.is-pinned.is-camera-key canvas { cursor: grab; }
.bp-stage.is-pinned.is-dragging canvas { cursor: grabbing; }
.bp-stage.is-moving, .bp-stage.is-resizing { user-select: none; -webkit-user-select: none; }
.bp-resize { position: absolute; display: none; touch-action: none; z-index: 2; }
.bp-stage.is-pinned .bp-resize { display: block; }
.bp-resize[data-dir="n"], .bp-resize[data-dir="s"] { left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.bp-resize[data-dir="e"], .bp-resize[data-dir="w"] { top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.bp-resize[data-dir="n"] { top: 0; } .bp-resize[data-dir="s"] { bottom: 0; }
.bp-resize[data-dir="e"] { right: 0; } .bp-resize[data-dir="w"] { left: 0; }
.bp-resize[data-dir="ne"], .bp-resize[data-dir="se"], .bp-resize[data-dir="sw"], .bp-resize[data-dir="nw"] { width: 12px; height: 12px; }
.bp-resize[data-dir="ne"] { top: 0; right: 0; cursor: nesw-resize; }
.bp-resize[data-dir="sw"] { bottom: 0; left: 0; cursor: nesw-resize; }
.bp-resize[data-dir="nw"] { top: 0; left: 0; cursor: nwse-resize; }
/* The bottom right corner carries the visible grip and is the larger target for touch. */
.bp-resize[data-dir="se"] { bottom: 0; right: 0; width: 22px; height: 22px; cursor: nwse-resize; }
.bp-resize[data-dir="se"]::after {
    content: ""; position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px; opacity: .55;
    background: linear-gradient(135deg, transparent 0 45%, #cfd6e2 45% 55%, transparent 55% 70%, #cfd6e2 70% 80%, transparent 80%);
    transition: opacity .12s;
}
.bp-resize[data-dir="se"]:hover::after, .bp-stage.is-resizing .bp-resize[data-dir="se"]::after { opacity: 1; }
/* With the stage out of the page, the materials spread into columns across the full width. */
.bp-layout:has(.bp-stage.is-pinned) { grid-template-columns: minmax(0, 1fr); }
.bp-layout:has(.bp-stage.is-pinned) .bp-materials { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 10px; flex: none; min-height: 0; max-height: 300px; align-content: start; }
@media (max-width: 700px) {
    .bp-stage.browser-preview-viewport.is-pinned { width: 190px; bottom: .5rem; right: .5rem; }
    .bp-stage.is-pinned .bp-group:not(:last-child) { display: none; }
}

/* ============================================================
   Surprise Me menu, second pass (11 Nov): style chips with a sample strip, strength slider,
   segmented "Apply to", one clear primary action with quiet undo/reset beside it.
   Overrides the earlier .surprise-* rules above.
   ============================================================ */
.surprise-menu:not(.hidden) { width: min(360px, calc(100vw - 20px)); gap: 16px; padding: 16px; border-radius: 18px; background: #1a1e27; }
.surprise-menu svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.surprise-menu-header { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; justify-content: stretch; gap: 10px; padding-right: 30px; }
.surprise-menu-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, rgba(126, 167, 255, .22), rgba(156, 124, 255, .22)); color: var(--accent-hover); }
.surprise-menu-title { min-width: 0; }
.surprise-menu-header strong { font-size: 1rem; line-height: 1.2; }
.surprise-menu-summary { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.surprise-menu-label { font-size: .7rem; letter-spacing: .07em; color: var(--muted); }
.surprise-intensity-field > .surprise-menu-label output { color: var(--text); font-size: .8rem; letter-spacing: 0; font-variant-numeric: tabular-nums; }

.surprise-preset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.surprise-menu .surprise-preset-button {
    display: grid; gap: 6px; justify-items: stretch; min-height: 0; padding: 7px 7px 6px; border: 1px solid rgba(126, 146, 190, .2); border-radius: 10px;
    background: rgba(255, 255, 255, .03); color: var(--muted-strong); font-size: .76rem; font-weight: 650; line-height: 1.2; text-align: center; box-shadow: none; transform: none;
}
.surprise-menu .surprise-preset-button:first-child { grid-column: span 2; }
.surprise-preset-sample { display: block; height: 12px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.surprise-menu .surprise-preset-button:hover:not(.is-selected) { border-color: rgba(126, 146, 190, .5); background: rgba(255, 255, 255, .06); color: var(--text); box-shadow: none; transform: none; }
.surprise-menu .surprise-preset-button.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: 0 0 0 1px var(--accent); transform: none; }
.surprise-menu .surprise-preset-button:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 2px; }

.surprise-intensity-field { gap: 9px; }
.surprise-intensity-field input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer;
}
.surprise-intensity-field input[type="range"]::-webkit-slider-runnable-track {
    height: 6px; border-radius: 3px;
    background: linear-gradient(90deg, var(--accent) 0, var(--accent-strong) var(--fill, 100%), rgba(126, 146, 190, .22) var(--fill, 100%));
}
.surprise-intensity-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border: 2px solid #1a1e27; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(126, 146, 190, .5);
}
.surprise-intensity-field input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(126, 146, 190, .22); }
.surprise-intensity-field input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }
.surprise-intensity-field input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #1a1e27; border-radius: 50%; background: #fff; }
.surprise-intensity-field input[type="range"]:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 3px; border-radius: 6px; }
.surprise-intensity-scale { margin-top: -3px; font-size: .7rem; }

.surprise-target-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid rgba(126, 146, 190, .2); border-radius: 10px; background: rgba(0, 0, 0, .18); }
.surprise-target-modes .surprise-radio-option { position: relative; justify-content: center; min-height: 30px; border-radius: 7px; color: var(--muted-strong); font-size: .8rem; font-weight: 650; transition: background .12s, color .12s; }
.surprise-target-modes .surprise-radio-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.surprise-target-modes .surprise-radio-option:hover { color: var(--text); }
.surprise-target-modes .surprise-radio-option:has(input:checked) { background: rgba(126, 167, 255, .2); color: var(--text); }
.surprise-target-modes .surprise-radio-option:has(input:focus-visible) { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 1px; }
.surprise-target-row:not(.hidden) { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.surprise-target-row .surprise-target-summary { margin: 0; }

.surprise-menu .surprise-edit-targets, .surprise-menu .surprise-quiet-button {
    display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px;
    background: transparent; color: var(--muted-strong); font-size: .78rem; font-weight: 650; box-shadow: none; transform: none;
}
.surprise-menu .surprise-edit-targets { color: var(--accent-hover); }
.surprise-menu .surprise-edit-targets:hover:not(:disabled), .surprise-menu .surprise-quiet-button:hover:not(:disabled) { border-color: transparent; background: rgba(255, 255, 255, .07); color: var(--text); box-shadow: none; transform: none; }
.surprise-menu .surprise-quiet-button svg { width: 15px; height: 15px; }
.surprise-menu .surprise-quiet-button:disabled { opacity: .38; }

.surprise-menu-actions { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; gap: 8px; padding-top: 14px; }
.surprise-menu .surprise-apply-button {
    gap: 8px; width: 100%; min-height: 40px; border: 0; border-radius: 11px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); color: #0d1220;
    font-size: .9rem; font-weight: 800; box-shadow: 0 6px 18px rgba(110, 120, 255, .22);
}
.surprise-menu .surprise-apply-button:hover:not(:disabled), .surprise-menu .surprise-apply-button:focus-visible:not(:disabled) { border: 0; background: linear-gradient(90deg, #93b6ff, #ad92ff); color: #0d1220; }
.surprise-menu .surprise-apply-button svg { transition: transform .18s ease; }
.surprise-menu .surprise-apply-button:active:not(:disabled) svg { transform: rotate(90deg); }
.surprise-menu .surprise-apply-button:disabled { background: rgba(126, 146, 190, .2); color: var(--muted); box-shadow: none; opacity: 1; }
.surprise-menu-reset-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.surprise-reset-group.has-more #surprise-reset-colors { border-radius: 8px 0 0 8px; }
.surprise-menu .surprise-reset-more { width: 22px; min-width: 22px; min-height: 30px; border: 0; border-radius: 0 8px 8px 0; background: transparent; color: var(--muted-strong); box-shadow: none; transform: none; }
.surprise-menu .surprise-reset-more:hover, .surprise-menu .surprise-reset-more[aria-expanded="true"] { border: 0; background: rgba(255, 255, 255, .07); color: var(--text); }
@media (max-width: 560px) { .surprise-preset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Surprise Me inside the color box (11 Nov): style dots, strength and a Roll button for one color. */
#custom-color-picker .color-picker-surprise { display: grid; gap: 8px; margin-top: 10px; padding: 10px 11px; border: 1px solid rgba(126, 146, 190, .3); border-radius: 12px; background: rgba(255, 255, 255, .025); }
#custom-color-picker .color-picker-surprise svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.color-picker-surprise-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.color-picker-surprise-label { color: var(--muted-strong); font-size: .74rem; font-weight: 700; letter-spacing: .01em; }
.color-picker-surprise-head output { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.color-picker-surprise-styles { display: flex; justify-content: space-between; gap: 4px; }
#custom-color-picker .color-picker-surprise-style { width: 26px; height: 26px; min-width: 0; min-height: 0; padding: 0; border: 2px solid var(--panel); border-radius: 50%; box-shadow: 0 0 0 1px rgba(126, 146, 190, .35); transform: none; transition: box-shadow .12s, transform .12s; }
#custom-color-picker .color-picker-surprise-style:hover { box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); transform: scale(1.08); }
#custom-color-picker .color-picker-surprise-style[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
#custom-color-picker .color-picker-surprise-style:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 3px; }
.color-picker-surprise-row { display: flex; align-items: center; gap: 10px; }
#custom-color-picker .color-picker-surprise-row input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 18px; margin: 0; padding: 0; border: 0; background: transparent; }
#custom-color-picker .color-picker-surprise-row input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) 0, var(--accent-strong) var(--fill, 100%), rgba(126, 146, 190, .22) var(--fill, 100%)); }
#custom-color-picker .color-picker-surprise-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border: 2px solid var(--panel); border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(126, 146, 190, .5); }
#custom-color-picker .color-picker-surprise-row input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(126, 146, 190, .22); }
#custom-color-picker .color-picker-surprise-row input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }
#custom-color-picker .color-picker-surprise-row input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid var(--panel); border-radius: 50%; background: #fff; }
#custom-color-picker .color-picker-surprise-roll { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 32px; padding: 0 12px; border: 0; border-radius: 9px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); color: #0d1220; font-size: .78rem; font-weight: 800; box-shadow: none; }
#custom-color-picker .color-picker-surprise-roll:hover { border: 0; background: linear-gradient(90deg, #93b6ff, #ad92ff); }
#custom-color-picker .color-picker-surprise-roll svg { transition: transform .18s ease; }
#custom-color-picker .color-picker-surprise-roll:active svg { transform: rotate(90deg); }

/* Corner icons (11 Nov): the minimized reference viewer is an icon button, and a coffee link sits
   in the bottom right corner. Both stay under the full screen preview. */
.reference-viewer-restore, .coffee-link {
    position: fixed !important; z-index: 1000 !important; display: grid !important; place-items: center; width: 40px; height: 40px;
    min-height: 0 !important; padding: 0 !important; border: 1px solid rgba(126, 146, 190, .35) !important; border-radius: 50% !important;
    background: rgba(16, 19, 27, .94) !important; color: var(--muted-strong) !important; box-shadow: 0 10px 26px rgba(0, 0, 0, .35) !important;
    transition: color .15s, border-color .15s, transform .15s;
}
.reference-viewer-restore { top: 18px !important; right: 18px !important; }
.coffee-link { right: 18px; bottom: 18px; z-index: 900 !important; text-decoration: none; }
.reference-viewer-restore svg, .coffee-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.reference-viewer-restore:hover, .reference-viewer-restore:focus-visible { color: var(--text) !important; border-color: var(--accent) !important; }
.coffee-link:hover, .coffee-link:focus-visible { color: #ffd9a8 !important; border-color: #d9a066 !important; transform: translateY(-1px); outline: none; }
/* The floating 3D preview starts in the same corner; step aside until it is moved. */
body:has(.bp-stage.is-pinned:not(.is-placed)) .coffee-link { display: none !important; }
@media (max-width: 700px) { .reference-viewer-restore, .coffee-link { width: 36px; height: 36px; } .coffee-link { right: 10px; bottom: 10px; } }

/* Preview dropdowns (11 Nov): own chevron at a fixed inset, solid dark field, and a dark option
   list (the translucent site field made the native list open light gray). */
.bp select {
    -webkit-appearance: none; appearance: none; color-scheme: dark; min-height: 36px; padding: 0 34px 0 11px; border-radius: 9px; font-size: .8rem;
    color: var(--text); background-color: #171b23; text-overflow: ellipsis; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aeb8c9' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center; background-size: 14px 14px;
}
.bp select:hover { border-color: rgba(126, 146, 190, .6); }
.bp select option, .bp select optgroup { background-color: #1b1f27; color: var(--text); }
.bp select option:checked { background-color: #2a3350; }

/* Blend Rate / Roughness / Metalness (16 Nov): an icon column on every slot row opens one shared
   pop-up with a slider line per setting. Sliders fill outward from the "no change" point. */
#cluster-inspector .cluster-slot-row {
    grid-template-columns:
        42px
        minmax(150px, 1.1fr)
        minmax(110px, 0.9fr)
        minmax(140px, 1.1fr)
        96px
        42px !important;
}
#cluster-inspector .cluster-slot-surface-toggle {
    position: relative; display: grid; place-items: center; width: 42px; height: 42px; min-height: 0; padding: 0;
    border: 1px solid rgba(126, 146, 190, .28); border-radius: 10px; background: rgba(255, 255, 255, .03);
    color: var(--muted); box-shadow: none; cursor: pointer; justify-self: end;
}
#cluster-inspector .cluster-slot-surface-toggle svg { width: 20px; height: 20px; pointer-events: none; }
#cluster-inspector .cluster-slot-surface-toggle:hover:not(:disabled),
#cluster-inspector .cluster-slot-surface-toggle:focus-visible { color: var(--text); border-color: var(--accent); transform: none; }
#cluster-inspector .cluster-slot-surface-toggle[aria-expanded="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
/* Dot only for slots whose Blend Rate/Roughness/Metalness differ from the loaded file;
   most stock slots already have Blend Rate on, so "on" alone is not marked. */
#cluster-inspector .cluster-slot-surface-toggle.is-edited::after {
    content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--warning);
}
#cluster-inspector .cluster-slot-surface-toggle:disabled { opacity: .35; cursor: not-allowed; }

.surface-popover:not(.hidden) {
    position: fixed; z-index: 1200; display: grid; gap: 12px;
    width: min(360px, calc(100vw - 20px)); max-height: calc(100vh - 20px); padding: 12px 14px 14px; overflow: auto;
    border: 1px solid rgba(126, 146, 190, .38); border-radius: 16px; background: #1b1f27; box-shadow: var(--shadow-floating);
}
.surface-popover.hidden { display: none; }
html.bp-full-open .surface-popover { z-index: 2100 !important; }
.surface-popover-header { display: flex; align-items: flex-start; gap: 4px; }
.surface-popover-heading { flex: 1; min-width: 0; }
.surface-popover-heading strong { display: block; font-size: .92rem; overflow-wrap: anywhere; }
.surface-popover-slot { display: block; margin-top: 2px; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.surface-popover .surface-popover-icon {
    display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0;
    border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); cursor: pointer;
}
.surface-popover .surface-popover-icon svg { width: 17px; height: 17px; }
.surface-popover .surface-popover-icon:hover,
.surface-popover .surface-popover-icon[aria-expanded="true"] { background: transparent; color: var(--accent-hover); transform: none; }
.surface-popover .surface-popover-icon:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 1px; }
.surface-popover-help { margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(126, 146, 190, .08); color: var(--muted-strong); font-size: .78rem; line-height: 1.45; }
.surface-popover-help[hidden] { display: none; }
.surface-popover .surface-popover-close {
    display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0;
    border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); font-size: 1.35rem; line-height: 1; cursor: pointer;
}
.surface-popover .surface-popover-close:hover { background: transparent; color: var(--accent-hover); transform: none; }
.surface-popover .surface-popover-close:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 1px; }
.surface-popover-body { display: grid; gap: 14px; }
.surface-field { display: grid; gap: 4px; }
/* Blend Rate (color strength) is set apart from the two shading offsets below it. */
.surface-field[data-surface-key="blendRate"] { padding-bottom: 14px; border-bottom: 1px solid rgba(126, 146, 190, .14); }
.surface-field-head { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.surface-field-switch { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; margin: 0; cursor: pointer; }
.surface-field-tag {
    padding: 1px 6px; border: 1px solid rgba(225, 173, 97, .45); border-radius: 999px; color: var(--warning);
    font-size: .68rem; font-weight: 650; white-space: nowrap;
}
.surface-popover .surface-field-reset {
    display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; min-width: 26px; min-height: 26px; padding: 0;
    border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); cursor: pointer;
}
.surface-popover .surface-field-reset[hidden] { display: none; }
.surface-popover .surface-field-reset svg { width: 16px; height: 16px; }
.surface-popover .surface-field-reset:hover { background: rgba(126, 146, 190, .12); color: var(--text); transform: none; }
.surface-popover .surface-field-reset:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 1px; }
.surface-field-switch input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.surface-field-name { color: var(--text); font-weight: 650; font-size: .88rem; }
.surface-field-slider { position: relative; display: grid; min-width: 0; }
/* Faint tick at 0 (no change) on the signed Roughness / Metalness sliders. */
.surface-field-zero {
    position: absolute; left: 50%; top: 3px; bottom: 3px; width: 2px; margin-left: -1px; border-radius: 1px;
    background: rgba(220, 228, 245, .35); pointer-events: none;
}
.surface-field-slider input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer;
}
.surface-field-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 6px; border-radius: 3px;
    background: linear-gradient(90deg, rgba(126, 146, 190, .22) var(--from, 50%), var(--accent) var(--from, 50%), var(--accent) var(--to, 50%), rgba(126, 146, 190, .22) var(--to, 50%));
}
.surface-field-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border: 2px solid #1a1e27; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(126, 146, 190, .5);
}
.surface-field-slider input[type="range"]::-moz-range-track {
    height: 6px; border-radius: 3px;
    background: linear-gradient(90deg, rgba(126, 146, 190, .22) var(--from, 50%), var(--accent) var(--from, 50%), var(--accent) var(--to, 50%), rgba(126, 146, 190, .22) var(--to, 50%));
}
.surface-field-slider input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #1a1e27; border-radius: 50%; background: #fff; }
.surface-field-slider input[type="range"]:focus-visible { outline: 2px solid rgba(156, 124, 255, .72); outline-offset: 3px; border-radius: 6px; }
.surface-field-slider input[type="range"]:disabled { cursor: not-allowed; opacity: .45; }
.surface-field.is-off .surface-field-slider input[type="range"]::-webkit-slider-runnable-track { filter: grayscale(1); opacity: .55; }
.surface-field.is-off .surface-field-slider input[type="range"]::-moz-range-track { filter: grayscale(1); opacity: .55; }
.surface-field-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; }
.surface-field.is-off .surface-field-name { color: var(--muted-strong); }
.surface-popover .surface-field-number {
    flex: none; width: 64px; min-width: 0; height: 28px; min-height: 0; padding: 0 6px; border-radius: 7px;
    font-size: .84rem; font-variant-numeric: tabular-nums; text-align: right;
}
.surface-popover .surface-field-number.invalid { border-color: var(--danger); }
.surface-note { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.surface-note.is-blocked { color: var(--warning); }
.current-change-surface { color: var(--muted-strong); font-size: .85rem; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
    #cluster-inspector .cluster-slot-row {
        grid-template-columns: 42px 1fr 96px !important;
        grid-template-areas:
            "swatch name flags"
            "swatch friendly surface"
            "hex hex hex" !important;
    }
    #cluster-inspector .cluster-slot-surface-toggle { grid-area: surface; width: 36px; height: 30px; }
}

/* Phones: the pop-up becomes a sheet along the bottom edge, clear of the row it came from. */
@media (max-width: 600px) {
    .surface-popover:not(.hidden) { left: 10px !important; right: 10px; top: auto !important; bottom: 10px; width: auto; max-height: 70vh; }
}

/* Sync options: copy Blend Rate / Roughness / Metalness along with the color. */
.sync-surface-option { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; color: var(--muted-strong); font-size: .86rem; cursor: pointer; }
.sync-surface-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* Material-file Blend Rate / Roughness / Metalness rows in Current Changes have no color swatch. */
.current-change-picker-spacer { display: block; width: 42px; height: 1px; }
/* Color 1 settings kept in the mod's material file. */
.surface-note.is-default { color: var(--muted-strong); border-left: 2px solid var(--warning); padding-left: 10px; }

/* Color box resize grip (16 Nov): the box scrolls when its content is taller than the size you
   dragged it to, and an absolute grip scrolled away with the content. Keep it in the visible
   bottom-right corner instead. Negative margins take it out of the grid flow (gap + its own size)
   and into the box padding, so it sits where it always did when nothing scrolls. */
#custom-color-picker .color-picker-resize {
    position: sticky !important;
    right: auto !important;
    /* Sticky offsets are measured inside the box's 20px bottom padding: -17px = 3px from the edge. */
    bottom: -17px !important;
    justify-self: end;
    align-self: end;
    grid-column: 1 / -1;
    margin: -34px -11px -17px auto !important;
}

/* 3D preview texture detail option. */
.bp-check { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: .85rem; cursor: pointer; }
.bp-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* 3D preview: Blend Rate / Roughness / Metalness button under each slot swatch. */
.bp-slot-surface {
    position: relative; display: grid; place-items: center; width: 34px; height: 20px; min-height: 0; padding: 0; border-radius: 7px; cursor: pointer;
    box-sizing: border-box; color: var(--muted); background: transparent; border: 1px solid transparent; transition: background .12s, color .12s;
}
.bp-slot-surface .bp-icon { width: 14px; height: 14px; }
.bp-slot-surface:hover, .bp-slot-surface[aria-expanded="true"] { background: rgba(255, 255, 255, .08); color: var(--text); }
.bp-slot-surface:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bp-slot-surface.is-edited::after { content: ""; position: absolute; top: 2px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }

/* The floating 3D preview (z-index 1200) must not cover the color box, Surprise Me or the
   slot settings pop-up opened over it. */
body:has(.bp-stage.is-pinned) #custom-color-picker,
body:has(.bp-stage.is-pinned) .surprise-menu,
body:has(.bp-stage.is-pinned) .surface-popover { z-index: 1300; }

/* Surface pop-up (16 Nov): matching ⓘ / × icons on the title line, and the window can be dragged. */
.surface-popover-header { align-items: center; }
.surface-popover .surface-popover-close { font-size: 0; }
.surface-popover .surface-popover-close svg { width: 16px; height: 16px; }
.surface-popover .surface-popover-close:hover { color: var(--accent-hover); }
.surface-popover-header { cursor: grab; }
.surface-popover.is-dragging, .surface-popover.is-dragging * { cursor: grabbing !important; user-select: none; }
.surface-field-switch { cursor: default; }
.surface-field.is-off .surface-field-name { color: var(--muted); }
@media (max-width: 600px) { .surface-popover-header { cursor: default; } }
