/** * Detects system/browser color scheme and sets the "style_variant" cookie accordingly. * Reloads the page if the variant changes. */ (function () { const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; const cookie = document.cookie.split('; ').find(r => r.startsWith('style_variant=')); const current = cookie ? cookie.split('=')[1] : ''; const desired = prefersDark ? '01-evening' : 'default'; // Customize variant names as needed if (current !== desired) { document.cookie = "style_variant=" + desired + "; path=/; max-age=31536000"; location.reload(); } })();