/* Shared by the document shells and the modern modules with a shadow root. */
:where(:root, [data-theme="light"], .theme-light) {
    --jp-control-focus: #817000;
    --jp-control-selected-fill: #fcfbe8;
    --jp-control-selected-edge: rgb(190 166 8 / .62);
    --jp-control-selected-edge-soft: rgb(238 228 59 / .27);
    --jp-scroll-thumb: rgb(21 24 24 / .17);
    --jp-scroll-thumb-active: rgb(21 24 24 / .38);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --jp-control-focus: #d5c66a;
        --jp-control-selected-fill: #1c1a0c;
        --jp-control-selected-edge: rgb(238 228 59 / .62);
        --jp-control-selected-edge-soft: rgb(238 228 59 / .19);
        --jp-scroll-thumb: rgb(255 255 255 / .19);
        --jp-scroll-thumb-active: rgb(255 255 255 / .40);
    }
}

:where([data-theme="dark"], .theme-dark) {
    --jp-control-focus: #d5c66a;
    --jp-control-selected-fill: #1c1a0c;
    --jp-control-selected-edge: rgb(238 228 59 / .62);
    --jp-control-selected-edge-soft: rgb(238 228 59 / .19);
    --jp-scroll-thumb: rgb(255 255 255 / .19);
    --jp-scroll-thumb-active: rgb(255 255 255 / .40);
}

@supports selector(::-webkit-scrollbar) {
    :root { --jp-native-scroll-width: auto; }
}

/* Normalize legacy outlines without changing field borders, selected fills or overflow. */
@layer joyplan-interactions {
    :where(button, .btn, a.button, [role="button"], [role="tab"], [role="menuitem"], summary, input[type="button"], input[type="submit"], input[type="reset"]):focus:not(:focus-visible) {
        outline: none !important;
    }

    :where(.btn):focus:not(:focus-visible) {
        box-shadow: none !important;
    }

    :where(button, .btn, a.button, [role="button"], [role="tab"], [role="menuitem"], summary, input[type="button"], input[type="submit"], input[type="reset"]):focus-visible {
        outline: 2px solid var(--jp-control-focus, #817000) !important;
        outline-offset: 2px;
    }

    :where(button, .btn, a.button, [role="button"], [role="tab"], [role="menuitem"]):where([aria-pressed="true"], [aria-selected="true"], [aria-current="page"], .is-current, .is-selected, .active):not(:focus-visible) {
        outline-color: var(--jp-control-selected-edge, #c9b74d) !important;
        outline-width: 1px !important;
    }

    @media (forced-colors: active) {
        :where(button, .btn, a.button, [role="button"], [role="tab"], [role="menuitem"], summary, input[type="button"], input[type="submit"], input[type="reset"]):focus-visible {
            outline-color: Highlight !important;
        }

        :where(*) { scrollbar-color: auto !important; }
    }

    @media (forced-colors: none) {
        :where(*) {
            scrollbar-width: var(--jp-native-scroll-width, thin);
            scrollbar-color: var(--jp-scroll-thumb, rgb(21 24 24 / .17)) transparent !important;
        }

        @supports selector(::-webkit-scrollbar) {
            :where(*) { scrollbar-color: auto !important; }
            :where(*)::-webkit-scrollbar { width: 5px !important; height: 5px !important; }
            :where(*)::-webkit-scrollbar-track,
            :where(*)::-webkit-scrollbar-corner { background: transparent !important; }
            :where(*)::-webkit-scrollbar-thumb {
                background: var(--jp-scroll-thumb, rgb(21 24 24 / .17)) !important;
                border: 0 !important;
                border-radius: 999px;
            }
            :where(*)::-webkit-scrollbar-thumb:hover,
            :where(*)::-webkit-scrollbar-thumb:active {
                background: var(--jp-scroll-thumb-active, rgb(21 24 24 / .38)) !important;
            }
        }

        @media (max-width: 768px) {
            :where(*) { scrollbar-width: none !important; }
            :where(*)::-webkit-scrollbar { display: none !important; }
        }
    }
}
