document.addEventListener('DOMContentLoaded', function() { const lightMode = document.getElementById('lightMode'); const darkMode = document.getElementById('darkMode'); const body = document.body; // Set initial theme based on system preference if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { body.classList.add('dark-mode'); darkMode.style.display = 'none'; lightMode.style.display = 'block'; } else { body.classList.remove('dark-mode'); darkMode.style.display = 'block'; lightMode.style.display = 'none'; } // Toggle theme functions lightMode.addEventListener('click', () => { body.classList.remove('dark-mode'); darkMode.style.display = 'block'; lightMode.style.display = 'none'; localStorage.setItem('theme', 'light'); }); darkMode.addEventListener('click', () => { body.classList.add('dark-mode'); darkMode.style.display = 'none'; lightMode.style.display = 'block'; localStorage.setItem('theme', 'dark'); }); // Check for saved theme preference const savedTheme = localStorage.getItem('theme'); if (savedTheme) { if (savedTheme === 'dark') { body.classList.add('dark-mode'); darkMode.style.display = 'none'; lightMode.style.display = 'block'; } else { body.classList.remove('dark-mode'); darkMode.style.display = 'block'; lightMode.style.display = 'none'; } } }); function createPaperCard(paper) { return `