PGMapCSS is a library for PostgreSQL/PostGIS which works between an osm2pgsql based database and Mapnik (and maybe other renderers). It processes database (usually OpenStreetMap) objects according to MapCSS rules and calculates resulting colors, widths and other properties for Symbolizers, even geometric modifications.
JOSM introduced CSS style @media queries: http://josm.openstreetmap.de/wiki/Help/Styles/MapCSSImplementation#Mediaqueriessince6970
pgmapcss should support them too.