@font-face {
  font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}
:root {
  --bg: #ffffff; --surface: #ffffff; --ink: #0b0d12; --muted: #5a606b; --line: #e3e6ea;
  --teal: #0b7a6f; --teal-soft: #e3f4f1; --btn: #0b0d12; --btn-ink: #ffffff; --mark-ink: #ffffff;
  --brass: #8a5a00; --brass-soft: #fdf3dc; --brass-rule: #c48a1a;
  --red: #b3261e; --red-soft: #fdecea;
  --code: #f4f6f8; --focus: #2f6bff;
  --sans: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: var(--sans);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(11, 13, 18, .05), 0 6px 20px rgba(11, 13, 18, .05);
  --hero-grad: linear-gradient(120deg, #d3f1ec 0%, #c9d8ff 52%, #b9a9ff 100%);
  --term: #0d1117; --term-ink: #d6deeb; --term-dim: #7d8794; --term-k: #ff9e64; --term-f: #7dcfff; --term-n: #e0af68; --term-c: #7a8aa0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0c10; --surface: #12151b; --ink: #eef1f5; --muted: #9aa3b0; --line: #262b34;
    --teal: #4fd1c1; --teal-soft: #11302d; --btn: #ffffff; --btn-ink: #0b0d12; --mark-ink: #0b0d12;
    --brass: #e8b75d; --brass-soft: #2e2410; --brass-rule: #c99a3f;
    --red: #ff9a92; --red-soft: #3a1916;
    --code: #0e1116; --focus: #86a8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --hero-grad: linear-gradient(120deg, #123a37 0%, #1a2a52 55%, #2b2260 100%);
    --term: #070a0e;
  }
}
* { 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); font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, textarea { font-family: inherit; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.fine { font-size: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.ico { flex: none; vertical-align: -2px; }
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; color: var(--ink); }
.wordmark span { color: var(--ink); }
.mark { color: var(--ink); }

/* buttons + inputs */
.btn {
  min-height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn:hover:not(:disabled) { border-color: var(--teal); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.primary:hover:not(:disabled) { filter: none; background: #2a2f3a; border-color: #2a2f3a; }
@media (prefers-color-scheme: dark) { .btn.primary:hover:not(:disabled) { background: #d9dee6; border-color: #d9dee6; } }
.btn.block { width: 100%; min-height: 44px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
input[type=text]:focus, textarea:focus { border-color: var(--ink); }
.error { color: var(--red); font-size: .88rem; }
.error:empty { display: none; }

/* ---------- token gate ---------- */
.gate { min-height: 100vh; background: var(--bg); }
.gate[hidden] { display: none !important; }
.gate-top { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 12px clamp(20px, 4vw, 40px); }
.gate-tag { font-size: .82rem; font-weight: 550; color: var(--muted); padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; }
.gate-hero { max-width: 980px; margin: 0 auto; padding: clamp(12px, 3vh, 36px) clamp(20px, 4vw, 40px) clamp(20px, 3vh, 32px); text-align: center; display: grid; justify-items: center; gap: 12px; }
.eyebrow { font-size: .82rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
.gate-hero h1 { font: 700 clamp(2rem, 4.4vw, 3.4rem)/1.06 var(--sans); letter-spacing: -.035em; max-width: 24ch; }
.lede { font-size: clamp(1rem, 1.4vw, 1.12rem); line-height: 1.5; max-width: 64ch; color: var(--muted); }
#token-form { width: 100%; max-width: 520px; margin-top: 10px; display: grid; gap: 10px; text-align: left; }
.token-row { display: flex; gap: 8px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.token-row:focus-within { border-color: var(--ink); }
.token-row input { border: 0; background: transparent; min-height: 44px; font: 1rem var(--mono); letter-spacing: .06em; padding: 0 12px; }
.token-row input::placeholder { font-family: var(--sans); letter-spacing: 0; color: var(--muted); }
.token-row input:focus { outline: none; }
.token-row .btn { min-height: 44px; padding: 0 26px; border-radius: 10px; white-space: nowrap; }
#token-form .error, #token-form .fine { text-align: center; }

.gate-show { background: var(--hero-grad); padding: clamp(16px, 3vh, 32px) clamp(16px, 4vw, 40px) clamp(32px, 6vw, 72px); }
.show-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.show-grid .flow { margin: 0; max-width: none; background: var(--surface); border-radius: 18px; padding: 20px; box-shadow: 0 10px 40px rgba(30, 20, 90, .14); }
.show-grid .flow-stage { border: 0; padding: 4px 0 0; background: transparent; }
.term { background: var(--term); color: var(--term-ink); border-radius: 18px; overflow: hidden; box-shadow: 0 10px 40px rgba(10, 10, 40, .35); min-width: 0; }
.term-bar { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #3a424f; }
.term-bar span { margin-left: 10px; font-size: .76rem; color: var(--term-dim); }
.term-body { margin: 0; padding: 16px 18px 20px; font: .8rem/1.7 var(--mono); white-space: pre; overflow-x: auto; }
.term .c { color: var(--term-c); } .term .k { color: var(--term-k); } .term .f { color: var(--term-f); } .term .n { color: var(--term-n); } .term .d { color: var(--term-dim); }

/* ---------- app shell ---------- */
.top {
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 3vw, 32px); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand .sub { color: var(--muted); font-size: .88rem; padding-left: 14px; border-left: 1px solid var(--line); }
.top-right { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hint { font: .82rem var(--mono); color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 5px 12px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; background: var(--teal-soft); color: var(--teal);
}
.chip .meter { width: 44px; height: 6px; border-radius: 3px; background: rgba(127, 127, 127, .28); overflow: hidden; }
.chip .meter i { display: block; height: 100%; background: currentColor; border-radius: 3px; }
.chip .exp { font-weight: 450; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); }
.chip.amber { background: var(--brass-soft); color: var(--brass); }
.chip.red { background: var(--red-soft); color: var(--red); }

.shell {
  max-width: 1180px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 64px;
  display: grid; grid-template-columns: 280px minmax(0, 1fr); column-gap: 32px; row-gap: 16px;
  grid-template-areas: "rail ask" "rail feed"; align-items: start;
}
.ask { grid-area: ask; min-width: 0; }
.feed { grid-area: feed; min-width: 0; }
.rail { grid-area: rail; position: sticky; top: 84px; min-width: 0; }
.rail h2 { font-size: .95rem; margin-bottom: 10px; }
.ex-group { margin-bottom: 18px; }
.ex-group h3 { margin: 0 0 6px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.ex-list { display: grid; gap: 6px; }
.ex {
  min-height: 40px; padding: 8px 12px; text-align: left; font: inherit; font-size: .88rem; line-height: 1.35;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.ex:hover { border-color: var(--teal); background: var(--teal-soft); }

/* composer */
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; }
.composer:focus-within { border-color: var(--ink); }
.composer textarea { border: 0; padding: 4px 6px; resize: vertical; min-height: 76px; font-size: 1rem; background: transparent; }
.composer textarea:focus { outline: none; }
.composer-foot { display: flex; align-items: center; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; flex-wrap: wrap; }
.composer-foot .note-warn { flex: 1; color: var(--brass); font-weight: 550; min-width: 0; }
.composer-foot #kbd-hint { margin-right: auto; }
.composer-foot .note-warn:not(:empty) ~ #kbd-hint { display: none; }

/* feed */
.banner-error { color: var(--red); background: var(--red-soft); border-radius: 8px; padding: 10px 14px; font-weight: 550; }
.banner-error:empty { display: none; }
.empty { padding: 8px 4px; max-width: 62ch; }
.empty h2 { font: 650 1.4rem/1.2 var(--sans); letter-spacing: -.02em; margin-bottom: 14px; }
.steps-intro { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.steps-intro li { counter-increment: s; display: flex; gap: 12px; align-items: baseline; }
.steps-intro li::before {
  content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--teal-soft); color: var(--teal); font-weight: 700; font-size: .8rem;
}
.empty p { color: var(--muted); }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px 18px 26px; margin-bottom: 16px; min-width: 0; box-shadow: var(--shadow); overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--muted); }
.card.cert::before { background: var(--teal); }
.card.gen::before { background: repeating-linear-gradient(to bottom, var(--brass-rule) 0 8px, transparent 8px 12px); }
.card.failed { background: var(--red-soft); border-color: var(--red); }
.card.failed::before { background: var(--red); }
.card .q { color: var(--muted); font-size: .85rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.card .answer { font: 500 1.08rem/1.6 var(--sans); letter-spacing: -.005em; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 12px; max-width: 64ch; }
.card .errtext { color: var(--red); font-weight: 650; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 10px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 550;
  background: var(--code); border: 1px solid var(--line); color: var(--muted);
}
.badge.cert { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.badge.gen { background: var(--brass-soft); color: var(--brass); border-color: transparent; }
.badge.fail { background: var(--red-soft); color: var(--red); border-color: transparent; }
.caveats { margin: 0 0 12px; padding: 0; list-style: none; display: grid; gap: 6px; }
.caveats li { display: flex; gap: 8px; align-items: flex-start; color: var(--brass); background: var(--brass-soft); padding: 8px 12px; border-radius: 8px; font-size: .9rem; overflow-wrap: anywhere; }
.caveats .ico { margin-top: 3px; }

.table-wrap { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { padding: 7px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--code) 55%, transparent); }
tbody tr:hover td { background: var(--teal-soft); }
th { position: sticky; top: 0; background: var(--code); text-align: left; z-index: 1; font-weight: 650; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: .84rem; margin-bottom: 10px; }

details { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; background: var(--surface); }
details > summary { min-height: 42px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
details[open] > summary::before { transform: rotate(45deg); }
details[open] { padding-bottom: 12px; }
.sql-head { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.sql-head .btn { min-height: 32px; padding: 0 12px; font-size: .82rem; }
pre.sql { margin: 0; padding: 14px 16px; background: var(--term); color: var(--term-ink); border-radius: 10px; overflow: auto; font: .82rem/1.6 var(--mono); white-space: pre; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.tag { padding: 1px 8px; border-radius: 4px; background: var(--teal-soft); color: var(--teal); font: .76rem var(--mono); }

.steps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: grid; gap: 3px; padding-left: 14px; border-left: 2px solid var(--line); font-size: .86rem; overflow-wrap: anywhere; }
.steps .head { display: flex; justify-content: space-between; gap: 12px; }
.steps .node { font-weight: 650; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; display: inline; }
.steps .node::before, .steps .node::after { content: none; }
.steps .ms { color: var(--muted); font-variant-numeric: tabular-nums; }
.steps .track { height: 4px; border-radius: 2px; background: var(--code); overflow: hidden; }
.steps .track i { display: block; height: 100%; background: var(--teal); border-radius: 2px; }
.steps .det { color: var(--muted); font: .78rem/1.4 var(--mono); }
.usage { color: var(--muted); font-size: .82rem; margin-top: 12px; }
.cites-title { margin-top: 12px; font-weight: 600; font-size: .86rem; }
.cites { margin: 4px 0 0; padding-left: 1.2rem; font-size: .88rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.followups { margin-top: 12px; }
.chip-btn {
  min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-size: .86rem; cursor: pointer; text-align: left; max-width: 100%;
}
.chip-btn:hover { border-color: var(--teal); background: var(--teal-soft); }

/* loading skeleton */
.loading { padding-left: 24px; }
.loading #loading-text { color: var(--muted); font-weight: 550; margin-bottom: 14px; }
.sk { height: 14px; border-radius: 6px; margin-bottom: 10px; background: linear-gradient(90deg, var(--code) 25%, var(--line) 50%, var(--code) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.sk.w80 { width: 80%; } .sk.w60 { width: 60%; } .sk.block { height: 72px; margin-bottom: 0; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } details > summary::before { transition: none; } }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .show-grid { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "ask" "rail" "feed"; }
  .rail { position: static; }
  .ex-list { display: flex; flex-wrap: wrap; }
  .brand .sub { border-left: 0; padding-left: 0; width: 100%; }
}
@media (max-width: 520px) {
  .btn, .ex, details > summary { min-height: 44px; }
  .chip-btn { min-height: 40px; }
  .top-right { width: 100%; }
  .card { padding: 16px 14px 14px 20px; }
  .composer-foot #kbd-hint { display: none; }
}

/* ---------- grounding animation (sign-in screen) ---------- */
.flow { --h: 80px; --g: 30px; --cg: 14px; margin: 10px 0 0; max-width: 700px; }
.flow-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.flow-tab {
  min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .82rem; font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.flow-tab b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--code); color: var(--muted); font-size: .72rem; }
.flow-tab:hover { border-color: var(--teal); color: var(--ink); }
.flow[data-step="1"] .flow-tab[data-step="1"], .flow[data-step="2"] .flow-tab[data-step="2"], .flow[data-step="3"] .flow-tab[data-step="3"] {
  background: var(--btn); border-color: var(--btn); color: var(--btn-ink);
}
.flow[data-step="1"] .flow-tab[data-step="1"] b, .flow[data-step="2"] .flow-tab[data-step="2"] b, .flow[data-step="3"] .flow-tab[data-step="3"] b {
  background: var(--btn-ink); color: var(--btn);
}
.flow-stage { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 18px 18px; }
.lane { position: relative; }
.lane-alt { margin-top: var(--g); }
.nodes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: var(--cg); }
.node {
  position: relative; z-index: 1; min-height: var(--h); padding: 9px 10px; display: flex; flex-direction: column; gap: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.n-t { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: .82rem; line-height: 1.2; }
.n-t .ico { color: var(--muted); }
.n-s { font-size: .72rem; line-height: 1.3; color: var(--muted); }
.node.cert { background: var(--teal-soft); border-color: var(--teal); }
.node.cert .n-t, .node.cert .n-t .ico { color: var(--teal); }
.node.gen { background: var(--brass-soft); border: 1px dashed var(--brass-rule); }
.node.gen .n-t, .node.gen .n-t .ico { color: var(--brass); }

/* line + travelling packet behind the nodes */
.base { position: absolute; z-index: 0; left: 10%; right: 10%; top: calc(var(--h) / 2 - 1px); height: 2px; background: var(--teal); transform-origin: left; }
.packet { position: absolute; z-index: 0; left: 10%; top: calc(var(--h) / 2 - 5px); width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 25%, transparent); opacity: 0; }
.flow.run .base { animation: draw .9s ease-out both; }
.flow.run .packet { animation: travel 4.6s linear .9s infinite; }
.flow.run .lane-main .node { animation: lit 4.6s ease-out .9s infinite both; }
.flow.run .lane-main .node:nth-child(2) { animation-delay: 1.7s; }
.flow.run .lane-main .node:nth-child(3) { animation-delay: 2.5s; }
.flow.run .lane-main .node:nth-child(4) { animation-delay: 3.3s; }
.flow.run .lane-main .node:nth-child(5) { animation-delay: 4.1s; }
@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes travel { 0% { left: 10%; opacity: 0; } 3% { opacity: 1; } 70% { left: 90%; opacity: 1; } 75%, 100% { left: 90%; opacity: 0; } }
@keyframes lit { 0% { box-shadow: 0 0 0 0 transparent; } 6% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 38%, transparent); } 22%, 100% { box-shadow: 0 0 0 0 transparent; } }

/* stage 2: fallback lane (model + guard) */
.alt-label { grid-column: 1; align-self: center; text-align: right; font-size: .72rem; line-height: 1.3; color: var(--brass); font-weight: 600; padding-right: 4px; }
.node.m { grid-column: 2; }
.node.g { grid-column: 3; }
.node.m::before { content: ""; position: absolute; left: 50%; bottom: 100%; height: var(--g); border-left: 2px dashed var(--brass-rule); }
.node.m::after { content: ""; position: absolute; left: calc(50% - 4px); bottom: calc(100% + var(--g) - 18px); }
.elbow { position: absolute; left: 100%; width: calc(var(--cg) + 50%); bottom: 50%; height: calc(var(--h) / 2 + var(--g)); border-bottom: 2px dashed var(--brass-rule); border-right: 2px dashed var(--brass-rule); border-radius: 0 0 10px 0; pointer-events: none; }
.s2, .s3 { display: none; }
.flow[data-step="2"] .s2, .flow[data-step="3"] .s2, .flow[data-step="3"] .s3 { display: block; animation: rise .5s ease both; }
.flow[data-step="2"] .lane-alt, .flow[data-step="3"] .lane-alt { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flow.run[data-step="2"] .lane-alt .node.m, .flow.run[data-step="3"] .lane-alt .node.m { animation: litb 4.6s ease-out 1.7s infinite both; }
.flow.run[data-step="2"] .lane-alt .node.g, .flow.run[data-step="3"] .lane-alt .node.g { animation: litb 4.6s ease-out 2.5s infinite both; }
@keyframes litb { 0% { box-shadow: 0 0 0 0 transparent; } 6% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brass-rule) 40%, transparent); } 22%, 100% { box-shadow: 0 0 0 0 transparent; } }

/* stage 3: safeguards band */
.flow[data-step="3"] .band { display: flex; }
.band { margin-top: 18px; padding: 10px 12px; border: 1.5px dashed var(--teal); border-radius: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: color-mix(in srgb, var(--teal) 7%, transparent); }
.band-label { font-size: .78rem; font-weight: 650; color: var(--teal); margin-right: 4px; }
.pill { padding: 3px 12px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface); border: 1px solid var(--teal); color: var(--teal); }
#flow-cap { margin-top: 14px; min-height: 4.4em; font-size: .92rem; line-height: 1.5; color: var(--muted); max-width: 60ch; }

@media (prefers-reduced-motion: reduce) {
  .flow.run .base, .flow.run .packet, .flow.run .node, .flow.run .lane-alt .node { animation: none !important; }
  .base { transform: none; }
  .s2, .s3 { animation: none !important; }
}

@media (max-width: 860px) {
  .flow { --g: 20px; }
  .nodes { grid-template-columns: minmax(0, 1fr); row-gap: var(--g); }
  .base, .packet, .elbow, .node.m::before { display: none; }
  .node { min-height: 0; }
  .node.m, .node.g { grid-column: auto; }
  .alt-label { grid-column: auto; text-align: left; padding: 0; }
  .nodes .node + .node::before { content: ""; position: absolute; left: 22px; bottom: 100%; height: var(--g); border-left: 2px solid var(--teal); }
  .lane-alt .node.g::before { border-left: 2px dashed var(--brass-rule); }
  .lane-alt .node.m::before { display: block; border-left: 0; height: 0; }
  .flow.run .lane-main .node { animation-name: lit; }
}

@media (max-width: 520px) {
  .token-row { flex-direction: column; }
  .token-row .btn { width: 100%; }
  .show-grid .flow { padding: 14px; }
}

/* ---------- tabs and extra panes ---------- */
[hidden] { display: none !important; }
.tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg); overflow-x: auto; }
.tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 14px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.tab:focus-visible, .chip-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pane { max-width: 1100px; margin: 0 auto; padding: 28px 24px 72px; }
.pane h2 { font-size: 1.5rem; letter-spacing: -.02em; margin: 0 0 8px; }
.pane h3 { font-size: 1.05rem; margin: 32px 0 10px; }
.pane .lead { max-width: 70ch; color: var(--muted); font-size: 1.02rem; margin: 0 0 8px; }
.arch { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.arch li { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.arch li b { font-size: .95rem; }
.arch li span { color: var(--muted); font-size: .9rem; }
.arch li.cert { border-color: var(--teal); background: var(--teal-soft); }
.arch li.gen { border-style: dashed; border-color: var(--brass-rule); background: var(--brass-soft); }
.usp { padding-left: 20px; margin: 0; }
.usp li { margin: 6px 0; max-width: 75ch; }
.erd { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.erd svg { display: block; width: 100%; min-width: 760px; height: auto; }
.erd .box { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.erd .head { fill: var(--code); }
.erd .tname { fill: var(--ink); font: 700 13px var(--sans); }
.erd .cname { fill: var(--ink); font: 11.5px var(--mono); }
.erd .ctype { fill: var(--muted); font: 10.5px var(--mono); }
.erd .key { fill: var(--teal); font: 700 9.5px var(--sans); }
.erd .fkey { fill: var(--brass); font: 700 9.5px var(--sans); }
.erd .edge { fill: none; stroke: var(--teal); stroke-width: 1.5; opacity: .75; }
.erd .dot { fill: var(--teal); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.chip-btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip-btn small { color: var(--muted); margin-left: 6px; }
.chip-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-btn.on small { color: inherit; opacity: .75; }
.tablewrap { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 12px; }
.dtable { border-collapse: collapse; width: 100%; font: 12.5px var(--mono); }
.dtable th, .dtable td { padding: 7px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.dtable th { position: sticky; top: 0; background: var(--code); font-weight: 650; }
.dtable td.num { text-align: right; }

/* ---------- metrics and policies ---------- */
.search { margin: 10px 0 4px; max-width: 420px; }
.mgroup { margin: 28px 0 8px; font-size: 1rem; }
.mgroup small { color: var(--muted); font-weight: 500; margin-left: 8px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mcard { border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 12px; padding: 14px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.mcard h4 { margin: 0; font-size: 1rem; }
.mcard p { margin: 0; color: var(--muted); font-size: .9rem; }
.mcard .tag { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--teal); background: var(--teal-soft); border-radius: 999px; padding: 2px 10px; }
.mcard .syn { font-size: .82rem; color: var(--muted); }
.mcard details { font-size: .85rem; }
.mcard summary { cursor: pointer; font-weight: 600; }
.mcard pre { margin: 8px 0 0; padding: 10px 12px; background: var(--code); border-radius: 8px; overflow-x: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.mcard .btn { align-self: flex-start; min-height: 32px; padding: 0 14px; font-size: .85rem; margin-top: 2px; }
.doc { max-width: 78ch; margin-top: 12px; padding: 4px 2px; }
.doc h3 { font-size: 1.25rem; margin: 6px 0 10px; letter-spacing: -.01em; }
.doc h4 { font-size: 1rem; margin: 22px 0 6px; color: var(--teal); }
.doc p { margin: 0 0 10px; }
.doc .src { color: var(--muted); font-size: .82rem; margin-top: 22px; }
