:root {
  --ink: #0d0b1f;
  --ink-2: #16132e;
  --ink-3: #221d44;
  --line: rgba(217, 197, 110, .18);
  --text: #ece8f6;
  --muted: #a49fbd;
  --gold: #d9c56e;
  --violet: #9b6fd6;
  --mint: #80da9c;
  --amber: #f2b33d;
  --red: #ff6b6b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--ink); color: var(--text); font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-decoration-color: rgba(217, 197, 110, .4); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold); }
code { font: .88em var(--mono); color: var(--gold); }
button { font: inherit; color: inherit; }

/* header */
.top { position: fixed; inset: 0 0 auto; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 14px clamp(16px, 3vw, 36px); background: linear-gradient(var(--ink), rgba(13, 11, 31, 0)); pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font: 600 20px var(--serif); letter-spacing: .02em; }
.brand svg { width: 28px; height: 28px; }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 15px; }
.top nav { display: flex; gap: clamp(12px, 2.5vw, 28px); }
.top nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.top nav a:hover { color: var(--text); }

/* realm */
.realm { position: relative; height: 100vh; min-height: 640px; overflow: hidden; background: radial-gradient(ellipse at 60% 45%, #2a2160 0%, #120f2a 55%, var(--ink) 100%); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#scene:active { cursor: grabbing; }
.realm::after { content: ""; position: absolute; inset: 0 auto 0 0; width: min(560px, 48%); background: linear-gradient(90deg, rgba(13, 11, 31, .78), rgba(13, 11, 31, .45) 60%, rgba(13, 11, 31, 0)); pointer-events: none; z-index: 3; transition: opacity .5s; }
.focused::after { opacity: .7; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); font-size: 14px; z-index: 5; transition: opacity .6s; pointer-events: none; }
.loading.done { opacity: 0; }
.sigil { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--gold); border-right-color: var(--violet); animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.intro { position: absolute; z-index: 10; left: clamp(16px, 4vw, 56px); top: clamp(84px, 14vh, 140px); max-width: 440px; pointer-events: none; }
.intro > * { pointer-events: auto; }
.eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .18em; font-size: 12px; color: var(--gold); }
h1 { margin: 0 0 16px; font: 500 clamp(34px, 4.4vw, 54px)/1.05 var(--serif); letter-spacing: -.01em; text-wrap: balance; }
h1 span { color: var(--gold); font-style: italic; }
.lede { margin: 0 0 22px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line); background: rgba(34, 29, 68, .7); cursor: pointer; backdrop-filter: blur(6px); }
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn.primary { background: linear-gradient(135deg, #7b3fb4, #4b2a86); border-color: rgba(217, 197, 110, .5); box-shadow: 0 0 0 0 rgba(155, 111, 214, .5); }
.btn.primary:hover { box-shadow: 0 0 24px 2px rgba(155, 111, 214, .45); }
.btn:disabled { opacity: .55; cursor: progress; }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--violet); width: 16px; height: 16px; }
.runlog { display: inline-block; margin: 16px 0 0; padding: 5px 10px; border-radius: 8px; background: rgba(13, 11, 31, .72); min-height: 1.6em; font: 13px var(--mono); color: var(--muted); }
.runlog b { color: var(--text); font-weight: 600; }
.runlog .ok { color: var(--mint); }
.runlog .bad { color: var(--red); }

/* stage card */
.card { position: absolute; z-index: 12; right: clamp(12px, 3vw, 40px); top: 84px; width: min(370px, calc(100% - 24px)); max-height: calc(100% - 200px); overflow: auto; padding: 22px 22px 18px; border-radius: 16px; border: 1px solid var(--line); background: rgba(22, 19, 46, .86); backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0, 0, 0, .45); animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.card .close { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.card .close:hover { background: var(--ink-3); color: var(--text); }
.step { margin: 0; font: 12px var(--mono); color: var(--gold); letter-spacing: .08em; }
.card h2 { margin: 4px 0 8px; font: 500 28px/1.15 var(--serif); }
.card > p { color: var(--muted); font-size: 14.5px; margin: 0 0 14px; }
.remix { display: grid; gap: 10px; margin-bottom: 12px; }
.remix label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--ink-2); font-size: 12.5px; color: var(--text); cursor: pointer; }
.chips button:hover { border-color: rgba(217, 197, 110, .5); }
.chips button[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.call { margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; background: #0a0818; border: 1px solid rgba(255, 255, 255, .06); overflow-x: auto; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.call code { color: #cfc8ea; }
.models { margin: 0; font-size: 12.5px; color: var(--muted); }

/* stage rail */
.rail { position: absolute; z-index: 10; left: 50%; bottom: clamp(14px, 3vh, 28px); transform: translateX(-50%); display: flex; gap: 6px; margin: 0; padding: 6px; list-style: none; border-radius: 999px; border: 1px solid var(--line); background: rgba(13, 11, 31, .72); backdrop-filter: blur(8px); max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail button { display: flex; align-items: center; gap: 7px; padding: 7px 13px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.rail button:hover { color: var(--text); background: var(--ink-3); }
.rail button[aria-current="true"] { color: var(--ink); background: var(--gold); }
.rail i { width: 8px; height: 8px; border-radius: 50%; background: #4a4670; transition: background .3s, box-shadow .3s; }
.rail i.running { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.rail i.passed { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.rail i.failed { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* bands */
.band { padding: clamp(64px, 10vw, 110px) 0; border-top: 1px solid var(--line); }
.band.alt { background: var(--ink-2); }
.wrap { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.band h2 { margin: 0 0 28px; font: 500 clamp(28px, 3.4vw, 40px)/1.15 var(--serif); max-width: 760px; text-wrap: balance; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; margin-bottom: 36px; }
.cols article { padding: 22px; border-radius: 14px; border: 1px solid var(--line); background: var(--ink-2); }
.cols h3 { margin: 0 0 8px; font: 500 20px var(--serif); color: var(--gold); }
.cols p { margin: 0; color: var(--muted); font-size: 15px; }
.snippet { margin: 0; padding: 20px 22px; border-radius: 14px; background: #0a0818; border: 1px solid var(--line); overflow-x: auto; font: 13.5px/1.65 var(--mono); color: #cfc8ea; }
.snippet .k { color: #c792ea; }
.snippet .s { color: var(--mint); }
.snippet .c { color: #6f6a90; font-style: italic; }
.sub { margin: -14px 0 28px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.grid a { display: block; height: 100%; padding: 10px 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink); text-decoration: none; color: var(--text); transition: border-color .2s, transform .2s; }
.grid a:hover { border-color: rgba(217, 197, 110, .55); transform: translateY(-2px); }
.grid img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #e9edf3; }
.grid strong { display: block; margin-top: 9px; font-size: 14px; font-weight: 600; }
.grid span { display: block; font-size: 12px; color: var(--muted); }

footer { padding: 30px 20px 40px; text-align: center; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .top nav { display: none; }
  .intro { top: 76px; right: 16px; max-width: none; }
  .lede, .intro .eyebrow { display: none; }
  .focused .runlog:not(:has(span)) { display: none; }
  .realm::after { width: 100%; height: 300px; background: linear-gradient(rgba(13, 11, 31, .8), rgba(13, 11, 31, 0)); }
  h1 { font-size: 32px; }
  .card { top: auto; bottom: 74px; max-height: 46vh; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sigil { animation-duration: 3s; }
}

/* station labels */
.label { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(13, 11, 31, .78); color: var(--text); font: 12.5px var(--sans); cursor: pointer; white-space: nowrap; backdrop-filter: blur(4px); transition: border-color .3s, box-shadow .3s; }
.label b { font: 600 11px var(--mono); color: var(--gold); }
.label:hover { border-color: var(--gold); }
.label.merlin { font: 600 14px var(--serif); padding: 5px 13px; }
.label[data-status="running"] { border-color: var(--amber); box-shadow: 0 0 14px rgba(242, 179, 61, .45); }
.label[data-status="passed"] { border-color: var(--mint); }
.label[data-status="failed"] { border-color: var(--red); box-shadow: 0 0 14px rgba(255, 107, 107, .45); }

/* when a stage is open, the headline steps aside */
.focused .intro .eyebrow, .focused .intro h1, .focused .intro .lede { display: none; }
.focused .intro { top: 84px; }
