/* ──────────────────────────────────────────────────────────────────────────
   Единая тема платформы. Класс theme-dark/theme-light выставляется на <html> и
   <body> (см. theme.js + инлайн-бутстрап в base-шаблонах). Тёмная тема:
   1) переопределяем токены обоих шеллов (студенческий base.html и teacher/base.html
      уже используют CSS-переменные) → большинство стилей темнеют «само»;
   2) точечные оверрайды для захардкоженных мест шапок/сайдбаров;
   3) оверрайды Bootstrap-компонентов (студенческий base их использует).
   Палитра согласована с эфиром/домашкой/доской.
   ────────────────────────────────────────────────────────────────────────── */

/* Анти-мигание: фон страницы до загрузки CSS страницы. */
html.theme-dark { background: #0d1117; }
html.theme-dark body { background: #0d1117; }
/* Нативные select/date/time в тёмной теме:
   - color-scheme:dark на самом элементе переводит нативные попапы браузера в
     тёмную палитру. Ставим явно, чтобы не зависеть от наследования (у контролов
     задан свой фон).
   - option background/color — для Chrome/Firefox (там color-scheme не всегда красит). */
.theme-dark select, .theme-dark input[type="date"], .theme-dark input[type="time"] { color-scheme: dark; }
.theme-dark select option, .theme-dark select optgroup { background: #161b22; color: #e6edf3; }
/* Примечание: на macOS Chrome/Safari рисуют ВЫПАДАЮЩИЙ список <select> нативным
   контролом ОС, который следует системной теме macOS и игнорирует CSS/color-scheme
   страницы. Полностью затемнить popup на macOS-light можно только заменой select на
   кастомный дропдаун. Правила выше работают на платформах, где popup рисует браузер. */

/* ── 1. Тёмные значения токенов (имена — как в обоих base) ── */
.theme-dark {
  --bg:         #0d1117;
  --bg-light:   #161b22;
  --block-bg:   #161b22;
  --card-bg:    #1a2030;
  --card-hover: #21262d;
  --card-text:  #c4b5fd;
  --tab-active: #1f2937;
  --tab-border: #30363d;
  --tab-hover:  #21262d;
  --accent:     #bc8cff;
  --accent-h:   #cdb4ff;
  --accent-soft:#21262d;
  --accent-soft-h:#2b3340;
  --btn-bg:     #21262d;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --text-soft:  #8b949e;
  --border:     #30363d;
  --card-border:#30363d;
  --danger:     #ff7b72;
  --danger-bg:  #3a1d1d;
  --danger-bg-h:#4a2424;
  --danger-border:#5c2626;
  --primary-bg: #14301f;
  --primary-bg-h:#1d422b;
  --primary-text:#7ee787;
  --primary-border:#1f5132;
}

/* ── 2. Шеллы: захардкоженные цвета ── */
/* Студенческий (s-*) */
.theme-dark body { background: var(--bg); color: var(--text); }
.theme-dark .s-topbar { background: #161b22; border-bottom-color: #30363d; }
.theme-dark .s-topbar-right { color: #adb6c2; }
.theme-dark .s-logout { background: #21262d; border-color: #30363d; color: #cdd9e5; }
.theme-dark .s-logout:hover { background: #2b3340; }
.theme-dark .s-burger span { background: #adb6c2 !important; }
.theme-dark .s-sidebar { background: #161b22; border-right-color: #30363d; }
.theme-dark .s-nav-item { color: #adb6c2; }
.theme-dark .s-nav-item:hover { background: #21262d; color: #e6edf3; }
.theme-dark .s-nav-item.active { background: #1f2937; color: #bc8cff; }
.theme-dark .s-overlay { background: rgba(0,0,0,.55); }

/* Учительский (t-*) */
.theme-dark .t-topbar { background: #161b22; border-bottom-color: #30363d; }
.theme-dark .t-topbar-right { color: #adb6c2; }
.theme-dark .t-username { color: #bc8cff; }
.theme-dark .btn-logout { background: #21262d; border-color: #30363d; color: #cdd9e5; }
.theme-dark .btn-logout:hover { background: #2b3340; }
.theme-dark .t-burger span { background: #adb6c2 !important; }
.theme-dark .t-sidebar { background: #161b22; border-right-color: #30363d; }
.theme-dark .t-nav-item { color: #adb6c2; }
.theme-dark .t-nav-item:hover { background: #21262d; color: #e6edf3; }
.theme-dark .t-nav-item.active { background: #1f2937; color: #bc8cff; }
.theme-dark .t-overlay { background: rgba(0,0,0,.55); }

/* ── 3. Кнопка-переключатель темы ── */
.theme-toggle {
  flex-shrink: 0; width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1.5px solid #d8dee4; border-radius: 8px;
  color: #6b7280; cursor: pointer; transition: all .12s;
}
.theme-toggle:hover { border-color: #8b5cf6; color: #5a3e8a; background: #f3eeff; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-dark .theme-toggle { background: #21262d; border-color: #30363d; color: #e6b85c; }
.theme-dark .theme-toggle:hover { border-color: #6366f1; color: #ffd479; background: #1f2d3d; }

/* ── 4. Bootstrap-компоненты (студенческий base их использует) ── */
.theme-dark .card,
.theme-dark .list-group-item,
.theme-dark .modal-content,
.theme-dark .dropdown-menu,
.theme-dark .accordion-item,
.theme-dark .accordion-button {
  background-color: #161b22; color: #e6edf3; border-color: #30363d;
}
.theme-dark .accordion-button:not(.collapsed) { background-color: #1f2937; color: #bc8cff; }
.theme-dark .card-header, .theme-dark .card-footer { background-color: #1b2230; border-color: #30363d; }
.theme-dark .dropdown-item { color: #cdd9e5; }
.theme-dark .dropdown-item:hover, .theme-dark .dropdown-item:focus { background-color: #21262d; color: #fff; }
.theme-dark .table { --bs-table-bg: transparent; color: #e6edf3; border-color: #30363d; }
.theme-dark .table > :not(caption) > * > * { border-color: #30363d; background-color: transparent; color: #e6edf3; }
.theme-dark .table-hover > tbody > tr:hover > * { background-color: #1f2937; color: #fff; }
.theme-dark .table thead th { border-color: #30363d; color: #adb6c2; }
.theme-dark .form-control, .theme-dark .form-select, .theme-dark textarea, .theme-dark input[type="text"],
.theme-dark input[type="email"], .theme-dark input[type="password"], .theme-dark input[type="search"],
.theme-dark input[type="number"], .theme-dark input[type="date"], .theme-dark input[type="time"] {
  background-color: #0d1117; border-color: #30363d; color: #e6edf3;
}
.theme-dark .form-control::placeholder, .theme-dark textarea::placeholder { color: #6e7681; }
.theme-dark .form-control:focus, .theme-dark .form-select:focus {
  background-color: #0d1117; border-color: #6366f1; color: #e6edf3;
  box-shadow: 0 0 0 .2rem rgba(99,102,241,.25);
}
.theme-dark .form-check-input { background-color: #0d1117; border-color: #30363d; }
.theme-dark .form-check-input:checked { background-color: #8b5cf6; border-color: #8b5cf6; }
.theme-dark .btn-light, .theme-dark .btn-outline-secondary { background-color: #21262d; border-color: #30363d; color: #cdd9e5; }
.theme-dark .btn-light:hover, .theme-dark .btn-outline-secondary:hover { background-color: #2b3340; color: #fff; }
.theme-dark .btn-outline-primary { color: #bc8cff; border-color: #6366f1; }
.theme-dark .btn-outline-primary:hover { background-color: #6366f1; color: #fff; }
.theme-dark .text-muted { color: #8b949e !important; }
.theme-dark .bg-white, .theme-dark .bg-light { background-color: #161b22 !important; }
.theme-dark .border, .theme-dark .border-top, .theme-dark .border-bottom,
.theme-dark .border-start, .theme-dark .border-end { border-color: #30363d !important; }
.theme-dark hr { border-color: #30363d; }
.theme-dark .badge.bg-light { color: #cdd9e5 !important; }
.theme-dark .alert-secondary { background-color: #21262d; border-color: #30363d; color: #cdd9e5; }
.theme-dark .modal-header, .theme-dark .modal-footer { border-color: #30363d; }
.theme-dark .close, .theme-dark .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* ── 4b. Фоллбэки для частых инлайн-фонов страниц (style="background:#fff" и
   светло-серые контейнеры). Перебивают инлайн через !important. Светло-серые
   почти всегда панели/фон — затемнять безопасно; чистый белый — контейнеры. ── */
.theme-dark [style*="#f6f8fa"], .theme-dark [style*="#f7f7fb"], .theme-dark [style*="#f7f4fb"],
.theme-dark [style*="#fafafd"], .theme-dark [style*="#f9f9fb"], .theme-dark [style*="#f5f0fc"],
.theme-dark [style*="#fafafa"], .theme-dark [style*="#f4f4f7"], .theme-dark [style*="#f8f8fb"],
.theme-dark [style*="#f3eeff"], .theme-dark [style*="#ededf5"] { background-color: #161b22 !important; }
.theme-dark [style*="background:#fff"], .theme-dark [style*="background: #fff"],
.theme-dark [style*="background:#ffffff"], .theme-dark [style*="background: #ffffff"],
.theme-dark [style*="background-color:#fff"], .theme-dark [style*="background-color: #fff"],
.theme-dark [style*="background:white"], .theme-dark [style*="background-color:white"] {
  background-color: #161b22 !important;
}
.theme-dark :is(.ql-editor,.ql-content,.task-desc,.task-description,.code-solution,.solv-pane) [style*="background-color: rgb(255, 255, 255)"],
.theme-dark :is(.ql-editor,.ql-content,.task-desc,.task-description,.code-solution,.solv-pane) [style*="background: rgb(255, 255, 255)"] {
  background-color: #0d1117 !important;
}
/* частые тёмные инлайн-цвета текста на белом — осветляем, чтобы читалось */
.theme-dark [style*="color:#111"], .theme-dark [style*="color:#222"], .theme-dark [style*="color:#333"],
.theme-dark [style*="color: #111"], .theme-dark [style*="color: #222"], .theme-dark [style*="color: #333"],
.theme-dark [style*="color:#000"], .theme-dark [style*="color: #000"],
.theme-dark [style*="color:#1f23"], .theme-dark [style*="color:#1a1a"] { color: #e6edf3 !important; }

/* ── 4c. Карточки/секции учительских страниц (одинаковая палитра #fff/#ececf3/
   #fafafd по многим страницам — темним централизованно: ученики, работы, выдача,
   банк заданий, планы, проверка). ── */
.theme-dark .st-card, .theme-dark .tp-card, .theme-dark .tk-card, .theme-dark .tk-filter-card,
.theme-dark .wf-card, .theme-dark .wt-card, .theme-dark .gt-card, .theme-dark .gt-answer,
.theme-dark .gt-grade-form, .theme-dark .wl-left, .theme-dark .wl-right, .theme-dark .at-card,
.theme-dark .sd-card, .theme-dark .pk-card, .theme-dark .pk-summary,
.theme-dark .pk-filter-card {
  background: #161b22 !important; border-color: #30363d !important; color: #e6edf3;
}
.theme-dark .stu-body { background: #0d1117 !important; border-top-color: #30363d !important; }
.theme-dark .stu-body .st-card { background: #161b22 !important; }
.theme-dark .tk-section { background: #1a2030 !important; border-color: #30363d !important; }
.theme-dark .tk-section .tk-section-body { background: #161b22 !important; border-top-color: #30363d !important; }
.theme-dark .wt-tabs { background: #1a2030 !important; border-bottom-color: #30363d !important; }
.theme-dark .wt-num { background: #21262d !important; color: #cdd9e5 !important; }
.theme-dark .st-empty, .theme-dark .tk-empty, .theme-dark .wf-empty { background: #161b22 !important; border-color: #30363d !important; color: #8b949e !important; }
.theme-dark .topic-row { background: #161b22 !important; border-bottom-color: #30363d !important; }
.theme-dark .tp-groups-toggle { background: #161b22 !important; border-color: #30363d !important; }
/* код/логин-чипы со светлой подложкой */
.theme-dark .stu-login, .theme-dark .sd-sub .stu-login { background: #2a2150 !important; color: #c4b5fd !important; }
.theme-dark .tk-code { background: #21262d !important; color: #adb6c2 !important; }
/* Чип типа работы используется в списке работ, выдаче и проверке ответов. */
.work-type-badge, .ga-work-code {
  display:inline-block; font-size:.72rem; font-weight:600; padding:1px 7px;
  border-radius:4px; white-space:nowrap; flex-shrink:0;
}
.work-type-badge--lesson    { background:#d8f0e8; color:#1e5c40; }
.work-type-badge--trial     { background:#fde8e8; color:#8a1a1a; }
.work-type-badge--trial-oge { background:#ede8f8; color:#5a3e8a; }
.work-type-badge--homework  { background:#dde8f8; color:#3b4a70; }
.ga-work-code { background:#f4f4f7; color:#9aa3b2; letter-spacing:.02em; }
.theme-dark .work-type-badge--lesson    { background:#14301f; color:#7ee787; }
.theme-dark .work-type-badge--trial     { background:#2a1416; color:#ff7b72; }
.theme-dark .work-type-badge--trial-oge { background:#2a2150; color:#c4b5fd; }
.theme-dark .work-type-badge--homework  { background:#1e2633; color:#8fa8d9; }
.theme-dark .ga-work-code { background:#21262d; color:#adb6c2; }
/* светлые «призрачные» кнопки на карточках */
.theme-dark .st-cancel, .theme-dark .wf-cancel, .theme-dark .wf-delete,
.theme-dark .tk-fbtn-ghost, .theme-dark .tk-fbtn-more, .theme-dark .tk-btn-edit,
.theme-dark .tk-btn-danger, .theme-dark .tk-btn-ghost {
  background: #21262d !important; border-color: #30363d !important;
}
/* строки/наведение внутри карточек */
.theme-dark .wt-card:hover, .theme-dark .st-card:hover, .theme-dark .tk-card:hover { border-color: #6366f1 !important; }

/* ── Конструктор состава работы: эти элементы рендерятся в ветке `sub=create`,
   поэтому стили списка работ до них не доходят. Без явных тёмных цветов белая
   панель фильтров и чёрные названия заданий были почти нечитаемы. ── */
.theme-dark .pk-breadcrumb .current, .theme-dark .pk-title { color: #e6edf3; }
.theme-dark .pk-breadcrumb a, .theme-dark .pk-breadcrumb .sep,
.theme-dark .pk-comment, .theme-dark .pk-filter-count { color: #adb6c2; }
.theme-dark .pk-filter-grid label { color: #adb6c2; }
.theme-dark .pk-card.in-work { background: #1c2030 !important; border-color: #6366f1 !important; }
.theme-dark .pk-code { background: #21262d; color: #adb6c2; }
.theme-dark .pk-sub-chip { background: #2a2150; color: #c4b5fd; }
.theme-dark .pk-bg.type   { background: #1e2633; color: #8fa8d9; }
.theme-dark .pk-bg.auto   { background: #14301f; color: #6ee787; }
.theme-dark .pk-bg.manual { background: #2e2510; color: #e3b34d; }
.theme-dark .pk-bg.points { background: #251c40; color: #c4b5fd; }
.theme-dark .pk-bg.stars  { background: #211c10; color: #f5a623; border-color: #5c4a1e; }
.theme-dark .pk-desc, .theme-dark .pk-card .wt-tab-content { color: #c9d1d9; }
.theme-dark .pk-fbtn-ghost, .theme-dark .pk-remove-btn {
  background: #21262d; color: #c4b5fd; border-color: #3a2a52;
}
.theme-dark .pk-fbtn-ghost:hover, .theme-dark .pk-remove-btn:hover {
  background: #2a2150; border-color: #6366f1;
}
.theme-dark .pk-section, .theme-dark .pk-section .pk-section-body {
  background: #161b22; border-color: #30363d;
}
.theme-dark .pk-section summary { color: #c4b5fd; }
.theme-dark .pk-section summary:hover { background: #2a2150; }
.theme-dark .pk-inline-warn, .theme-dark .we-inline-warn {
  background: #2e2510; border-color: #5c4a1e; color: #e3b34d;
}

/* ── 4d. Осветляем «текстовые» элементы ВНУТРИ затемнённых карточек, чтобы не
   было чёрного текста на тёмном. Берём только нейтральные текстовые теги; цветные
   бейджи/чипы/кнопки/ссылки (span/a/div с собственным цветом) не трогаем. ── */
.theme-dark :is(.st-card,.tp-card,.tk-card,.tk-filter-card,.wf-card,.wt-card,.gt-card,
  .gt-answer,.gt-grade-form,.wl-left,.wl-right,.at-card,.sd-card,.pk-card,.stu-body)
  :is(h1,h2,h3,h4,h5,h6,p,label,th,td,strong,b,small,li,dt,dd) {
  color: #e6edf3;
}

/* ── 4e. Глобально затемняем поля форм (в тёмной теме все инпуты/селекты тёмные).
   !important — перебить per-page .xxx select{background:#fff}; заодно убирает
   «штриховку» нативных селектов, которая была от color-scheme. ── */
.theme-dark select,
.theme-dark input[type="text"], .theme-dark input[type="search"], .theme-dark input[type="email"],
.theme-dark input[type="password"], .theme-dark input[type="url"], .theme-dark input[type="number"],
.theme-dark input[type="tel"], .theme-dark input[type="date"], .theme-dark input[type="time"],
.theme-dark input:not([type]), .theme-dark textarea {
  background-color: #0d1117 !important; color: #e6edf3 !important; border-color: #30363d !important;
}
/* Селекты: одна стрелка без повтора (иначе на тёмном фоне иконка тайлится в
   «зигзаг»-штриховку) + appearance:none, чтобы iOS не рисовал нативный контрол. */
.theme-dark select {
  -webkit-appearance: none !important; appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  padding-right: 30px;
}
.theme-dark select option { background-color: #161b22; color: #e6edf3; }
.theme-dark ::placeholder { color: #6e7681 !important; }

/* ── 4f. Редактор Quill (rich-text) в тёмной теме — используется на нескольких
   страницах (банк заданий, решения, материалы). ── */
.theme-dark .ql-editor-wrap, .theme-dark .sv-solution-wrap { background: #0d1117 !important; }
.theme-dark .ql-toolbar.ql-snow { background: #161b22; border-color: #30363d; }
.theme-dark .ql-container.ql-snow { border-color: #30363d; }
.theme-dark .ql-editor { background: #0d1117; color: #e6edf3; }
.theme-dark .ql-editor.ql-blank::before { color: #6e7681; }
.theme-dark .ql-snow .ql-stroke { stroke: #adb6c2; }
.theme-dark .ql-snow .ql-fill { fill: #adb6c2; }
.theme-dark .ql-snow .ql-picker { color: #adb6c2; }
.theme-dark .ql-snow .ql-picker-options { background: #161b22; border-color: #30363d; }
.theme-dark .ql-toolbar.ql-snow button:hover .ql-stroke,
.theme-dark .ql-toolbar.ql-snow button.ql-active .ql-stroke { stroke: #bc8cff; }

/* ── 4g. Блоки кода py-code в тёмной теме (прозрачные варианты с !important
   останутся прозрачными — они вложены в уже тёмные карточки). ── */
.theme-dark .py-code { background: #0d1117; color: #e6edf3; border-color: #30363d; }
/* Подсветка Python (инлайн-цвета из assignment_tags.py) адаптируется под тёмный фон —
   глобально, чтобы код в решении был ярко подсвечен ВЕЗДЕ: банк, проверка, домашки,
   страница ученика. Селектор .theme-dark матчит класс и на html, и на body. */
.theme-dark .py-code span[style*="#8c52ff"] { color: #bc8cff !important; }  /* keyword / op */
.theme-dark .py-code span[style*="#ff66c4"] { color: #ff8eda !important; }  /* function / builtin */
.theme-dark .py-code span[style*="#ff751f"] { color: #ffb074 !important; }  /* number */
.theme-dark .py-code span[style*="#0cc0df"] { color: #56d4ea !important; }  /* string */
.theme-dark .py-code span[style*="#0097b2"] { color: #5ec4d4 !important; }  /* method */
.theme-dark .py-code span[style*="#6a9a4a"] { color: #7ee787 !important; }  /* comment */
.theme-dark .py-code span[style*="#1a1a1a"] { color: #e6edf3 !important; }  /* variable (был чёрный = невидим) */

/* ── 4h. Превью интерактивов — это светлые мини-снимки самих упражнений. НЕ
   применяем к ним тёмные оверрайды: внутри оставляем тёмный текст на светлом
   фоне (как в исходном превью), иначе текст сливается. ── */
.theme-dark .preview-thumb * { background-color: transparent !important; color: #2b2b3a !important; }
.theme-dark .preview-thumb [class*="code"], .theme-dark .preview-thumb code { color: #2b2b3a !important; }

/* ── 4i. Текст условия задач (Quill-HTML) — базовый цвет от контейнера.
   Цветные выделения автора не перебиваем; ниже точечно лечим только чёрный текст. */
.theme-dark .task-desc, .theme-dark .task-description, .theme-dark .ql-content,
.theme-dark .solv-pane { color: #e6edf3; }
/* Чипы вариантов решения (стиль инъектится из JS — перебиваем по специфичности) */
.theme-dark .solv-chip { background: #21262d; border-color: #30363d; color: #c4b5fd; }
.theme-dark .solv-chip:hover { background: #2b3340; }
.theme-dark .solv-chip.active { background: linear-gradient(135deg,#a78bfa,#8b5cf6); border-color: transparent; color: #fff; }
/* Бейджи задания (.gt-bg / .at-bg) — светлые пастельные пилюли, тёмные варианты */
.theme-dark .gt-bg.type,   .theme-dark .at-bg.type   { background:#1e2633; color:#8fa8d9; }
.theme-dark .gt-bg.auto,   .theme-dark .at-bg.auto   { background:#14301f; color:#6ee787; }
.theme-dark .gt-bg.manual, .theme-dark .at-bg.manual { background:#2e2510; color:#e3b34d; }
.theme-dark .gt-bg.points, .theme-dark .at-bg.points { background:#251c40; color:#c4b5fd; }
.theme-dark .gt-bg.stars,  .theme-dark .at-bg.stars  { background:#211c10; color:#f5a623; border-color:#5c4a1e; }
.theme-dark .solv-pane td, .theme-dark .solv-pane th,
.theme-dark .ql-content td, .theme-dark .ql-content th { border-color: #30363d !important; }
.theme-dark .task-desc table td, .theme-dark .task-desc table th,
.theme-dark .task-description table td, .theme-dark .task-description table th,
.theme-dark .ql-content table td, .theme-dark .ql-content table th { border-color: #30363d; background: transparent; }
.theme-dark .task-img--invert { filter: invert(1) hue-rotate(180deg); }
/* Quill проставляет инлайновый color: rgb(0,0,0) при форматировании (подчёркивание,
   жирный и т.п.) — в тёмной теме это чёрный текст на тёмном фоне, нечитаемо.
   Переопределяем ТОЛЬКО чёрный; осмысленный цветной текст пользователя не трогаем. */
.theme-dark .code-solution [style*="color: rgb(0, 0, 0)"],
.theme-dark .code-solution [style*="color:#000"], .theme-dark .code-solution [style*="color: #000"],
.theme-dark .code-solution [style*="color:#111"], .theme-dark .code-solution [style*="color: #111"],
.theme-dark .code-solution [style*="color:#1a1a1a"], .theme-dark .code-solution [style*="color: #1a1a1a"],
.theme-dark .code-solution [style*="color:#222"], .theme-dark .code-solution [style*="color: #222"],
.theme-dark .code-solution [style*="color:#333"], .theme-dark .code-solution [style*="color: #333"],
.theme-dark .ql-content [style*="color: rgb(0, 0, 0)"],
.theme-dark .ql-content [style*="color:#000"], .theme-dark .ql-content [style*="color: #000"],
.theme-dark .ql-content [style*="color:#111"], .theme-dark .ql-content [style*="color: #111"],
.theme-dark .ql-content [style*="color:#1a1a1a"], .theme-dark .ql-content [style*="color: #1a1a1a"],
.theme-dark .ql-content [style*="color:#222"], .theme-dark .ql-content [style*="color: #222"],
.theme-dark .ql-content [style*="color:#333"], .theme-dark .ql-content [style*="color: #333"],
.theme-dark .task-desc [style*="color: rgb(0, 0, 0)"],
.theme-dark .task-desc [style*="color:#000"], .theme-dark .task-desc [style*="color: #000"],
.theme-dark .task-desc [style*="color:#111"], .theme-dark .task-desc [style*="color: #111"],
.theme-dark .task-desc [style*="color:#1a1a1a"], .theme-dark .task-desc [style*="color: #1a1a1a"],
.theme-dark .task-desc [style*="color:#222"], .theme-dark .task-desc [style*="color: #222"],
.theme-dark .task-desc [style*="color:#333"], .theme-dark .task-desc [style*="color: #333"],
.theme-dark .task-description [style*="color: rgb(0, 0, 0)"],
.theme-dark .task-description [style*="color:#000"], .theme-dark .task-description [style*="color: #000"],
.theme-dark .task-description [style*="color:#111"], .theme-dark .task-description [style*="color: #111"],
.theme-dark .task-description [style*="color:#1a1a1a"], .theme-dark .task-description [style*="color: #1a1a1a"],
.theme-dark .task-description [style*="color:#222"], .theme-dark .task-description [style*="color: #222"],
.theme-dark .task-description [style*="color:#333"], .theme-dark .task-description [style*="color: #333"],
.theme-dark .wt-tab-content [style*="color: rgb(0, 0, 0)"],
.theme-dark .wt-tab-content [style*="color:#000"], .theme-dark .wt-tab-content [style*="color: #000"],
.theme-dark .wt-tab-content [style*="color:#111"], .theme-dark .wt-tab-content [style*="color: #111"],
.theme-dark .wt-tab-content [style*="color:#1a1a1a"], .theme-dark .wt-tab-content [style*="color: #1a1a1a"],
.theme-dark .wt-tab-content [style*="color:#222"], .theme-dark .wt-tab-content [style*="color: #222"],
.theme-dark .wt-tab-content [style*="color:#333"], .theme-dark .wt-tab-content [style*="color: #333"],
.theme-dark .solv-pane [style*="color: rgb(0, 0, 0)"],
.theme-dark .solv-pane [style*="color:#000"], .theme-dark .solv-pane [style*="color: #000"],
.theme-dark .solv-pane [style*="color:#111"], .theme-dark .solv-pane [style*="color: #111"],
.theme-dark .solv-pane [style*="color:#1a1a1a"], .theme-dark .solv-pane [style*="color: #1a1a1a"],
.theme-dark .solv-pane [style*="color:#222"], .theme-dark .solv-pane [style*="color: #222"],
.theme-dark .solv-pane [style*="color:#333"], .theme-dark .solv-pane [style*="color: #333"] { color: #e6edf3 !important; }
/* Импортированные задания (из umschool и т.п.) оборачивают текст в
   color: rgb(65, 65, 65) (#414141) и подобные тёмно-серые — на тёмном фоне они
   тусклые/нечитаемые. Гасим весь тёмно-серый диапазон (#404040…#555) во всех
   контейнерах условия/решения. :is() уже используется выше — браузеры ок. */
.theme-dark :is(.code-solution,.ql-content,.task-desc,.task-description,.wt-tab-content,.solv-pane,.gt-desc,.bw-cond-body) :is(
  [style*="color: rgb(65, 65, 65)"],[style*="color:rgb(65,65,65)"],
  [style*="color:#404040"],[style*="color: #404040"],
  [style*="color:#414141"],[style*="color: #414141"],
  [style*="color:#444"],[style*="color: #444"],
  [style*="color: rgb(68, 68, 68)"],[style*="color:rgb(68,68,68)"],
  [style*="color:#4d4d4d"],[style*="color: #4d4d4d"],
  [style*="color:#555"],[style*="color: #555"],
  [style*="color: rgb(85, 85, 85)"],[style*="color:rgb(85,85,85)"]
) { color: #e6edf3 !important; }
/* Скрываем картинки условия, пока theme.js не проверил прозрачность и не решил,
   инвертировать ли — иначе видно, как картинка «перещёлкивается». После проверки
   (data-inv-checked) показываем уже в правильном виде. */
.theme-dark .task-desc img, .theme-dark .task-description img, .theme-dark .ql-content img,
.theme-dark .gt-desc img, .theme-dark .wt-tab-content img, .theme-dark img.task-img,
.theme-dark .bw-cond-body img, .theme-dark .code-solution img { opacity: 0; }
.theme-dark .task-desc img[data-inv-checked], .theme-dark .task-description img[data-inv-checked],
.theme-dark .ql-content img[data-inv-checked], .theme-dark .gt-desc img[data-inv-checked],
.theme-dark .wt-tab-content img[data-inv-checked], .theme-dark img.task-img[data-inv-checked],
.theme-dark .bw-cond-body img[data-inv-checked], .theme-dark .code-solution img[data-inv-checked] {
  opacity: 1; transition: opacity .1s;
}

/* ── 4j. Низкоконтрастные места в тёмной теме (найдено визуально) ──
   • .s-stats — белый фон задан КЛАССОМ (не инлайном), фолбэки его не ловили →
     светлый текст на белом. Темним фон.
   • Захардкоженный тёмно-фиолетовый текст #5a3e8a (бейдж времени ⏱, чипы) —
     осветляем до #c4b5fd, иначе тёмно-фиолетовый на тёмном не читается.
   • SVG-пончик прогресса: fill="#5a3e8a" → светлее. */
.theme-dark .s-stats { background: #161b22 !important; border-color: #30363d; color: #e6edf3; }
.theme-dark [style*="color:#5a3e8a"], .theme-dark [style*="color: #5a3e8a"] { color: #c4b5fd !important; }
.theme-dark [fill="#5a3e8a"] { fill: #c4b5fd !important; }
/* светло-фиолетовые подложки чипов — затемняем (как другие светлые инлайн-фоны) */
.theme-dark [style*="#ede8f8"], .theme-dark [style*="#ede5f8"], .theme-dark [style*="#e0d4ff"] { background-color: #2a2150 !important; border-color: #3a2d6e !important; }
/* светло-фиолетовый чип «Выдана» (фон задан КЛАССОМ, не инлайном) */
.theme-dark .wtb-chip { background: #2a2150; color: #c4b5fd; }
/* Расписание: карточка занятия (.lesson-row background:#fff — классом) + статусные
   зелёный/красный (прошло/отменено) заданы инлайном — даём тёмные тинты. */
.theme-dark .lesson-row { background: #161b22; border-color: #30363d; }
.theme-dark [style*="#d4edda"] { background-color: #14301f !important; border-color: #1f5132 !important; }
.theme-dark [style*="#fce4e4"] { background-color: #3a1d1d !important; border-color: #5c2626 !important; }
/* .btn-teal (Применить/Назад/Далее) — фон #fff классом → светлый текст на белом */
.theme-dark .btn-teal { background: #21262d; border-color: #30363d; color: #e6edf3; }
.theme-dark .btn-teal:hover { background: #2b3340; border-color: #6366f1; color: #fff; }
/* Чипы вариантов решения: класс .sol-chip (в theme выше правило было только для
   .solv-chip — опечатка/расхождение имён) → белые плашки в тёмной. */
.theme-dark .sol-chip { background: #1c2128 !important; border-color: #30363d !important; color: #8b949e !important; }
.theme-dark .sol-chip:hover { background: #262c36 !important; color: #c4b5fd !important; }
.theme-dark .sol-chip.active { background: linear-gradient(135deg,#a78bfa,#8b5cf6) !important; border-color: transparent !important; color: #fff !important; }
/* Кнопка «Перенести» в расписании — инлайн светлые цвета, темним (перебиваем inline через !important) */
.theme-dark .lesson-move-btn { background: #21262d !important; color: #bc8cff !important; border-color: #3a3450 !important; }
.theme-dark .lesson-move-btn:hover { background: #2a2150 !important; border-color: #8b5cf6 !important; }
/* Фильтр источника контента (_content_source_filter) — инлайн светлые цвета, темним */
.theme-dark .content-src-filter { background: #161b22 !important; border-color: #30363d !important; }
.theme-dark .content-src-filter > span { color: #c4b5fd !important; }
.theme-dark .content-src-filter label { color: #c9d1d9 !important; }
.theme-dark .content-src-filter button[type="submit"] { background: #2a2150 !important; color: #c4b5fd !important; }
.theme-dark .content-src-filter button[type="submit"]:hover { background: #352a63 !important; }
/* Инлайн-код <code> в условии/решении — в светлой теме буквы-переменные без видимых
   плашек (просто текст). В тёмной дефолтный фон даёт серые/белые коробки → убираем
   фон, оставляем только цвет текста. Только строчный контекст (p/li/td/span), не pre. */
.theme-dark :is(.ql-content,.sol-pane,.solv-pane,.task-desc,.task-description) :is(p,li,td,span) code {
  background: transparent !important; color: inherit !important; padding: 0; border: 0;
}
/* Список заданий в домашке: ховер/активная — светлые фоны заданы классом. */
.theme-dark .hw-task-row:hover { background: #21262d; }
.theme-dark .hw-task-row.active { background: #1f2937; color: #bc8cff; }
.theme-dark .hw-task-row.active .num { color: #bc8cff; }

/* ── 5. Мелочи: скроллбары в тёмной теме ── */
.theme-dark ::-webkit-scrollbar { width: 12px; height: 12px; }
.theme-dark ::-webkit-scrollbar-track { background: #0d1117; }
.theme-dark ::-webkit-scrollbar-thumb { background: #30363d; border-radius: 6px; border: 3px solid #0d1117; }
.theme-dark ::-webkit-scrollbar-thumb:hover { background: #3f4651; }
