 }
        }

        function addMessage(role, content) {
            const messageDiv = document.createElement('div');
            messageDiv.classList.add('message', role);
            messageDiv.textContent = content;
            chatMessages.appendChild(messageDiv);
            chatMessages.scrollTop = chatMessages.scrollHeight;
        }

        function stop() {
            if (animationFrame) {
                cancelAnimationFrame(animationFrame);
            }
            if (audioContext) {
     