Created attachment 261241 [details]
The attached testcase shows that after an invalid media query block inside <style>, the CSS parser is unable to recover and ignores anything and everything that will follow the invalid block.
Browsers like Chrome and Firefox, ignore the first statement after the invalid media query block (which in the testcase would have made the div blue), but then do apply any following statements (in the testcase making the div green).
This caused a serious CSS styling issue on Wikimedia Commons, where a good percentage of CSS statements was ignored by Safari. Downstream report in Wikipedia: https://phabricator.wikimedia.org/T112552#1643002