:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #10141c;
  --panel-2: #0d1118;
  --line: #252b36;
  --line-soft: #1a202a;
  --text: #f2f4f7;
  --muted: #8a94a6;
  --dim: #5e6878;
  --blue: #6485ff;
  --blue-soft: #182340;
  --coral: #ff7b68;
  --amber: #f4bd62;
  --cyan: #66c7e8;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
button, a { font: inherit; }
button { letter-spacing: 0; }
a { color: inherit; text-decoration: none; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; height: 68px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--line); background: rgba(9, 11, 16, .94); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-size: 15px; }
.brand small { color: var(--dim); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 7px; }
.brand-mark { display: flex; align-items: flex-end; gap: 3px; width: 35px; height: 35px; padding: 8px; border: 1px solid #32416b; border-radius: 6px; background: #11182a; }
.brand-mark i { display: block; width: 4px; border-radius: 1px; }
.brand-mark i:nth-child(1) { height: 9px; background: var(--coral); }
.brand-mark i:nth-child(2) { height: 17px; background: var(--blue); }
.brand-mark i:nth-child(3) { height: 13px; background: var(--cyan); }
.topbar nav { display: flex; gap: 25px; color: #a6afbd; font-size: 12px; }
.topbar nav a:hover { color: var(--text); }

main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.intro { display: grid; grid-template-columns: 1.04fr .96fr; gap: 52px; align-items: center; min-height: 440px; padding: 58px 0 42px; }
.eyebrow { display: block; color: #8299ec; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; font-weight: 700; }
.intro h1 { max-width: 660px; margin: 15px 0 18px; font-size: clamp(38px, 4.3vw, 59px); line-height: 1.02; letter-spacing: 0; }
.intro-copy > p { max-width: 620px; margin: 0; color: #9aa4b5; font-size: 14px; line-height: 1.7; }
.project-stats { display: flex; gap: 28px; margin-top: 28px; color: var(--dim); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; }
.project-stats span { display: flex; align-items: baseline; gap: 7px; }
.project-stats strong { color: #dfe4ec; font-family: Inter, sans-serif; font-size: 18px; }
.intro-visual { position: relative; min-height: 270px; margin: 0; overflow: hidden; border: 1px solid #2b3240; border-radius: 7px; background: var(--panel); }
.intro-visual img { display: block; width: 100%; height: 270px; object-fit: cover; }
.intro-visual::after { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.04); content: ""; pointer-events: none; }
.intro-visual figcaption { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 5px; color: #bfc6d2; background: rgba(8,10,15,.86); font-size: 8px; }
.intro-visual figcaption i, .status i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(102,199,232,.55); }

.demo { display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 650px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); }
.controls { padding: 27px; border-right: 1px solid var(--line); background: #0d1118; }
.controls h2, .trace h2, .how h2, .json-preview h2 { margin: 9px 0 10px; font-size: 22px; letter-spacing: 0; }
.controls > p { margin: 0 0 26px; color: var(--muted); font-size: 11px; line-height: 1.6; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend, .chain-block > span { margin-bottom: 9px; color: var(--dim); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; }
.segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.segments button { min-height: 38px; border: 1px solid var(--line); border-radius: 5px; color: #7e899b; background: #121722; cursor: pointer; }
.segments button.selected { border-color: #5570c8; color: #f1f4fb; background: var(--blue-soft); }
.chain-block { margin-top: 27px; }
.chain-block ol { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; counter-reset: chain; }
.chain-block li { position: relative; display: grid; grid-template-columns: 25px 1fr; align-items: center; min-height: 46px; padding: 0 11px; border: 1px solid #242c39; border-radius: 5px; color: #c4ccd8; background: #111720; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; counter-increment: chain; }
.chain-block li::before { color: var(--coral); content: "0" counter(chain); }
.chain-block li:not(:last-child)::after { position: absolute; bottom: -8px; left: 22px; z-index: 1; width: 1px; height: 8px; background: #465779; content: ""; }
.settings-row { display: flex; justify-content: space-between; margin: 24px 0 15px; padding: 13px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); color: var(--dim); font-size: 9px; }
.settings-row strong { color: #bec7d5; }
.generate { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 46px; padding: 0 15px; border: 1px solid var(--blue); border-radius: 5px; color: #070a10; background: var(--blue); font-size: 11px; font-weight: 800; cursor: pointer; }
.generate:disabled { cursor: wait; opacity: .66; }
.generate b { font-size: 18px; }
.keyless { display: block; margin-top: 11px; color: #596476; font-size: 8px; text-align: center; }

.trace { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.trace-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 26px 29px 19px; border-bottom: 1px solid var(--line); }
.trace-head h2 { margin-bottom: 0; }
.status { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; padding: 8px 10px; border: 1px solid #2a4c5d; border-radius: 4px; color: var(--cyan); background: #0f1c23; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; }
.status.running { color: var(--amber); border-color: #5d4d2d; background: #201a10; }
.status.running i { background: var(--amber); animation: pulse .8s ease infinite; }
.messages { display: grid; align-content: start; gap: 1px; padding: 17px 29px 25px; }
.message { display: grid; grid-template-columns: 88px 1fr; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); animation: enter 220ms ease both; }
.message > span { padding-top: 2px; color: #687487; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; text-transform: uppercase; }
.message p { margin: 0; color: #c2cad6; font-size: 11px; line-height: 1.55; }
.message.tool-call p, .message.tool-result p { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; }
.message.tool-call > span { color: var(--coral); }
.message.tool-result > span { color: var(--cyan); }
.message.assistant > span { color: #879cf0; }
.message code { color: #aebcf1; }
.trace-footer { display: flex; align-items: center; justify-content: space-between; min-height: 57px; padding: 0 29px; border-top: 1px solid var(--line); color: var(--dim); font-size: 9px; }
.trace-footer button, .result-strip > button { min-height: 34px; padding: 0 12px; border: 1px solid #35415a; border-radius: 5px; color: #aeb8c7; background: #141a24; cursor: pointer; }
.trace-footer button:hover, .result-strip > button:hover { border-color: #566c9d; color: var(--text); }

.result-strip { display: grid; grid-template-columns: 190px repeat(3, 1fr) auto; align-items: center; gap: 23px; margin: 14px 0 72px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.score-summary { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 6px; }
.score-summary .eyebrow { grid-column: 1 / -1; margin-bottom: 5px; }
.score-summary strong { font-size: 28px; }
.score-summary small { color: var(--dim); font-size: 8px; }
.score { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.score span { color: #7f8999; font-size: 8px; }
.score strong { color: #dce1e9; font-size: 10px; }
.score i { grid-column: 1 / -1; height: 3px; overflow: hidden; background: #252c38; }
.score b { display: block; height: 100%; background: var(--blue); transition: width 300ms ease; }

.how { padding: 0 0 72px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-title h2 { margin-bottom: 0; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.steps > div { min-height: 180px; padding: 24px; border-right: 1px solid var(--line); }
.steps > div:last-child { border-right: 0; }
.steps span { color: var(--coral); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; }
.steps strong { display: block; margin-top: 25px; font-size: 14px; }
.steps p { margin: 9px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.json-preview { display: grid; grid-template-columns: .85fr 1.15fr; gap: 55px; align-items: center; padding: 47px; border: 1px solid var(--line); border-radius: 7px; background: #0d1118; }
.json-preview p { color: var(--muted); font-size: 11px; line-height: 1.65; }
.json-preview pre { max-height: 255px; margin: 0; overflow: auto; padding: 20px; border: 1px solid #252f3f; border-radius: 5px; color: #a9b7e8; background: #090c12; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
footer { display: flex; align-items: center; gap: 22px; width: min(1180px, calc(100% - 48px)); min-height: 100px; margin: 60px auto 0; border-top: 1px solid var(--line); color: var(--dim); font-size: 10px; }
footer span:first-child { color: var(--text); font-weight: 800; }
footer a { margin-left: auto; color: #aeb7c6; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; padding: 12px 15px; border: 1px solid #43567f; border-radius: 5px; color: #d5dbea; background: #121928; font-size: 10px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 160ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 50% { opacity: .4; } }

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 28px; }
  .intro-visual { min-height: 230px; }
  .intro-visual img { height: 230px; }
  .demo { grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-strip { grid-template-columns: repeat(3, 1fr); }
  .score-summary { grid-column: 1 / -1; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .steps > div:nth-child(2) { border-right: 0; }
  .steps > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .topbar { height: 60px; padding: 0 15px; }
  .topbar nav a:first-child { display: none; }
  main { width: min(100% - 28px, 1180px); }
  .intro { min-height: 0; padding-top: 36px; }
  .intro h1 { font-size: 39px; }
  .project-stats { gap: 13px; }
  .intro-visual, .intro-visual img { height: 205px; min-height: 205px; }
  .controls, .trace-head, .messages { padding-left: 18px; padding-right: 18px; }
  .message { grid-template-columns: 70px 1fr; gap: 9px; }
  .trace-footer { align-items: flex-start; flex-direction: column; gap: 10px; padding: 14px 18px; }
  .result-strip { grid-template-columns: 1fr; gap: 18px; }
  .score-summary { grid-column: auto; }
  .result-strip > button { width: 100%; }
  .steps { grid-template-columns: 1fr; }
  .steps > div { min-height: 145px; border-right: 0; border-bottom: 1px solid var(--line); }
  .steps > div:last-child { border-bottom: 0; }
  .json-preview { grid-template-columns: 1fr; gap: 23px; padding: 25px 20px; }
  footer { align-items: flex-start; flex-direction: column; gap: 8px; padding: 25px 0; }
  footer a { margin-left: 0; }
}
