 displayMessage("Connection closed. Please refresh the page.", 'system');
            disableInput();
        };

        document.getElementById('message-input').addEventListener('keydown', function (event) {
            if (event.key === 'Enter' && !event.target.disabled) {
                sendMessage();
            }
        });

        async function sendMessage() {
            const input = document.getElementById('message-input');
            const button = document.getElementById('send-button');
   