export type ThemePreference = "light" | "dark" | "system"; export function applyThemePreference(root: HTMLElement, theme: ThemePreference, systemDark = false): void { root.classList.toggle("light", theme === "light"); root.classList.toggle("dark", theme === "dark" || (theme === "system" && systemDark)); root.style.colorScheme = theme === "system" ? "" : theme; }