:root {
  --bg: #0b1a24;
  --bg-2: #0e212c;
  --panel: #10242f;
  --panel-2: #163140;
  --line: #1f3d4d;
  --text: #f1f6f8;
  --muted: #8aa4b2;
  --accent: #7fd1e6;
  --hot: #e0465e;
  --code-bg: #07131a;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(127, 209, 230, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(224, 70, 94, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- header ---------- */

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 clamp(14px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.brand-text b { font-weight: 650; letter-spacing: 0.01em; }
.brand-text .sep { color: var(--muted); margin: 0 8px; }
.brand-text .product { color: var(--muted); }
.sim-badge {
  flex: none; font-size: 12px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px;
}

.view { padding: clamp(14px, 3vw, 32px); max-width: 1500px; margin: 0 auto; }

/* ---------- gallery ---------- */

.hero { max-width: 780px; margin: clamp(8px, 4vh, 40px) 0 clamp(18px, 4vh, 36px); }
.hero h1 { font-size: clamp(28px, 4.4vw, 48px); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 14px; font-weight: 700; }
.lede { color: var(--muted); font-size: clamp(15px, 1.6vw, 18px); margin: 0; }
.lede .model-name { color: var(--accent); font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-width: 1100px; }
.card {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto;
  column-gap: 14px; row-gap: 2px; align-items: center;
  padding: 18px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  color: var(--text); text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-2px); border-color: rgba(127, 209, 230, 0.55);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(127, 209, 230, 0.15) inset; outline: none;
}
.card-icon {
  grid-row: 1 / span 2; width: 52px; height: 52px; display: grid; place-items: center;
  font-size: 28px; border-radius: 12px; background: var(--panel-2);
}
.card-title { font-weight: 650; font-size: 17px; }
.card-blurb { color: var(--muted); font-size: 13.5px; }
.card-go { grid-column: 1 / -1; margin-top: 12px; font-size: 13px; color: var(--accent); opacity: 0.75; }
.card:hover .card-go { opacity: 1; }
.foot { color: var(--muted); font-size: 13px; margin-top: 28px; }

/* ---------- build ---------- */

.build-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: 12.5px; letter-spacing: 0.04em; }
.build-head h2 { margin: 2px 0 0; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -0.01em; }
.actions { display: flex; gap: 8px; }
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #0b1a24;
  padding: 8px 16px; border-radius: 999px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }

.stage {
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1.6fr) minmax(0, 1fr);
  grid-template-areas: "preview stats" "code stats";
  height: calc(100dvh - 56px - 2 * clamp(14px, 3vw, 32px) - 76px);
  min-height: 560px;
  transition: grid-template-rows 0.4s ease;
}
.is-ready .stage { grid-template-rows: minmax(0, 2.6fr) minmax(0, 1fr); }
/* Reading the prompt: give the lower pane more room. */
@media (min-width: 901px) {
  .prompt-open .stage, .is-ready.prompt-open .stage { grid-template-rows: minmax(0, 1.3fr) minmax(0, 1fr); }
}

.preview {
  grid-area: preview; position: relative; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg);
}
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); }
.ph-inner { display: grid; justify-items: center; gap: 12px; }
.ph-icon { font-size: 44px; filter: drop-shadow(0 0 18px rgba(127, 209, 230, 0.35)); animation: bob 1.6s ease-in-out infinite; }
.ph-bar { width: 180px; height: 3px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.ph-bar span { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
.placeholder.is-error { color: var(--hot); }
.placeholder.is-error .ph-bar, .placeholder.is-error .ph-icon { display: none; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@keyframes bob { 50% { transform: translateY(-6px); } }

.stats {
  grid-area: stats; display: flex; flex-direction: column; gap: 14px;
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  min-height: 0; overflow: auto;
}
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.steps li {
  flex: 1; font-size: 11.5px; color: var(--muted); padding-top: 8px; position: relative; white-space: nowrap;
}
.steps li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--panel-2); }
.steps li.active { color: var(--text); }
.steps li.active::before { background: linear-gradient(90deg, var(--accent), rgba(127, 209, 230, 0.25)); animation: pulse 1s ease-in-out infinite; }
.steps li.done { color: var(--accent); }
.steps li.done::before { background: var(--accent); }
.steps li.error { color: var(--hot); }
.steps li.error::before { background: var(--hot); animation: none; }
@keyframes pulse { 50% { opacity: 0.45; } }
.status { font-weight: 600; font-size: 14.5px; min-height: 1.5em; }
.is-ready .status { color: var(--accent); }

.gauge-wrap { position: relative; text-align: center; }
.gauge { width: 100%; max-width: 260px; display: block; margin: 0 auto; overflow: visible; }
.g-track { fill: none; stroke: var(--panel-2); stroke-width: 12; stroke-linecap: round; }
.g-fill { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.g-needle { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.g-hub { fill: var(--text); }
.tick { stroke: var(--line); stroke-width: 1.5; }
.tick.major { stroke: var(--muted); }
.tick-label { fill: var(--muted); font: 9px var(--font); }
.gauge-read { margin-top: -6px; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.gauge-read small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.gauge-label { font-size: 12px; color: var(--muted); }

.nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; }
.nums div { min-width: 0; }
.nums dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.nums dd { margin: 0; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nums dd small { font-size: 0.62em; font-weight: 500; color: var(--muted); margin-left: 3px; }

.compare { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.cmp-row { display: grid; grid-template-columns: 82px 1fr 44px; gap: 8px; align-items: center; font-size: 12px; }
.cmp-name { color: var(--muted); white-space: nowrap; }
.cmp-bar { height: 8px; background: var(--panel-2); border-radius: 8px; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 8px; }
.cmp-bar.base i { background: var(--muted); opacity: 0.6; }
.cmp-val { text-align: right; font-variant-numeric: tabular-nums; }
.cmp-note { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.code {
  grid-area: code; display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--code-bg); overflow: hidden;
}
.code-head {
  display: flex; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.code-head { align-items: center; }
.tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: 0; padding: 2px 8px; border-radius: 6px; cursor: pointer;
  font: inherit; text-transform: inherit; letter-spacing: inherit; color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel-2); }
.prompt-view {
  flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; font-size: 13px; color: var(--text);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.prompt-view .pv-note { margin: 0 0 12px; color: var(--muted); }
.prompt-view h4 {
  margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent);
}
.prompt-view h4:first-of-type { margin-top: 0; }
.prompt-view pre {
  margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  font: 12.5px/1.55 var(--mono); color: #cfe3ea; white-space: pre-wrap; overflow-wrap: anywhere;
}
#code {
  flex: 1; margin: 0; padding: 12px 14px; overflow: auto; min-height: 0;
  font: 12.5px/1.55 var(--mono); color: #cfe3ea; tab-size: 2;
  white-space: pre; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}

/* ---------- phone / narrow ---------- */

@media (max-width: 760px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { grid-template-columns: 1fr; padding: 14px; row-gap: 4px; align-content: start; }
  .card-icon { grid-row: auto; width: 44px; height: 44px; font-size: 24px; margin-bottom: 6px; }
  .card-title { font-size: 16px; }
  .card-blurb { font-size: 12.5px; line-height: 1.35; }
  .card-go { display: none; }
  .hero { margin-top: 4px; }
}

@media (max-width: 900px) {
  .brand-text .product, .brand-text .sep { display: none; }
  .build-head { align-items: center; }
  .build-head .eyebrow { display: none; }
  .actions .btn { padding: 7px 12px; font-size: 13px; }
  .stage {
    height: auto; min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto 58dvh;
    grid-template-areas: "stats" "code";
  }
  /* While writing, the code is the show; the empty preview comes back when the game is ready. */
  .preview { display: none; }
  .is-ready .preview { display: block; }
  .is-ready .stage { grid-template-rows: auto 74dvh 30dvh; grid-template-areas: "stats" "preview" "code"; }
  .stats {
    display: grid; grid-template-columns: 128px 1fr; gap: 8px 14px; padding: 12px; overflow: visible;
  }
  .steps, .status, .compare { grid-column: 1 / -1; }
  .compare { display: none; }
  .is-ready .compare { display: grid; }
  .is-ready .steps { display: none; }
  .is-ready .cmp-row { display: none; }
  .is-ready .compare { border-top: 0; padding-top: 0; }
  .gauge-wrap { align-self: center; }
  .gauge-read { font-size: 22px; }
  .gauge-read small { font-size: 11px; margin-left: 4px; }
  .gauge-label { display: none; }
  .nums { align-self: center; gap: 6px 12px; }
  .nums .opt { display: none; }
  .nums dd { font-size: 16px; }
  #code { font-size: 11px; white-space: pre-wrap; word-break: break-all; }
  .prompt-view pre { font-size: 11.5px; }
}
