import { Html, Head, Main, NextScript } from 'next/document'; // Ensures the correct theme class is applied before the app paints const themeInitScript = `(() => { try { const stored = localStorage.getItem('theme'); const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; const theme = stored || (prefersDark ? 'dark' : 'light'); if (theme === 'dark') document.documentElement.classList.add('dark'); } catch (e) {} })();`; export default function Document() { return (