Fix an output order of nested media queries. Closes #1701