/*
 * MedDarvish color modes
 * This file only changes colors. Layout, sizing and component behaviour remain
 * owned by the existing theme and quiz/workbench code.
 */

html[data-md-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg2: #edf1f8;
  --card: #ffffff;
  --card2: #eef2f9;
  --panel: #ffffff;
  --panel2: #edf1f8;
  --surface: #ffffff;
  --surface2: #eef2f9;
  --toolbar: #ffffff;
  --text: #171a2a;
  --soft: #353b50;
  --muted: #626b82;
  --border: #d6dceb;
  --border2: #c8d0e3;
  --line: rgba(91, 77, 194, .24);
  --line2: rgba(91, 77, 194, .16);
  --line-strong: rgba(91, 77, 194, .48);
  --brand: #6254df;
  --brand2: #7453c8;
  --purple: #6254df;
  --purple2: #7453c8;
  --accent: #c84646;
  --accent2: #267fa8;
  --accent3: #16825a;
  --accent4: #8b6a12;
  --cyan: #147fa7;
  --green: #16825a;
  --red: #c63f4d;
  --gold: #8b6a12;
  --blue: #2765ca;
  --yellow: #8b6a12;
  --ink: #171a2a;
  --opt-bg: #f5f7fc;
  --opt-hover: #e9edfa;
  --correct-bg: #e8f7ef;
  --correct-border: #61b987;
  --correct-text: #126d42;
  --wrong-bg: #fff0f1;
  --wrong-border: #dc8790;
  --wrong-text: #a92f3a;
  --shadow: 0 18px 45px rgba(52, 60, 91, .13);
}

html[data-md-theme="light"],
html[data-md-theme="light"] body {
  background-color: var(--bg) !important;
  color: var(--text) !important;
}

html[data-md-theme="light"] body {
  background-image:
    radial-gradient(circle at 78% 0%, rgba(98, 84, 223, .09), transparent 32rem),
    radial-gradient(circle at 12% 18%, rgba(38, 127, 168, .07), transparent 28rem) !important;
}

html[data-md-theme="light"] .md-navbar {
  background: rgba(250, 251, 254, .96) !important;
  border-bottom-color: var(--border) !important;
  box-shadow: 0 8px 26px rgba(52, 60, 91, .08) !important;
}

html[data-md-theme="light"] :where(
  .md-nav-menu,
  .md-nav-search,
  .md-auth-btn,
  .md-nav-toggle,
  .md-card,
  .md-box,
  .md-panel,
  .md-profile-card,
  .md-course-card,
  .md-lesson-card,
  .md-accordion,
  .md-acc-head,
  .md-acc-body,
  .md-lpane,
  .md-footer-card,
  .md-notice,
  .md-modal,
  .md-modal-box,
  .md-popup,
  .md-dialog
) {
  background-color: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow);
}

html[data-md-theme="light"] :where(
  input,
  textarea,
  select,
  .md-nav-search-input
) {
  background-color: #ffffff !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  color-scheme: light;
}

html[data-md-theme="light"] :where(input, textarea)::placeholder {
  color: #7b8499 !important;
  opacity: 1;
}

html[data-md-theme="light"] :where(
  .md-brand-text,
  .md-auth-btn,
  .md-nav-menu a,
  .md-nav-toggle,
  .md-content,
  .md-content h1,
  .md-content h2,
  .md-content h3,
  .md-content h4,
  .md-content strong
) {
  color: var(--text);
}

html[data-md-theme="light"] :where(
  .md-muted,
  .md-meta,
  .md-subtitle,
  .md-description,
  .md-card p,
  .md-content p
) {
  color: var(--muted);
}

html[data-md-theme="light"] :where(
  .md-site-footer,
  .site-footer,
  footer
) {
  background-color: #edf1f8 !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

html[data-md-theme="light"] .md-fl-bg {
  opacity: .27 !important;
  mix-blend-mode: multiply !important;
  filter: saturate(.82) contrast(.9);
}

html[data-md-theme="light"] .md-scrollrail {
  opacity: .7;
}

/* Theme controls */
.md-theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.md-theme-toggle:hover {
  border-color: rgba(124, 111, 255, .62);
  transform: translateY(-1px);
}

.md-theme-toggle-desktop {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.md-theme-toggle-mobile {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border-radius: 9px;
  padding: 9px 13px;
  font-weight: 800;
  text-align: right;
}

.md-theme-toggle-icon {
  width: 24px;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.md-theme-menu-item {
  display: none;
  width: 100%;
}

@media (max-width: 1024px) {
  .md-theme-toggle-desktop {
    display: none;
  }

  .md-theme-menu-item {
    display: block;
  }
}

@media (min-width: 1025px) {
  .md-theme-toggle-desktop {
    display: inline-grid;
  }
}

/* Educational/offline quiz plugin: variables and hard-coded dark surfaces. */
html[data-md-theme="light"] .mdq {
  --mq-bg: #f4f6fb;
  --mq-card: #ffffff;
  --mq-card2: #eef2f9;
  --mq-border: #d6dceb;
  --mq-text: #171a2a;
  --mq-muted: #626b82;
  --mq-brand: #6254df;
  --mq-brand2: #7453c8;
  --mq-red: #c63f4d;
  --mq-blue: #267fa8;
  --mq-green: #16825a;
  --mq-yellow: #8b6a12;
}

html[data-md-theme="light"] :where(
  .mdq-bar,
  .mdq-card,
  .mdq-result,
  .mdq-modal-box,
  .mdq-cdlg-box
) {
  background: rgba(255, 255, 255, .96) !important;
  color: var(--mq-text) !important;
  border-color: var(--mq-border) !important;
  box-shadow: 0 14px 36px rgba(52, 60, 91, .12) !important;
}

html[data-md-theme="light"] :where(
  .mdq-progress-track,
  .mdq-stat,
  .mdq-opt,
  .mdq-flag,
  .mdq-cell,
  .mdq-modal-x,
  .mdq-advice .tag,
  .mdq-timer input,
  .mdq-cdlg-no
) {
  background: #f4f6fb !important;
  color: var(--mq-text) !important;
  border-color: var(--mq-border) !important;
}

html[data-md-theme="light"] .mdq-opt:hover {
  background: #e9edfa !important;
}

html[data-md-theme="light"] .mdq-exp {
  color: #654f13 !important;
  background: #fff9e9 !important;
}

html[data-md-theme="light"] :where(.mdq-modal, .mdq-cdlg) {
  background: rgba(24, 28, 43, .36) !important;
}

html[data-md-theme="light"] .mdq-advice {
  color: #3e3a65 !important;
  background: #f2f0ff !important;
}

html[data-md-theme="light"] .mdq-table td {
  color: var(--mq-text) !important;
}

html[data-md-theme="light"] .mdq-table th {
  color: #44378f !important;
  background: #eeebff !important;
}

/* Common standalone lesson/answer-key HTML, including documents injected into iframes. */
html[data-md-theme="light"] :where(
  .navbar,
  .topbar,
  .header,
  .card,
  .box,
  .panel,
  .qa-card,
  .question-card,
  .quiz-card,
  .answer-card,
  .summary-card,
  .toc,
  .toc-wrap,
  .part-header,
  .fig,
  .figure-card,
  .table-wrap,
  .accordion,
  .accordion-item,
  .accordion-content,
  .tabs,
  .tab-panel,
  .notice,
  .callout
) {
  color: var(--text) !important;
  border-color: var(--border) !important;
}

html[data-md-theme="light"] :where(
  .card,
  .box,
  .panel,
  .qa-card,
  .question-card,
  .quiz-card,
  .answer-card,
  .summary-card,
  .toc,
  .part-header,
  .fig,
  .figure-card,
  .accordion,
  .accordion-item,
  .accordion-content,
  .tab-panel,
  .notice,
  .callout
) {
  background-color: var(--card) !important;
  background-image: none !important;
  box-shadow: var(--shadow) !important;
}

html[data-md-theme="light"] :where(
  .navbar,
  .topbar,
  .header
) {
  background: rgba(250, 251, 254, .96) !important;
  color: var(--text) !important;
}

html[data-md-theme="light"] :where(
  h1, h2, h3, h4, h5, h6,
  .title, .question, .question-text, .q-text
) {
  color: var(--text);
}

html[data-md-theme="light"] :where(
  p, li, td, figcaption,
  .subtitle, .description, .explanation, .muted
) {
  color: var(--soft);
}

html[data-md-theme="light"] table {
  border-color: var(--border) !important;
}

html[data-md-theme="light"] th {
  background: #e9edfa !important;
  color: #302866 !important;
  border-color: var(--border) !important;
}

html[data-md-theme="light"] td {
  background: #ffffff !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

html[data-md-theme="light"] tr:nth-child(even) td {
  background: #f5f7fc !important;
}

html[data-md-theme="light"] pre,
html[data-md-theme="light"] code {
  background: #e9edfa;
  color: #302866;
}

@media (prefers-reduced-motion: reduce) {
  .md-theme-toggle {
    transition: none;
  }
}

/* Interactive study workbench shell. */
html[data-md-theme="light"] :where(.top-card,.work-head,.chapter-switch,.course-toggle,.chapter-toggle,.course-menu,.chapter-menu,.panel-toggle,.side-reopen,.side-panel,.status-strip,.settings-pop,.modal,.item-card){background-color:#fff!important;background-image:none!important;color:var(--text)!important;border-color:var(--border)!important;box-shadow:0 12px 34px rgba(52,60,91,.11)!important}
html[data-md-theme="light"] .work-head{background:rgba(250,251,254,.97)!important}
html[data-md-theme="light"] :where(.doc-title,.work-brand,.work-brand .brand-med,.chapter-label,.course-toggle,.chapter-toggle,.course-option,.chapter-option,.side-panel h3,.tool-btn){color:var(--text)!important}
html[data-md-theme="light"] :where(.course-option:hover,.chapter-option:hover,.tool-btn:hover,.tool-btn.active){background-color:#e9edfa!important}
html[data-md-theme="light"] :where(select,.chapter-switch select,.modal textarea,.modal input){background:#f5f7fc!important;color:var(--text)!important;border-color:var(--border)!important;color-scheme:light!important}
html[data-md-theme="light"] select option{background:#fff!important;color:var(--text)!important}
html[data-md-theme="light"] :where(.reader-wrap,.reader-main,.study-surface,.lesson-host){background-color:transparent!important}
html[data-md-theme="light"] .work-progress{background:#eeebff!important;border-color:rgba(98,84,223,.28)!important}
html[data-md-theme="light"] .work-progress-row{color:#44378f!important}
html[data-md-theme="light"] .work-progress-track{background:#dfe4f1!important}
html[data-md-theme="light"] .xodo-tools{background:#fff!important;border-color:var(--border)!important}
html[data-md-theme="light"] .divider{background:var(--border)!important}
html[data-md-theme="light"] .empty{border-color:#c8d0e3!important;color:var(--muted)!important}
html[data-md-theme="light"] .modal-backdrop{background:rgba(24,28,43,.34)!important}
/* Online exam shell. */
html[data-md-theme="light"] .mdx-wrap{color:var(--text)!important}
html[data-md-theme="light"] :where(.mdx-head,.mdx-countdown,.mdx-done,.mdx-card,.mdx-sched span,.mdx-personal-result){background:#fff!important;color:var(--text)!important;border-color:var(--border)!important;box-shadow:0 14px 34px rgba(52,60,91,.11)!important}
html[data-md-theme="light"] .mdx-clock .u{background:#f4f6fb!important;color:var(--text)!important;border-color:var(--border)!important}
html[data-md-theme="light"] :where(.mdx-sched,.mdx-cd-label,.mdx-card-meta,.mdx-done .mdx-sub){color:var(--muted)!important}
html[data-md-theme="light"] .mdx-card-main b{color:var(--text)!important}
html[data-md-theme="light"] .mdx-enter-alert{background:#fff9e9!important;color:#654f13!important;border-color:#d5bd70!important}
html[data-md-theme="light"] .mdx-personal-result i{color:var(--text)!important}
/* Semantic result colors stay visible in light mode. */
html[data-md-theme="light"] :where(.correct,.is-correct,.qa-correct,.answer-correct,.ok,.md-ok){background-color:var(--correct-bg)!important;border-color:var(--correct-border)!important;color:var(--correct-text)!important}
html[data-md-theme="light"] :where(.wrong,.is-wrong,.qa-wrong,.answer-wrong,.bad,.md-bad){background-color:var(--wrong-bg)!important;border-color:var(--wrong-border)!important;color:var(--wrong-text)!important}
html[data-md-theme="light"] svg text[fill="#fff"],html[data-md-theme="light"] svg text[fill="#ffffff"],html[data-md-theme="light"] svg text[fill="white"]{fill:#171a2a!important}

/*
 * Light-mode refinements.
 * Every rule in this section is scoped to the light theme so the original
 * dark presentation remains untouched.
 */
html[data-md-theme="light"] body {
  background-image:
    linear-gradient(rgba(90, 111, 155, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 111, 155, .035) 1px, transparent 1px),
    linear-gradient(180deg, #f7f9fd 0%, #eef3fa 100%) !important;
  background-size: 48px 48px, 48px 48px, auto !important;
}

html[data-md-theme="light"] .md-fl-bg {
  opacity: .46 !important;
  mix-blend-mode: multiply !important;
  filter: saturate(.95) contrast(1.12) brightness(.86);
}

html[data-md-theme="light"] .md-hero {
  background:
    linear-gradient(180deg, rgba(235, 239, 252, .96), rgba(248, 250, 255, .9)) !important;
  border-bottom: 1px solid rgba(98, 84, 223, .14) !important;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .75);
}

html[data-md-theme="light"] .md-hero-glow {
  opacity: .78;
  filter: saturate(.75);
}

html[data-md-theme="light"] :where(.md-about-sec, .md-courses-sec, .md-home-reviews-sec) {
  position: relative;
}

html[data-md-theme="light"] .md-journey-3d {
  background-color: rgba(233, 239, 249, .72);
  border-top: 1px solid rgba(98, 84, 223, .1);
  border-bottom: 1px solid rgba(38, 127, 168, .1);
}

/* Front-page cards that retained hard-coded dark colors. */
html[data-md-theme="light"] .md-about-card {
  background: #ffffff !important;
  border-color: #d8deed !important;
  box-shadow:
    inset -4px 0 0 rgba(98, 84, 223, .72),
    0 22px 50px rgba(54, 65, 96, .13) !important;
}

html[data-md-theme="light"] .md-about-card h2,
html[data-md-theme="light"] .md-about-lead {
  color: #171a2a !important;
}

html[data-md-theme="light"] .md-about-body p {
  color: #4e586f !important;
}

html[data-md-theme="light"] .md-about-note {
  color: #5843bd !important;
}

html[data-md-theme="light"] :where(.md-support-card, .md-contact-card) {
  background: #ffffff !important;
  color: var(--text) !important;
  border-color: #d5dced !important;
  box-shadow: 0 18px 42px rgba(54, 65, 96, .11) !important;
}

html[data-md-theme="light"] :where(.md-support-card p, .md-contact-card p) {
  color: #566078 !important;
}

/* Educational disclaimer and footer. */
html[data-md-theme="light"] .md-disc-box {
  background: #eaf4fb !important;
  border-color: #b8d7e7 !important;
  border-right-color: #267fa8 !important;
  box-shadow: 0 10px 26px rgba(38, 127, 168, .08);
}

html[data-md-theme="light"] .md-disc-box b {
  color: #176d91 !important;
}

html[data-md-theme="light"] .md-disc-box p {
  color: #354b62 !important;
}

html[data-md-theme="light"] .md-footer {
  background: #edf2f8 !important;
  color: var(--text) !important;
}

html[data-md-theme="light"] .md-footer::after {
  background: #edf2f8 !important;
  border-color: rgba(98, 84, 223, .2) !important;
  box-shadow: 0 16px 34px rgba(54, 65, 96, .1) !important;
}

html[data-md-theme="light"] :where(
  .md-footer-brandbox,
  .md-footer-trustbox
) {
  background: #ffffff !important;
  color: var(--text) !important;
  border-color: #d3daea !important;
  box-shadow: 0 12px 28px rgba(54, 65, 96, .09) !important;
}

html[data-md-theme="light"] .md-footer-links a {
  color: #333c55 !important;
  border-color: #d5dced !important;
  box-shadow: none !important;
}

html[data-md-theme="light"] .md-footer-links a:nth-child(4n + 1) {
  background: #f2efff !important;
  border-color: #d9d1f7 !important;
}

html[data-md-theme="light"] .md-footer-links a:nth-child(4n + 2) {
  background: #edf6fd !important;
  border-color: #c9deed !important;
}

html[data-md-theme="light"] .md-footer-links a:nth-child(4n + 3) {
  background: #edf8f3 !important;
  border-color: #c8e4d7 !important;
}

html[data-md-theme="light"] .md-footer-links a:nth-child(4n) {
  background: #fff2f3 !important;
  border-color: #eccfd3 !important;
}

html[data-md-theme="light"] :where(
  .md-footer-about,
  .md-footer-description,
  .md-footer-brandbox p,
  .md-footer-trustbox p
) {
  color: #5b657c !important;
}

html[data-md-theme="light"] .md-footer-rights {
  background: #e7ecf7 !important;
  color: #3d4963 !important;
  border-color: #cbd5e6 !important;
}

html[data-md-theme="light"] .md-footer-wordmark {
  background: #ffffff !important;
  color: #252b3e !important;
  border-color: #d4d9e8 !important;
  box-shadow: 0 10px 24px rgba(54, 65, 96, .1) !important;
}

/* Standalone lesson layouts with hard-coded dark component surfaces. */
html[data-md-theme="light"] :where(
  .source-table-figure,
  .image-card,
  .image-box,
  .figure,
  .figure-box,
  .media-card,
  .mini,
  .review-item,
  .step,
  .formula,
  .chapter-divider,
  .integrated-map .map-item,
  .method-flow .flow-step,
  .epithelium-card,
  .junction-strip .junction,
  .clinical-box,
  .audit-note
) {
  background: #ffffff !important;
  background-image: none !important;
  color: var(--text) !important;
  border-color: #d4dbea !important;
  box-shadow: 0 12px 30px rgba(54, 65, 96, .09) !important;
}

html[data-md-theme="light"] :where(
  .source-table-figure figcaption,
  .image-card figcaption,
  .image-box figcaption,
  .figure figcaption,
  .figure-box figcaption,
  .media-card figcaption,
  .source-note,
  .fcap
) {
  color: #4f5b73 !important;
}

html[data-md-theme="light"] :where(
  .mini strong,
  .review-item strong,
  .step-body strong,
  .integrated-map strong,
  .epithelium-card strong
) {
  color: #20263a !important;
}

html[data-md-theme="light"] :where(
  .step-body,
  .integrated-map span,
  .method-flow .flow-step span,
  .epithelium-card span,
  .junction-strip span
) {
  color: #4f5b73 !important;
}

html[data-md-theme="light"] .chapter-tags span {
  background: #f1effc !important;
  color: #4e3ca8 !important;
  border-color: #d7cff2 !important;
}

html[data-md-theme="light"] .route-line span {
  color: #303950 !important;
  border-color: #d1d8e8 !important;
  box-shadow: 0 5px 14px rgba(54, 65, 96, .06);
}

html[data-md-theme="light"] .route-line span:nth-of-type(4n + 1) {
  background: #f2efff !important;
  border-color: #d9d1f7 !important;
}

html[data-md-theme="light"] .route-line span:nth-of-type(4n + 2) {
  background: #edf6fd !important;
  border-color: #c9deed !important;
}

html[data-md-theme="light"] .route-line span:nth-of-type(4n + 3) {
  background: #edf8f3 !important;
  border-color: #c8e4d7 !important;
}

html[data-md-theme="light"] .route-line span:nth-of-type(4n) {
  background: #fff2f3 !important;
  border-color: #eccfd3 !important;
}

/* Distinct but quiet colors make answer choices easier to scan. */
html[data-md-theme="light"] :where(
  .q-options > .opt,
  .options > .option,
  .answers > .answer,
  .choices > .choice,
  .mdq-options > .mdq-opt
):not(.correct):not(.wrong):not(.is-correct):not(.is-wrong):not(.selected) {
  color: #263047 !important;
}

html[data-md-theme="light"] :where(
  .q-options > .opt,
  .options > .option,
  .answers > .answer,
  .choices > .choice,
  .mdq-options > .mdq-opt
):nth-child(4n + 1):not(.correct):not(.wrong):not(.is-correct):not(.is-wrong):not(.selected) {
  background: #f2efff !important;
  border-color: #d8cff7 !important;
}

html[data-md-theme="light"] :where(
  .q-options > .opt,
  .options > .option,
  .answers > .answer,
  .choices > .choice,
  .mdq-options > .mdq-opt
):nth-child(4n + 2):not(.correct):not(.wrong):not(.is-correct):not(.is-wrong):not(.selected) {
  background: #edf6fd !important;
  border-color: #c7deef !important;
}

html[data-md-theme="light"] :where(
  .q-options > .opt,
  .options > .option,
  .answers > .answer,
  .choices > .choice,
  .mdq-options > .mdq-opt
):nth-child(4n + 3):not(.correct):not(.wrong):not(.is-correct):not(.is-wrong):not(.selected) {
  background: #edf8f3 !important;
  border-color: #c6e5d6 !important;
}

html[data-md-theme="light"] :where(
  .q-options > .opt,
  .options > .option,
  .answers > .answer,
  .choices > .choice,
  .mdq-options > .mdq-opt
):nth-child(4n):not(.correct):not(.wrong):not(.is-correct):not(.is-wrong):not(.selected) {
  background: #fff2f3 !important;
  border-color: #edcdd2 !important;
}

html[data-md-theme="light"] :where(
  .opt-num,
  .option-num,
  .answer-num,
  .choice-num,
  .mdq-opt-num
) {
  background: #e2ddff !important;
  color: #4938a8 !important;
  border-color: #cfc5fa !important;
}

/* The quiz plugin renders option labels directly inside each question card. */
html[data-md-theme="light"] .mdq-opt:not(.mdq-correct):not(.mdq-wrong) {
  color: #263047 !important;
}

html[data-md-theme="light"] .mdq-opt:nth-of-type(4n + 1):not(.mdq-correct):not(.mdq-wrong) {
  background: #f2efff !important;
  border-color: #d8cff7 !important;
}

html[data-md-theme="light"] .mdq-opt:nth-of-type(4n + 2):not(.mdq-correct):not(.mdq-wrong) {
  background: #edf6fd !important;
  border-color: #c7deef !important;
}

html[data-md-theme="light"] .mdq-opt:nth-of-type(4n + 3):not(.mdq-correct):not(.mdq-wrong) {
  background: #edf8f3 !important;
  border-color: #c6e5d6 !important;
}

html[data-md-theme="light"] .mdq-opt:nth-of-type(4n):not(.mdq-correct):not(.mdq-wrong) {
  background: #fff2f3 !important;
  border-color: #edcdd2 !important;
}

html[data-md-theme="light"] .mdq-opt.mdq-correct {
  background: var(--correct-bg) !important;
  border-color: var(--correct-border) !important;
  color: var(--correct-text) !important;
}

html[data-md-theme="light"] .mdq-opt.mdq-wrong {
  background: var(--wrong-bg) !important;
  border-color: var(--wrong-border) !important;
  color: var(--wrong-text) !important;
}
