Add inline script to root layout that reads the stored theme preference
from cookie/localStorage synchronously before React hydrates, eliminating
the light→dark flash for users who prefer dark mode.
Also guard the theme storage write with the hydrated flag so the initial
render does not overwrite a stored 'dark' preference with 'light'.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>