export type ThemeMode = "dark" | "light"; const THEME_KEY = "cyrene.theme"; /** Read the persisted theme, defaulting to dark-first (Miuix). */ export function readTheme(): ThemeMode { const saved = localStorage.getItem(THEME_KEY); return saved === "light" ? "light" : "dark"; } /** Apply a theme by toggling the `.theme-light` class on . */ export function applyTheme(theme: ThemeMode): void { document.documentElement.classList.toggle("theme-light", theme === "light"); localStorage.setItem(THEME_KEY, theme); const meta = document.querySelector('meta[name="theme-color"]'); if (meta) meta.setAttribute("content", theme === "light" ? "#f6f6f8" : "#161616"); } /** Apply the persisted theme on app start. */ export function initTheme(): void { applyTheme(readTheme()); }