// ─────────────────────────────────────────────────────────────────────────────
// EDGE — Business Decision Simulation
// Working prototype · The Architect's Lab · The Game Changers
// Black & white design system. No colour accents.
//
// Standalone web version. Two changes from the original Claude artifact:
//   1. callClaude now talks to /api/chat (the backend relay) instead of calling
//      api.anthropic.com directly. The API key lives only on the server.
//   2. A short access-code gate sits in front of the experience.
// Everything else — the scenarios, the engine prompts, the design — is unchanged.
// ─────────────────────────────────────────────────────────────────────────────

const { useState, useRef, useEffect } = React;

const INK = "#161614";
const SOFT = "#6E6E69";
const HAIR = "#DCDCD6";
const PAPER = "#FCFCFA";

const SCENARIOS = [
  {
    id: "supplier",
    title: "The Supplier Ultimatum",
    sector: "Agro-processing · Export",
    opening: {
      act_title: "A call from Réunion",
      situation:
        "You run a small agro-processing business in Moka, exporting flavoured rum bases and fruit concentrates to hotels and two distributors in Réunion. Sixty per cent of your raw input comes from a single supplier, a family operation in Saint-Pierre you have worked with for four years. This morning the son, who has just taken over from his father, calls you. He is courteous but firm: a larger Mauritian competitor has offered to buy his entire output at a fourteen per cent premium, with payment at thirty days instead of your sixty. He says the family would prefer to keep working with you, out of loyalty to his father's relationship, but he needs an answer within one week.",
      the_pressure:
        "Matching the premium would erase most of your margin on your two biggest contracts. Your hotel clients have fixed-price agreements until December. Your operations manager, who negotiated the original supplier terms, has not yet been told.",
      decision_required:
        "What do you do in the next seven days, and what do you actually say, to the son, and to anyone else you choose to involve? Write your reasoning and your words.",
    },
  },
  {
    id: "cash",
    title: "The Quiet Cash Crisis",
    sector: "Services · B2B",
    opening: {
      act_title: "Healthy on paper",
      situation:
        "Your facilities-services company in Port Louis has just closed its best quarter on record. Revenue is up thirty per cent, you have signed two corporate clients, and your team has grown to eighteen people. Yesterday evening your part-time accountant sent you a short message: receivables have stretched from forty-five days to over ninety, your two newest clients are the slowest payers, and at the current rhythm you will not cover payroll in five weeks. One of the slow payers is a large group whose business represents a quarter of your revenue, and whose procurement officer has stopped answering your emails.",
      the_pressure:
        "Your relationship manager at the bank has hinted that an overdraft extension is possible but would require a personal guarantee. Your operations lead, who recruited most of the new team, does not know how tight things are. Your spouse co-signed the original business loan.",
      decision_required:
        "What do you do this week, and what do you actually say, to the procurement officer, to your bank, to your team if you choose to tell them? Write your reasoning and your words.",
    },
  },
  {
    id: "board",
    title: "The Boardroom Challenge",
    sector: "Family enterprise · Retail",
    opening: {
      act_title: "In front of the bank",
      situation:
        "You founded a homeware retail business eight years ago and brought in your uncle as a director when the family invested at the start. The business now has three outlets and you are presenting an expansion plan to your bank, seeking financing for a fourth location in the west. In the meeting, with your relationship manager and her credit analyst present, your uncle interrupts your presentation. He says, smiling, that the family has 'not yet agreed' to the expansion, that the figures are 'your daughter's optimism', and that perhaps the bank should wait until 'the family has discussed it properly'. The relationship manager closes her folder and suggests reconvening once the shareholders are aligned.",
      the_pressure:
        "The landlord of the west-coast site has given you until the end of the month before opening the lease to other offers. Your uncle holds twenty per cent of the shares; you hold sixty. Your mother, who holds the remaining twenty, avoids conflict and has not taken a position.",
      decision_required:
        "What do you do in the next forty-eight hours, and what do you actually say, in the room, to your uncle afterwards, to the relationship manager? Write your reasoning and your words.",
    },
  },
];

const DIMENSIONS =
  "1. Strategic clarity — does the participant reach the systemic cause or only the surface symptom? 2. Stakeholder awareness — does the response account for the interests and likely reactions of others? 3. Risk orientation — does the participant move toward the risk, around it, or away from it? 4. Leadership agency — does the response reflect ownership or deflection? 5. Relational intelligence — when the participant writes the words they would actually say, how do those words land: do they preserve dignity, build trust, and create the conditions for the other person to move?";

// ── The only networking change: talk to our own backend, never Anthropic directly.
async function callClaude(prompt, accessCode) {
  const response = await fetch("/api/chat", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ prompt, accessCode }),
  });
  if (!response.ok) {
    const err = await response.json().catch(() => ({}));
    throw new Error(err.error || "Request failed");
  }
  const data = await response.json();
  const text = (data.content || [])
    .filter((b) => b.type === "text")
    .map((b) => b.text)
    .join("\n");
  const clean = text.replace(/```json|```/g, "").trim();
  return JSON.parse(clean);
}

function buildHistory(scenario, acts, responses) {
  let h = `SCENARIO: ${scenario.title} (${scenario.sector})\n\n`;
  acts.forEach((a, i) => {
    h += `ACT ${i + 1} — ${a.act_title}\nSituation: ${a.situation}\nPressure: ${a.the_pressure}\nDecision required: ${a.decision_required}\n`;
    if (responses[i])
      h += `PARTICIPANT'S RESPONSE (their reasoning and their actual words): ${responses[i]}\n`;
    h += `\n`;
  });
  return h;
}

function evolvePrompt(scenario, acts, responses, actNumber) {
  return `You are the adaptive engine of EDGE, a business simulation platform for young entrepreneurs and women leaders in Mauritius, built by The Game Changers. You evolve a live scenario in response to the participant's actual decisions. You are rigorous but never cruel; the pressure must feel like real Mauritian business life, not a punishment.

${buildHistory(scenario, acts, responses)}

Silently analyse the participant's latest response across these five dimensions (do not output the analysis): ${DIMENSIONS}

Now write ACT ${actNumber} of the scenario. The world must respond directly and plausibly to what the participant actually did and said: consequences of their choices arrive, a stakeholder reacts to the participant's specific words, and the pressure escalates in a way that targets the weakest dimension you observed. Keep it grounded in Mauritian business texture (banking relationships, family dynamics, suppliers, regulators). Introduce at most one new element. End with a decision that requires the participant to both decide and to write the actual words they would say to someone.

Respond ONLY with valid JSON, no preamble, no markdown fences, in exactly this shape:
{"act_title": "short evocative title, 3-6 words", "situation": "what has happened since their decision, reacting to their specific words and choices, 90-130 words", "the_pressure": "the constraint or stake that makes this hard, 40-70 words", "decision_required": "the decision and the words they must write, one or two sentences ending with: Write your reasoning and your words."}`;
}

function profilePrompt(scenario, acts, responses) {
  return `You are the reflective layer of EDGE, a simulation platform within The Architect's Lab, a coaching programme by The Game Changers (Mauritius). A participant has completed a three-act simulation. Your task is to write their Thinking Profile.

The profile is descriptive, never evaluative. It does not score, rank, praise or condemn. It mirrors, in the spirit of person-centred practice: it gives the participant precise, dignified language for patterns in how they think and communicate under pressure, so that they can examine those patterns with their coach. Write warmly and plainly, in the second person, with quiet authority. Quote or closely paraphrase the participant's own words where it illuminates a pattern.

${buildHistory(scenario, acts, responses)}

The five dimensions to mirror: ${DIMENSIONS}

Respond ONLY with valid JSON, no preamble, no markdown fences, in exactly this shape:
{"opening": "a 60-90 word portrait of how this person approached the whole arc, naming the throughline you observed", "dimensions": [{"name": "Strategic clarity", "mirror": "2-3 sentences"}, {"name": "Stakeholder awareness", "mirror": "2-3 sentences"}, {"name": "Risk orientation", "mirror": "2-3 sentences"}, {"name": "Leadership agency", "mirror": "2-3 sentences"}, {"name": "Relational intelligence", "mirror": "2-3 sentences, drawing on the actual words they wrote to stakeholders"}], "coaching_questions": ["three open questions, each one sentence, that the participant should bring to their next coaching session — questions only a human conversation can resolve"], "closing_line": "one sentence that settles rather than concludes, no advice, no exclamation"}`;
}

const LOADING_LINES = [
  "The world is responding to your decision",
  "Your words have reached their audience",
  "Consequences are taking shape",
];

function App() {
  const [screen, setScreen] = useState("gate");
  const [accessCode, setAccessCode] = useState("");
  const [codeInput, setCodeInput] = useState("");
  const [gateError, setGateError] = useState(null);
  const [gateChecking, setGateChecking] = useState(false);
  const [scenario, setScenario] = useState(null);
  const [acts, setActs] = useState([]);
  const [responses, setResponses] = useState([]);
  const [draft, setDraft] = useState("");
  const [loading, setLoading] = useState(false);
  const [loadLine, setLoadLine] = useState(0);
  const [profile, setProfile] = useState(null);
  const [error, setError] = useState(null);
  const topRef = useRef(null);

  useEffect(() => {
    if (!loading) return;
    const t = setInterval(
      () => setLoadLine((n) => (n + 1) % LOADING_LINES.length),
      2600
    );
    return () => clearInterval(t);
  }, [loading]);

  useEffect(() => {
    if (topRef.current) topRef.current.scrollIntoView({ behavior: "smooth" });
  }, [acts.length, screen]);

  const unlock = async () => {
    const code = codeInput.trim();
    if (!code || gateChecking) return;
    setGateError(null);
    setGateChecking(true);
    try {
      const r = await fetch("/api/chat", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ verify: true, accessCode: code }),
      });
      if (r.ok) {
        setAccessCode(code);
        setScreen("intro");
      } else {
        setGateError("That code was not recognised. Check it and try again.");
      }
    } catch (e) {
      setGateError("Could not reach the server. Try again in a moment.");
    }
    setGateChecking(false);
  };

  const begin = (s) => {
    setScenario(s);
    setActs([s.opening]);
    setResponses([]);
    setDraft("");
    setProfile(null);
    setError(null);
    setScreen("simulation");
  };

  const commit = async () => {
    if (draft.trim().length < 40 || loading) return;
    const newResponses = [...responses, draft.trim()];
    setResponses(newResponses);
    setDraft("");
    setLoading(true);
    setError(null);
    try {
      if (acts.length < 3) {
        const next = await callClaude(
          evolvePrompt(scenario, acts, newResponses, acts.length + 1),
          accessCode
        );
        setActs((a) => [...a, next]);
      } else {
        const p = await callClaude(
          profilePrompt(scenario, acts, newResponses),
          accessCode
        );
        setProfile(p);
        setScreen("profile");
      }
    } catch (e) {
      setError(
        "EDGE could not reach its reasoning engine. Your response is kept below — try committing it again."
      );
      setResponses(responses);
      setDraft(newResponses[newResponses.length - 1]);
    }
    setLoading(false);
  };

  const reset = () => {
    setScreen("intro");
    setScenario(null);
    setActs([]);
    setResponses([]);
    setProfile(null);
    setError(null);
  };

  const roman = ["I", "II", "III"];

  return (
    <div style={{ minHeight: "100vh", background: PAPER, color: INK }}>
      <style>{`
        @import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=Inter:wght@300;400;500&display=swap');
        .ar-serif { font-family: 'Cormorant Garamond', Georgia, serif; }
        .ar-body { font-family: 'Inter', -apple-system, sans-serif; }
        .ar-fade { animation: arfade .7s ease both; }
        @keyframes arfade { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }
        .ar-card { transition: background .25s ease, border-color .25s ease; cursor: pointer; }
        .ar-card:hover { background: ${INK}; }
        .ar-card:hover * { color: ${PAPER} !important; }
        .ar-card:hover .ar-hair { background: ${PAPER} !important; opacity: .35; }
        textarea:focus, input:focus, button:focus-visible { outline: 1.5px solid ${INK}; outline-offset: 3px; }
        .ar-pulse { animation: arpulse 2.4s ease-in-out infinite; }
        @keyframes arpulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
        @media (prefers-reduced-motion: reduce) { .ar-fade, .ar-pulse { animation: none; } }
      `}</style>

      <div ref={topRef} />

      {/* Masthead */}
      <header
        className="ar-body"
        style={{
          borderBottom: `1px solid ${HAIR}`,
          padding: "18px 24px",
          display: "flex",
          justifyContent: "space-between",
          alignItems: "baseline",
        }}
      >
        <div
          style={{
            letterSpacing: "0.32em",
            fontSize: 13,
            fontWeight: 500,
          }}
        >
          E D G E
        </div>
        <div style={{ fontSize: 10.5, letterSpacing: "0.14em", color: SOFT }}>
          THE ARCHITECT'S LAB · THE GAME CHANGERS
        </div>
      </header>

      <main style={{ maxWidth: 720, margin: "0 auto", padding: "48px 24px 96px" }}>
        {/* ── GATE ───────────────────────────────────────────────── */}
        {screen === "gate" && (
          <div className="ar-fade" style={{ paddingTop: 28 }}>
            <h1
              className="ar-serif"
              style={{
                fontSize: "clamp(30px, 5vw, 46px)",
                fontWeight: 500,
                lineHeight: 1.1,
                margin: "8px 0 18px",
              }}
            >
              Enter your access code
            </h1>
            <p
              className="ar-body"
              style={{
                fontSize: 14.5,
                lineHeight: 1.75,
                color: SOFT,
                maxWidth: 520,
                fontWeight: 300,
              }}
            >
              EDGE is open to participants of The Architect's Lab. Enter the
              code you were given to begin.
            </p>
            <input
              className="ar-body"
              type="password"
              value={codeInput}
              onChange={(e) => setCodeInput(e.target.value)}
              onKeyDown={(e) => e.key === "Enter" && unlock()}
              placeholder="Access code"
              style={{
                width: "100%",
                maxWidth: 340,
                boxSizing: "border-box",
                border: `1px solid ${HAIR}`,
                background: "#FFFFFF",
                padding: "14px 16px",
                fontSize: 15,
                color: INK,
                marginTop: 28,
                fontWeight: 300,
                letterSpacing: "0.04em",
              }}
            />
            {gateError && (
              <p
                className="ar-body"
                style={{ fontSize: 12.5, color: SOFT, marginTop: 12 }}
              >
                {gateError}
              </p>
            )}
            <div style={{ marginTop: 18 }}>
              <button
                className="ar-body"
                onClick={unlock}
                disabled={!codeInput.trim() || gateChecking}
                style={{
                  background: !codeInput.trim() ? PAPER : INK,
                  color: !codeInput.trim() ? SOFT : PAPER,
                  border: `1px solid ${!codeInput.trim() ? HAIR : INK}`,
                  padding: "12px 26px",
                  fontSize: 12,
                  letterSpacing: "0.12em",
                  cursor: !codeInput.trim() ? "default" : "pointer",
                }}
              >
                {gateChecking ? "CHECKING…" : "ENTER"}
              </button>
            </div>
          </div>
        )}

        {/* ── INTRO ─────────────────────────────────────────────── */}
        {screen === "intro" && (
          <div className="ar-fade">
            <h1
              className="ar-serif"
              style={{
                fontSize: "clamp(34px, 6vw, 52px)",
                fontWeight: 500,
                lineHeight: 1.08,
                margin: "8px 0 20px",
              }}
            >
              A thinking environment,
              <br />
              <em style={{ fontWeight: 400 }}>not a test.</em>
            </h1>
            <p
              className="ar-body"
              style={{
                fontSize: 15,
                lineHeight: 1.75,
                color: SOFT,
                maxWidth: 560,
                fontWeight: 300,
              }}
            >
              EDGE places you inside a live business situation drawn from
              Mauritian reality. Your decisions change what happens next, and
              the people in the scenario respond to the words you actually
              write, not the ones you meant. There are no scores and no right
              answers. At the end, EDGE mirrors back how you think under
              pressure, and gives you questions to bring to your coach.
            </p>

            <div
              className="ar-body"
              style={{
                margin: "44px 0 14px",
                fontSize: 10.5,
                letterSpacing: "0.18em",
                color: SOFT,
              }}
            >
              CHOOSE YOUR SITUATION
            </div>

            <div style={{ display: "grid", gap: 14 }}>
              {SCENARIOS.map((s) => (
                <div
                  key={s.id}
                  className="ar-card"
                  role="button"
                  tabIndex={0}
                  onClick={() => begin(s)}
                  onKeyDown={(e) => e.key === "Enter" && begin(s)}
                  style={{
                    border: `1px solid ${HAIR}`,
                    background: "#FFFFFF",
                    padding: "22px 24px",
                  }}
                >
                  <div
                    className="ar-body"
                    style={{
                      fontSize: 10,
                      letterSpacing: "0.16em",
                      color: SOFT,
                      marginBottom: 8,
                    }}
                  >
                    {s.sector.toUpperCase()}
                  </div>
                  <div
                    className="ar-serif"
                    style={{ fontSize: 26, fontWeight: 500, color: INK }}
                  >
                    {s.title}
                  </div>
                  <div
                    className="ar-hair"
                    style={{
                      height: 1,
                      background: HAIR,
                      margin: "14px 0 12px",
                    }}
                  />
                  <div
                    className="ar-body"
                    style={{
                      fontSize: 13,
                      color: SOFT,
                      lineHeight: 1.6,
                      fontWeight: 300,
                    }}
                  >
                    {s.opening.situation.slice(0, 130)}…
                  </div>
                </div>
              ))}
            </div>

            <p
              className="ar-body"
              style={{
                marginTop: 36,
                fontSize: 11.5,
                color: SOFT,
                lineHeight: 1.7,
                fontWeight: 300,
              }}
            >
              Three acts. Write freely, in your own words — reasoning and what
              you would actually say. Nothing you write is stored beyond this
              session.
            </p>
          </div>
        )}

        {/* ── SIMULATION ─────────────────────────────────────────── */}
        {screen === "simulation" && scenario && (
          <div>
            <div
              className="ar-body"
              style={{
                display: "flex",
                alignItems: "center",
                gap: 14,
                marginBottom: 36,
              }}
            >
              <span style={{ fontSize: 10.5, letterSpacing: "0.18em", color: SOFT }}>
                {scenario.title.toUpperCase()}
              </span>
              <div style={{ flex: 1, height: 1, background: HAIR, position: "relative" }}>
                <div
                  style={{
                    position: "absolute",
                    left: 0,
                    top: 0,
                    height: 1,
                    background: INK,
                    width: `${(acts.length / 3) * 100}%`,
                    transition: "width .8s ease",
                  }}
                />
              </div>
              <span style={{ fontSize: 10.5, letterSpacing: "0.14em", color: SOFT }}>
                ACT {roman[acts.length - 1]} OF III
              </span>
            </div>

            {acts.map((a, i) => {
              const isCurrent = i === acts.length - 1;
              return (
                <section
                  key={i}
                  className="ar-fade"
                  style={{
                    opacity: isCurrent ? 1 : 0.42,
                    marginBottom: 40,
                    paddingBottom: isCurrent ? 0 : 32,
                    borderBottom: isCurrent ? "none" : `1px solid ${HAIR}`,
                  }}
                >
                  <div
                    className="ar-body"
                    style={{
                      fontSize: 10,
                      letterSpacing: "0.18em",
                      color: SOFT,
                      marginBottom: 8,
                    }}
                  >
                    ACT {roman[i]}
                  </div>
                  <h2
                    className="ar-serif"
                    style={{ fontSize: 30, fontWeight: 500, margin: "0 0 16px" }}
                  >
                    {a.act_title}
                  </h2>
                  <p className="ar-body" style={{ fontSize: 14.5, lineHeight: 1.8, fontWeight: 300 }}>
                    {a.situation}
                  </p>
                  <p
                    className="ar-body"
                    style={{
                      fontSize: 14.5,
                      lineHeight: 1.8,
                      fontWeight: 300,
                      borderLeft: `2px solid ${INK}`,
                      paddingLeft: 16,
                      margin: "18px 0",
                    }}
                  >
                    {a.the_pressure}
                  </p>
                  <p
                    className="ar-serif"
                    style={{ fontSize: 19, fontStyle: "italic", lineHeight: 1.55 }}
                  >
                    {a.decision_required}
                  </p>

                  {responses[i] && (
                    <div style={{ marginTop: 18 }}>
                      <div
                        className="ar-body"
                        style={{
                          fontSize: 10,
                          letterSpacing: "0.16em",
                          color: SOFT,
                          marginBottom: 6,
                        }}
                      >
                        YOUR RESPONSE
                      </div>
                      <p
                        className="ar-body"
                        style={{
                          fontSize: 13.5,
                          lineHeight: 1.7,
                          color: SOFT,
                          whiteSpace: "pre-wrap",
                          fontWeight: 300,
                        }}
                      >
                        {responses[i]}
                      </p>
                    </div>
                  )}
                </section>
              );
            })}

            {!loading && !responses[acts.length - 1] && (
              <div className="ar-fade">
                <textarea
                  className="ar-body"
                  value={draft}
                  onChange={(e) => setDraft(e.target.value)}
                  rows={8}
                  placeholder="Your reasoning, and the words you would actually say…"
                  style={{
                    width: "100%",
                    boxSizing: "border-box",
                    border: `1px solid ${HAIR}`,
                    background: "#FFFFFF",
                    padding: "16px 18px",
                    fontSize: 14.5,
                    lineHeight: 1.7,
                    color: INK,
                    resize: "vertical",
                    fontWeight: 300,
                  }}
                />
                {error && (
                  <p className="ar-body" style={{ fontSize: 12.5, color: SOFT, marginTop: 10 }}>
                    {error}
                  </p>
                )}
                <div
                  style={{
                    display: "flex",
                    justifyContent: "space-between",
                    alignItems: "center",
                    marginTop: 14,
                  }}
                >
                  <span className="ar-body" style={{ fontSize: 11.5, color: SOFT, fontWeight: 300 }}>
                    {draft.trim().length < 40
                      ? "Take your time — a few sentences at least."
                      : "When you commit, the world responds."}
                  </span>
                  <button
                    className="ar-body"
                    onClick={commit}
                    disabled={draft.trim().length < 40}
                    style={{
                      background: draft.trim().length < 40 ? PAPER : INK,
                      color: draft.trim().length < 40 ? SOFT : PAPER,
                      border: `1px solid ${draft.trim().length < 40 ? HAIR : INK}`,
                      padding: "12px 26px",
                      fontSize: 12,
                      letterSpacing: "0.12em",
                      cursor: draft.trim().length < 40 ? "default" : "pointer",
                    }}
                  >
                    {acts.length < 3 ? "COMMIT YOUR RESPONSE" : "COMMIT & RECEIVE YOUR PROFILE"}
                  </button>
                </div>
              </div>
            )}

            {loading && (
              <div style={{ padding: "36px 0", textAlign: "center" }}>
                <div
                  className="ar-serif ar-pulse"
                  style={{ fontSize: 21, fontStyle: "italic" }}
                >
                  {acts.length < 3 || responses.length < 3
                    ? LOADING_LINES[loadLine]
                    : "EDGE is writing your Thinking Profile"}
                  …
                </div>
              </div>
            )}
          </div>
        )}

        {/* ── PROFILE ────────────────────────────────────────────── */}
        {screen === "profile" && profile && (
          <div className="ar-fade">
            <div
              className="ar-body"
              style={{ fontSize: 10.5, letterSpacing: "0.18em", color: SOFT, marginBottom: 10 }}
            >
              {scenario.title.toUpperCase()} · SIMULATION COMPLETE
            </div>
            <h1 className="ar-serif" style={{ fontSize: 42, fontWeight: 500, margin: "0 0 26px" }}>
              Your Thinking Profile
            </h1>
            <p
              className="ar-serif"
              style={{ fontSize: 21, lineHeight: 1.6, fontStyle: "italic", marginBottom: 38 }}
            >
              {profile.opening}
            </p>

            {(profile.dimensions || []).map((d, i) => (
              <div key={i} style={{ borderTop: `1px solid ${HAIR}`, padding: "20px 0" }}>
                <div
                  className="ar-body"
                  style={{ fontSize: 11, letterSpacing: "0.16em", marginBottom: 8 }}
                >
                  {d.name.toUpperCase()}
                </div>
                <p className="ar-body" style={{ fontSize: 14.5, lineHeight: 1.75, fontWeight: 300 }}>
                  {d.mirror}
                </p>
              </div>
            ))}

            <div
              style={{
                border: `1px solid ${INK}`,
                padding: "26px 28px",
                margin: "36px 0",
                background: "#FFFFFF",
              }}
            >
              <div
                className="ar-body"
                style={{ fontSize: 11, letterSpacing: "0.16em", marginBottom: 14 }}
              >
                BRING THIS TO YOUR COACHING CONVERSATION
              </div>
              {(profile.coaching_questions || []).map((q, i) => (
                <p
                  key={i}
                  className="ar-serif"
                  style={{ fontSize: 18.5, lineHeight: 1.5, margin: "0 0 12px", fontStyle: "italic" }}
                >
                  {q}
                </p>
              ))}
              <p className="ar-body" style={{ fontSize: 11.5, color: SOFT, marginTop: 6, fontWeight: 300 }}>
                EDGE does not answer these. Your coach, and you, will.
              </p>
            </div>

            <p className="ar-serif" style={{ fontSize: 19, fontStyle: "italic", color: SOFT }}>
              {profile.closing_line}
            </p>

            <button
              className="ar-body"
              onClick={reset}
              style={{
                marginTop: 36,
                background: "transparent",
                border: `1px solid ${INK}`,
                color: INK,
                padding: "12px 26px",
                fontSize: 12,
                letterSpacing: "0.12em",
                cursor: "pointer",
              }}
            >
              BEGIN ANOTHER SIMULATION
            </button>
          </div>
        )}
      </main>

      <footer
        className="ar-body"
        style={{
          borderTop: `1px solid ${HAIR}`,
          padding: "16px 24px",
          fontSize: 10,
          letterSpacing: "0.12em",
          color: SOFT,
          display: "flex",
          justifyContent: "space-between",
        }}
      >
        <span>EDGE · PROTOTYPE</span>
        <span>RESPONSES ARE NOT STORED BEYOND THIS SESSION</span>
      </footer>
    </div>
  );
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
