If you put that CSS code into a theme component, it would be almost like a toggle. It’s easy to create a theme component with the theme CLI.
I just tried it and it seems to work. If you want, you can fork this repo (it contains the CSS from the other topic), edit the CSS how you want, paste the Github URL into the theme components section, and then it will be toggable with a button.