A boundary-layer theory for cellular convection