How to split the categories into sections with titles?

I used the same CSS edit on my Discourse forum, but with the latest updates adding the sidebar it’s now a bit messed up:

How can I apply this edit only on the main outlet and not in the sidebar?
Thanks!

EDIT: This also happens in the header dropdown: