/* Shared light/dark preference for the public site, portal, admin tools, and exam runtime. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1422;
  --page-bg: #0b1422;
  --paper: #142338;
  --paper-strong: #182b43;
  --panel: #142338;
  --panel-soft: #1a2b42;
  --line: rgba(178, 205, 232, .18);
  --line-mid: #42546a;
  --ink: #ecf4fc;
  --navy: #ecf4fc;
  --muted: #aebfd0;
  --accent: #70a8ee;
  --accent-deep: #9ac5ff;
  --teal: #8fc5ed;
  --header: #172a40;
  --header-dark: #102036;
  --header-text: #f2f7fc;
  --shadow: 0 20px 46px rgba(0, 0, 0, .24);
  --error-bg: #402830;
  --error-border: #89505a;
  --error-text: #ffd2d7;
}

.theme-toggle {
  position: fixed;
  z-index: 1100;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: .55rem .8rem;
  border: 1px solid #b9cadb;
  border-radius: 999px;
  background: #fff;
  color: #18334f;
  box-shadow: 0 8px 26px rgba(12, 35, 68, .18);
  font: 700 .82rem/1.1 "Avenir Next", "Segoe UI", sans-serif;
  cursor: pointer;
}
.theme-toggle:hover { transform: translateY(-2px); }
.theme-toggle:focus-visible { outline: 3px solid #6eb2f7; outline-offset: 2px; }
.theme-icon { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon.sun { display: none; }
:root[data-theme="dark"] .theme-icon.moon { display: none; }
:root[data-theme="dark"] .theme-icon.sun { display: block; }
:root[data-theme="dark"] .theme-toggle { background: #223953; border-color: #526a84; color: #edf6ff; box-shadow: 0 8px 26px rgba(0, 0, 0, .35); }

:root[data-theme="dark"] body {
  background: radial-gradient(circle at 10% 0, rgba(42, 91, 150, .22), transparent 28%), linear-gradient(180deg, #0b1422, #101d2d 70%, #0b1422);
  color: var(--ink);
}
:root[data-theme="dark"] .eyebrow { color: #a6bdd4; }
:root[data-theme="dark"] a:not([class]) { color: #9ccaff; }
:root[data-theme="dark"] a:focus-visible,
:root[data-theme="dark"] button:focus-visible { outline-color: #8bc1ff; }
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #102035;
  border-color: #435a72;
  color: #f1f7ff;
}
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #91a5ba; }
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .catalog-card,
:root[data-theme="dark"] .empty-card,
:root[data-theme="dark"] .feature-card,
:root[data-theme="dark"] .report-metric-card,
:root[data-theme="dark"] .report-exam-card,
:root[data-theme="dark"] .marks-distribution-card,
:root[data-theme="dark"] .managed-exam,
:root[data-theme="dark"] .admin-metric,
:root[data-theme="dark"] .admin-link-card,
:root[data-theme="dark"] .question-image-editor,
:root[data-theme="dark"] .resource-table,
:root[data-theme="dark"] .catalog-summary-item,
:root[data-theme="dark"] .admin-check,
:root[data-theme="dark"] .viewer-badge,
:root[data-theme="dark"] .save-status {
  background: #142338;
  border-color: #354960;
  color: var(--ink);
}
:root[data-theme="dark"] .resource-table th,
:root[data-theme="dark"] .resource-table td { border-color: #354960; }
:root[data-theme="dark"] .resource-table th { background: #1c3049; color: var(--ink); }
:root[data-theme="dark"] .resource-table td { color: #c6d5e4; }
:root[data-theme="dark"] .nav-links a,
:root[data-theme="dark"] .logout-btn,
:root[data-theme="dark"] .admin-tab,
:root[data-theme="dark"] .managed-exam-actions button,
:root[data-theme="dark"] .managed-exam-actions a,
:root[data-theme="dark"] .question-list button,
:root[data-theme="dark"] .question-step button,
:root[data-theme="dark"] .student-role-inline select {
  background: #20344d;
  border-color: #4c6680;
  color: #eef5fc;
}
:root[data-theme="dark"] .admin-tab.active,
:root[data-theme="dark"] .nav-pill,
:root[data-theme="dark"] .auth-btn { background: #315d91; color: #fff; }
:root[data-theme="dark"] .question-list button.active { background: #274d78; border-color: #83baf0; }
:root[data-theme="dark"] .admin-field span,
:root[data-theme="dark"] .auth-field span { color: #bbcee1; }
:root[data-theme="dark"] .admin-metric::after { opacity: .12; }
:root[data-theme="dark"] .legend-dot.mock { background: #8ec1ff; }
:root[data-theme="dark"] .legend-dot.qbank { background: #70d5b6; }
:root[data-theme="dark"] .admin-activity-row { border-color: #435a72; }
:root[data-theme="dark"] .admin-activity-row strong,
:root[data-theme="dark"] .admin-activity-row b,
:root[data-theme="dark"] .admin-link-card strong { color: #edf6ff; }
:root[data-theme="dark"] .mock-card-meta span,
:root[data-theme="dark"] .catalog-tag.open,
:root[data-theme="dark"] .catalog-tag.closed,
:root[data-theme="dark"] .status-chip,
:root[data-theme="dark"] .exam-preview-badge { background: #254363; color: #d6eaff; }
:root[data-theme="dark"] .quality-chip.good { background: #173c32; color: #9ee4bc; }
:root[data-theme="dark"] .quality-chip.warning { background: #473a1e; color: #f5d88b; }
:root[data-theme="dark"] .quality-chip.danger { background: #4e2930; color: #ffc4c9; }
:root[data-theme="dark"] .admin-notice.error,
:root[data-theme="dark"] .managed-exam-actions .danger { color: #ffc4c9; }
:root[data-theme="dark"] .exam-status-active { background: #173c32; color: #9ee4bc; border-color: #367b5d; }
:root[data-theme="dark"] .exam-status-hidden { background: #30344b; color: #d2d3ed; border-color: #666d8d; }
:root[data-theme="dark"] .exam-status-closed,
:root[data-theme="dark"] .exam-status-ended { background: #4e2930; color: #ffc4c9; border-color: #93606a; }
:root[data-theme="dark"] .exam-status-scheduled { background: #473a1e; color: #f5d88b; border-color: #9b8141; }
:root[data-theme="dark"] .question-image-preview { background: #142338; border-color: #435a72; }
:root[data-theme="dark"] .auth-links a { color: #a9d1ff; }

/* Public homepage surfaces. */
:root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .hero-panel,
:root[data-theme="dark"] .nav-link:not(.nav-link-strong),
:root[data-theme="dark"] .secondary-link,
:root[data-theme="dark"] .resource-row,
:root[data-theme="dark"] .impact-card,
:root[data-theme="dark"] .story-card,
:root[data-theme="dark"] .accent-card,
:root[data-theme="dark"] .service-card,
:root[data-theme="dark"] .resource-card,
:root[data-theme="dark"] .showcase-note,
:root[data-theme="dark"] .session-main,
:root[data-theme="dark"] .showcase-card,
:root[data-theme="dark"] .exam-feature-card,
:root[data-theme="dark"] .exam-preview,
:root[data-theme="dark"] .score-box,
:root[data-theme="dark"] .exam-preview-block,
:root[data-theme="dark"] .recognition-media,
:root[data-theme="dark"] .team-media {
  background: #192c44;
  border-color: #3a536d;
  color: var(--ink);
}
:root[data-theme="dark"] .resource-icon,
:root[data-theme="dark"] .resource-pill,
:root[data-theme="dark"] .resource-kicker,
:root[data-theme="dark"] .session-link,
:root[data-theme="dark"] .exam-preview-badge,
:root[data-theme="dark"] .service-label { background: #294765; color: #d4e9ff; }
:root[data-theme="dark"] .resource-row strong,
:root[data-theme="dark"] .resource-icon,
:root[data-theme="dark"] .exam-preview-heading,
:root[data-theme="dark"] .objective-item strong,
:root[data-theme="dark"] .exam-preview-top h3 { color: #eaf5ff; }
:root[data-theme="dark"] .floating-icon { color: rgba(148, 194, 243, .12); }

/* Discussions and community cards. */
:root[data-theme="dark"] .discussion-lounge-hero,
:root[data-theme="dark"] .discussion-post-card,
:root[data-theme="dark"] .discussion-detail-card,
:root[data-theme="dark"] .discussion-reply-card,
:root[data-theme="dark"] .discussion-community-link,
:root[data-theme="dark"] .discussion-meta-chip,
:root[data-theme="dark"] .discussion-post-status,
:root[data-theme="dark"] .discussion-status-badge,
:root[data-theme="dark"] .discussion-quick-points span,
:root[data-theme="dark"] .community-chip,
:root[data-theme="dark"] .discussion-post-actions a {
  background: #1a2c43;
  border-color: #3b536d;
  color: var(--ink);
}
:root[data-theme="dark"] .community-chip.active { background: #b95a27; color: #fff; }
:root[data-theme="dark"] .discussion-chat-bubble,
:root[data-theme="dark"] .discussion-attachment-list a,
:root[data-theme="dark"] .discussion-inline-tools,
:root[data-theme="dark"] .discussion-reply-bubble,
:root[data-theme="dark"] .discussion-save-status { background: #233c59; border-color: #435b75; color: var(--ink); }
:root[data-theme="dark"] .discussion-save-status.error { background: #4e2930; color: #ffc4c9; }

/* Exam runtime and result review. */
:root[data-theme="dark"] .loading-screen,
:root[data-theme="dark"] .start-screen,
:root[data-theme="dark"] .results-screen { background: #0b1422; }
:root[data-theme="dark"] .loading-card,
:root[data-theme="dark"] .launch-card,
:root[data-theme="dark"] .summary-tile,
:root[data-theme="dark"] .workspace,
:root[data-theme="dark"] .toolkit-panel,
:root[data-theme="dark"] .modal-card,
:root[data-theme="dark"] .result-card,
:root[data-theme="dark"] .analysis-panel,
:root[data-theme="dark"] .analysis-card,
:root[data-theme="dark"] .slg-gpt-panel,
:root[data-theme="dark"] .resources-panel {
  background: #142338;
  border-color: #354960;
  color: var(--ink);
}
:root[data-theme="dark"] .question-rail,
:root[data-theme="dark"] .exam-footer,
:root[data-theme="dark"] .toolkit-tabs,
:root[data-theme="dark"] .toolkit-body,
:root[data-theme="dark"] .settings-section,
:root[data-theme="dark"] .setting-tile,
:root[data-theme="dark"] .detail-panel,
:root[data-theme="dark"] .tool-info-card,
:root[data-theme="dark"] .result-header,
:root[data-theme="dark"] .result-meta,
:root[data-theme="dark"] .result-options-block,
:root[data-theme="dark"] .explanation-block,
:root[data-theme="dark"] .results-list-wrap {
  background: #192c44;
  border-color: #354960;
  color: var(--ink);
}
:root[data-theme="dark"] .question-grid button,
:root[data-theme="dark"] .option-main,
:root[data-theme="dark"] .eye-toggle,
:root[data-theme="dark"] .flag-chip,
:root[data-theme="dark"] .clear-highlights-btn,
:root[data-theme="dark"] .tool-tab,
:root[data-theme="dark"] .calc-display,
:root[data-theme="dark"] .calculator-grid button,
:root[data-theme="dark"] .footer-btn.previous-btn,
:root[data-theme="dark"] .modal-close-btn,
:root[data-theme="dark"] .modal-secondary-btn,
:root[data-theme="dark"] .result-option-row,
:root[data-theme="dark"] .slg-gpt-link,
:root[data-theme="dark"] .resource-link-card {
  background: #203650;
  border-color: #435b75;
  color: #eaf4ff;
}
:root[data-theme="dark"] .footer-left,
:root[data-theme="dark"] .resource-copy span { color: #bbcee1; }
:root[data-theme="dark"] .resource-copy strong,
:root[data-theme="dark"] .analysis-header h3,
:root[data-theme="dark"] .analysis-card h4 { color: #eef6ff; }
:root[data-theme="dark"] .copy-question-btn { background: #203650; border-color: #435b75; color: #eaf4ff; }
body:has(#exam-screen:not(.hidden)) .theme-toggle { bottom: 74px; }
:root[data-theme="dark"] .option-card.selected .option-main,
:root[data-theme="dark"] .question-grid button.current { background: #265582; border-color: #91c3f5; color: #fff; }
:root[data-theme="dark"] .option-card.eliminated .option-main { background: #1b293a; }
:root[data-theme="dark"] .question-stem,
:root[data-theme="dark"] .option-text,
:root[data-theme="dark"] .question-title,
:root[data-theme="dark"] .workspace-title-wrap h2,
:root[data-theme="dark"] .result-option-text,
:root[data-theme="dark"] .result-body,
:root[data-theme="dark"] .result-card h3 { color: #eef6ff; }
:root[data-theme="dark"] .launch-header p,
:root[data-theme="dark"] .version-copy,
:root[data-theme="dark"] .password-label span,
:root[data-theme="dark"] .launch-field span,
:root[data-theme="dark"] .field-hint,
:root[data-theme="dark"] .question-meta,
:root[data-theme="dark"] .workspace-title-wrap p { color: #b6c9dd !important; }
:root[data-theme="dark"] .highlight-chip { background: #5e4e20; color: #ffea8f; border-color: #ba9c45; }
:root[data-theme="dark"] .next-btn { background: #315d91; color: #fff; }
:root[data-theme="dark"] .next-btn.submit-mode { background: #24734b; }
:root[data-theme="dark"] .exam-highlight { background: #ebc746; color: #1e2833; }
:root[data-theme="dark"] .results-hero { background: #173650; }
:root[data-theme="dark"] .result-option-row.correct .result-option-badge,
:root[data-theme="dark"] .answer-chip.correct { background: #1b4a37; color: #a9efc5; border-color: #4c9773; }
:root[data-theme="dark"] .result-option-row.selected-wrong .result-option-badge,
:root[data-theme="dark"] .answer-chip.incorrect { background: #532f35; color: #ffc2ca; border-color: #a26068; }
:root[data-theme="dark"] .answer-chip.neutral { background: #2c4058; color: #c4d6e8; }
:root[data-theme="dark"] .result-status.correct { color: #95e0b1; }
:root[data-theme="dark"] .result-status.incorrect { color: #ffabb5; }
:root[data-theme="dark"] .submit-progress { background: #183c31; border-color: #4b8766; }
:root[data-theme="dark"] .submit-progress-topline,
:root[data-theme="dark"] .submit-progress p { color: #b9f4d0; }
:root[data-theme="dark"] .submit-progress-topline span { background: #25543e; color: #c9f9dc; border-color: #70a982; }
:root[data-theme="dark"] .submit-progress-bar { background: #2a5b41; }
:root[data-theme="dark"] .modal::backdrop { background: rgba(0, 0, 0, .72); }

@media (max-width: 760px) { .theme-toggle { right: 10px; bottom: 10px; } body:has(#exam-screen:not(.hidden)) .theme-toggle { bottom: 132px; } }
@media print { .theme-toggle { display: none !important; } }
