script>
        // Inline script to apply the theme from the cookie immediately
        (function() {
            function getThemeFromCookie() {
                const cookies = document.cookie.split(';');
                for (const cookie of cookies) {
                    const [name, value] = cookie.trim().split('=');
                    if (name === 'theme') {
                        return value;
                    }
                }
                return 'light'; // Default to light mode 