Well, you have at least prefers-color-scheme CSS media feature, but maybe you can also use System Colors: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value...
I remember the early days of Windows 95, where for a brief, glorious moment in time, all your applications would look like proper Windows 95 applications, respecting your color scheme, text size and font face, highlight/disable behavior, tooltip/hover behavior and colors, everything. Everything you launched just looked like it fit in with the rest of the system. Then, I think one of the first (at least most prominent) egregious violators was WinAmp. You'd launch it and it just decided by itself what the title bar, status bar, min/max/close buttons, content, everything, should look like. And not just colors--they used bitmap graphics to entirely override what common controls looked like. It stuck out on your desktop like a sore thumb. Yuck! If you wanted to change its appearance, you had to use the application's own plugin or theming system since it just ignored the system.
Fast forward to today, and every developer just treats the application's entire visual surface as their own art project, basically ignoring the system preferences altogether. If you're lucky, they let you specify "dark" vs. "light" or even more rarely, let you go in and do minor tweaks using the app's own bespoke preference settings. But fallback to system colors? Fuggetaboutit!
The problem for app developers is that there are so many completely different implementations of theming in platforms. On Windows, you have the Win95 era legacy theming (color schemes, fonts and window framing), like five or six different UI frameworks that may or may not integrate with the legacy settings, and on top of that the entire DPI settings which many app developers don't bother to test. On Linux, you have the big players KDE and Gnome and a truckload of splintered smaller projects. On macOS and iOS, you don't have anything but dark mode. On Android, you have dark mode and fonts. On web, you don't have anything but dark mode (and I wonder if that's going to be taken away like a million other things that got exploited to fingerprint users!). Oh and you have Java frameworks that have the same limitation.
And depending which kind of framework you use, it may or may not well integrate with whatever implementation the OS provides.