Thank you so much for your reply @Comfy.n!
So you got it in one shot. In fact, as soon as I had changed the UI style to "calibre", I didn't need to customise the link colors: the default colors set in the "calibre UI" settings are OK in both light and dark modes.
TIL that it is better to use the calibre UI settings which give one much more control that the "system" UI settings.
I think that was the only thing I had not tried yet. Thanks for pointing me in the right direction.
The only minor problem now is that I have quite a few hyperlinks in book comments which still have the old <span> code with the problematic colors, which are still overriding the new defaults. But I can probably just edit them gradually over time.
Thanks again for the help!
PS It is interesting once you enter a hyperlink in the comments, the color that is applied (depending on whether you are in light or dark mode at the time) is kept permanently regardless of which mode you later switch to. It would be a nice enhancement for them to switch color depending on the mode you are currently in (using the colors preset in the settings for the calibre UI style).