Dual-Theme Design Tokens Without Contrast Regressions
Building light and dark mode palettes around semantic surface pairs, optical text compensation, and zero brittle CSS overrides.

Dark mode fails when it's bolted on with !important color inversions. Reliable dual-theme systems define semantic roles—canvas, surface, nested item, hairline border, primary ink, and muted ink—once at the root and swap values cleanly.
Keep surface contrast measured
In light mode, keep subtle container elevation deltas tight and crisp; in dark mode, avoid pure black cards on pure black canvases by stepping surfaces gently from #080708 to #151617 and #1c1d1f.
Prevent flash of wrong theme
Running a tiny inline script before hydration reads localStorage and system color-scheme preferences immediately, setting data-theme before first paint so switching pages never flickers.