function set_day_night_mode(){
  // On page load or when changing themes, best to add inline in `head` to avoid FOUC
  if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
    document.documentElement.classList.add('dark')
  } else {
    document.documentElement.classList.remove('dark')
  }
}
set_day_night_mode()
matchMedia('(prefers-color-scheme: dark)').addEventListener("change", set_day_night_mode)
