Going back a bit... 'Hydrogen and Helium are lost into space'.... I don't think so.... In a vacuum both hydrogen and helium will weigh something, it's only when weighed in air that the buoyancy makes them float.
So I would think they find a gravitational balance, on top of the air layer, much the same as the Ozone layer... We have invented the Hydrogen and Helium layers..! In practice, turbulence and heat energy keeps all the gasses mixed, or else the Nitrogen would separate from the Oxygen.
.