) {
      const openaiKey = document.getElementById("openaiKey").value.trim();
      const promptElem = document.getElementById("prompt");
      const promptText = promptElem.value.trim();
      const resultBox = document.getElementById("resultBox");
      resultBox.textContent = "";
      resultBox.classList.remove("error");

      if (!openaiKey) {
        alert("OpenAI key is missing - needed to improve prompt.");
        return;
      }
      if (!promptText) {
        alert("Enter a prompt first.");
  