(function () {
  try {
    var saved = localStorage.getItem('site-theme');
    var theme = saved || (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
    document.documentElement.setAttribute('data-theme', theme);
  } catch (error) {
    // Ignore storage and media query failures during bootstrap.
  }
})();
