/** * Inline scripts run in before paint (server-safe module: no 'use client', so the root layout can embed the strings). * They apply the persisted theme and density to so the first frame is right. Keys are shared with * `components/layout/theme.tsx` and `lib/density.ts`. */ export const THEME_KEY = 'aia-theme'; export const DENSITY_KEY = 'aia-density'; export const THEME_SCRIPT = `(function(){try{var k='${THEME_KEY}',p=localStorage.getItem(k),m=window.matchMedia('(prefers-color-scheme: dark)'),t=(p==='light'||p==='dark')?p:(m.matches?'dark':'light');document.documentElement.setAttribute('data-theme',t);document.documentElement.style.colorScheme=t;}catch(e){}})();`; export const DENSITY_SCRIPT = `(function(){try{var d=localStorage.getItem('${DENSITY_KEY}');if(d==='compact'||d==='dense'){document.documentElement.setAttribute('data-density',d);}}catch(e){}})();`; export const PREPAINT_SCRIPT = THEME_SCRIPT + DENSITY_SCRIPT;