/* Shared scrollbars for page, menu, and component scrolling. */
:root {
    --scrollbar-track: #f7eeff;
    --scrollbar-thumb: #9948e8;
    --scrollbar-thumb-hover: #7434b1;
}

:root,
:root * {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.bg_secondary2,
.dark {
    --scrollbar-track: #482263;
    --scrollbar-thumb: #c77fff;
    --scrollbar-thumb-hover: #e5caff;
}

/* WebKit fallback also overrides older component-specific grey tracks. */
html:root::-webkit-scrollbar,
html:root *:not(.stage_main_div)::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html:root::-webkit-scrollbar-track,
html:root *::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

html:root::-webkit-scrollbar-thumb,
html:root *::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 2px solid var(--scrollbar-track);
    border-radius: 999px;
    min-height: 32px;
}

html:root::-webkit-scrollbar-thumb:hover,
html:root *::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

html:root::-webkit-scrollbar-corner,
html:root *::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

/* These panels intentionally hide their scrollbar in the existing design. */
.stage_main_div {
    scrollbar-width: none;
}

@media (forced-colors: active) {
    :root,
    :root * {
        scrollbar-color: auto;
    }
}

/* The page scrollbar overlays content; only component scrollbars reserve space. */
html:root.has-overlay-scrollbar {
    scrollbar-width: none;
}

html:root.has-overlay-scrollbar::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.site-scrollbar {
    position: fixed;
    inset: 0 0 0 auto;
    width: 10px;
    z-index: 100001;
    background: transparent;
    touch-action: none;
}

.site-scrollbar[hidden] {
    display: none;
}

.site-scrollbar__thumb {
    position: absolute;
    top: 0;
    right: 2px;
    width: 6px;
    border-radius: 999px;
    background: #9948e8;
    cursor: grab;
}

.site-scrollbar:hover .site-scrollbar__thumb,
.site-scrollbar:focus-visible .site-scrollbar__thumb {
    background: #7434b1;
}

.site-scrollbar:focus-visible {
    outline: 2px solid #c77fff;
    outline-offset: -2px;
}

html.is-scrollbar-dragging {
    user-select: none;
}

html.is-scrollbar-dragging .site-scrollbar__thumb {
    cursor: grabbing;
}

@media (forced-colors: active) {
    html:root.has-overlay-scrollbar {
        scrollbar-width: auto;
    }

    html:root.has-overlay-scrollbar::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }

    .site-scrollbar {
        display: none;
    }
}
