document.getElementById('file').addEventListener('change', function() {
    const name = this.files.length ? this.files[0].name : '';
    document.getElementById('filename').textContent = name;
});

(function() {
    var toggleBtn = document.getElementById('theme-toggle');

    function isLight() {
        return document.documentElement.getAttribute('data-theme') === 'light';
    }

    function updateIcon() {
        // Shows the icon for the theme you'd switch TO.
        toggleBtn.textContent = isLight() ? '\u{1F319}' : '☀️';
    }

    toggleBtn.addEventListener('click', function() {
        if (isLight()) {
            document.documentElement.removeAttribute('data-theme');
            localStorage.setItem('nymdrop-theme', 'dark');
        } else {
            document.documentElement.setAttribute('data-theme', 'light');
            localStorage.setItem('nymdrop-theme', 'light');
        }
        updateIcon();
    });

    updateIcon();
})();
