cument.getElementById("loadingText");

    const userMessage = messageInput.value.trim();
    let conversationContext = conversationContextElement.value;
    const popupText = popupTextElement ? popupTextElement.innerText.trim() : "";

    if (!userMessage) return;

    if (popupText && !conversationContext.includes(popupText)) {
        conversationContext = popupText + "\n" + conversationContext;
    }

    const userBubble = document.createElement("div");
    userBubble.classList.add("chat-bubble", "user