In about:config the layout.css.prefers-color-scheme.content-override setting was on 2 (system). Setting it to 3 (browser) turned the dark mode off.