/* Dark appearance for public / student / lesson pages. Management keeps its own theme. */
html[data-academy-theme="dark"] {
  --ux-blue:#9abfff;
  --ux-blue-tint:#233349;
  --ux-warning:#efc086;
  --ux-warning-tint:#3b3023;
  --ux-danger:#ffaba5;
  --ux-danger-tint:#3b282c;
  --ux-info:#9fd7ed;
  --ux-info-tint:#233640;
  scrollbar-color:#556171 #171c23;
}

/* Match the exam workspace to the shared dark palette instead of overriding it. */
html[data-academy-theme="dark"] .ux-student:has(.ep-page) {
  --ux-bg:inherit;--ux-panel:inherit;--ux-soft:inherit;--ux-ink:inherit;--ux-muted:inherit;--ux-line:inherit;
}

/* The home illustration is an interface, so it follows the theme too. */
html[data-academy-theme="dark"] .ux-study-preview {background:var(--ux-soft);border-color:var(--ux-line)}
html[data-academy-theme="dark"] :is(.ux-preview-inner,.ux-preview-float) {background:var(--ux-panel);border-color:var(--ux-line);box-shadow:0 12px 30px #0002;color:var(--ux-ink)}
html[data-academy-theme="dark"] :is(.ux-preview-top,.ux-preview-label,.ux-preview-note,.ux-preview-float small,.ux-preview-lesson>span:last-child) {color:var(--ux-muted)}
html[data-academy-theme="dark"] .ux-preview-top i {background:#718078}
html[data-academy-theme="dark"] .ux-preview-inner h2 {color:var(--ux-ink)}
html[data-academy-theme="dark"] .ux-preview-lesson {color:var(--ux-ink);border-color:var(--ux-line)}
html[data-academy-theme="dark"] .ux-preview-lesson.current {background:var(--ux-tint);border-color:#527964}
html[data-academy-theme="dark"] .ux-mini-icon {background:var(--ux-soft);color:var(--ux-green);border-color:var(--ux-line)}
html[data-academy-theme="dark"] .ux-preview-lesson.current .ux-mini-icon {background:var(--ux-green);color:var(--ux-panel);border-color:var(--ux-green)}
html[data-academy-theme="dark"] .ux-preview-tag {background:var(--ux-tint);color:var(--ux-green);border-color:#527964}
html[data-academy-theme="dark"] .ux-preview-progress {background:var(--ux-soft)}
html[data-academy-theme="dark"] .ux-preview-progress span {background:var(--ux-green)}
html[data-academy-theme="dark"] .ux-cta {background:var(--ux-panel);border:1px solid var(--ux-line)}
html[data-academy-theme="dark"] .ux-cta h2 {color:var(--ux-ink)}
html[data-academy-theme="dark"] .ux-cta p {color:var(--ux-muted)}
html[data-academy-theme="dark"] .ux-course-state {background:var(--ux-panel);color:var(--ux-green);border:1px solid var(--ux-line)}
html[data-academy-theme="dark"] :is(.ux-button:hover,.ux-course-card:hover) {border-color:#607264}

/* Distinguishable controls and readable hints, including native menus and placeholders. */
html[data-academy-theme="dark"] :is(input,textarea)::placeholder {color:var(--ux-muted)!important;opacity:1}
html[data-academy-theme="dark"] select option {background:var(--ux-panel);color:var(--ux-ink)}
html[data-academy-theme="dark"] :is(input,select,textarea):disabled {color:#9aa6b5;background:#202630;opacity:1}
html[data-academy-theme="dark"] input[type=file]::file-selector-button {background:var(--ux-soft);color:var(--ux-ink);border:1px solid var(--ux-line)}
html[data-academy-theme="dark"] :is(.ux-backdrop,.pp-modal-backdrop,.subject-modal-backdrop) {background:#080b11b8}
html[data-academy-theme="dark"] .btn-close {filter:invert(1) grayscale(1);opacity:.8}
html[data-academy-theme="dark"] :is(.table thead,.table-light) {--bs-table-bg:var(--ux-soft);--bs-table-color:var(--ux-ink)}
html[data-academy-theme="dark"] :is(.text-dark,.text-black) {color:var(--ux-ink)!important}

/* Status colors keep their meaning on dark surfaces. Avoid dark blue / brown text on charcoal. */
html[data-academy-theme="dark"] :is(.aa-pill.blue,.lib-pill.blue) {color:var(--ux-blue);background:var(--ux-blue-tint);border-color:#466187}
html[data-academy-theme="dark"] :is(.aa-pill.amber,.lib-pill.amber,.ux-answer-status.is-incorrect) {color:var(--ux-warning);background:var(--ux-warning-tint);border-color:#78603f}
html[data-academy-theme="dark"] .aa-classes :is(.course-progress-line strong,.next-label) {color:var(--ux-green)}
html[data-academy-theme="dark"] .aa-classes .course-status {color:var(--ux-green);background:var(--ux-tint);border:1px solid #527964}
html[data-academy-theme="dark"] body .aa-classes .course-status.is-expired {color:var(--ux-danger);background:var(--ux-danger-tint);border-color:#805553}
html[data-academy-theme="dark"] body .aa-classes :is(.course-status.is-pending,.course-status.is-identity) {color:var(--ux-warning);background:var(--ux-warning-tint);border-color:#78603f}
html[data-academy-theme="dark"] .aa-classes .course-cover {background:var(--ux-soft)}
html[data-academy-theme="dark"] .aa-library :is(.quick-tabs a.active,.mini.category,.empty-icon) {color:var(--ux-green);background:var(--ux-tint);border-color:#527964}
html[data-academy-theme="dark"] :is(.ux-error,.ux-field-error,.field-error,.settings-error,.guardian-alert-error,.teacher-error,.errorlist) {color:var(--ux-danger)!important}
html[data-academy-theme="dark"] :is(.ux-notice-error,.identity-result--danger,.ep-error) {background:var(--ux-danger-tint);color:var(--ux-danger)!important;border-color:#805553}
html[data-academy-theme="dark"] :is(.ux-notice-error,.identity-result--danger,.ep-error) :is(p,h2,h3,a) {color:inherit!important}
html[data-academy-theme="dark"] .alert-danger {background:var(--ux-danger-tint);color:var(--ux-danger);border-color:#805553}
html[data-academy-theme="dark"] .alert-warning {background:var(--ux-warning-tint);color:var(--ux-warning);border-color:#78603f}
html[data-academy-theme="dark"] .alert-success {background:var(--ux-tint);color:var(--ux-green);border-color:#527964}
html[data-academy-theme="dark"] .alert-info {background:var(--ux-info-tint);color:var(--ux-info);border-color:#4d7381}
html[data-academy-theme="dark"] :is(.alert-danger,.alert-warning,.alert-success,.alert-info) :is(p,h2,h3,h4,a) {color:inherit}
html[data-academy-theme="dark"] :is(.text-danger,.identity-status.is-rejected) {color:var(--ux-danger)!important}
html[data-academy-theme="dark"] :is(.text-warning,.identity-status.is-pending_review) {color:var(--ux-warning)!important}
html[data-academy-theme="dark"] :is(.text-success,.identity-status.is-verified) {color:var(--ux-green)!important}

/* Remove the decorative light gradients still carried by older page components. */
html[data-academy-theme="dark"] :is(.aa-library .lib-hero,.aa-library .lib-filter,.aa-library .filter-panel,.aa-library .file-card,.aa-library .empty,.notifications-hero,.nd-hero,.teacher-chat-window,.teacher-messages,.guardian-hero,.sessions-hero) {background:var(--ux-panel);border-color:var(--ux-line);box-shadow:none}
html[data-academy-theme="dark"] :is(.teacher-chat-window,.teacher-messages)::before {display:none}
html[data-academy-theme="dark"] .notification-item.is-unread {background:#23322e;border-color:#4e7862}
html[data-academy-theme="dark"] .notification-item:hover {background:var(--ux-soft);border-color:#607264}
html[data-academy-theme="dark"] :is(.nd-button.primary,.lib-filter button,.teacher-send) {background:var(--ux-green);color:var(--ux-panel);box-shadow:none}
html[data-academy-theme="dark"] .teacher-msg.is-me {background:var(--ux-tint);color:var(--ux-ink)}
html[data-academy-theme="dark"] .teacher-msg.is-me .teacher-msg-body {color:var(--ux-ink)}
html[data-academy-theme="dark"] .ep-warning {background:var(--ux-warning-tint);border-color:#78603f}
html[data-academy-theme="dark"] .ep-warning strong {color:var(--ux-warning)}

/* Only interface surfaces are recolored. Course images, diagrams and video pixels stay intact. */
html[data-academy-theme="dark"] .aa-library .continue-card {background:var(--ux-panel);border-color:var(--ux-line);box-shadow:none}
html[data-academy-theme="dark"] .aa-library .lib-btn.primary {background:var(--ux-green);color:var(--ux-panel);box-shadow:none}

/* The standalone lesson has older mode-specific rules with higher specificity. */
html[data-academy-theme="dark"] body.aa-dark {--primary-rgb:139,204,168;--unit-line:var(--ux-line);--unit-border:var(--ux-line);--unit-shadow:transparent;color:var(--ux-ink)}
html[data-academy-theme="dark"] body.aa-dark :is(.aa-topbar,.card-surface,.lesson-toolbar,.mode-ribbon,.video-notes-card,.video-bottom-nav,.learning-session-card) {background:var(--ux-panel)!important;color:var(--ux-ink)!important;border-color:var(--ux-line)!important;box-shadow:none!important;backdrop-filter:none}
html[data-academy-theme="dark"] body.aa-dark :is(.aa-topbar .btn-back,.icon-btn,.video-filter-bar,.video-filter-chip,.form-control,.form-select) {background:var(--ux-soft)!important;color:var(--ux-ink)!important;border-color:var(--ux-line)!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark :is(.lesson-toolbar,.video-bottom-nav)::before {display:none}
html[data-academy-theme="dark"] body.aa-dark .accordion-button,
html[data-academy-theme="dark"] body.aa-dark .accordion-button:not(.collapsed) {background:var(--ux-soft)!important;color:var(--ux-ink)!important;border-color:var(--ux-line)!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark .accordion-button:not(.collapsed) {background:var(--ux-tint)!important;color:var(--ux-green)!important}
html[data-academy-theme="dark"] body.aa-dark .accordion-button :is(.small,.text-muted),
html[data-academy-theme="dark"] body.aa-dark .accordion-button::before {color:var(--ux-muted)!important}
html[data-academy-theme="dark"] body.aa-dark .accordion-body::before {background:var(--ux-line)!important}
html[data-academy-theme="dark"] body.aa-dark .lesson-toc-card,
html[data-academy-theme="dark"] body.aa-dark .video-sublist .video-btn {background:var(--ux-panel)!important;color:var(--ux-ink)!important;border-color:var(--ux-line)!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark .lesson-toc-card:has(.lesson-link.active),
html[data-academy-theme="dark"] body.aa-dark .video-sublist .video-btn.is-current {background:var(--ux-tint)!important;border-color:#527964!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark .lesson-toc-card:has(.lesson-link.active)::after {background:var(--ux-green)!important;color:var(--ux-panel)!important;border-color:var(--ux-green)!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark :is(.lesson-link.active,.video-btn.is-current .vtitle) {color:var(--ux-green)!important;text-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark .video-sublist .thumb {background:var(--ux-soft)!important;border-color:var(--ux-line)!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark .video-sublist .video-btn::before {background:var(--ux-line)!important}
html[data-academy-theme="dark"] body.aa-dark .video-sublist .video-btn.is-current::before {background:var(--ux-green)!important}
html[data-academy-theme="dark"] body.aa-dark :is(.video-sublist .vtitle,.bm-head .title,.learning-session-card h2) {color:var(--ux-ink)!important}
html[data-academy-theme="dark"] body.aa-dark :is(.text-muted,.bm-subtitle,.bm-empty,.learning-session-card p) {color:var(--ux-muted)!important}
html[data-academy-theme="dark"] body.aa-dark :is(.video-filter-chip.active,.video-filter-chip.is-active,.video-bottom-nav .btn-primary,.video-notes-card .btn-primary,.learning-session-card a) {background:var(--ux-green)!important;color:var(--ux-panel)!important;border-color:var(--ux-green)!important;box-shadow:none!important}
html[data-academy-theme="dark"] body.aa-dark .lp-wrap .progress-bar {background:var(--ux-green)!important}
html[data-academy-theme="dark"] body.aa-dark :is(.lp-wrap .progress,.course-progress-overlay) {background:var(--ux-line)!important}
html[data-academy-theme="dark"] body.aa-dark .learning-session-overlay {background:#080b11d9;backdrop-filter:blur(4px)}
html[data-academy-theme="dark"] body.aa-dark .alert-warning {background:var(--ux-warning-tint)!important;color:var(--ux-warning)!important;border-color:#78603f!important}
html[data-academy-theme="dark"] body.aa-dark #tocOffcanvas {background:var(--ux-panel)!important;color:var(--ux-ink)!important;border-color:var(--ux-line)!important}
html[data-academy-theme="dark"] body.aa-dark .offcanvas .btn-close {background-color:transparent!important;opacity:1}
html[data-academy-theme="dark"] .cp-price img {filter:brightness(0) invert(1)}
