:root {
  color-scheme: light;
  --page: #f8fafc;
  --surface: #fff;
  --surface-muted: #f1f5f9;
  --surface-raised: #e2e8f0;
  --ink: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --line: #e2e8f0;
  --navbar: rgb(15 23 42 / .95);
  --footer: #020617;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #090f1c;
  --surface: #111c2e;
  --surface-muted: #172337;
  --surface-raised: #24334b;
  --ink: #edf2fa;
  --ink-secondary: #c0cddd;
  --ink-muted: #9cacc1;
  --line: #2b3c54;
  --navbar: rgb(9 15 28 / .96);
  --footer: #060c16;
}
body { background-color: var(--page) !important; color: var(--ink) !important; }
header.sticky { background-color: var(--navbar) !important; }
footer { background-color: var(--footer) !important; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid #475569;
  border-radius: 12px;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
}
.theme-toggle:hover { color: #fbbf24; background: #1e293b; border-color: #f59e0b; }
.theme-toggle:focus-visible { outline: 2px solid #fbbf24; outline-offset: 3px; }
.theme-toggle:active { transform: scale(.95); }
.theme-sun { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
[data-theme="dark"] .theme-moon { display: none; }
/* Keep the existing utility-based templates themed, including dynamically rendered cards. */
[data-theme="dark"] :is(.bg-white, .bg-white\/90) { background-color: var(--surface) !important; }
[data-theme="dark"] :is(.bg-slate-50, .bg-slate-50\/70) { background-color: var(--page) !important; }
[data-theme="dark"] :is(.bg-slate-100, .bg-slate-100\/60, .bg-slate-100\/70, .bg-slate-100\/90) { background-color: var(--surface-muted) !important; }
[data-theme="dark"] :is(.bg-slate-200, .bg-slate-300) { background-color: var(--surface-raised) !important; }
[data-theme="dark"] :is(.text-slate-800, .text-slate-900) { color: var(--ink) !important; }
[data-theme="dark"] :is(.text-slate-600, .text-slate-700) { color: var(--ink-secondary) !important; }
[data-theme="dark"] .text-slate-500 { color: var(--ink-muted) !important; }
[data-theme="dark"] :is(.border-slate-100, .border-slate-200, .border-slate-200\/90, .border-slate-300) { border-color: var(--line) !important; }
[data-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--line) !important; }
[data-theme="dark"] .hover\:bg-slate-50:hover,
[data-theme="dark"] .hover\:bg-slate-100:hover { background-color: var(--surface-raised) !important; }
[data-theme="dark"] :is(.bg-amber-50, .bg-amber-100) { background-color: #352811 !important; }
[data-theme="dark"] :is(.text-amber-600, .text-amber-700, .text-amber-800) { color: #fbbf24 !important; }
[data-theme="dark"] :is(.bg-emerald-50, .bg-emerald-100) { background-color: #11352b !important; }
[data-theme="dark"] :is(.text-emerald-600, .text-emerald-700, .text-emerald-800) { color: #6ee7b7 !important; }
[data-theme="dark"] :is(.bg-blue-50, .bg-blue-100) { background-color: #162d4b !important; }
[data-theme="dark"] :is(.text-blue-600, .text-blue-700, .text-blue-800) { color: #93c5fd !important; }
[data-theme="dark"] :is(.bg-rose-50, .bg-red-100) { background-color: #3b1d2a !important; }
[data-theme="dark"] :is(.text-rose-600, .text-rose-700, .text-red-700) { color: #fda4af !important; }
[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-track { background: var(--page); }
[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb { background: var(--line); }
/* Only animate during a theme change; preserve the site's existing interaction animations. */
@media (prefers-reduced-motion: no-preference) {
  .theme-switching *, .theme-switching *::before, .theme-switching *::after {
    transition-property: background-color, color, border-color, box-shadow, fill, stroke !important;
    transition-duration: 300ms !important;
    transition-timing-function: ease !important;
  }
  .theme-toggle { transition: color 200ms, background-color 200ms, border-color 200ms, transform 200ms; }
}
