 {
          promptElem.value = responses[0].trim();
          resultBox.textContent = "Prompt improved!";
        } else {
          resultBox.textContent = "No response from OpenAI.";
        }
      } catch (err) {
        setError("Error: " + err.message);
      }
    }

    // ---------- D) Apply Control (Sketch/Structure/Style) ----------
    async function applyControl() {
      const stabilityKey = document.getElementById("stabilityKey").value.trim();
      const method = document.getElementById("co