:root {
  --bg: #f6f6f2; --panel: #ffffff; --ink: #15171c; --muted: #636973; --faint: #8d939c; --line: #e3e3dc;
  --soft: #efefe9; --code: #f1f1ec;
  --fast: #0c8a79; --fast-soft: #e1f3ef; --pro: #6847e0; --pro-soft: #eeeafd;
  --warn: #9c5a00; --warn-soft: #fbf0dc; --bad: #b23a2c; --good: #1c7a45;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 22, 28, .05), 0 8px 24px rgba(20, 22, 28, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e11; --panel: #15171b; --ink: #e8e9ed; --muted: #9ba1ab; --faint: #6f757f; --line: #262932;
    --soft: #1b1e24; --code: #1b1e24;
    --fast: #3cc4ad; --fast-soft: #10302a; --pro: #a08bff; --pro-soft: #241e40;
    --warn: #e2a64c; --warn-soft: #33270f; --bad: #ef7f6f; --good: #5fcf8f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: inherit; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

/* ------------------------------------------------------------------ header */
header.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; gap: 18px; min-height: 58px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.02em;
  text-decoration: none; font-size: 17px; }
.logo svg { width: 26px; height: 26px; flex: none; }
.logo .tld { color: var(--faint); font-weight: 500; }
nav { margin-left: auto; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
nav a:hover, nav a.on { color: var(--ink); }
nav form { margin: 0; }

main { padding: 32px 0 72px; }
footer.bottom { border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; padding: 22px 0 40px; }
footer.bottom .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

/* ------------------------------------------------------------------ type */
h1 { font-size: clamp(30px, 5vw, 50px); line-height: 1.06; letter-spacing: -0.035em; margin: 6px 0 16px; font-weight: 760; }
h2 { font-size: 22px; letter-spacing: -0.02em; margin: 44px 0 14px; }
h3 { font-size: 15px; margin: 0 0 6px; letter-spacing: -0.005em; }
p { margin: 0 0 12px; }
.lead { font-size: clamp(16px, 2vw, 18.5px); color: var(--muted); max-width: 680px; line-height: 1.55; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.eyebrow { font: 600 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fast { color: var(--fast); }
.pro { color: var(--pro); }
.num { font-variant-numeric: tabular-nums; }
code, pre, kbd { font-family: var(--mono); font-size: 13px; }
:not(pre) > code { background: var(--code); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--code); padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 8px 0; line-height: 1.5;
  border: 1px solid var(--line); }

/* ------------------------------------------------------------------ layout */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card.flat { box-shadow: none; }
.card h3 + p { margin-top: 2px; }
.stat { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ------------------------------------------------------------------ controls */
.btn, button { display: inline-flex; align-items: center; gap: 6px; background: var(--ink); color: var(--bg); border: 1px solid var(--ink);
  border-radius: 9px; padding: 8px 15px; font: 600 14px/1.3 var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover, button:hover { opacity: .9; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover, button.ghost:hover { border-color: var(--faint); opacity: 1; }
.btn.small, button.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 11px 20px; font-size: 15px; border-radius: 10px; }
button.danger { background: transparent; color: var(--bad); border-color: var(--line); padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { font: inherit; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--pro) 45%, transparent); outline-offset: 0; border-color: var(--pro); }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 12.5px; }
label.field { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; cursor: pointer; }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.auth { max-width: 400px; margin: 24px auto; }
.auth label { display: block; margin: 14px 0 5px; font-weight: 600; font-size: 14px; }
.auth input { width: 100%; }
.error { color: var(--bad); }
.flash { background: var(--pro-soft); border: 1px solid color-mix(in srgb, var(--pro) 25%, var(--line)); padding: 11px 15px;
  border-radius: 10px; margin-bottom: 20px; }

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ------------------------------------------------------------------ pills & badges */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 99px; font-size: 12px;
  background: var(--soft); color: var(--muted); white-space: nowrap; font-weight: 500; }
.pill.ok, .pill.done, .pill.on { background: color-mix(in srgb, var(--good) 13%, transparent); color: var(--good); }
.pill.fast { background: var(--fast-soft); color: var(--fast); }
.pill.pro, .pill.swapping { background: var(--pro-soft); color: var(--pro); }
.pill.thinking, .pill.answering, .pill.queued, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.error, .pill.cancelled, .pill.off { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.dot.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.swap-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; margin: 0 2px; border-radius: 99px;
  font: 600 11.5px/1.6 var(--mono); background: var(--pro-soft); color: var(--pro); border: 1px solid color-mix(in srgb, var(--pro) 30%, transparent);
  vertical-align: 1px; white-space: nowrap; }

/* ------------------------------------------------------------------ landing */
.hero { display: grid; gap: 34px; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; padding: 14px 0 6px; }
@media (max-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero h1 .grad { background: linear-gradient(92deg, var(--fast), var(--pro)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .cta { margin-top: 22px; }
.ticker { display: flex; gap: 0; flex-wrap: wrap; margin-top: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.ticker > div { padding: 10px 14px; border-right: 1px solid var(--line); flex: 1 1 120px; }
.ticker > div:last-child { border-right: 0; }
.ticker .k { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ticker .v { font: 650 17px/1.3 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ticker .v.flash-up { animation: flashv 1.2s; }
@keyframes flashv { 0% { color: var(--pro); } 100% { color: inherit; } }

.demo { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.demo-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.demo-head .who { margin-left: auto; display: inline-flex; gap: 6px; }
.demo-body { padding: 16px 18px 6px; min-height: 290px; font-size: 14.5px; line-height: 1.6; }
.demo-body .q { color: var(--muted); margin-bottom: 10px; font-size: 13.5px; }
.demo-body .think { font-size: 13px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; margin-bottom: 10px; white-space: pre-wrap; }
.seg-fast { color: var(--ink); }
.think .seg-fast { color: var(--muted); }
.seg-pro { color: var(--pro); }
.timeline { position: relative; height: 34px; margin: 4px 14px 12px; }
.timeline .track { position: absolute; left: 0; right: 0; top: 15px; height: 4px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.timeline .bar { position: absolute; top: 0; bottom: 0; left: 0; width: 0; }
.timeline .bar.f { background: var(--fast); }
.timeline .bar.p { background: var(--pro); }
.timeline .tick { position: absolute; top: 10px; width: 2px; height: 14px; border-radius: 2px; background: var(--faint); transform: translateX(-1px); }
.timeline .tick.hit { background: var(--pro); height: 20px; top: 7px; width: 3px; }
.timeline .lbl { position: absolute; top: -1px; font: 600 10.5px/1 var(--mono); color: var(--pro); transform: translateX(-50%); white-space: nowrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 0 14px 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.steps { counter-reset: s; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.steps .card { position: relative; padding-top: 44px; }
.steps .card::before { counter-increment: s; content: counter(s); position: absolute; top: 16px; left: 20px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--soft); color: var(--muted); font: 700 12px/22px var(--mono); text-align: center; }
.steps .card.c-fast::before { background: var(--fast-soft); color: var(--fast); }
.steps .card.c-pro::before { background: var(--pro-soft); color: var(--pro); }
.price-grid { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.price-grid > div { padding: 16px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.price-grid .p { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.price-grid .p small { font-size: 12.5px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.spark { width: 100%; height: 46px; display: block; }
.trigger-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.trigger-list .card { padding: 14px 16px; }
.trigger-list code { font-size: 12.5px; }

/* ------------------------------------------------------------------ playground */
.pg { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .pg { grid-template-columns: minmax(0, 1fr); } }
.chat { display: flex; flex-direction: column; gap: 14px; min-height: 340px; }
.msg { border-radius: 14px; padding: 13px 16px; max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--soft); max-width: 85%; white-space: pre-wrap; }
.msg.bot { background: var(--panel); border: 1px solid var(--line); }
.msg.bot .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.msg.bot .answer { white-space: pre-wrap; word-break: break-word; }
.msg.bot details.reasoning { margin: 0 0 10px; }
.msg.bot details.reasoning summary { cursor: pointer; font-size: 12.5px; color: var(--muted); list-style: none; }
.msg.bot details.reasoning summary::-webkit-details-marker { display: none; }
.msg.bot details.reasoning summary::before { content: "▸ "; }
.msg.bot details[open].reasoning summary::before { content: "▾ "; }
.msg.bot .think { white-space: pre-wrap; font-size: 13px; color: var(--muted); border-left: 2px solid var(--line);
  padding: 4px 0 4px 12px; margin-top: 8px; max-height: 300px; overflow: auto; word-break: break-word; }
.msg.bot .checks { margin-top: 10px; font: 12px/1.6 var(--mono); color: var(--faint); max-height: 160px; overflow: auto; }
.msg.bot .checks .hit { color: var(--pro); }
.msg.bot .foot { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.composer { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 28%); padding: 22px 0 6px; }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 52px; max-height: 220px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.suggest button { font-weight: 500; }
aside .card + .card { margin-top: 12px; }
aside label.field { margin-top: 10px; }
aside select, aside input:not([type=checkbox]) { width: 100%; }

/* ------------------------------------------------------------------ admin */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.trig-row textarea { min-height: 54px; font-size: 13px; }
.trig-row td { vertical-align: top; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details.req summary { cursor: pointer; }
pre.json { max-height: 420px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.bar-h { height: 6px; border-radius: 6px; background: var(--soft); overflow: hidden; }
.bar-h > i { display: block; height: 100%; background: var(--pro); }
.live-view pre { max-height: 300px; white-space: pre-wrap; word-break: break-word; }
.live-view pre.thinking { color: var(--muted); }
