I would tolerate some js to implement dark mode with a class rather than a media query. It allows more control with a toggle if user wants some site dark some light.
Edit: it's covered in the article actually.
Here is an article that was posted to HN which implements the three-state (auto/light/dark) toggle in HTML and CSS only: https://lyra.horse/blog/2025/08/you-dont-need-js/