Mostly fairly manual, with a bunch of regular expressions and things like sorting the CSS block by background-color (Vim: `:sort /{/`). It was tempting to slurp it in Python, gargle it about a bit and spit it out neatly refactored, but I didn’t do it that way. A small quantity of Vimscript would also have been fairly straightforward. But no, I did it the hard way out of the wrong type of laziness. (Why did I do it at all? Who knows.)