[css mode] Fix bad context management

Closes #2046