In fact, the sun at sunset which appears to be above the horizon is already well below the horizon, precisely because the atmosphere is less dense at higher altitudes. See https://www.feynmanlectures.caltech.edu/I_26.html Fig. 26-7
(Presumably this is also true at sunrise, so the day is longer than it "should" be from purely geometric considerations.)