/* Binary light/dark theme toggle */
#theme-toggle-wrap {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 99999;
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.92);
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
html.theme-dark-mode #theme-toggle-wrap {
    background: rgba(30,30,30,0.92);
    border-color: #444;
}
#theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    color: var(--text, #333);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
#theme-toggle:hover {
    background: var(--hover-bg, #f8f8f8);
    color: var(--accent, #00CCCC);
}
#theme-toggle:active {
    background: var(--hover-bg, #f8f8f8);
}
#theme-toggle:focus-visible {
    outline: 2px solid var(--accent, #00CCCC);
    outline-offset: 2px;
}
#theme-toggle[aria-pressed="true"] {
    color: var(--accent, #00CCCC);
}
.theme-toggle-icon {
    flex: 0 0 auto;
    font-size: 16px;
    line-height: 1;
}
.theme-toggle-label {
    white-space: nowrap;
}

body.lp #theme-toggle-wrap {
    top: auto;
    right: 20px;
    bottom: 18px;
}

/* ==========================================================================
   Тёмная тема: нативные элементы и скроллбары подчиняются переключателю.
   Правила общие (theme.css подключён на всех страницах), структура БД
   и серверные инструменты не затрагиваются.
   ========================================================================== */

/* color-scheme переключает нативную отрисовку: чекбоксы, радио, выпадающие
   списки <select>, каретку и системные скроллбары — сразу в тёмном виде. */
body.theme-dark-mode { color-scheme: dark; }

/* Скроллбары: Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border, #cfd8d8) transparent; }

/* Скроллбары: WebKit / Blink. Цвет берётся из переменных темы, которые
   пересчитывает theme.js, поэтому полосы меняются вместе с переключателем. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border, #cfd8d8);
    border: 2px solid transparent;
    border-radius: 8px;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent, #00CCCC);
    background-clip: content-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* Списки выбора и пикеры на /admin/assign-tests: трек в тон карточки */
body.theme-dark-mode select,
body.theme-dark-mode select[multiple],
body.theme-dark-mode .picker-list,
body.theme-dark-mode .table-wrap,
body.theme-dark-mode textarea { scrollbar-color: var(--border, #3c3c3c) var(--card-bg, #232323); }
body.theme-dark-mode select::-webkit-scrollbar-track,
body.theme-dark-mode .picker-list::-webkit-scrollbar-track,
body.theme-dark-mode .table-wrap::-webkit-scrollbar-track,
body.theme-dark-mode textarea::-webkit-scrollbar-track { background: var(--card-bg, #232323); }

/* Чекбоксы и радио: акцент + тёмная подложка */
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent, #00CCCC); }
body.theme-dark-mode input[type="checkbox"],
body.theme-dark-mode input[type="radio"] { color-scheme: dark; accent-color: var(--accent, #00CCCC); }
