How does Iran's theocratic system of power work?

Who could succeed Khamenei as supreme leader, and what role could the Revolutionary Guards play?