A theory of electron energy confinement in tokamaks