CSS is tricky, touch one place the whole thing could collapse. I guess that just the nature.
I find this course is very helpful for me https://css-for-js.dev/
I think this is best evidenced by our constant innovation of news ways to undermine the "cascading" part of CSS and introducing scope wherever possible.
The solution is a careful consideration of scoping: most programming languages encourage the developer to carefully consider whether a variable should be local and global, and a similar amount of care must be taken in CSS too. The programmer needs to have a high awareness of which rules should apply to the whole document and which should apply to this particular component.
That's one very strong indicator that you are doing it wrong.