A model for layer formation in stably stratified turbulence