How customize the appearance of sections like Amazon?

Ah, I see.

The correct thing to do is to place this CSS into a theme component, which is only slightly different from what you are doing!

If you edit the Light theme, the changes will not be visible on the Dark theme.

Create a single theme component for all your site local customizations!