/* QuizHub Dark Mode — opt-in theme, applied after the light/mobile palettes. */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body {
  color: #e7ecf8 !important;
  background: radial-gradient(ellipse at 12% 8%,#1b2948 0,transparent 38%),radial-gradient(ellipse at 88% 12%,#292044 0,transparent 34%),linear-gradient(135deg,#101827,#141d2d 55%,#19182b) !important;
  background-color: #101827 !important;
}
html[data-theme="dark"] :is(.glass,.welcome,.profile-panel,.analytics-intro,.analytics-panel,.analytics-stat,.subject-card,.student-quiz-card,.subject-select-card,.subject-detail-heading,.subject-detail-view .subject-lesson,.quiz-heading,.quiz-progress-shell,.quiz-question-active,.quiz-final-result,.question-card,#history,.table-wrap,.mobile-leaderboard-view,.admin-content,.admin-nav,.auth-shell,.result-card,.profile-modal,.ui-dialog) {
  color: #e7ecf8 !important;
  background: #1b2638 !important;
  background-color: #1b2638 !important;
  border-color: #334158 !important;
  box-shadow: 0 12px 32px rgba(0,0,0,.22) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html[data-theme="dark"] :is(.topbar,.profile-modal-header,.profile-modal-body) {
  color: #e7ecf8 !important;
  background: #151f30 !important;
  background-color: #151f30 !important;
  border-color: #334158 !important;
}
html[data-theme="dark"] :is(h1,h2,h3,h4,h5,strong,b,.brand,.profile-modal-header h2,.profile-modal-section h3,.profile-avatar-editor strong,.subject-card-title,.analytics-panel h3,.analytics-section-title h3) { color: #f0f4ff !important; }
html[data-theme="dark"] :is(p,.muted,small,.profile-avatar-editor span,.profile-avatar-editor small,.lesson-row small,.quiz-row small,.analytics-stat span,.analytics-stat small,.admin-mark) { color: #aab7cc !important; }
html[data-theme="dark"] :is(label,.topbar nav a,.admin-nav button,.question-meta,.manage-item) { color: #c2cde0 !important; }
html[data-theme="dark"] a { color: #a8b7ff; }
html[data-theme="dark"] .topbar nav a.active { color: #fff !important; background: linear-gradient(120deg,#5369e8,#8973e8) !important; }
html[data-theme="dark"] :is(input,select,textarea,.ui-dialog-input) {
  color: #edf2ff !important;
  background: #111b2b !important;
  border-color: #3a4962 !important;
  color-scheme: dark !important;
}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder { color: #8795ad !important; }
html[data-theme="dark"] :is(.ghost,.profile-modal-close) { color: #d5def0 !important; background: #26344a !important; border-color: #3a4962 !important; }
html[data-theme="dark"] :is(.chip,.timer,.analytics-rank-chip) { color: #c7d0ff !important; background: #29365a !important; }
html[data-theme="dark"] :is(.quiz-list,.analytics-mini-stats span,.analytics-bar-track,.profile-avatar-editor,.subject-detail-heading) { background: #202d42 !important; }
html[data-theme="dark"] :is(.answer-option,.quiz-answer-option,.student-quiz-card) { color: #dce5f6 !important; background: #202d42 !important; border-color: #3a4962 !important; }
html[data-theme="dark"] .quiz-answer-option:has(input:checked) { background: #2b3960 !important; }
html[data-theme="dark"] :is(.quiz-answer-option.answer-correct,.answer-option.answer-correct) { color: #a9e8c8 !important; background: #183b32 !important; }
html[data-theme="dark"] :is(.quiz-answer-option.answer-incorrect,.answer-option.answer-incorrect) { color: #ffc0c6 !important; background: #452630 !important; }
html[data-theme="dark"] :is(table th,.leaderboard-table th) { color: #c4cee0 !important; background: #202d42 !important; }
html[data-theme="dark"] :is(table td,.leaderboard-table td) { color: #d7e0f0 !important; border-color: #334158 !important; }
html[data-theme="dark"] .leaderboard-you { background: #29365a !important; }
html[data-theme="dark"] :is(.profile-modal-section,.profile-modal-header,.profile-modal-body,.lesson-row,.quiz-row,.manage-item,.quiz-admin-item) { border-color: #334158 !important; }
html[data-theme="dark"] #profile-modal .profile-modal { color: #e7ecf8 !important; background: #1b2638 !important; border-color: #334158 !important; }
html[data-theme="dark"] #profile-modal :is(.profile-modal-header,.profile-modal-body,.profile-modal-section) { color: #e7ecf8 !important; background: #1b2638 !important; }
html[data-theme="dark"] #profile-modal :is(h2,h3,strong,label,p,span) { color: inherit !important; }
html[data-theme="dark"] .profile-modal-close { background: #26344a !important; color: #e7ecf8 !important; }
html[data-theme="dark"] .profile-modal-backdrop { background: rgba(2,7,16,.72) !important; }
html[data-theme="dark"] .notice.success { color: #a9e8c8 !important; background: #183b32 !important; }
html[data-theme="dark"] .notice.error { color: #ffc0c6 !important; background: #452630 !important; }
.theme-toggle { display:inline-flex; align-items:center; justify-content:center; gap:7px; min-height:38px; padding:8px 12px; border:1px solid rgba(135,153,190,.35); border-radius:11px; background:rgba(255,255,255,.68); color:#445477; font:700 12px 'DM Sans',Arial,sans-serif; cursor:pointer; white-space:nowrap; }
.theme-toggle:hover { border-color:#8998ef; }
html[data-theme="dark"] .theme-toggle { color:#e6edff !important; background:#26344a !important; border-color:#40516e !important; }
.auth-page .theme-toggle { position:fixed; top:18px; right:18px; z-index:20; }
@media(max-width:760px) {
  .theme-toggle { min-height:38px; padding:8px 10px; font-size:11px; }
  .auth-page .theme-toggle { top:12px; right:12px; }
}


/* Smooth, lightweight transitions when switching between light and dark themes. */
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html, body {
  transition: background-color .32s ease, color .32s ease;
}
body, body * {
  transition-property: color, background-color, border-color, box-shadow;
  transition-duration: .32s;
  transition-timing-function: ease;
}
.theme-toggle {
  transition: color .24s ease, background-color .24s ease, border-color .24s ease, box-shadow .24s ease, transform .18s ease;
}
.theme-toggle:active { transform: scale(.97); }
@media (prefers-reduced-motion: reduce) {
  html, body, body *, .theme-toggle { transition-duration: .01ms !important; }
  .theme-toggle:active { transform: none; }
}


/* Dark-mode colors for compact quiz history cards on phones and desktop. */
html[data-theme="dark"] .history-summary-card,
html[data-theme="dark"] .history-chart-panel{background:#202d42!important;border-color:#35445d!important}
html[data-theme="dark"] .history-summary-card span,
html[data-theme="dark"] .history-summary-card small,
html[data-theme="dark"] .history-chart-heading small,
html[data-theme="dark"] .history-recent-heading span,
html[data-theme="dark"] .history-chart-legend{color:#aab7cc!important}
html[data-theme="dark"] .history-summary-card strong,
html[data-theme="dark"] .history-chart-heading b,
html[data-theme="dark"] .history-recent-heading b{color:#e7ecff!important}
html[data-theme="dark"] .history-chart-track{background:#334158!important}
html[data-theme="dark"] .history-result-pill{background:#29365a!important;color:#c7d0ff!important}
@media screen and (max-width:760px){
 html[data-theme="dark"] body .history-table-wrap tr{background:#202d42!important;border-color:#35445d!important}
 html[data-theme="dark"] body .history-table-wrap td:first-child{border-color:#35445d!important}
 html[data-theme="dark"] body .history-table-wrap td:nth-child(n+2)::before{color:#aab7cc!important}
}


/* My Results page — complete dark palette, including phone layouts. */
html[data-theme="dark"] body.results-page {
  --page-bg:#101827;
  --surface:#1b2638;
  --text:#e7ecf8;
  --muted:#aab7cc;
  --line:#334158;
  --card-bg:#202d42;
  color:#e7ecf8!important;
}
html[data-theme="dark"] body.results-page :is(.mr-stat-card,.mr-panel,.mr-review-dialog) {
  color:#e7ecf8!important;
  background:#1b2638!important;
  background-color:#1b2638!important;
  border-color:#334158!important;
  box-shadow:0 12px 32px rgba(0,0,0,.22)!important;
}
html[data-theme="dark"] body.results-page :is(.results-loading,.results-error,.results-empty) {
  color:#e7ecf8!important;
  background:#1b2638!important;
  border-color:#334158!important;
}
html[data-theme="dark"] body.results-page :is(.mr-stat-card>small,.mr-stat-card em,.mr-panel-heading p,.mr-bar-col>b,.mr-bar-col>small,.mr-subject-card small,.mr-muted,.mr-empty-inline,.mr-achievement small,.mr-disclaimer,.mr-review-dialog header p,.mr-review-score span,.mr-question-top,.mr-review-bottom) {
  color:#aab7cc!important;
}
html[data-theme="dark"] body.results-page :is(.mr-stat-card>strong,.mr-stat-card>strong small,.mr-panel-heading h2,.mr-subject-card strong,.mr-subject-card>b,.mr-achievement strong,.mr-achievement>b,.mr-review-dialog h2,.mr-review-score strong,.mr-question-review h3,.mr-explanation strong,.mr-explanation p) {
  color:#e7ecf8!important;
}
html[data-theme="dark"] body.results-page :is(.mr-subject-card,.mr-review-option) {
  color:#dce5f6!important;
  background:#202d42!important;
  border-color:#35445d!important;
}
html[data-theme="dark"] body.results-page :is(.mr-mini-track,.mr-chart) {
  border-color:#334158!important;
}
html[data-theme="dark"] body.results-page .mr-mini-track {background:#334158!important}
html[data-theme="dark"] body.results-page .mr-achievement {border-color:#35445d!important}
html[data-theme="dark"] body.results-page .mr-achievement.earned {
  background:rgba(34,197,94,.09)!important;
  border-color:rgba(74,222,128,.28)!important;
}
html[data-theme="dark"] body.results-page :is(.mr-xp-chip,.mr-history-count) {
  color:#fcd98a!important;
  background:#44351f!important;
}
html[data-theme="dark"] body.results-page .mr-footer-note {
  color:#dce5f6!important;
  background:#202d42!important;
}
html[data-theme="dark"] body.results-page .mr-table-wrap th {
  color:#c4cee0!important;
  background:#202d42!important;
}
html[data-theme="dark"] body.results-page .mr-table-wrap td {
  color:#d7e0f0!important;
  border-color:#334158!important;
}
html[data-theme="dark"] body.results-page .mr-result-pill.good {
  color:#a9e8c8!important;
  background:#183b32!important;
}
html[data-theme="dark"] body.results-page .mr-result-pill.mid {
  color:#fcd98a!important;
  background:#44351f!important;
}
html[data-theme="dark"] body.results-page .mr-result-pill.low {
  color:#ffc0c6!important;
  background:#452630!important;
}
html[data-theme="dark"] body.results-page .mr-review-option.is-correct {
  color:#a9e8c8!important;
  background:#183b32!important;
}
html[data-theme="dark"] body.results-page .mr-review-option.is-wrong {
  color:#ffc0c6!important;
  background:#452630!important;
}
html[data-theme="dark"] body.results-page .mr-explanation {
  color:#dce5f6!important;
  background:#202d42!important;
}
html[data-theme="dark"] body.results-page .mr-review-score {
  color:#e7ecf8!important;
  background:#29365a!important;
}
@media screen and (max-width:760px) {
  html[data-theme="dark"] body.results-page .results-topbar {
    color:#e7ecf8!important;
    background:#151f30!important;
    border-color:#334158!important;
  }
  html[data-theme="dark"] body.results-page .results-topbar nav a {
    color:#c2cde0!important;
  }
  html[data-theme="dark"] body.results-page .results-topbar nav a.active {
    color:#fff!important;
    background:linear-gradient(120deg,#5369e8,#8973e8)!important;
  }
}

/* XP rewards and Badge Gallery — complete dark-mode palette. */
html[data-theme="dark"] body .rewards-overview {
  color:#e7ecf8!important;
  background:linear-gradient(135deg,#1b2638 0%,#252342 100%)!important;
  border-color:#3b4260!important;
}
html[data-theme="dark"] body .rewards-overview :is(.rewards-overview-head h2,.rewards-stat strong,.rewards-activity>strong,.rewards-progress-label strong) {
  color:#f0f4ff!important;
}
html[data-theme="dark"] body .rewards-overview :is(.rewards-overview-head p,.rewards-stat span,.rewards-progress-label span,.rewards-badge-action>span,.rewards-activity-row>span) {
  color:#aab7cc!important;
}
html[data-theme="dark"] body .rewards-overview .rewards-level-pill {
  color:#d8ceff!important;background:#39345f!important;
}
html[data-theme="dark"] body .rewards-overview .rewards-stat {
  color:#e7ecf8!important;background:#202d42!important;border-color:#3a4962!important;
}
html[data-theme="dark"] body .rewards-overview .rewards-progress-track {background:#35415a!important}
html[data-theme="dark"] body .rewards-overview .rewards-activity {border-color:#3a4962!important}
html[data-theme="dark"] body .rewards-overview .rewards-activity-row strong {color:#75d6a5!important}
html[data-theme="dark"] body .rewards-overview .rewards-badge-action {border-color:#3a4962!important}
html[data-theme="dark"] body .badge-gallery-modal {
  color:#e7ecf8!important;background:#1b2638!important;
  border-color:#3a4962!important;box-shadow:0 24px 80px rgba(0,0,0,.55)!important;
}
html[data-theme="dark"] body .badge-gallery-modal-head :is(h2,p) {color:#f0f4ff!important}
html[data-theme="dark"] body .badge-gallery-modal-head p {color:#aab7cc!important}
html[data-theme="dark"] body .badge-gallery-modal-head .eyebrow {color:#b9a8ff!important}
html[data-theme="dark"] body .badge-gallery-modal .badge-gallery-count {
  color:#d8ceff!important;background:#39345f!important;
}
html[data-theme="dark"] body .badge-gallery-modal-close {
  color:#e7ecf8!important;background:#26344a!important;border-color:#40516e!important;
}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-card {
  color:#dce5f6!important;background:#202d42!important;border-color:#3a4962!important;
}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-card strong {color:#f0f4ff!important}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-card small,
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-status,
html[data-theme="dark"] body .badge-gallery-modal .badge-gallery-note {color:#aab7cc!important}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-icon {background:#303957!important}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-card.is-earned {
  background:#183b32!important;border-color:#34765a!important;
}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-card.is-earned .badge-preview-status {color:#8de0b4!important}
html[data-theme="dark"] body .badge-gallery-modal .badge-preview-card.is-locked .badge-preview-status {color:#aab7cc!important}
html[data-theme="dark"] body .badge-gallery-modal .empty {color:#aab7cc!important;background:#202d42!important;border-color:#3a4962!important}
html[data-theme="dark"] body .badge-gallery-modal-backdrop {background:rgba(2,7,16,.78)!important}

/* Quiz page: correct-answer feedback box, dark mode only. */
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-correct {
  color:#b9f2d3!important;
  background:#173b30!important;
  border-color:#34765a!important;
}
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-correct strong,
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-correct p {
  color:#b9f2d3!important;
}
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-correct .quiz-explanation {
  color:#d0f5df!important;
  border-color:#34765a!important;
}
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-correct .feedback-symbol {
  color:#b9f2d3!important;
  background:#245541!important;
}


/* Quiz page: incorrect-answer feedback box, dark mode only. */
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-wrong {
  color:#ffc0c6!important;
  background:#452630!important;
  border-color:#8b4654!important;
}
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-wrong strong,
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-wrong p {
  color:#ffc0c6!important;
}
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-wrong .quiz-explanation {
  color:#ffd5d9!important;
  border-color:#8b4654!important;
}
html[data-theme="dark"] body .quiz-feedback.quiz-feedback-wrong .feedback-symbol {
  color:#ffc0c6!important;
  background:#663441!important;
}
