:root {
  --bg: #08090a;
  --panel: #0f1112;
  --panel-2: #16191b;
  --text: #eeede6;
  --text-2: rgba(238, 237, 230, .66);
  --text-3: rgba(238, 237, 230, .40);
  --line: rgba(238, 237, 230, .11);
  --line-2: rgba(238, 237, 230, .2);
  --accent: #ff5b23;
  --accent-soft: rgba(255, 91, 35, .14);
  --radius: 6px;
  --gutter: clamp(16px, 4.5vw, 64px);
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2 { margin: 0; font-family: var(--mono); font-weight: 500; }

/* the 3D layer; CSS fallback underneath when WebGL is off */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: 0; transition: opacity 1.2s ease-out; pointer-events: none; }
#bg.ready { opacity: 1; }
html.no-webgl body, html:not(.js) body {
  background:
    radial-gradient(900px 500px at 75% 20%, rgba(255, 91, 35, .08), transparent 70%),
    radial-gradient(rgba(238, 237, 230, .07) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--bg);
}

/* header */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  height: 60px; padding: 0 var(--gutter);
  background: rgba(8, 9, 10, .78); border-bottom: 1px solid var(--line);
}
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 600 15px/1 var(--mono); letter-spacing: -.02em; }
.nav { display: flex; gap: 24px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--text-2); font: 400 12px/1 var(--mono); transition: color .18s ease-out; }
.nav a:hover { color: var(--text); }
.top-actions { display: flex; gap: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius);
  font: 500 13px/1 var(--mono); letter-spacing: -.01em; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: opacity .18s ease-out, border-color .18s ease-out, color .18s ease-out;
}
.btn-primary { background: var(--text); color: #0b0b0b; border: 1px solid var(--text); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { border: 1px solid var(--line-2); color: var(--text); }
.btn-secondary:hover { border-color: var(--text); }
.btn-icon { min-width: 48px; padding: 0; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 12px; }
.top-actions .btn-icon { min-height: 38px; min-width: 38px; }
.btn[aria-disabled="true"] { background: transparent; border: 1px solid var(--line-2); color: var(--text-2); cursor: default; opacity: 1; }
.link { color: var(--text-2); font: 12px var(--mono); align-self: center; padding: 0 4px; }

/* hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  align-items: end; gap: 28px 56px;
  padding: clamp(36px, 6vh, 72px) var(--gutter) clamp(28px, 4.5vh, 48px);
}
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 22px; font: 400 11px/1 var(--mono); color: var(--text); }
.status .dim { color: var(--text-3); }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); flex: none; }
.js .status .led { animation: blink 2.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: .35; } }
h1 {
  font-size: clamp(34px, 5vw, 82px); line-height: .98; letter-spacing: -.045em;
  font-weight: 600; font-stretch: 112.5%;
}
.h1-line { display: block; white-space: nowrap; }
.cursor { display: inline-block; width: .55em; height: .78em; margin-left: .12em; background: var(--accent); vertical-align: -.02em; }
.js .cursor { animation: blink 1.05s steps(1) infinite; }
.ticker { margin: 0 0 12px; font: 500 12px/1 var(--mono); color: var(--accent); }
.lede { margin: 0 0 20px; font-size: 16px; color: var(--text-2); max-width: 34em; }

.token { display: flex; gap: 8px; align-items: stretch; }
.ca {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  min-height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: rgba(15, 17, 18, .9); color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.ca:not(.is-set) { cursor: default; }
.ca-label { font: 11px var(--mono); color: var(--text-3); }
.ca-value { flex: 1; min-width: 0; font: 13px/1 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ca-copy { font: 12px var(--mono); color: var(--text-2); }
.ca:not(.is-set) .ca-copy { display: none; }
.ca.is-copied .ca-copy { color: var(--accent); }

/* the flow */
.graph {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 1.2fr) minmax(64px, .5fr) minmax(250px, .95fr) minmax(64px, .5fr) minmax(230px, .85fr);
  align-items: center;
  margin: 0 var(--gutter);
  padding: 34px 0 0;
  scroll-margin-top: 80px;
}
.wires { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 0; }
.tags { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.wire { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 6; transition: stroke .25s ease-out, stroke-width .25s ease-out; }
.js .wire { animation: hum 1.4s linear infinite; }
.wire.on { stroke: rgba(255, 91, 35, .65); stroke-width: 1.4; stroke-dasharray: 3 4; animation-duration: .5s; }
.wire.drawn { stroke-dasharray: none; }
@keyframes hum { to { stroke-dashoffset: -16; } }
.trail { fill: none; stroke-width: 2.4; stroke-linecap: round; }
.trail.req { stroke: var(--accent); }
.trail.res { stroke: var(--text); }
.halo { opacity: .2; }
.req-fill { fill: var(--accent); }
.res-fill { fill: var(--text); }
.ring { fill: none; stroke-width: 1.5; transform-box: fill-box; transform-origin: center; }
.ring.req { stroke: var(--accent); }
.ring.res { stroke: var(--text); }
.wire-label { position: absolute; font: 400 10px/1 var(--mono); color: var(--text-3); white-space: nowrap; transform: translate(-50%, -100%); }
.tag {
  position: absolute; left: 0; top: 0; padding: 4px 7px; border-radius: 4px;
  font: 500 10px/1 var(--mono); white-space: nowrap; will-change: transform;
  background: #0b0c0d; border: 1px solid rgba(255, 91, 35, .55); color: var(--text);
}
.tag.res { border-color: var(--line-2); color: var(--text-2); }
.lat { position: absolute; font: 500 10px/1 var(--mono); color: var(--accent); white-space: nowrap; pointer-events: none; }

.node {
  position: relative; z-index: 1; min-width: 0;
  background: rgba(13, 15, 16, .94); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .9);
}
.node::before { /* corner ticks */
  content: ""; position: absolute; inset: -1px; border-radius: 8px; pointer-events: none;
  background:
    linear-gradient(var(--accent), var(--accent)) left top / 10px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left top / 1px 10px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 10px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 1px 10px no-repeat;
  opacity: 0; transition: opacity .25s ease-out;
}
.node.busy::before { opacity: 1; }
.node-agent { grid-column: 1; }
.node-mcp { grid-column: 3; }
.node-fomo { grid-column: 5; }
.node-head { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.node-head .led { background: var(--text-3); box-shadow: none; transition: background .2s ease-out, box-shadow .2s ease-out; }
.node.busy .node-head .led { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.node-name { font: 600 13px/1 var(--mono); }
.node-mcp .node-name { color: var(--accent); }
.node-sub { margin-left: auto; font: 400 10px/1 var(--mono); color: var(--text-3); }
.node-foot { display: flex; gap: 14px; margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); font: 400 10px/1 var(--mono); color: var(--text-3); }
.node-foot b { font-weight: 500; color: var(--text); }
.node-foot span:last-child { margin-left: auto; }

.chat {
  height: 352px; overflow: hidden; padding: 14px;
  display: flex; flex-direction: column; justify-content: flex-start; gap: 10px;
}
.msg p { margin: 0; font-size: 14px; line-height: 1.45; }
.msg.user { align-self: flex-end; max-width: 88%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px 10px 2px 10px; padding: 9px 12px; }
.msg.bot { max-width: 94%; }
.call { display: flex; flex-direction: column; gap: 3px; font: 400 10.5px/1.45 var(--mono); color: var(--text-3); padding: 2px 0 2px 10px; border-left: 2px solid var(--line-2); transition: border-color .2s ease-out; }
.call .fn { color: var(--text-2); }
.call .ret { color: var(--text); }
.call.live { border-left-color: var(--accent); }
.call.live .fn { color: var(--text); }
.caret::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); }

.confirm { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; background: var(--panel-2); }
.confirm p { margin: 0 0 10px; font-size: 13px; }
.confirm .row { display: flex; gap: 6px; }
.confirm span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: var(--radius); font: 500 11px var(--mono); transition: opacity .18s ease-out; }
.confirm .yes { background: var(--text); color: #0b0b0b; }
.confirm .no { border: 1px solid var(--line-2); color: var(--text-2); }
.confirm .yes.pressed { opacity: .5; }
.confirm.done p { color: var(--text-2); margin: 0; }

.tools-list, .surfaces { list-style: none; margin: 0; padding: 6px; }
.tools-list li, .surfaces li {
  position: relative; padding: 0 10px; height: 30px; display: flex; align-items: center; gap: 10px;
  border-radius: 4px; border-left: 2px solid transparent;
  transition: background .2s ease-out, border-color .2s ease-out, color .2s ease-out;
}
.tools-list li { font: 400 11.5px/1 var(--mono); color: var(--text-2); }
.tools-list .ix { color: var(--text-3); font-size: 10px; }
.surfaces li { font-size: 13.5px; color: var(--text-2); }
.surfaces li::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: var(--text-3); transition: background .2s ease-out; }
.tools-list li.on, .surfaces li.on { background: var(--accent-soft); border-left-color: var(--accent); color: var(--text); }
.tools-list li.on .ix { color: var(--accent); }
.surfaces li.on::before { background: var(--accent); }
.tools-list li.reg { color: var(--text); }

.log {
  list-style: none; margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); height: 76px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  font: 400 10px/1.6 var(--mono); color: var(--text-2);
}
.log li { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log li:last-child { color: var(--text); }
.log .o { color: var(--accent); }

.resp {
  margin: 0; padding: 10px 14px; border-top: 1px solid var(--line);
  font: 400 10.5px/1.5 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-all; min-height: 62px;
}

.graph-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 0 0; }
.scenes { display: flex; gap: 4px; }
.scenes button {
  min-height: 38px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid transparent; background: none; color: var(--text-2);
  font: 500 12px/1 var(--mono); cursor: pointer; transition: color .18s ease-out, border-color .18s ease-out;
}
.scenes button:hover { color: var(--text); }
.scenes button[aria-pressed="true"] { border-color: var(--line-2); background: rgba(15, 17, 18, .9); color: var(--text); }
.sim { margin: 0; font: 400 11px var(--mono); color: var(--text-3); }

/* scroll beats over the 3D layers */
.layers { padding: 10vh var(--gutter) 0; }
.beat { min-height: 78svh; display: flex; flex-direction: column; justify-content: center; max-width: 820px; }
.kicker { margin: 0 0 14px; font: 400 11px/1 var(--mono); color: var(--accent); }
.beat-line { margin: 0; font: 500 clamp(28px, 4.6vw, 64px)/1.05 var(--mono); letter-spacing: -.045em; font-stretch: 100%; text-wrap: balance; }

/* sections */
.tools, .connect { position: relative; padding: clamp(72px, 10vw, 128px) var(--gutter) 0; scroll-margin-top: 60px; }
.section-head { max-width: 560px; }
h2 { font-size: clamp(28px, 3.6vw, 48px); line-height: 1.02; letter-spacing: -.045em; margin-bottom: 16px; font-weight: 500; }
.section-head > p:not(.kicker) { margin: 0; color: var(--text-2); font-size: 16px; }

table { width: 100%; border-collapse: collapse; margin-top: 36px; background: rgba(8, 9, 10, .82); }
th { text-align: left; font: 400 10px/1 var(--mono); color: var(--text-3); padding: 0 16px 12px 0; }
td { padding: 16px 16px 16px 0; border-top: 1px solid var(--line); vertical-align: top; font-size: 15px; }
td.n { font: 400 11px/1.9 var(--mono); color: var(--text-3); width: 48px; }
td.t { font: 500 12.5px/1.75 var(--mono); white-space: nowrap; }
td.s { font: 400 11px/1.9 var(--mono); white-space: nowrap; color: var(--text); }
td.s::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 1px; margin-right: 8px; vertical-align: 0; background: var(--accent); }
td.s.wait { color: var(--text-3); }
td.s.wait::before { background: none; box-shadow: inset 0 0 0 1px var(--text-3); }

.connect { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px 56px; align-items: start; }
.rules { margin: 28px 0 0; padding: 0; list-style: none; }
.rules li { display: flex; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rules .ix, .n { font-family: var(--mono); }
.rules .ix { font-size: 11px; color: var(--text-3); padding-top: 3px; }
.code-wrap { background: rgba(13, 15, 16, .94); border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); font: 400 11px var(--mono); color: var(--text-3); }
.copy-code { min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: none; color: var(--text); font: 500 11px var(--mono); cursor: pointer; }
.copy-code:hover { border-color: var(--text); }
.code { margin: 0; padding: 18px 20px; font: 400 12px/1.75 var(--mono); color: var(--text-3); overflow-x: auto; }
.code .k { color: var(--text); }
.code .v { color: var(--accent); }

.foot { padding: clamp(80px, 12vw, 140px) var(--gutter) 40px; }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line); }
.mark-small { font: 600 13px var(--mono); }
.foot-links { display: flex; gap: 20px; }
.foot-links a { font: 400 12px var(--mono); color: var(--text-2); text-decoration: none; }
.foot-links a:hover { color: var(--text); }
.foot p { margin: 16px 0 0; font: 400 11px/1.6 var(--mono); color: var(--text-3); }

/* reveals */
.js .hero > *, .js .graph .node { animation: rise .7s cubic-bezier(.2, .7, .2, 1) backwards; }
.js .hero-side { animation-delay: .1s; }
.js .node-agent { animation-delay: .18s; }
.js .node-mcp { animation-delay: .26s; }
.js .node-fomo { animation-delay: .34s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease-out, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

/* tablet: stack the flow */
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; }
  .graph { grid-template-columns: minmax(0, 1fr); row-gap: 64px; max-width: 620px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
  .node-agent, .node-mcp, .node-fomo { grid-column: 1; }
  .chat { height: 300px; }
  .tools-list, .surfaces { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
  .graph-foot { padding-top: 0; margin-top: -36px; }
  .connect { grid-template-columns: 1fr; }
  .wire-label { transform: translate(14px, -50%); }
}

/* phone */
@media (max-width: 760px) {
  .top { gap: 12px; height: 56px; padding-right: 10px; }
  .nav { display: none; }
  .top-actions { margin-left: auto; }
  .top-actions .btn-icon { min-height: 44px; min-width: 44px; }
  .hide-phone { display: none; }
  .hero { padding-top: 28px; gap: 22px; }
  .status { margin-bottom: 16px; }
  h1 { font-size: clamp(30px, 9.6vw, 48px); font-stretch: 100%; }
  .lede { font-size: 15px; margin-bottom: 0; }
  .token {
    position: fixed; z-index: 20; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px; gap: 6px; background: rgba(8, 9, 10, .96); border: 1px solid var(--line-2); border-radius: 10px;
  }
  .token .ca, .token .btn { min-height: 46px; }
  .token .chart { display: none; }
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .graph { row-gap: 56px; padding-top: 20px; }
  .graph-foot { margin-top: -28px; flex-direction: column; align-items: stretch; }
  .scenes { width: 100%; }
  .scenes button { flex: 1; padding: 0 6px; min-height: 42px; }
  .chat { height: 286px; }
  .log { height: 62px; }
  .tools-list li, .surfaces li { height: 32px; }
  .beat { min-height: 64svh; }
  table, thead, tbody, tr, td, th { display: block; }
  thead { display: none; }
  tr { border-top: 1px solid var(--line); padding: 14px 0; display: grid; grid-template-columns: auto 1fr auto; gap: 6px 12px; }
  td { border: 0; padding: 0; }
  td.n { width: auto; grid-column: 1; grid-row: 1; }
  td.t { grid-column: 2; grid-row: 1; }
  td.s { grid-column: 3; grid-row: 1; }
  td:nth-child(3) { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; }
  .code { font-size: 11px; padding: 16px; }
  .foot-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
