function toggleTheme() {
  const body = document.body;
  const btn = document.getElementById("themeToggleBtn");

  body.classList.toggle("dark-mode");
  const isDark = body.classList.contains("dark-mode");

  localStorage.setItem("readingTheme", isDark ? "dark" : "light");
  btn.innerHTML = isDark ? "☀️ Денний режим" : "🌙 Нічний режим";
}

document.addEventListener("DOMContentLoaded", () => {
  const savedTheme = localStorage.getItem("readingTheme");
  if (savedTheme === "dark") {
    document.body.classList.add("dark-mode");
    const btn = document.getElementById("themeToggleBtn");
    if (btn) btn.innerHTML = "☀️ Денний режим";
  }
});
