(light)
| 548 | const btn = $('themeToggle'); |
| 549 | const mql = window.matchMedia('(prefers-color-scheme: light)'); |
| 550 | const apply = (light) => { document.body.classList.toggle('light', light); document.documentElement.classList.toggle('light', light); }; |
| 551 | const saved = localStorage.getItem('theme'); |
| 552 | apply(saved ? saved === 'light' : mql.matches); |
| 553 | mql.addEventListener('change', e => { if(!localStorage.getItem('theme')) apply(e.matches); }); |