:root {
  color-scheme: light;
  --theme-bg: #fffefa;
  --theme-surface: #ffffff;
  --theme-surface-soft: #f5f7f3;
  --theme-text: #172124;
  --theme-muted: #66716f;
  --theme-border: #e3e7e1;
  --theme-accent: #0b604f;
  --theme-accent-soft: #e4f4ed;
  --theme-shadow: 0 18px 45px -30px rgba(4, 48, 39, .32);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-bg: #0d1715;
  --theme-surface: #15231f;
  --theme-surface-soft: #192b26;
  --theme-text: #edf8f3;
  --theme-muted: #a7bbb3;
  --theme-border: #30443d;
  --theme-accent: #66d8ad;
  --theme-accent-soft: #1c3a31;
  --theme-shadow: 0 20px 55px -30px rgba(0, 0, 0, .72);
}

html.theme-ready,
html.theme-ready body,
html.theme-ready .nav,
html.theme-ready section,
html.theme-ready article,
html.theme-ready footer {
  transition: background-color .28s ease, color .28s ease, border-color .28s ease;
}

.theme-toggle {
  position: relative;
  width: 56px;
  height: 34px;
  flex: 0 0 56px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px;
  border: 1px solid #ccd9d3;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7fbf8, #e8f4ee);
  color: #875e0c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 8px 20px -13px #063e34;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 72% 24%, #fff7bd 0 8%, transparent 9%), linear-gradient(135deg, #e9f8ff, #fff5ca);
  opacity: 1;
  transition: opacity .25s ease;
}

.theme-toggle__thumb {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(20,57,48,.25);
  transform: translateX(0);
  transition: transform .28s cubic-bezier(.2,.8,.2,1), background .25s ease;
}

.theme-toggle__moon,
.theme-toggle__sun {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  pointer-events: none;
}
.theme-toggle__moon { left: 7px; color: #496a61; }
.theme-toggle__sun { right: 7px; color: #9c6a08; }
.theme-toggle__moon svg,
.theme-toggle__sun svg { width: 15px; height: 15px; }
html[data-theme="dark"] .theme-toggle__moon { color: #e9f6ff; }
html[data-theme="dark"] .theme-toggle__sun { color: #8fa39a; }

.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.theme-toggle:focus-visible { outline: 3px solid color-mix(in srgb, var(--theme-accent) 32%, transparent); outline-offset: 3px; }
.theme-toggle:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -13px #063e34; }

html[data-theme="dark"] .theme-toggle {
  justify-content: flex-start;
  color: #ffe08a;
  border-color: #476158;
  background: #142720;
}

html[data-theme="dark"] .theme-toggle::before {
  background: radial-gradient(circle at 27% 25%, #fff 0 2%, transparent 3%), radial-gradient(circle at 52% 38%, #fff 0 1.5%, transparent 2.5%), linear-gradient(135deg, #132a35, #101b2f);
}

html[data-theme="dark"] .theme-toggle__thumb {
  background: #243c34;
  transform: translateX(-22px);
  box-shadow: 0 3px 11px rgba(0,0,0,.45);
}

html[data-theme="dark"] body { background: var(--theme-bg); color: var(--theme-text); }
html[data-theme="dark"] .site-footer { background: #07120f; border-color: var(--theme-border); }

/* Shared dark treatment for public marketing pages. */
html[data-theme="dark"] .stats-row,
html[data-theme="dark"] .steps-section,
html[data-theme="dark"] .chart-section,
html[data-theme="dark"] .apply-section { background: var(--theme-bg); color: var(--theme-text); }
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .step,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .apply-card { background: var(--theme-surface); color: var(--theme-text); border-color: var(--theme-border); box-shadow: var(--theme-shadow); }
html[data-theme="dark"] .stat-card:nth-child(n) { background: linear-gradient(145deg, #1b302a, #14231f); border-color: var(--theme-border); }
html[data-theme="dark"] .section-title h2,
html[data-theme="dark"] .step h3,
html[data-theme="dark"] .stat-card .num { color: #e7f8f1; }
html[data-theme="dark"] .section-title p,
html[data-theme="dark"] .step p,
html[data-theme="dark"] .stat-card .label,
html[data-theme="dark"] .chart-note { color: var(--theme-muted); }
html[data-theme="dark"] .chart-wrap { background: var(--theme-surface-soft); border-color: var(--theme-border); }

@media (prefers-reduced-motion: reduce) {
  html.theme-ready, html.theme-ready body, html.theme-ready *, .theme-toggle, .theme-toggle__thumb { transition: none !important; }
}
