loseModal();
                }
            }

            document.addEventListener('keydown', function(event) {
                if (event.key === "Escape" && modal.style.display === "block") {
                    closeModal();
                }
            });
        } else {
            console.error('Modal or modal close button not found on DOMContentLoaded. Check IDs: mediaModal, modalCloseButton');
        }

        // Load data when the page loads
        loadMediaCache();
    });
</