Optimize CSS Export: extract similar rules into combining CSS block

Tests are pending… Comments are welcome.
My linter is complaining on variable redeclaration.