/* The screen palettes extend the existing W005 surfaces and brand accents. */
@media screen {
    body.shiftflow[data-palette="sand"],
    .shiftflow .shift-theme-sample[data-palette="sand"] {
        --sidebar-bg: #33281e;
        --canvas: #f6e9d1;
        --header-bg: #fbf1df;
        --card-bg: #fff8ea;
        --modal-bg: #fff6e4;
        --raised: #eeddbd;
        --card-border: #c8b68f;
        --input-bg: #fcf1dc;
        --text-color: #372c20;
        --text-muted: #665440;
    }

    body.shiftflow[data-palette="mint"],
    .shiftflow .shift-theme-sample[data-palette="mint"] {
        --sidebar-bg: #17372d;
        --canvas: #def1e7;
        --header-bg: #ebf8f1;
        --card-bg: #f4fdf8;
        --modal-bg: #f0fcf5;
        --raised: #cfe8da;
        --card-border: #a6c9b6;
        --input-bg: #eaf8f0;
        --text-color: #19382b;
        --text-muted: #415e50;
    }

    body.shiftflow[data-palette="sky"],
    .shiftflow .shift-theme-sample[data-palette="sky"] {
        --sidebar-bg: #1b3047;
        --canvas: #dfedfb;
        --header-bg: #ebf5ff;
        --card-bg: #f5faff;
        --modal-bg: #f0f7ff;
        --raised: #cddff1;
        --card-border: #a2bfd8;
        --input-bg: #e8f2fc;
        --text-color: #1d344b;
        --text-muted: #455d74;
    }

    body.shiftflow[data-palette="lavender"],
    .shiftflow .shift-theme-sample[data-palette="lavender"] {
        --sidebar-bg: #35273e;
        --canvas: #ede3f8;
        --header-bg: #f5eefa;
        --card-bg: #fbf8fe;
        --modal-bg: #f9f3ff;
        --raised: #e2d4ef;
        --card-border: #c4afd5;
        --input-bg: #f3ebfa;
        --text-color: #35273f;
        --text-muted: #63516d;
    }

    body.shiftflow[data-palette="navy"],
    .shiftflow .shift-theme-sample[data-palette="navy"] {
        --canvas: #111e32;
        --header-bg: #0c1728;
        --card-bg: #1a2b45;
        --modal-bg: #1d304a;
        --raised: #253b57;
        --card-border: #475e79;
        --input-bg: #12233b;
        --text-color: #eff5ff;
        --text-muted: #c1d0e1;
    }

    body.shiftflow[data-palette="forest"],
    .shiftflow .shift-theme-sample[data-palette="forest"] {
        --canvas: #10251d;
        --header-bg: #0c1c17;
        --card-bg: #1b3328;
        --modal-bg: #1f392d;
        --raised: #294837;
        --card-border: #476452;
        --input-bg: #152b22;
        --text-color: #ecf8ee;
        --text-muted: #bdd5c4;
    }

    body.shiftflow[data-palette="plum"],
    .shiftflow .shift-theme-sample[data-palette="plum"] {
        --canvas: #2b1b31;
        --header-bg: #211526;
        --card-bg: #38253e;
        --modal-bg: #3d2943;
        --raised: #4b3252;
        --card-border: #6f5175;
        --input-bg: #302035;
        --text-color: #f9effb;
        --text-muted: #d9c0dc;
    }

    body.shiftflow[data-palette="mocha"],
    .shiftflow .shift-theme-sample[data-palette="mocha"] {
        --canvas: #2c211c;
        --header-bg: #221a16;
        --card-bg: #392c24;
        --modal-bg: #3e3028;
        --raised: #4c392d;
        --card-border: #705848;
        --input-bg: #31251f;
        --text-color: #f9f2e9;
        --text-muted: #dfc8b6;
    }

    /* The default pair takes its application colors from w005.css. */
    .shiftflow .shift-theme-sample[data-palette="dark"] {
        --canvas: #19191c;
        --raised: #303035;
        --text-muted: #bbb9c2;
    }
    body.shiftflow[data-palette="light"],
    .shiftflow .shift-theme-sample[data-palette="light"] { --sidebar-bg: #151518; }
    .shiftflow .shift-theme-sample[data-palette="light"] {
        --canvas: #f3f2f5;
        --raised: #efedf2;
        --text-muted: #595460;
    }

    /* AutoFlow keeps the navigation dark beside each light workspace. */
    .shiftflow.theme-light #sidebar {
        --header-bg: var(--sidebar-bg, #151518);
        --card-bg: #232326;
        --card-border: #414147;
        --raised: #28272c;
        --text-color: #f6f5f3;
        --text-muted: #c5c3c7;
        --accent-text: #d7a9ff;
        --selected: #382745;
        color: var(--text-color);
        color-scheme: dark;
    }
    .shiftflow.theme-light #sidebar .brand { background: var(--header-bg); }
    .shiftflow.theme-light #sidebar .nav-group-label { opacity: 1; }
    .shiftflow.theme-light #sidebar .nav-item {
        color: #c5c3cd;
        border: 1px solid transparent;
    }
    .shiftflow.theme-light #sidebar .nav-item:hover {
        color: var(--text-color);
        border-color: #44414a;
    }
    .shiftflow.theme-light #sidebar .nav-item.active {
        color: var(--accent-text);
        border-color: #9262b4;
    }
    .shiftflow .shift-theme-groups [data-scheme="light"] .shift-theme-sample {
        background: linear-gradient(to right, var(--sidebar-bg) 25%, var(--canvas) 25%);
    }

    .shiftflow #shift-theme-dialog {
        box-sizing: border-box;
        width: min(480px, calc(100% - 24px));
        max-width: none;
        max-height: calc(100% - 24px);
        max-height: calc(100dvh - 24px);
        margin: auto;
        padding: 20px;
        overflow: auto;
        overscroll-behavior: contain;
        border: 1px solid var(--card-border);
        border-radius: 14px;
        color: var(--text-color);
        background: var(--modal-bg);
        box-shadow: 0 16px 54px #0005;
    }
    .shiftflow #shift-theme-dialog::backdrop { background: #0c0b108a; }
    .shiftflow .shift-theme-heading {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 14px;
    }
    .shiftflow .shift-theme-heading h2 {
        margin: 0;
        color: var(--text-color);
        font-size: 1.25rem;
        line-height: 1.3;
    }
    .shiftflow .shift-theme-close {
        width: 40px;
        height: 40px;
        padding: 0;
        border: 1px solid var(--card-border);
        border-radius: 7px;
        background: var(--card-bg);
        color: var(--text-color);
        font-size: 1.5rem;
        line-height: 1;
        cursor: pointer;
    }
    .shiftflow .shift-theme-close:hover { background: var(--raised); }
    .shiftflow .shift-theme-groups {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
    .shiftflow .shift-theme-groups fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
    .shiftflow .shift-theme-groups legend {
        padding: 0;
        margin-bottom: 8px;
        color: var(--text-muted);
        font-size: .83rem;
        font-weight: 650;
    }
    .shiftflow .shift-theme-choice {
        box-sizing: border-box;
        display: grid;
        grid-template-columns: 37px minmax(0, 1fr) 16px;
        align-items: center;
        gap: 9px;
        min-height: 48px;
        padding: 5px 10px;
        border: 1px solid var(--card-border);
        border-radius: 7px;
        background: var(--card-bg);
        color: var(--text-color);
        font-size: .87rem;
        line-height: 1.2;
        cursor: pointer;
    }
    .shiftflow .shift-theme-choice + .shift-theme-choice { margin-top: 6px; }
    .shiftflow .shift-theme-choice:hover { background: var(--raised); }
    .shiftflow .shift-theme-choice:has(:checked) {
        background: var(--selected);
        color: var(--accent-text);
        border-color: var(--accent-text);
        font-weight: 650;
    }
    .shiftflow .shift-theme-choice input {
        width: 15px;
        height: 15px;
        margin: 0;
        accent-color: var(--accent-text);
        cursor: pointer;
    }
    .shiftflow .shift-theme-choice:has(:focus-visible) {
        outline: 2px solid var(--accent-text);
        outline-offset: 2px;
    }
    .shiftflow .shift-theme-sample {
        position: relative;
        box-sizing: border-box;
        width: 100%;
        height: 27px;
        overflow: hidden;
        border: 1px solid color-mix(in srgb, var(--text-muted) 52%, var(--canvas));
        border-radius: 4px;
        background: linear-gradient(to right, var(--raised) 25%, var(--canvas) 25%);
    }
    .shiftflow .shift-theme-sample::after {
        content: "";
        position: absolute;
        top: 28%;
        left: 37%;
        width: 46%;
        height: 2px;
        background: var(--text-muted);
        box-shadow: 0 5px var(--text-muted);
    }
}
@media screen and (max-width: 420px) {
    .shiftflow #shift-theme-dialog { padding: 14px; }
    .shiftflow .shift-theme-groups { gap: 9px; }
    .shiftflow .shift-theme-choice {
        grid-template-columns: 26px minmax(0, 1fr) 15px;
        gap: 5px;
        padding-inline: 6px;
    }
    .shiftflow .shift-theme-sample { height: 22px; }
}
@media print {
    .shiftflow #shift-theme-dialog, .shiftflow #shift-theme-dialog::backdrop { display: none; }
}
