:root {
  --bg: #05060a;
  --ink: #e8ecf5;
  --muted: #7a849c;
  --line: rgba(255, 255, 255, 0.1);
  --glass: rgba(12, 16, 28, 0.55);
  --accent: #cfe0ff;
  --accent-2: #9ec0ff;
  --warn: #f0c27a;
  --radius: 22px;
  --font: "SF Pro Display", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Aurora mesh */
.aurora {
  position: fixed; inset: -20% -10% auto -10%; height: 70vh; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(80, 140, 220, 0.22), transparent 70%),
    radial-gradient(35% 45% at 75% 20%, rgba(60, 200, 180, 0.12), transparent 70%),
    radial-gradient(50% 40% at 50% 60%, rgba(180, 140, 80, 0.08), transparent 70%);
  filter: blur(40px);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.05); }
}
.noise {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.top, .shell, .foot { position: relative; z-index: 2; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; max-width: 1120px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.mark {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--accent-2) 45%, #3a6ea8 80%);
  box-shadow: 0 0 20px rgba(150, 200, 255, 0.55);
}
.name { font-weight: 700; letter-spacing: -0.04em; font-size: 17px; }
.nav { display: flex; gap: 8px; }

.ghost, .primary, .go {
  appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  color: var(--ink); border-radius: 999px; padding: 9px 16px; font: inherit; font-size: 13px;
  letter-spacing: 0.02em; cursor: pointer; text-decoration: none; transition: background .2s, border-color .2s, transform .15s;
}
.ghost:hover { background: rgba(255,255,255,0.08); }
.primary, .go {
  border: none;
  background: linear-gradient(135deg, #e8f0ff 0%, #9eb8ff 55%, #7aa0ef 100%);
  color: #0a1020; font-weight: 650;
  box-shadow: 0 8px 30px rgba(100, 150, 255, 0.25);
}
.primary:hover, .go:hover { transform: translateY(-1px); }
.primary:disabled, .go:disabled { opacity: 0.55; cursor: wait; transform: none; }

.shell { max-width: 1120px; margin: 0 auto; padding: 12px 22px 80px; }

.hero { padding: 36px 0 28px; max-width: 820px; }
.eyebrow {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 18px;
}
h1 {
  font-size: clamp(2.4rem, 6vw, 4.2rem); line-height: 1.02; letter-spacing: -0.045em; font-weight: 650;
}
h1 em {
  font-style: normal;
  background: linear-gradient(105deg, #f2f6ff 10%, #9ec8ff 45%, #7ad4c4 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { margin-top: 16px; color: var(--muted); font-size: 1.05rem; max-width: 36rem; }

.prompt-wrap { margin-top: 32px; }
.prompt-glass {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px); box-shadow: 0 20px 60px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
}
textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 1.05rem; line-height: 1.4; min-height: 56px; padding: 8px 10px;
}
textarea::placeholder { color: #5c657a; }
.go { flex-shrink: 0; min-width: 112px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.go-spinner {
  width: 14px; height: 14px; border: 2px solid rgba(10,16,32,.25); border-top-color: #0a1020;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  border: 1px solid var(--line); background: rgba(255,255,255,0.03); color: #b7c0d4;
  padding: 8px 12px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.chip:hover, .chip.active {
  border-color: rgba(160, 200, 255, 0.45); color: #eef4ff; background: rgba(120, 170, 255, 0.08);
}

.stage-panel { margin-top: 28px; animation: rise .45s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stage-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.stage-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; min-width: 0; }
.stage-meta strong { font-size: 1.05rem; letter-spacing: -0.02em; }
.stage-meta .muted { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(420px, 50vw); }
.pill {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; border: 1px solid rgba(160,200,255,.3); color: var(--accent-2);
}
.pill.ai { border-color: rgba(120, 220, 180, .35); color: #9fe8cb; }
.pill.fallback { border-color: rgba(240, 194, 122, .4); color: var(--warn); }
.stage-actions { display: flex; gap: 8px; }

.viewport {
  position: relative; height: min(62vh, 640px); min-height: 360px; border-radius: calc(var(--radius) + 4px);
  overflow: hidden; border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.glass { background: rgba(8,10,18,.65); backdrop-filter: blur(12px); }
.viewport iframe { width: 100%; height: 100%; border: 0; background: #05060a; }
.loading {
  position: absolute; inset: 0; place-content: center; gap: 16px; text-align: center;
  background: rgba(5,6,10,.72); color: var(--muted); backdrop-filter: blur(6px);
  display: none;
}
.loading:not([hidden]) {
  display: grid;
}
.orbit-loader {
  width: 48px; height: 48px; margin: 0 auto; border-radius: 50%;
  border: 2px solid rgba(150,190,255,.15); border-top-color: var(--accent-2);
  animation: spin 0.9s linear infinite;
}

.gallery { margin-top: 72px; }
.gallery-head h2 { font-size: 1.5rem; letter-spacing: -0.03em; }
.gallery-head p { color: var(--muted); margin-top: 6px; }
.cards {
  margin-top: 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px;
}
.card {
  text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,0.03);
  border-radius: 18px; padding: 18px; cursor: pointer; color: inherit; font: inherit;
  transition: transform .2s, border-color .2s, background .2s;
}
.card:hover { transform: translateY(-3px); border-color: rgba(160,200,255,.35); background: rgba(120,160,255,.06); }
.card .kicker { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.card h3 { margin-top: 8px; font-size: 1.15rem; letter-spacing: -0.03em; }
.card p { margin-top: 8px; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 50;
  padding: 12px 18px; border-radius: 999px; background: rgba(20,24,36,.92); border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0,0,0,.4); animation: rise .25s ease;
}

.foot {
  max-width: 1120px; margin: 0 auto; padding: 24px 22px 40px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  color: #5a6478; font-size: 12px;
}
.foot .sep { opacity: .5; }

@media (max-width: 640px) {
  .prompt-glass { flex-direction: column; align-items: stretch; }
  .go { width: 100%; }
  .stage-meta .muted { max-width: 100%; white-space: normal; }
  .hero { padding-top: 18px; }
  h1 { font-size: 2.2rem; }
}
