let _themeMM = matchMedia("(prefers-color-scheme: light)");
let light, useAutoTheme;
light = _themeMM.matches;

function setTheme() {
  if (light) {
    document.documentElement.setAttribute("data-light", "");
  } else {
    document.documentElement.removeAttribute("data-light");
  }
}

_themeMM.addEventListener("change", function() {
  light = _themeMM.matches;
  setTheme();
});

setTheme();
