/* Light/dark mode on both sites. Persisted (strictly necessary localStorage), honors prefers-color-scheme on first visit. Toggle button: #theme-btn in the nav. */ (function () { var KEY = 'uas_theme'; function apply(t) { document.documentElement.setAttribute('data-theme', t); var b = document.getElementById('theme-btn'); if (b) b.textContent = t === 'dark' ? '☀️' : '🌙'; var m = document.querySelector('meta[name="theme-color"]'); if (m) m.setAttribute('content', t === 'dark' ? '#08111B' : '#ffffff'); } window.Theme = { current: function () { var s = null; try { s = localStorage.getItem(KEY); } catch (e) {} if (!s) s = document.documentElement.getAttribute('data-theme'); // brand default in HTML if (!s) s = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; return s; }, init: function () { apply(this.current()); }, toggle: function () { var t = this.current() === 'dark' ? 'light' : 'dark'; try { localStorage.setItem(KEY, t); } catch (e) {} apply(t); } }; window.addEventListener('DOMContentLoaded', function () { Theme.init(); var b = document.getElementById('theme-btn'); if (b) b.addEventListener('click', function () { Theme.toggle(); }); }); })();