"use client"; import { useState } from "react"; /** * Light/dark toggle. The actual class lives on (so `.app.dark` selectors * and the dark CSS-var block apply); we mirror localStorage so the choice * survives reloads. The inline boot script in the root layout applies the saved * theme before paint to avoid a flash — this component only reflects/toggles it. */ export function ThemeSwitcher() { const [dark, setDark] = useState( () => typeof window !== "undefined" && document.documentElement.classList.contains("dark"), ); function toggle() { const next = !dark; setDark(next); document.documentElement.classList.toggle("dark", next); try { localStorage.setItem("theme", next ? "dark" : "light"); } catch { /* private mode / storage disabled — runtime toggle still works */ } } return ( ); }