How to detect the current theme variant
<script>const isDarkMode = localStorage.theme === "dark" || (!("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches);document.documentElement.dataset.theme = isDarkMode ? "dark" : "light";</script>