let theme = localStorage.getItem("nexus_theme") || "dark"; function applyTheme(t) { theme = t; document.body.className = t; localStorage.setItem("nexus_theme", t); } document.addEventListener("DOMContentLoaded", async () => { applyTheme(theme); try { const res = await fetch("/api/settings", { credentials: "include" }); if (res.ok) { const data = await res.json(); if (data.settings && data.settings.theme) { applyTheme(data.settings.theme); } } } catch {} });