// Theme bootstrap: runs synchronously in <head> to avoid a flash of the
// wrong theme. The server renders data-default-theme from the user profile;
// localStorage wins so the choice applies before login too.
(function () {
  var el = document.documentElement;
  var saved = null;
  try { saved = localStorage.getItem('theme'); } catch (e) { /* private mode */ }
  var THEMES = ['light', 'dark', 'neon', 'terminal', 'blueprint', 'sunset'];
  var theme = saved || el.dataset.defaultTheme || 'light';
  if (THEMES.indexOf(theme) === -1) theme = 'light';
  el.dataset.theme = theme;
  el.dataset.themes = THEMES.join(',');
})();
