(function () { var root = document.documentElement, KEY = "ricehub-mode"; try { var saved = localStorage.getItem(KEY); if (saved) root.dataset.theme = saved; } catch (e) {} document.addEventListener("DOMContentLoaded", function () { var mode = document.getElementById("mode"); if (mode) mode.onclick = function () { var dark = root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme:dark)").matches; var next = dark ? "light" : "dark"; root.dataset.theme = next; try { localStorage.setItem(KEY, next); } catch (e) {} }; var toast = document.getElementById("toast"); document.querySelectorAll(".sw button").forEach(function (b) { b.onclick = function () { var hex = b.dataset.hex; function done() { toast.textContent = "Copied " + hex; toast.classList.add("on"); setTimeout(function () { toast.classList.remove("on"); }, 1400); } try { navigator.clipboard.writeText(hex).then(done, done); } catch (e) { done(); } }; }); }); })();