// JARVIS v3 — theme persistence hook (useTweaks)
// Minimal: just stores/restores the theme preference. The full tweaks panel
// from the previous version is replaced by the new design system.

(function() {
  function useTweaks() {
    const [theme, setThemeState] = React.useState(() => {
      try { return localStorage.getItem("jarvis-theme") || "light"; } catch { return "light"; }
    });

    React.useEffect(() => {
      document.documentElement.setAttribute("data-theme", theme);
    }, [theme]);

    const setTheme = (t) => {
      setThemeState(t);
      try { localStorage.setItem("jarvis-theme", t); } catch {}
      document.documentElement.setAttribute("data-theme", t);
    };

    return { theme, setTheme };
  }

  window.useTweaks = useTweaks;
})();
