How to style main sidebar and SubPage sidebar differently using CSS?

I have a main sidebar


and a SubPage sidebar


How to style the two differently using CSS?

For example I'd like the sidebar shown on any page inside /blog to have a blue border and any other page outside of /blog to have a sidebar with red border.