Optimize CSS Export: extract similar rules into combining CSS block

Tests are pending… Comments are welcome.
More a code style thing, but could you add braces after the for loop initialization and a newline for the if please?