How to build an authoritarian regime — and how to stop one