If refraction is the answer, why are sunsets red? Think about it again.
This is much the same as asking why is the sky blue. It's not a matter of refraction, but the selective scattering of light waves by the nature of what the white light is passing through. The composition of the atmosphere contains the molecules with chemical bonds that scatter the blue light and this is apparent. The red light seen before and during the first of sunset is affected by the far thicker and different atmosphere across the surface of the earth at that angle of incidence. Refraction does occur and the spectrum is momentarily evident as the last of the light passes the limb of the earth, but this phenomenon is not related to the earlier seen red color or the even still earlier blue color.