/* Theme the palette itself so opacity, gradients, hover and focus utilities
   follow the same surfaces. Keep white assets (Google button, switch knobs)
   white; only the foreground utility changes with the theme. */
:root {
  color-scheme: dark;
  --bg: #030309;
  --surface: #111827;
  --surface2: #1f2937;
  --border: #374151;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --input-bg: #1f2937;
  --nav-bg: rgba(3,3,9,.95);
  --accent-text: #c4b5fd;
  --syntax-tag: #c4b5fd;
  --syntax-attr: #7dd3fc;
  --syntax-string: #86efac;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --input-bg: #f1f5f9;
  --nav-bg: rgba(248,250,252,.95);
  --accent-text: #6d28d9;
  --syntax-tag: #6d28d9;
  --syntax-attr: #0369a1;
  --syntax-string: #047857;
  --color-gray-950: #f8fafc;
  --color-gray-900: #ffffff;
  --color-gray-800: #f1f5f9;
  --color-gray-700: #e2e8f0;
  --color-gray-600: #cbd5e1;
  --color-gray-500: #64748b;
  --color-gray-400: #475569;
  --color-gray-300: #334155;
  --color-gray-200: #1e293b;
  --color-gray-100: #0f172a;
  --color-gray-50: #020617;
}
body { background: var(--bg); color: var(--text); }

/* Foregrounds on saturated actions are independent of page surfaces. */
[data-theme="light"] .text-white,
[data-theme="light"] .hover\:text-white:hover,
[data-theme="light"] .group:hover .group-hover\:text-white {
  color: var(--text);
}
:is(.bg-violet-500,.bg-violet-600,.bg-violet-700,
    .bg-indigo-500,.bg-indigo-600,.bg-indigo-700,
    .bg-purple-500,.bg-purple-600,.bg-purple-700,
    .bg-emerald-500,.bg-emerald-600,.bg-emerald-700,
    .bg-green-500,.bg-green-600,.bg-green-700,
    .bg-amber-500,.bg-amber-600,.bg-amber-700,
    .bg-orange-500,.bg-orange-600,.bg-orange-700,
    .bg-red-500,.bg-red-600,.bg-red-700,
    .bg-rose-500,.bg-rose-600,.bg-rose-700,
    .bg-sky-500,.bg-sky-600,.bg-sky-700,
    .bg-blue-500,.bg-blue-600,.bg-blue-700,
    .bg-cyan-500,.bg-cyan-600,.bg-cyan-700,
    .bg-teal-500,.bg-teal-600,.bg-teal-700,
    .bg-pink-500,.bg-pink-600,.bg-pink-700,
    .bg-fuchsia-500,.bg-fuchsia-600,.bg-fuchsia-700) {
  &.text-white, & .text-white { color: #fff; }
}

/* These grays serve both as backgrounds and text in legacy templates. */
.text-gray-500, .text-gray-600 { color: var(--muted); }
[data-theme="light"] .text-gray-700 { color: #334155; }
[data-theme="light"] nav.border-b { background: var(--nav-bg); }

/* Leave layered source editors transparent: a blanket textarea background
   hides the highlighted code underneath. Native controls follow color-scheme. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="color"]),
textarea:not(.html-editor-textarea), select {
  background-color: var(--input-bg);
  color: var(--text);
  border-color: var(--border);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.google-sign-in, .google-sign-in:hover { color: #111827; background: #fff; color-scheme: light; }
.google-sign-in:hover { background: #f3f4f6; }

#theme-toggle { transition: all .2s; }
[data-theme="light"] #theme-toggle .icon-dark { display: none; }
[data-theme="dark"] #theme-toggle .icon-light { display: none; }

/* Tinted status panels and their foregrounds share a complete light palette. */
[data-theme="light"] {
  --color-violet-950: #f5f3ff; --color-violet-900: #ede9fe;
  --color-violet-200: #6d28d9; --color-violet-300: #6d28d9; --color-violet-400: #6d28d9;
  --color-indigo-950: #eef2ff; --color-indigo-900: #e0e7ff;
  --color-indigo-200: #4338ca; --color-indigo-300: #4338ca; --color-indigo-400: #4338ca;
  --color-purple-950: #faf5ff; --color-purple-900: #f3e8ff;
  --color-purple-200: #7e22ce; --color-purple-300: #7e22ce; --color-purple-400: #7e22ce;
  --color-emerald-950: #ecfdf5; --color-emerald-900: #d1fae5;
  --color-emerald-200: #047857; --color-emerald-300: #047857; --color-emerald-400: #047857;
  --color-green-950: #f0fdf4; --color-green-900: #dcfce7;
  --color-green-200: #15803d; --color-green-300: #15803d; --color-green-400: #15803d;
  --color-amber-950: #fffbeb; --color-amber-900: #fef3c7;
  --color-amber-200: #92400e; --color-amber-300: #92400e; --color-amber-400: #92400e;
  --color-yellow-950: #fefce8; --color-yellow-900: #fef9c3;
  --color-yellow-200: #854d0e; --color-yellow-300: #854d0e; --color-yellow-400: #854d0e;
  --color-orange-950: #fff7ed; --color-orange-900: #ffedd5;
  --color-orange-200: #9a3412; --color-orange-300: #9a3412; --color-orange-400: #9a3412;
  --color-red-950: #fef2f2; --color-red-900: #fee2e2;
  --color-red-200: #b91c1c; --color-red-300: #b91c1c; --color-red-400: #b91c1c;
  --color-rose-950: #fff1f2; --color-rose-900: #ffe4e6;
  --color-rose-200: #be123c; --color-rose-300: #be123c; --color-rose-400: #be123c;
  --color-sky-950: #f0f9ff; --color-sky-900: #e0f2fe;
  --color-sky-200: #0369a1; --color-sky-300: #0369a1; --color-sky-400: #0369a1;
  --color-blue-950: #eff6ff; --color-blue-900: #dbeafe;
  --color-blue-200: #1d4ed8; --color-blue-300: #1d4ed8; --color-blue-400: #1d4ed8;
  --color-cyan-950: #ecfeff; --color-cyan-900: #cffafe;
  --color-cyan-200: #0e7490; --color-cyan-300: #0e7490; --color-cyan-400: #0e7490;
  --color-teal-950: #f0fdfa; --color-teal-900: #ccfbf1;
  --color-teal-200: #0f766e; --color-teal-300: #0f766e; --color-teal-400: #0f766e;
  --color-pink-950: #fdf2f8; --color-pink-900: #fce7f3;
  --color-pink-200: #be185d; --color-pink-300: #be185d; --color-pink-400: #be185d;
  --color-fuchsia-950: #fdf4ff; --color-fuchsia-900: #fae8ff;
  --color-fuchsia-200: #a21caf; --color-fuchsia-300: #a21caf; --color-fuchsia-400: #a21caf;
}
