/* =========================================================
   CM Academy Dark Theme
   - Default site remains light.
   - Dark theme activates only when html[data-cm-theme="dark"] exists.
   - Preference is saved on the user's device with localStorage.
   - Main public navbar intentionally keeps the current light design.
   ========================================================= */

.cm-theme-toggle {
  border: 1px solid rgba(160, 33, 73, .16);
  background: rgba(251, 237, 242, .82);
  color: #3d0d22;
  font: inherit;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.2;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.cm-theme-toggle:hover {
  background: #fff;
  border-color: rgba(160, 33, 73, .28);
  box-shadow: 0 10px 24px rgba(61, 13, 34, .08);
  transform: translateY(-1px);
}
.cm-theme-toggle-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: #a02149;
  font-size: .86rem;
  line-height: 1;
}
.cm-theme-toggle-text { font-size: .86rem; }

html[data-cm-theme="dark"] {
  color-scheme: dark;
  --cm-red: #ff7aa2;
  --cm-red-2: #ff8cac;
  --cm-red-dark: #ffd3df;
  --cm-red-soft: rgba(255, 122, 162, .14);
  --cm-ink: #f4f7ff;
  --cm-muted: #bbc4d9;
  --cm-bg: #0f1118;
  --cm-white: #171b25;
  --cm-card: rgba(24, 29, 41, .88);
  --cm-card-solid: #1a2030;
  --cm-border: rgba(219, 228, 255, .14);
  --cm-border-strong: rgba(255, 122, 162, .32);
  --cm-shadow: 0 24px 70px rgba(0, 0, 0, .46);
  --cm-shadow-soft: 0 14px 42px rgba(0, 0, 0, .34);
}

html[data-cm-theme="dark"] body {
  color: var(--cm-ink);
  background:
    radial-gradient(circle at top left, rgba(255, 122, 162, .10), transparent 34rem),
    radial-gradient(circle at 80% 8%, rgba(125, 184, 255, .09), transparent 28rem),
    linear-gradient(180deg, #0f1118, #111522 48%, #0d1018);
}
html[data-cm-theme="dark"] p,
html[data-cm-theme="dark"] li,
html[data-cm-theme="dark"] small,
html[data-cm-theme="dark"] span { color: inherit; }
html[data-cm-theme="dark"] p { color: var(--cm-muted); }
html[data-cm-theme="dark"] strong { color: #fff; }
html[data-cm-theme="dark"] a { color: inherit; }
html[data-cm-theme="dark"] hr { border-color: var(--cm-border); }

/* Keep the main public navbar visually light as requested */
html[data-cm-theme="dark"] .cm-site-header {
  --cm-red: #a02149;
  --cm-red-2: #c92b55;
  --cm-red-dark: #3d0d22;
  --cm-red-soft: #fbedf2;
  --cm-ink: #201821;
  --cm-muted: #625863;
  --cm-bg: #fffafb;
  --cm-white: #ffffff;
  --cm-card: rgba(255, 255, 255, .78);
  --cm-card-solid: #ffffff;
  --cm-border: rgba(160, 33, 73, .13);
  --cm-border-strong: rgba(160, 33, 73, .22);
  --cm-shadow-soft: 0 12px 34px rgba(61, 13, 34, .09);
  color: #2a2029;
}
html[data-cm-theme="dark"] .cm-topbar {
  background: linear-gradient(90deg, #3b0b20, #a02149, #7d1739);
  color: #fff;
}
html[data-cm-theme="dark"] .cm-navbar {
  background: rgba(255, 255, 255, .86);
  border-bottom-color: rgba(160, 33, 73, .10);
  box-shadow: 0 12px 34px rgba(61, 13, 34, .055);
}
html[data-cm-theme="dark"] .cm-nav-menu > a,
html[data-cm-theme="dark"] .cm-dropdown > button { color: #2a2029; }
html[data-cm-theme="dark"] .cm-dropdown-menu {
  background: rgba(255, 255, 255, .98);
  border-color: rgba(160, 33, 73, .13);
  box-shadow: 0 24px 70px rgba(61, 13, 34, .16);
}
html[data-cm-theme="dark"] .cm-dropdown-menu a { color: #625863; }
html[data-cm-theme="dark"] .cm-dropdown-menu a:hover { color: #3d0d22; background: #fbedf2; }
html[data-cm-theme="dark"] .cm-site-header .cm-theme-toggle {
  background: #26131d;
  border-color: rgba(160, 33, 73, .28);
  color: #fff;
}
html[data-cm-theme="dark"] .cm-site-header .cm-theme-toggle-icon {
  background: #ffdce7;
  color: #7d1739;
}
html[data-cm-theme="dark"] .cm-site-header .cm-nav-toggle { background: #fbedf2; }
html[data-cm-theme="dark"] .cm-site-header .cm-nav-toggle span { background: #3d0d22; }
@media (max-width: 900px) {
  html[data-cm-theme="dark"] .cm-site-header .cm-nav-menu {
    background: rgba(255, 255, 255, .985);
    border-color: rgba(160, 33, 73, .13);
  }
  .cm-theme-toggle { width: 100%; justify-content: flex-start; padding: 10px 12px; }
}

/* Shared dark surface system */
html[data-cm-theme="dark"] .cm-glass,
html[data-cm-theme="dark"] .cm-course-card,
html[data-cm-theme="dark"] .cm-final-cta-card,
html[data-cm-theme="dark"] .cm-footer-card,
html[data-cm-theme="dark"] .cm-contact-form,
html[data-cm-theme="dark"] .cm-lesson-main,
html[data-cm-theme="dark"] .cm-course-sidebar,
html[data-cm-theme="dark"] .cm-ad-box,
html[data-cm-theme="dark"] .cm-question-box,
html[data-cm-theme="dark"] .cm-caremedox-cta,
html[data-cm-theme="dark"] .cm-public-card,
html[data-cm-theme="dark"] .cm-public-aside-card,
html[data-cm-theme="dark"] .cm-community-search,
html[data-cm-theme="dark"] .cm-community-ask,
html[data-cm-theme="dark"] .cm-community-question,
html[data-cm-theme="dark"] .cm-community-empty,
html[data-cm-theme="dark"] .cm-community-side,
html[data-cm-theme="dark"] .cm-portal-card,
html[data-cm-theme="dark"] .cm-auth-card,
html[data-cm-theme="dark"] .cm-portal-table,
html[data-cm-theme="dark"] .cm-comment-thread,
html[data-cm-theme="dark"] .cm-message-card,
html[data-cm-theme="dark"] .cm-submission-card {
  background: var(--cm-card) !important;
  border-color: var(--cm-border) !important;
  box-shadow: var(--cm-shadow-soft) !important;
  color: var(--cm-ink) !important;
}
html[data-cm-theme="dark"] .cm-site-header .cm-glass { background: rgba(255,255,255,.82) !important; color: #2a2029 !important; }

html[data-cm-theme="dark"] :where(h1,h2,h3,h4,h5,h6),
html[data-cm-theme="dark"] .cm-course-card h3,
html[data-cm-theme="dark"] .cm-course-card h4,
html[data-cm-theme="dark"] .cm-contact-form h2,
html[data-cm-theme="dark"] .cm-footer-grid h3,
html[data-cm-theme="dark"] .cm-lesson-main h1,
html[data-cm-theme="dark"] .lesson-section h2,
html[data-cm-theme="dark"] .cm-public-card h2,
html[data-cm-theme="dark"] .cm-public-card h3,
html[data-cm-theme="dark"] .cm-community-hero-card h1,
html[data-cm-theme="dark"] .cm-community-side h2,
html[data-cm-theme="dark"] .cm-meta strong,
html[data-cm-theme="dark"] .cm-empty-chat strong {
  color: #f7f9ff !important;
}
html[data-cm-theme="dark"] .lesson-heading,
html[data-cm-theme="dark"] .cm-public-hero-card h1 {
  color: #fff !important;
}
html[data-cm-theme="dark"] .cm-kicker,
html[data-cm-theme="dark"] .cm-level,
html[data-cm-theme="dark"] .cm-badge {
  background: rgba(255, 122, 162, .16) !important;
  border-color: rgba(255, 122, 162, .26) !important;
  color: #ffc6d6 !important;
}
html[data-cm-theme="dark"] .cm-btn-soft,
html[data-cm-theme="dark"] .cm-portal-btn-soft {
  background: rgba(255, 255, 255, .08) !important;
  border-color: var(--cm-border) !important;
  color: #f2f5ff !important;
}
html[data-cm-theme="dark"] .cm-btn-primary,
html[data-cm-theme="dark"] .cm-portal-btn,
html[data-cm-theme="dark"] .cm-nav-cta {
  box-shadow: 0 16px 36px rgba(255, 122, 162, .18) !important;
}

/* Inputs/forms */
html[data-cm-theme="dark"] input,
html[data-cm-theme="dark"] select,
html[data-cm-theme="dark"] textarea,
html[data-cm-theme="dark"] .cm-contact-form input,
html[data-cm-theme="dark"] .cm-contact-form select,
html[data-cm-theme="dark"] .cm-contact-form textarea,
html[data-cm-theme="dark"] .cm-community-search input,
html[data-cm-theme="dark"] .cm-community-search select,
html[data-cm-theme="dark"] .cm-community-form input,
html[data-cm-theme="dark"] .cm-community-form textarea,
html[data-cm-theme="dark"] .cm-portal-form input,
html[data-cm-theme="dark"] .cm-portal-form select,
html[data-cm-theme="dark"] .cm-portal-form textarea,
html[data-cm-theme="dark"] .cm-chat-user-search input,
html[data-cm-theme="dark"] .cm-chat-user-search select,
html[data-cm-theme="dark"] .cm-chat-filters input {
  background: rgba(9, 12, 20, .72) !important;
  border-color: rgba(219, 228, 255, .18) !important;
  color: #f5f7ff !important;
}
html[data-cm-theme="dark"] input::placeholder,
html[data-cm-theme="dark"] textarea::placeholder { color: rgba(219, 228, 255, .50) !important; }
html[data-cm-theme="dark"] label,
html[data-cm-theme="dark"] .cm-community-search label,
html[data-cm-theme="dark"] .cm-community-form label,
html[data-cm-theme="dark"] .cm-portal-form label { color: #d3daec !important; }

/* Lesson pages */
html[data-cm-theme="dark"] .cm-lesson-shell { background: transparent !important; }
html[data-cm-theme="dark"] .cm-lesson-topline,
html[data-cm-theme="dark"] .cm-sidebar-current small,
html[data-cm-theme="dark"] .cm-lesson-author-box { color: #b8c1d9 !important; }
html[data-cm-theme="dark"] .cm-lesson-author-box b { color: #dfe6f8 !important; }
html[data-cm-theme="dark"] .cm-lesson-link { color: #c8d1e8 !important; border-color: transparent !important; }
html[data-cm-theme="dark"] .cm-lesson-link:hover { background: rgba(255, 255, 255, .07) !important; color: #fff !important; }
html[data-cm-theme="dark"] .cm-lesson-link span { background: rgba(255, 122, 162, .16) !important; color: #ffc6d6 !important; }
html[data-cm-theme="dark"] .cm-lesson-link.is-active {
  background: linear-gradient(135deg, #d43c69, #8c54ff) !important;
  color: #fff !important;
}
html[data-cm-theme="dark"] .cm-sidebar-current { background: rgba(10, 13, 22, .50) !important; border-color: var(--cm-border) !important; }
html[data-cm-theme="dark"] .cm-content-ad,
html[data-cm-theme="dark"] .cm-community-ad {
  background: rgba(19, 24, 35, .70) !important;
  border-color: rgba(255, 122, 162, .28) !important;
  color: var(--cm-muted) !important;
}

/* Lesson content color variations with readable contrast */
html[data-cm-theme="dark"] .content-section { background: rgba(24, 29, 41, .88) !important; border-color: var(--cm-border) !important; color: var(--cm-ink) !important; }
html[data-cm-theme="dark"] .content-section.section-red,
html[data-cm-theme="dark"] .addoninfo.addon-red,
html[data-cm-theme="dark"] .do-red { background: #3a1724 !important; border-color: #ff7aa2 !important; color: #ffe9f0 !important; }
html[data-cm-theme="dark"] .content-section.section-blue,
html[data-cm-theme="dark"] .addoninfo.addon-blue,
html[data-cm-theme="dark"] .do-blue { background: #11243b !important; border-color: #7db8ff !important; color: #e4f1ff !important; }
html[data-cm-theme="dark"] .content-section.section-green,
html[data-cm-theme="dark"] .addoninfo.addon-green,
html[data-cm-theme="dark"] .do-green { background: #113323 !important; border-color: #7ee89d !important; color: #e6ffee !important; }
html[data-cm-theme="dark"] .content-section.section-purple,
html[data-cm-theme="dark"] .addoninfo.addon-purple,
html[data-cm-theme="dark"] .do-purple { background: #271b40 !important; border-color: #c99cff !important; color: #f1e9ff !important; }
html[data-cm-theme="dark"] .content-section.section-orange,
html[data-cm-theme="dark"] .addoninfo.addon-orange,
html[data-cm-theme="dark"] .do-orange { background: #3b2914 !important; border-color: #ffca7a !important; color: #fff2dd !important; }
html[data-cm-theme="dark"] .section-red :is(h1,h2,h3,h4,h5,h6),
html[data-cm-theme="dark"] .addon-red :is(h1,h2,h3,h4,h5,h6) { color: #ff9db9 !important; }
html[data-cm-theme="dark"] .section-blue :is(h1,h2,h3,h4,h5,h6),
html[data-cm-theme="dark"] .addon-blue :is(h1,h2,h3,h4,h5,h6) { color: #96caff !important; }
html[data-cm-theme="dark"] .section-green :is(h1,h2,h3,h4,h5,h6),
html[data-cm-theme="dark"] .addon-green :is(h1,h2,h3,h4,h5,h6) { color: #91f4ae !important; }
html[data-cm-theme="dark"] .section-purple :is(h1,h2,h3,h4,h5,h6),
html[data-cm-theme="dark"] .addon-purple :is(h1,h2,h3,h4,h5,h6) { color: #d8bbff !important; }
html[data-cm-theme="dark"] .section-orange :is(h1,h2,h3,h4,h5,h6),
html[data-cm-theme="dark"] .addon-orange :is(h1,h2,h3,h4,h5,h6) { color: #ffd38c !important; }
html[data-cm-theme="dark"] .cm-lesson-content p,
html[data-cm-theme="dark"] .cm-lesson-content li,
html[data-cm-theme="dark"] .addoninfo > p,
html[data-cm-theme="dark"] .example-content { color: #d7deee !important; }
html[data-cm-theme="dark"] .headings { color: #f7f9ff !important; border-bottom-color: rgba(219, 228, 255, .16) !important; }
html[data-cm-theme="dark"] .quote blockquote::before { color: rgba(255,255,255,.55) !important; }

/* Tables */
html[data-cm-theme="dark"] table,
html[data-cm-theme="dark"] .modern-table-red,
html[data-cm-theme="dark"] .modern-table-blue,
html[data-cm-theme="dark"] .my-fix-table { background: #121722 !important; color: #e9eefc !important; }
html[data-cm-theme="dark"] th,
html[data-cm-theme="dark"] td,
html[data-cm-theme="dark"] .modern-table-red tbody td,
html[data-cm-theme="dark"] .modern-table-blue tbody td,
html[data-cm-theme="dark"] .my-fix-table th,
html[data-cm-theme="dark"] .my-fix-table td { color: #e9eefc !important; border-color: rgba(219, 228, 255, .12) !important; }
html[data-cm-theme="dark"] th { background: rgba(255, 122, 162, .15) !important; color: #ffd3df !important; }
html[data-cm-theme="dark"] .modern-table-blue thead th { background: #245f9f !important; color: #fff !important; }
html[data-cm-theme="dark"] .modern-table-red thead th { background: #b92f57 !important; color: #fff !important; }
html[data-cm-theme="dark"] .modern-table-blue tbody tr,
html[data-cm-theme="dark"] .modern-table-red tbody tr { border-color: rgba(219, 228, 255, .13) !important; }
html[data-cm-theme="dark"] .my-fix-table tr:nth-child(odd) { background: rgba(255, 202, 122, .12) !important; }

/* Public pages */
html[data-cm-theme="dark"] .cm-public-page,
html[data-cm-theme="dark"] .cm-community-page { background: transparent !important; }
html[data-cm-theme="dark"] .cm-public-hero-card,
html[data-cm-theme="dark"] .cm-community-hero-card {
  background: linear-gradient(135deg, #1a2030, #3a1724 62%, #2f2351) !important;
  border: 1px solid var(--cm-border) !important;
  box-shadow: var(--cm-shadow-soft) !important;
}
html[data-cm-theme="dark"] .cm-public-hero-card p,
html[data-cm-theme="dark"] .cm-community-hero-card p { color: #d8deee !important; }
html[data-cm-theme="dark"] .cm-public-note,
html[data-cm-theme="dark"] .cm-public-warning { background: rgba(255, 122, 162, .10) !important; border-color: rgba(255, 122, 162, .40) !important; }

/* Community */
html[data-cm-theme="dark"] .cm-community-alert { background: var(--cm-card-solid) !important; color: var(--cm-ink) !important; border-color: var(--cm-border) !important; }
html[data-cm-theme="dark"] .cm-community-alert-success { background:#12331f !important; color:#a4f5bb !important; border-color:#7ee89d !important; }
html[data-cm-theme="dark"] .cm-community-alert-error { background:#3a1724 !important; color:#ffc4d5 !important; border-color:#ff7aa2 !important; }
html[data-cm-theme="dark"] .cm-community-question-meta,
html[data-cm-theme="dark"] .cm-community-response-meta { color: #b8c1d9 !important; }
html[data-cm-theme="dark"] .cm-community-response { background: rgba(255,255,255,.055) !important; border-color: var(--cm-border) !important; }

/* Portal */
html[data-cm-theme="dark"] .cm-portal-body { background: #0f1118 !important; color: var(--cm-ink) !important; }
html[data-cm-theme="dark"] .cm-portal-shell { background: transparent !important; }
html[data-cm-theme="dark"] .cm-portal-sidebar {
  background: rgba(18, 22, 32, .96) !important;
  border-color: var(--cm-border) !important;
  box-shadow: var(--cm-shadow-soft) !important;
}
html[data-cm-theme="dark"] .cm-portal-main { background: transparent !important; }
html[data-cm-theme="dark"] .cm-portal-top h1 { color: #f7f9ff !important; }
html[data-cm-theme="dark"] .cm-portal-nav a { color: #c8d1e8 !important; }
html[data-cm-theme="dark"] .cm-portal-nav a:hover,
html[data-cm-theme="dark"] .cm-portal-nav a.is-active { color: #fff !important; background: linear-gradient(135deg, #d43c69, #8c54ff) !important; }
html[data-cm-theme="dark"] .cm-portal-user-mini { background: rgba(255,255,255,.06) !important; border-color: var(--cm-border) !important; }
html[data-cm-theme="dark"] .cm-portal-user-mini strong { color: #fff !important; }
html[data-cm-theme="dark"] .cm-portal-user-mini span { color: #b8c1d9 !important; }
html[data-cm-theme="dark"] .cm-portal-alert-success { background:#12331f !important; color:#a4f5bb !important; border-color:#7ee89d !important; }
html[data-cm-theme="dark"] .cm-portal-alert-error { background:#3a1724 !important; color:#ffc4d5 !important; border-color:#ff7aa2 !important; }
html[data-cm-theme="dark"] .cm-admin-reply,
html[data-cm-theme="dark"] .cm-reply-card,
html[data-cm-theme="dark"] .cm-quoted-message,
html[data-cm-theme="dark"] .cm-reply-preview,
html[data-cm-theme="dark"] .cm-empty-chat { background: rgba(255, 255, 255, .06) !important; border-color: var(--cm-border) !important; color: var(--cm-muted) !important; }
html[data-cm-theme="dark"] .cm-message-card.is-me { background: linear-gradient(135deg, rgba(255,122,162,.16), rgba(140,84,255,.12)) !important; }
html[data-cm-theme="dark"] .cm-message-card.is-other { background: rgba(255,255,255,.055) !important; }
html[data-cm-theme="dark"] .cm-team-mini { background: rgba(255,122,162,.16) !important; color: #ffc6d6 !important; }
html[data-cm-theme="dark"] .cm-portal-theme-toggle {
  margin-left: auto;
  background: rgba(255,255,255,.08);
  border-color: var(--cm-border);
  color: #f4f7ff;
}
html[data-cm-theme="dark"] .cm-portal-theme-toggle .cm-theme-toggle-icon { background: rgba(255,255,255,.11); color: #ffd3df; }

/* Misc hard-coded white/light pieces */
html[data-cm-theme="dark"] .cm-hero-panel,
html[data-cm-theme="dark"] .cm-hero-panel div,
html[data-cm-theme="dark"] .cm-auth-guide,
html[data-cm-theme="dark"] .cm-portal-inline-form,
html[data-cm-theme="dark"] .cm-chat-user-search,
html[data-cm-theme="dark"] .cm-chat-filters,
html[data-cm-theme="dark"] .cm-chat-compose,
html[data-cm-theme="dark"] .cm-chat-scroll {
  background: rgba(255,255,255,.055) !important;
  border-color: var(--cm-border) !important;
  color: var(--cm-ink) !important;
}
html[data-cm-theme="dark"] .cm-hero-panel strong { color: #fff !important; }
html[data-cm-theme="dark"] .cm-hero-panel span { color: #cbd4e8 !important; }
html[data-cm-theme="dark"] .cm-footer-grid a,
html[data-cm-theme="dark"] .cm-footer-contact a,
html[data-cm-theme="dark"] .cm-public-aside-card a,
html[data-cm-theme="dark"] .cm-file-link { color: #d6deef !important; }
html[data-cm-theme="dark"] .cm-footer-grid a:hover,
html[data-cm-theme="dark"] .cm-public-aside-card a:hover,
html[data-cm-theme="dark"] .cm-file-link:hover { color: #ffb0c8 !important; }

@media (max-width: 700px) {
  .cm-theme-toggle-text { font-size: .84rem; }
  html[data-cm-theme="dark"] .cm-portal-top { gap: 10px; }
  html[data-cm-theme="dark"] .cm-portal-theme-toggle { margin-left: 0; width: auto; }
}


/* Dark fix v2: stronger mobile menu + toggle contrast */
html[data-cm-theme="dark"] .cm-site-header .cm-nav-menu .cm-theme-toggle {
  background: #3d0d22 !important;
  color: #ffffff !important;
  border-color: rgba(160, 33, 73, .34) !important;
}
html[data-cm-theme="dark"] .cm-site-header .cm-nav-menu .cm-theme-toggle-icon {
  background: #ffdce7 !important;
  color: #7d1739 !important;
}
html[data-cm-theme="dark"] body:not(.cm-portal-body) main,
html[data-cm-theme="dark"] .cm-main,
html[data-cm-theme="dark"] #main-content {
  color: var(--cm-ink);
}
