/* ==========================================================================
   MathCracker Dark Theme
   Activated via: html[data-theme="dark"]
   Toggle persisted in localStorage['mc-theme']
   ========================================================================== */

/* 1. Override CSS custom properties — covers ~75% of the UI automatically
      via the existing variable system in style-inline.css               */
html[data-theme="dark"] {
  /* Site-wide variables (style-inline.css) */
  --primary:      #38bdf8;
  --bg-color:     #121212;
  --card-bg:      #1e1e1e;
  --border-color: #2d2d30;
  --text-color:   #f4f4f5;
  --ml-input-bg:  #2a2a2a;
  /* Dashboard-specific variables (dashboard.php :root) */
  --bg:           #121212;
  --border:       #2d2d30;
}

/* Dashboard header — hardcoded background: white on line 156 */
html[data-theme="dark"] .main > .header {
  background: var(--card-bg) !important;
  border-bottom-color: var(--border) !important;
  color: var(--text-color) !important;
}
html[data-theme="dark"] #mc-theme-toggle-dashboard {
  color: var(--text-color);
}
html[data-theme="dark"] #mc-theme-toggle-dashboard .icon-sun  { display: block; }
html[data-theme="dark"] #mc-theme-toggle-dashboard .icon-moon { display: none; }
#mc-theme-toggle-dashboard .icon-sun  { display: none; }
#mc-theme-toggle-dashboard .icon-moon { display: block; }

/* 2. Header — override the hardcoded #505050 (style-inline.css:30) and
      #909090 (sccss.css:239) which are both dark grays unreadable on a
      dark card-bg. Target the element AND every child to prevent inheritance. */
html[data-theme="dark"] .header .top,
html[data-theme="dark"] .header .top a,
html[data-theme="dark"] .header .top span,
html[data-theme="dark"] .header .top li,
html[data-theme="dark"] .header .top button,
html[data-theme="dark"] .header .top svg {
  color: var(--text-color) !important;
}

/* 3. Headings — style-inline.css:378 sets h1-h6 { color: #1f1f1f } directly,
      bypassing body color inheritance. Override explicitly. */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
  color: var(--text-color) !important;
}

/* 4. Body & page scaffolding not already covered by variables */
html[data-theme="dark"] body {
  background-color: var(--bg-color) !important;
  color: var(--text-color) !important;
}
html[data-theme="dark"] .page-wrapper,
html[data-theme="dark"] #mainContainer,
html[data-theme="dark"] article,
html[data-theme="dark"] .site-main,
html[data-theme="dark"] #main {
  background-color: var(--bg-color) !important;
  color: var(--text-color) !important;
}

/* 3. Links */
html[data-theme="dark"] a { color: #38bdf8; }
html[data-theme="dark"] a:hover { color: #7dd3fc; }

/* 4. Form elements (Boombox and sccss both hardcode #fff on inputs) */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background-color: var(--card-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}

/* 5. sccss.css hardcoded overrides — solution output & content blocks */
html[data-theme="dark"] .solver-explanation {
  background-color: #1a1a1a;
}
html[data-theme="dark"] .block-of-info,
html[data-theme="dark"] .radio-input {
  background-color: #1a2a1a;
}
html[data-theme="dark"] .solution-class {
  background-color: #2a2a35;
  color: var(--text-color);
}
html[data-theme="dark"] .highlight,
html[data-theme="dark"] .highlight-explanation {
  background-color: #252520;
}
html[data-theme="dark"] .highlight-inside-explanation {
  border-color: var(--border-color);
}
html[data-theme="dark"] .practice-question {
  background-color: #232318;
}
html[data-theme="dark"] .header_highlight,
html[data-theme="dark"] .par_highlight {
  background-color: #1a2e1a;
  color: #c8e6c9;
}
/* Step titles (see "STEP-PRINTER STEP TITLES" in whiteboard.css / sccss.css). Only the
   l1 chip has a fill to restate; l2 is weight-only and needs nothing here. */
html[data-theme="dark"] .mc-step-title-l1 {
  background-color: #1c2a1e;
  border-left-color: #4a8a55;
  color: #cfe8d2;
}
html[data-theme="dark"] .divTableHeading,
html[data-theme="dark"] .divTableFoot {
  background-color: #2a2a2a;
  color: var(--text-color);
}
html[data-theme="dark"] .table-generic {
  border-color: var(--border-color);
}
html[data-theme="dark"] .table-generic td,
html[data-theme="dark"] .table-generic th {
  border-color: var(--border-color);
}
/* render_html_table()'s zebra-striped rows leak the boombox theme's global
   rule (assets/css/boombox/css/style.css:413-414,
   "table tbody tr:nth-child(2n+1) th, td { background-color: #f7f7f7 }")
   the same way the MathQuill matrix does (see section 11b below) — odd rows
   painted light gray (#f7f7f7) with light dark-theme text on top, unreadable.
   Replace with a mild light-on-dark overlay so the zebra stripe stays
   visible against --card-bg without washing out the text. */
html[data-theme="dark"] .table-generic tr:nth-child(2n+1) th,
html[data-theme="dark"] .table-generic tr:nth-child(2n+1) td {
  background-color: rgba(255,255,255,0.06) !important;
}
/* Same boombox zebra-stripe leak (see comment above) hits the .data-table
   class used by the binary-division step table, whose odd rows otherwise get
   painted #f7f7f7 with light dark-theme text on top — white-on-white. */
html[data-theme="dark"] .data-table tr:nth-child(2n+1) th,
html[data-theme="dark"] .data-table tr:nth-child(2n+1) td {
  background-color: rgba(255,255,255,0.06) !important;
}
html[data-theme="dark"] .grouping-style,
html[data-theme="dark"] .define-probability-event {
  background-color: rgba(255,255,255,0.04);
}
html[data-theme="dark"] .download-deliverables-description,
html[data-theme="dark"] .membership-pitch-math-solutions {
  background-color: #2a2a2a;
  border-color: var(--border-color);
  color: var(--text-color);
}

/* 6. Math keyboard popup
      Inline styles in header-styles-functionality.php — all hardcoded #fff */
html[data-theme="dark"] .math-keyboard-popup {
  background: #1e1e1e !important;
  border-color: #2d2d30 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] .math-keyboard-tabs {
  background: #2a2a2a !important;
  border-bottom-color: #2d2d30 !important;
}
html[data-theme="dark"] .math-tab-btn {
  color: #b0b0b0 !important;
  border-right-color: rgba(255,255,255,0.08) !important;
}
html[data-theme="dark"] .math-tab-btn:hover {
  background: #333333 !important;
}
html[data-theme="dark"] .math-tab-btn.active {
  background: #0369a1 !important;
  color: #fff !important;
}
html[data-theme="dark"] .math-clear-btn {
  color: #f87171 !important;
  border-left-color: rgba(255,255,255,0.08) !important;
}
html[data-theme="dark"] .math-clear-btn:hover {
  background: #3a1f1f !important;
}
html[data-theme="dark"] .math-grid-container {
  background: #1e1e1e !important;
}
html[data-theme="dark"] .math-tool-btn {
  background: #2a2a2a !important;
  border-color: rgba(255,255,255,0.12) !important;
  color: #d0d0d0 !important;
}
html[data-theme="dark"] .math-tool-btn:hover {
  background: #1a3a5c !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
}
html[data-theme="dark"] .math-action-row {
  background: #252525 !important;
  border-top-color: rgba(255,255,255,0.08) !important;
}
html[data-theme="dark"] .math-action-btn {
  background: #2a2a2a !important;
  border-color: rgba(255,255,255,0.12) !important;
  color: #c0c0c0 !important;
}
html[data-theme="dark"] .math-action-btn:hover {
  background: #333333 !important;
  color: #ffffff !important;
}

/* 7. Practice checkpoints (practice-checkpoints.css) */
html[data-theme="dark"] .alternative {
  background-color: #2a2a2a;
  border-color: #3d3d3d;
  color: var(--text-color);
}
html[data-theme="dark"] .alternative.correct {
  background-color: #1a3a1a;
}
html[data-theme="dark"] .alternative.wrong {
  background-color: #3a1a1a;
}
html[data-theme="dark"] .dropdown-content {
  background-color: #1e1e1e;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
}
html[data-theme="dark"] .dropdown-content a {
  color: var(--text-color);
}
html[data-theme="dark"] .dropdown a:hover,
html[data-theme="dark"] .dropdown-content a:hover {
  background-color: #2a2a2a;
}

/* 8. Jspreadsheet (jspreadsheet-ce) input table */
html[data-theme="dark"] .jexcel {
  background-color: var(--card-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}
html[data-theme="dark"] .jexcel > thead > tr > td {
  background-color: #2a2a2a !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}
html[data-theme="dark"] .jexcel > thead > tr > td.selected {
  background-color: #383838 !important;
}
html[data-theme="dark"] .jexcel > tbody > tr > td {
  background-color: var(--card-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}
html[data-theme="dark"] .jexcel > tbody > tr > td:first-child {
  background-color: #2a2a2a !important;
  color: var(--text-color) !important;
}
html[data-theme="dark"] .jexcel > tbody > tr > td.highlight,
html[data-theme="dark"] .jexcel > tbody > tr > td.highlight-left,
html[data-theme="dark"] .jexcel > tbody > tr > td.highlight-top {
  background-color: rgba(56, 189, 248, 0.1) !important;
}
html[data-theme="dark"] .jexcel > tbody > tr > td.selected {
  background-color: rgba(56, 189, 248, 0.15) !important;
}
html[data-theme="dark"] .jexcel_content::-webkit-scrollbar-track {
  background: #2a2a2a;
}
html[data-theme="dark"] .jexcel_content::-webkit-scrollbar-thumb {
  background: #555;
}

/* 9. Dashboard (dashboard.php) — standalone page with its own hardcoded white backgrounds */
html[data-theme="dark"] .main                        { background: var(--bg) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .sidebar                     { background: var(--card-bg) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .feed                        { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .canvas-area                 { background: var(--card-bg) !important; border-color: var(--border) !important; }
html[data-theme="dark"] #graphing-view               { background: var(--bg) !important; }
html[data-theme="dark"] #practice-breadcrumb          { color: #9aa0a6 !important; }
html[data-theme="dark"] #practice-main               { background: var(--bg) !important; }
html[data-theme="dark"] .practice-alternative        { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .practice-alternative:hover  { background: #2a2a2a !important; border-color: #6b6b6b !important; }
html[data-theme="dark"] .practice-alternative.correct { background: #16281c !important; border-color: #2f7d4f !important; color: #81c995 !important; }
html[data-theme="dark"] .practice-alternative.wrong   { background: #2b1a19 !important; border-color: #8c3a34 !important; color: #f28b82 !important; }
/* Practice sidebar: header strip, the topic drill-down list, and the topic rows.
   The topics container/back button still carry inline light backgrounds set in
   dashboard.php, hence !important. */
html[data-theme="dark"] .practice-panel-header       { background: #232326 !important; border-color: var(--border) !important; color: var(--text-color) !important; }
/* Practice main area: welcome copy, the question card and the step-by-step panel
   (all three hardcode light backgrounds inline in dashboard.php). */
html[data-theme="dark"] #practice-welcome            { color: #9aa0a6 !important; }
html[data-theme="dark"] #practice-question           { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-color) !important; }
html[data-theme="dark"] #practice-explanation        { background: #23201a !important; border-color: #8a6d1f !important; color: var(--text-color) !important; }
html[data-theme="dark"] .hybrid-input:focus,
html[data-theme="dark"] .hybrid-input:focus-within   { background: var(--card-bg) !important; }
html[data-theme="dark"] math-field.search-input:focus-within { background: transparent !important; }
/* Composer: .search-container is the visible box now (the field itself is chrome-less),
   so the surface/border colors belong to it rather than to math-field.search-input. */
/* The input surface is a step lighter than the page around it (owner, 2026-11-07). */
html[data-theme="dark"] .search-container            { background: var(--ml-input-bg) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .camera-btn:hover            { background: var(--bg) !important; }
html[data-theme="dark"] .example-chip                { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .example-chip:hover          { background: var(--bg) !important; border-color: var(--primary, #8ab4f8) !important; }
html[data-theme="dark"] #welcome-msg p               { color: var(--text-color) !important; opacity: 0.75; }
/* Hero state deliberately strips the .feed card so the greeting floats on the page
   background; the generic .feed rule above would paint a card back onto it. */
html[data-theme="dark"] body.composer-hero .feed     { background: transparent !important; border-color: transparent !important; }
html[data-theme="dark"] body.composer-docked .composer-dock { background: var(--bg) !important; border-color: var(--border) !important; }
/* My History */
html[data-theme="dark"] #history-head h2             { color: var(--text-color) !important; }
html[data-theme="dark"] .history-item                { background: var(--card-bg) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .history-item:hover          { background: var(--bg) !important; border-color: var(--primary, #8ab4f8) !important; }
html[data-theme="dark"] .history-q                   { color: var(--text-color) !important; }
html[data-theme="dark"] .history-clear-btn           { background: var(--card-bg) !important; border-color: var(--border) !important; }
/* Help guide (includes/dashboard-help.php) */
html[data-theme="dark"] #help-panel,
html[data-theme="dark"] #help-head h2,
html[data-theme="dark"] .help-section h3,
html[data-theme="dark"] .help-section h4,
html[data-theme="dark"] .help-section p,
html[data-theme="dark"] .help-section li,
html[data-theme="dark"] .help-section dd          { color: var(--text-color) !important; }
html[data-theme="dark"] .help-lede                   { color: var(--text-color) !important; opacity: 0.75; }
html[data-theme="dark"] .help-toc a                  { background: var(--card-bg) !important; border: 1px solid var(--border); }
html[data-theme="dark"] .help-toc a:hover            { background: var(--bg) !important; }
html[data-theme="dark"] .help-card                   { background: var(--card-bg) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .help-section code           { background: var(--bg) !important; border-color: var(--border) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .help-table th               { background: var(--card-bg) !important; }
html[data-theme="dark"] .help-table th,
html[data-theme="dark"] .help-table td               { border-color: var(--border) !important; }

/* Mobile top strip (replaced the old header) + "New problem" button. */
html[data-theme="dark"] .mobile-topbar               { background: var(--card-bg) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .menu-toggle:hover           { background: var(--bg) !important; }
html[data-theme="dark"] .btn-new-problem             { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .btn-new-problem:hover       { background: var(--bg) !important; border-color: var(--primary, #8ab4f8) !important; }
/* The topbar logo needs the same light/dark image swap the sidebar logo gets. */
.topbar-logo .logo-dark                              { display: none !important; }
html[data-theme="dark"] .topbar-logo .logo-light     { display: none !important; }
html[data-theme="dark"] .topbar-logo .logo-dark      { display: block !important; }
html[data-theme="dark"] #mc-theme-toggle-dashboard:hover { background: rgba(255,255,255,0.08) !important; }
html[data-theme="dark"] #langSelect                  { background: var(--card-bg) !important; color: var(--text-color) !important; border-color: var(--border) !important; }

/* FormatConclusionBox (FormattingUtilities.php) hardcodes inline
   background:#f8fff9 on .conclusion-highlight-box, while the dark-theme
   body/heading rules force its text near-white -> white-on-white. Inline
   styles lose to !important, so override the box (and its inner
   .solution-row stripes, inline rgba(0,0,0,0.02)) here. */
html[data-theme="dark"] .conclusion-highlight-box {
  background: #16281c !important;
  border-color: #2f7d4f !important;
}
html[data-theme="dark"] .conclusion-highlight-box .solution-row {
  background: rgba(255,255,255,0.05) !important;
}

/* SSE solution region — now a NEUTRAL dark surface (the success/green moved to the
   answer box below), so the whole solution no longer reads as one big success banner. */
html[data-theme="dark"] .chunk.final-result {
  background: #23272b !important;
  border-color: #3c4043 !important;
  color: var(--text-color) !important;
}
/* The final answer keeps the green success cue in dark mode too. Not scoped to
   .chunk: that wrapper only exists on the SSE client-side render path, while the
   synchronous fallback echoes the same div directly into #solver-results-container
   (FormCreator's inline light-green rule hits both, so this must too). */
html[data-theme="dark"] .one_line_answer {
  background: #24352a !important;
  border-color: #2f7d4f !important;
  color: var(--text-color) !important;
}

/* FormattingUtilities::FormatResponsiveSolutionList (multi-step branch) hardcodes
   inline background-color:#fcf4f4 on the explanation .col inside
   .table-math-equation-aligned; dashboard.php's mobile breakpoint repeats the same
   #fcf4f4 for .col.span_2_of_10. Same white-on-white collision pattern as
   .conclusion-highlight-box above. */
html[data-theme="dark"] .table-math-equation-aligned .col[style*="fcf4f4"],
html[data-theme="dark"] .table-math-equation-aligned .col.span_2_of_10 {
  background-color: #16281c !important;
  color: var(--text-color) !important;
}

/* Dashboard logo swap — header (.header-logo) and sidebar (.logo) */
.header-logo .logo-dark,
.sidebar .logo .logo-dark                          { display: none !important; }
html[data-theme="dark"] .header-logo .logo-light,
html[data-theme="dark"] .sidebar .logo .logo-light { display: none !important; }
html[data-theme="dark"] .header-logo .logo-dark,
html[data-theme="dark"] .sidebar .logo .logo-dark  { display: block !important; }

/* Dashboard nav-item active/hover */
html[data-theme="dark"] .nav-item                  { color: #a0aab4 !important; }
html[data-theme="dark"] .nav-item:hover            { background: rgba(255,255,255,0.06) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .nav-item.active           { background: rgba(56,189,248,0.12) !important; color: #38bdf8 !important; }

/* 10. Graphing view expressions panel (whiteboard.css)
       — #graph-panel is intentionally left white per user preference */
html[data-theme="dark"] #graph-panel,
html[data-theme="dark"] .jxgbox                    { background-color: #e8e8e8 !important; }
html[data-theme="dark"] #expressions-panel         { background-color: var(--card-bg) !important; }
html[data-theme="dark"] #expressions-header        { background-color: #2a2a2a !important; border-bottom-color: var(--border-color) !important; }
html[data-theme="dark"] #expressions-list          { background-color: var(--card-bg) !important; }
html[data-theme="dark"] #resizer                   { background: #2d2d30 !important; }
html[data-theme="dark"] #resizer:hover             { background: #38bdf8 !important; }
html[data-theme="dark"] .expression-box            { background-color: #2a2a2a !important; border-color: var(--border-color) !important; color: var(--text-color) !important; }
html[data-theme="dark"] .expression-box.is-active  { border-color: #38bdf8 !important; }
html[data-theme="dark"] .main-content-area         { border-left-color: var(--border-color) !important; }
html[data-theme="dark"] .main-input-wrapper        { border-bottom-color: var(--border-color) !important; }
html[data-theme="dark"] .result-display            { color: #a0a0a0 !important; --container-background: #2a2a2a; }
html[data-theme="dark"] .expression-number         { color: #666 !important; }
html[data-theme="dark"] .delete-btn                { color: #555 !important; }
html[data-theme="dark"] .delete-btn:hover          { color: #f87171 !important; }
html[data-theme="dark"] #add-expression-btn        { background-color: #1a6b35 !important; }
html[data-theme="dark"] #stroke-width-slider-container { background-color: rgba(30,30,30,0.9) !important; }

/* 11. MathLive input fields
 *
 * MathLive picks its own chrome colours -- the shading behind the group the caret is
 * inside, the placeholder boxes, the smart-fence parentheses -- from an
 * @media (prefers-color-scheme: dark) block inside its shadow DOM. That media query
 * tracks the BROWSER, and this site's dark mode is html[data-theme="dark"], which
 * MathLive has never heard of. The two disagree whenever the OS/browser preference
 * and the site toggle point in opposite directions, and the disagreement is not
 * subtle: clicking into a fraction on a dark page in a light-preference browser
 * painted MathLive's light "contains highlight" -- hsl(212, 40%, 95%), i.e. nearly
 * white -- across the fraction, so the digits being typed went white-on-white. The
 * same page in a browser set to dark looked perfect, which is what made it read as a
 * browser bug.
 *
 * The fix is to stop letting the media query decide: every variable MathLive flips is
 * pinned explicitly on BOTH sides below, so the field follows the site toggle alone.
 * Values are MathLive 0.110's own defaults for each mode (hue 212), not invented ones,
 * except where the existing site accent already overrode them. */
html[data-theme="dark"] math-field {
  background: var(--card-bg) !important;
  color: var(--text-color) !important;
  --caret-color: #38bdf8;
  --selection-background-color: rgba(56, 189, 248, 0.2);
  --selection-color: #fff;
  --contains-highlight-background-color: hsl(212, 5%, 34%);
  --contains-highlight-color: hsl(212, 85%, 75%);
  /* MathLive paints every \text{} run while the field is focused
     (`.ML__focused .ML__text { background }`), which is what made "factor" in
     `\text{factor }x^2-5x+6` light up blue after a template click. Off, under both
     names MathLive 0.110 reads: --text-highlight-background-color in its dark block,
     --highlight-text in its light block (an inconsistency in MathLive itself). */
  --text-highlight-background-color: transparent;
  --highlight-text: transparent;
  --smart-fence-color: #fff;
  --smart-fence-opacity: 0.7;
  /* Both spellings on purpose: MathLive's dark block assigns the private
     --_placeholder-color a literal, skipping the public var, so the public one alone
     is silently ignored the moment the browser preference is also dark. */
  --placeholder-color: hsl(212, 60%, 69%);
  --_placeholder-color: hsl(212, 60%, 69%);
}
html[data-theme="dark"] math-field::part(container) {
  background: var(--card-bg);
}
/* The composer field is chrome-less: its box (.search-container) carries the surface. */
html[data-theme="dark"] math-field.search-input { background: transparent !important; }
html[data-theme="dark"] math-field.search-input::part(container) { background: transparent; }

/* 11a. The mirror image: site in light mode, browser preference dark. Without this,
        MathLive dresses a white field in its dark chrome -- a 34% grey block behind
        the fraction you just clicked into, pale placeholders on white.

        Caret and selection are deliberately left out: they stay legible either way, and
        pinning them here would outrank whiteboard.css's `math-field { --caret-color }`
        accent on specificity and quietly undo it. Only the fills are pinned. */
html:not([data-theme="dark"]) math-field {
  --selection-color: #000;
  --contains-highlight-background-color: hsl(212, 40%, 95%);
  --contains-highlight-color: hsl(212, 40%, 49%);
  --text-highlight-background-color: transparent;   /* see the dark block above */
  --highlight-text: transparent;
  --smart-fence-color: currentColor;
  --smart-fence-opacity: 0.5;
  --placeholder-color: hsl(212, 40%, 49%);
  --_placeholder-color: hsl(212, 40%, 49%);
}

/* 11b. MathQuill matrix table cells. The matrix widget renders as a real
        <table>/<tr>/<td>, so the boombox theme's global zebra-stripe rule
        (assets/css/boombox/css/style.css:413-414,
        "table tbody tr:nth-child(2n+1) td { background-color: #f7f7f7 }")
        leaks into it and paints every odd row's cells light gray — visible
        on the first row immediately, and on any row once MathQuill's own
        .mq-empty class (background: #ccc, mathquill-fork.css:122-123) is
        removed by clicking/typing into a cell. Force transparent on all
        matrix cells first (beats the zebra stripe via extra specificity,
        not just !important), then re-apply a visible placeholder color for
        genuinely empty cells only. */
html[data-theme="dark"] .mq-math-mode .mq-matrix td {
  background: transparent !important;
}
html[data-theme="dark"] .mq-math-mode .mq-matrix .mq-empty {
  background: var(--ml-input-bg) !important;
}
html[data-theme="dark"] .mq-math-mode .mq-matrix .mq-empty.mq-root-block {
  background: transparent !important;
}
/* Matrix cell wrapper (mathquill-fork.css:522-523 hardcodes
   .mq-matrixed { background: white }) — kept for completeness even though
   the zebra-stripe leak above was the actual source of the reported white
   cells. */
html[data-theme="dark"] .mq-math-mode .mq-matrixed {
  background: var(--card-bg) !important;
  color: var(--text-color) !important;
}

/* 10. Logo swap — must beat .header .top .branding img { display:block !important }
      which has specificity 0-3-1. Use 0-4-0 to win. */
.header .top .branding .logo-dark                           { display: none !important; }
html[data-theme="dark"] .header .top .branding .logo-light  { display: none !important; }
html[data-theme="dark"] .header .top .branding .logo-dark   { display: block !important; }

/* 10. Dark mode toggle button */
#mc-theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color, #1e293b);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  transition: background-color 0.2s, color 0.2s;
}
#mc-theme-toggle:hover {
  background-color: rgba(0,0,0,0.06);
  color: var(--primary, #0284c7);
}
html[data-theme="dark"] #mc-theme-toggle:hover {
  background-color: rgba(255,255,255,0.08);
}
/* Show moon in light mode, sun in dark mode */
#mc-theme-toggle .icon-sun,
#mc-theme-toggle-desktop .icon-sun  { display: none; }
#mc-theme-toggle .icon-moon,
#mc-theme-toggle-desktop .icon-moon { display: block; }
html[data-theme="dark"] #mc-theme-toggle .icon-sun,
html[data-theme="dark"] #mc-theme-toggle-desktop .icon-sun  { display: block; }
html[data-theme="dark"] #mc-theme-toggle .icon-moon,
html[data-theme="dark"] #mc-theme-toggle-desktop .icon-moon { display: none; }

/* 12. online-calculators.php — inline <style> block hardcodes a light-blue
      gradient hero and white cards; the h1's #0367bf and card text #222/#555
      are unreadable against the dark-theme body background. */
html[data-theme="dark"] .modern-hero {
  background: linear-gradient(135deg, #17202b 0%, #101820 100%) !important;
  border-bottom-color: var(--border-color) !important;
}
html[data-theme="dark"] .modern-hero h1 {
  color: var(--primary) !important;
}
html[data-theme="dark"] .modern-hero p {
  color: var(--text-color) !important;
}
html[data-theme="dark"] .hero-search input {
  background: var(--card-bg) !important;
  border-color: var(--border-color) !important;
  color: var(--text-color) !important;
}
html[data-theme="dark"] .hero-search .result {
  background: var(--card-bg) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4) !important;
}
html[data-theme="dark"] .hero-search .result p {
  border-bottom-color: var(--border-color) !important;
}
html[data-theme="dark"] .hero-search .result a {
  color: var(--text-color) !important;
}
html[data-theme="dark"] .hero-search .result a:hover {
  background: rgba(56, 189, 248, 0.1) !important;
  color: var(--primary) !important;
}
html[data-theme="dark"] .calc-card {
  background: var(--card-bg) !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4) !important;
}
html[data-theme="dark"] .calc-card:hover {
  box-shadow: 0 15px 40px rgba(0,0,0,0.5) !important;
}
html[data-theme="dark"] .calc-card h2 {
  color: var(--text-color) !important;
}
html[data-theme="dark"] .calc-card a {
  color: #b0b0b5 !important;
}
html[data-theme="dark"] .calc-card a:hover {
  color: var(--primary) !important;
}
html[data-theme="dark"] .see-more {
  background: rgba(56, 189, 248, 0.12) !important;
  color: var(--primary) !important;
}
html[data-theme="dark"] .see-more:hover {
  background: var(--primary) !important;
  color: #0b1220 !important;
}

/* 13. Category-list pages (algebra/calculus/probability/statistics/finance/
      operations-management-calculators.php) — inline <style> hardcodes
      .calc-item as a white card with a light-blue left border and dark text,
      unreadable against the dark-theme body background. */
html[data-theme="dark"] .calc-item {
  background: var(--card-bg) !important;
  border-left-color: var(--primary) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] .calc-item:hover {
  box-shadow: 0 8px 25px rgba(0,0,0,0.4) !important;
}
html[data-theme="dark"] .calc-item a {
  color: var(--text-color) !important;
}
html[data-theme="dark"] .calc-item a:hover {
  color: var(--primary) !important;
}
