I have decided that, just like Ryan said, galleries are a core WordPress feature and their CSS should be provided by the theme. There is no easy way to tell what content is to be loaded for any particular view because of the way WordPress themes are constructed, especially in case of custom database queries.

If your theme sticks to the standard loop, the best solution is to use Artem’s solution.