Getting dark mode right

Two things most sites get wrong about dark mode: the flicker on load and the jarring toggle. Here is how to fix both.