/* Shared scrollbar palette for full pages, nested panes, dialogs and textareas.
   Keep component widths/hidden rails intact; only their colors share tokens. */
:root {
    --rw-scrollbar-thumb: #697382;
    --rw-scrollbar-thumb-hover: #939dab;
    --rw-scrollbar-track: transparent;
    --rw-scrollbar-scheme: dark;
}
:root[data-scrollbar-default="light"] {
    --rw-scrollbar-thumb: #8a94a3;
    --rw-scrollbar-thumb-hover: #606c7d;
    --rw-scrollbar-scheme: light;
}
/* The compositor follows the OS until the user/parent explicitly sets a theme. */
@media (prefers-color-scheme: dark) {
    :root[data-scrollbar-default="system"] {
        --rw-scrollbar-thumb: #697382;
        --rw-scrollbar-thumb-hover: #939dab;
        --rw-scrollbar-scheme: dark;
    }
}
@media (prefers-color-scheme: light) {
    :root[data-scrollbar-default="system"] {
        --rw-scrollbar-thumb: #8a94a3;
        --rw-scrollbar-thumb-hover: #606c7d;
        --rw-scrollbar-scheme: light;
    }
}
:root:is(.theme-dark, .dark, [data-theme="dark"], [data-bs-theme="dark"]),
:root:has(> body:is(.theme-dark, .dark, [data-theme="dark"], [data-bs-theme="dark"])) {
    --rw-scrollbar-thumb: #697382;
    --rw-scrollbar-thumb-hover: #939dab;
    --rw-scrollbar-scheme: dark;
}
:root:is(.light, .theme-light, [data-theme="light"], [data-bs-theme="light"]),
:root:has(> body:is(.light, .theme-light, [data-theme="light"], [data-bs-theme="light"])) {
    --rw-scrollbar-thumb: #8a94a3;
    --rw-scrollbar-thumb-hover: #606c7d;
    --rw-scrollbar-scheme: light;
}
/* Root must follow body-only themes too, otherwise the viewport keeps a white rail. */
:where(html, body) { color-scheme: var(--rw-scrollbar-scheme); }
:where(*) {
    scrollbar-width: thin;
    scrollbar-color: var(--rw-scrollbar-thumb) var(--rw-scrollbar-track);
}
:where(*)::-webkit-scrollbar { width: 8px; height: 8px; }
:where(*)::-webkit-scrollbar-track,
:where(*)::-webkit-scrollbar-track-piece,
:where(*)::-webkit-scrollbar-corner { background: var(--rw-scrollbar-track); }
:where(*)::-webkit-scrollbar-thumb {
    background: var(--rw-scrollbar-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}
:where(*)::-webkit-scrollbar-thumb:hover { background-color: var(--rw-scrollbar-thumb-hover); }
:where(*)::-webkit-scrollbar-button { display: none; }
/* Let the OS supply its high-contrast palette instead of forcing brand grays. */
@media (forced-colors: active) {
    * { scrollbar-color: auto !important; }
    *::-webkit-scrollbar-thumb { background: ButtonText !important; }
    *::-webkit-scrollbar-track,
    *::-webkit-scrollbar-track-piece,
    *::-webkit-scrollbar-corner { background: Canvas !important; }
}
