/* TezGrid — shared site styles (landing, docs, network stats) */

:root {
  --paper: #FAFAF7;
  --surface: #FFFFFF;
  --sunken: #F3F2EE;
  --ink: #0F0F0D;
  --ink-2: #2A2A26;
  --muted: #64635D;
  --faint: #97958D;
  --line: #E5E3DC;
  --line-strong: #D3D0C7;

  --accent: #FF5B1F;
  --accent-ink: #C2410C;
  --accent-soft: #FFF1EA;

  --ok: #15803D;
  --ok-soft: #ECF7EF;
  --warn: #B45309;
  --warn-soft: #FDF4E6;
  --bad: #B91C1C;

  --code-bg: #121210;
  --code-line: #2A2925;
  --code-ink: #E8E6DF;
  --code-dim: #7C7A72;
  --code-kw: #FF9466;
  --code-str: #C7DFA4;
  --code-add: rgba(255, 91, 31, 0.16);
  --code-del: rgba(255, 255, 255, 0.05);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --max: 1160px;
  --header-h: 60px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-button { display: none; }
pre::-webkit-scrollbar-thumb { background: var(--code-line); }
pre::-webkit-scrollbar-thumb:hover { background: var(--code-dim); }
/* Chrome ignores ::-webkit-scrollbar wherever scrollbar-width is set, so keep it Firefox-only */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
  pre { scrollbar-color: var(--code-line) transparent; }
}
input, select { font: inherit; color: inherit; }
code, kbd, pre { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent); color: #fff; }

.container { width: min(var(--max), 100% - 48px); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--mono); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(250, 250, 247, 0.86);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.site-header.is-scrolled, .site-header.is-solid { border-bottom-color: var(--line); }
.site-header .container { height: 100%; display: flex; align-items: center; gap: 32px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
.brand-mark { width: 20px; height: 20px; flex: none; }
.brand-logo { display: block; height: 20px; width: auto; flex: none; }
.brand-tag {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; margin-left: 2px;
}
@media (max-width: 380px) { .brand-tag { display: none; } }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav a {
  font-size: 14px; color: var(--muted); padding: 6px 10px; border-radius: var(--r-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.nav a:hover { color: var(--ink); background: var(--sunken); }
.nav a[aria-current="page"] { color: var(--ink); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.menu-btn {
  display: none; width: 36px; height: 36px; border-radius: var(--r-sm);
  align-items: center; justify-content: center; border: 1px solid var(--line);
}
.menu-btn svg { width: 18px; height: 18px; overflow: visible; }
.menu-btn path { transform-box: view-box; transform-origin: 12px 12px; transition: transform 0.4s cubic-bezier(0.76, 0, 0.24, 1); }
.menu-btn[aria-expanded="true"] .l1 { transform: translateY(4px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .l2 { transform: translateY(-4px) rotate(-45deg); }
@media (prefers-reduced-motion: reduce) { .menu-btn path { transition: none; } }
.mobile-nav {
  --curtain: cubic-bezier(0.76, 0, 0.24, 1);
  display: none; position: fixed; inset: var(--header-h) 0 auto 0; z-index: 49;
  max-height: calc(100dvh - var(--header-h)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 8px 24px 20px;
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
  transition: clip-path 0.45s var(--curtain), visibility 0s linear 0.45s;
}
.mobile-nav.is-open {
  clip-path: inset(0 0 0 0);
  visibility: visible;
  transition: clip-path 0.5s var(--curtain), visibility 0s;
}
.mobile-nav > * {
  opacity: 0; transform: translateY(-10px);
  transition: opacity 0.18s ease, transform 0.25s var(--curtain);
}
.mobile-nav.is-open > * {
  opacity: 1; transform: none;
  transition: opacity 0.35s ease, transform 0.45s var(--ease);
  transition-delay: calc(80ms + var(--i, 0) * 30ms);
}
.mobile-nav > :nth-child(2) { --i: 1; }
.mobile-nav > :nth-child(3) { --i: 2; }
.mobile-nav > :nth-child(4) { --i: 3; }
.mobile-nav > :nth-child(5) { --i: 4; }
.mobile-nav > :nth-child(6) { --i: 5; }
.mobile-nav > :nth-child(7) { --i: 6; }
.mobile-nav > :nth-child(8) { --i: 7; }
.mobile-nav > :nth-child(9) { --i: 8; }
.mobile-nav > :nth-child(n+10) { --i: 9; }
.mobile-nav a { display: block; padding: 12px 0; font-size: 16px; border-bottom: 1px solid var(--line); }
.mobile-nav a:last-of-type { border-bottom: 0; }
.mobile-nav .btn { display: flex; margin-top: 12px; padding: 12px 16px; width: 100%; justify-content: center; border-bottom: 0; }

@media (max-width: 880px) {
  .nav, .header-actions .btn-ghost { display: none; }
  .menu-btn { display: inline-flex; }
  .mobile-nav { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-nav, .mobile-nav.is-open, .mobile-nav > *, .mobile-nav.is-open > * { transition: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2B2B27; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunken); }
.btn .arrow { transition: transform 0.15s ease; }
.btn:hover .arrow { transform: translateX(2px); }

.text-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.text-link:hover { text-decoration-color: var(--ink); }

/* ---------- Type ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.02em; color: var(--muted);
}
.eyebrow .idx { color: var(--accent-ink); }
.h-display {
  font-size: clamp(40px, 6.4vw, 76px);
  line-height: 0.98; letter-spacing: -0.045em; font-weight: 600;
}
.h-section {
  font-size: clamp(30px, 3.6vw, 44px);
  line-height: 1.06; letter-spacing: -0.035em; font-weight: 600;
}
.h-card { font-size: 19px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; }
.lede { font-size: clamp(17px, 1.5vw, 19px); line-height: 1.55; color: var(--muted); }
.lede strong, .body strong { color: var(--ink); font-weight: 500; }
.body { color: var(--muted); }
.small { font-size: 13.5px; }
.faint { color: var(--faint); }

code.inline, .body code, .lede code, p code, li code, td code {
  font-size: 0.88em; background: var(--sunken); border: 1px solid var(--line);
  padding: 0.05em 0.35em; border-radius: 4px; color: var(--ink-2);
}

/* ---------- Sections ---------- */
.section { padding: clamp(72px, 10vw, 128px) 0; border-top: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px 48px; margin-bottom: 56px; }
.section-head .eyebrow { padding-top: 10px; }
.section-head .h-section { max-width: 18ch; }
.section-head .lede { margin-top: 18px; max-width: 60ch; }
@media (max-width: 880px) {
  .section-head { grid-template-columns: minmax(0, 1fr); margin-bottom: 40px; }
  .section-head .eyebrow { padding-top: 0; }
}
.section-body { margin-left: calc(220px + 48px); }
@media (max-width: 880px) { .section-body { margin-left: 0; } }

/* ---------- Live dot ---------- */
.live-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.live-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1px solid var(--ok); opacity: 0; animation: ping 2.4s var(--ease) infinite;
}
.live-dot.is-off { background: var(--faint); }
.live-dot.is-off::after { display: none; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.7; } 80%, 100% { transform: scale(1.8); opacity: 0; } }

/* ---------- Code panels ---------- */
.code {
  background: var(--code-bg); color: var(--code-ink);
  border-radius: var(--r); overflow: hidden;
  border: 1px solid #000;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
.code-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 42px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--code-line);
  font-family: var(--mono); font-size: 12px; color: var(--code-dim);
}
.code-tabs { display: flex; gap: 2px; height: 100%; }
.code-tab {
  position: relative; height: 100%; padding: 0 10px;
  font-family: var(--mono); font-size: 12px; color: var(--code-dim);
}
.code-tab:hover { color: var(--code-ink); }
.code-tab[aria-selected="true"] { color: var(--code-ink); }
.code-tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 1px; background: var(--accent);
}
.copy-btn {
  font-family: var(--mono); font-size: 11.5px; color: var(--code-dim);
  padding: 5px 9px; border-radius: 5px; border: 1px solid var(--code-line);
}
.copy-btn:hover { color: var(--code-ink); border-color: #45433d; }
.copy-btn.is-done { color: var(--code-str); }
.code pre {
  padding: 18px 20px 20px; overflow-x: auto;
  font-size: 13px; line-height: 1.7; tab-size: 4;
}
.code .c { color: var(--code-dim); }
.code .k { color: var(--code-kw); }
.code .s { color: var(--code-str); }
.code .p { color: var(--code-dim); user-select: none; }
.code .ln { display: block; padding: 0 20px; margin: 0 -20px; }
.code .ln.add { background: var(--code-add); }
.code .ln.add::before { content: "+ "; color: var(--accent); }
.code .ln.del { background: var(--code-del); color: var(--code-dim); text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.25); }
.code .ln.del::before { content: "- "; text-decoration: none; display: inline-block; }
.code .ln.ctx::before { content: "  "; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th, .table td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: var(--faint);
  letter-spacing: 0.02em; background: var(--paper);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table .em { color: var(--ink); font-weight: 500; }
.table .hl { color: var(--accent-ink); font-weight: 500; }
@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr { display: block; }
  .table-stack tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td, .table-stack tbody tr:last-child td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 3px 0; border: 0; white-space: normal; text-align: right;
  }
  .table-stack td::before {
    content: attr(data-label); flex: none; font-family: var(--font); font-size: 13px;
    font-weight: 400; color: var(--muted); text-align: left;
  }
  .table-stack td:first-child { display: block; padding: 0 0 6px; font-size: 15.5px; text-align: left; }
  .table-stack td:first-child::before { content: none; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--muted); background: var(--surface);
}
.badge.ok { color: var(--ok); border-color: #BFE0C9; background: var(--ok-soft); }
.badge.warn { color: var(--warn); border-color: #F1D7AE; background: var(--warn-soft); }
.badge.accent { color: var(--accent-ink); border-color: #FFCDB6; background: var(--accent-soft); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 64px 0 40px; font-size: 14px; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 40px; }
.footer-grid h4 { font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 14px; }
.footer-grid li + li { margin-top: 8px; }
.footer-grid a:hover { color: var(--ink); }
.footer-about p { margin-top: 14px; max-width: 34ch; }
.footer-base {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
  margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: var(--faint);
}
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 24px; }
  .footer-about, .footer-grid > div:nth-child(4):last-child { grid-column: 1 / -1; }
  .footer-grid a { overflow-wrap: anywhere; }
}

/* =========================================================
   Landing page
   ========================================================= */

/* ---------- Hero ---------- */
.hero { padding: clamp(56px, 9vw, 112px) 0 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 56px; align-items: end; }
.hero-copy .eyebrow { margin-bottom: 28px; }
.hero-copy .h-display { max-width: 11ch; }
.hero-copy .h-display em { font-style: normal; color: var(--accent-ink); }
.hero-copy .lede { margin-top: 28px; max-width: 46ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 36px; }
.hero-note { margin-top: 18px; font-size: 13.5px; color: var(--faint); }
.hero-note a { color: var(--muted); }
.hero-note a:hover { color: var(--ink); }

.diff-card .code pre { font-size: 13px; }
.diff-caption { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.diff-caption .mono { color: var(--faint); }

@media (max-width: 960px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 48px; }
}

/* ---------- Live strip ---------- */
.live-strip {
  margin-top: clamp(64px, 8vw, 96px);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.live-strip .container { display: grid; grid-template-columns: 220px repeat(4, minmax(0, 1fr)); }
.live-head { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 22px 24px 22px 0; }
.live-head .eyebrow { color: var(--ink); }
.live-head .small { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.live-cell { padding: 22px 24px; border-left: 1px solid var(--line); }
.live-cell .v { font-family: var(--mono); font-size: 26px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.live-cell .l { font-size: 13px; color: var(--muted); margin-top: 2px; }
@media (max-width: 960px) {
  .live-strip .container { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-head { grid-column: 1 / -1; padding: 18px 0; border-bottom: 1px solid var(--line); }
  .live-cell:nth-child(2n) { border-left: 0; padding-left: 0; }
  .live-cell:nth-child(n+4) { border-top: 1px solid var(--line); }
}

/* ---------- How it works ---------- */
.how { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 56px; align-items: center; }
.steps { counter-reset: step; }
.steps li { position: relative; padding: 22px 0 22px 48px; border-top: 1px solid var(--line); }
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 24px; font-family: var(--mono); font-size: 12px; color: var(--accent-ink);
}
.steps h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.steps p { margin-top: 6px; color: var(--muted); font-size: 15px; }
.mesh { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 12px; }
.mesh svg { width: 100%; height: auto; }
.mesh .m-node { fill: var(--paper); stroke: var(--line-strong); stroke-width: 1; }
.mesh .m-node.core { fill: var(--ink); stroke: var(--ink); }
.mesh .m-title { font-family: var(--font); font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.mesh .m-label { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.mesh .m-node.core + .m-title, .mesh .core-text { fill: #fff; }
.mesh .core-sub { font-family: var(--mono); font-size: 10px; fill: #A9A79F; }
.mesh .m-path { fill: none; stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 4; }
.mesh .m-packet.req { fill: var(--accent); }
.mesh .m-packet.res { fill: var(--ink); }
.mesh .m-caption { font-family: var(--mono); font-size: 10px; fill: var(--faint); letter-spacing: 0.02em; }
.mesh.is-stacked .m-title { font-size: 13px; }
.mesh.is-stacked .m-label, .mesh.is-stacked .core-sub { font-size: 10.5px; }
@media (prefers-reduced-motion: reduce) { .mesh .m-packet { display: none; } }
@media (max-width: 960px) { .how { grid-template-columns: minmax(0, 1fr); gap: 40px; } }

/* ---------- Two sides ---------- */
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.split-col { padding: 36px 36px 32px; display: flex; flex-direction: column; }
.split-col + .split-col { border-left: 1px solid var(--line); }
.split-col .eyebrow { margin-bottom: 18px; }
.split-col .h-card { font-size: 24px; letter-spacing: -0.025em; max-width: 20ch; }
.split-col > p { margin-top: 12px; color: var(--muted); }
.ticks { margin: 24px 0 28px; display: grid; gap: 10px; }
.ticks li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 12px; font-size: 15px; color: var(--ink-2); }
.ticks li::before { content: ""; width: 9px; height: 1px; background: var(--accent); margin-top: 11px; }
.split-col .btn { margin-top: auto; align-self: flex-start; }
@media (max-width: 860px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-col + .split-col { border-left: 0; border-top: 1px solid var(--line); }
  .split-col { padding: 28px 24px; }
}

/* ---------- Path compare ---------- */
.paths { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.path { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: center; gap: 36px; padding: 30px 32px; }
.path + .path { border-top: 1px solid var(--line); }
.path.is-ours { background: var(--paper); }
.path-name { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.path-sum { margin-top: 8px; font-size: 15px; line-height: 1.45; color: var(--muted); }
.path-sum strong { display: block; font-size: 20px; letter-spacing: -0.02em; font-weight: 600; color: var(--ink); }
.path.is-ours .path-sum strong { color: var(--accent-ink); }

.path-track { display: flex; align-items: center; }
.hop {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
}
.hop-k { font-size: 12px; color: var(--faint); }
.hop-n { font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }
.hop.is-layer { background: var(--sunken); border-color: var(--line); }
.hop.is-layer .hop-n { color: var(--ink-2); }
.hop.is-source { border-color: var(--ink); }
.hop.is-gateway { background: var(--ink); border-color: var(--ink); }
.hop.is-gateway .hop-k { color: rgba(255, 255, 255, 0.55); }
.hop.is-gateway .hop-n { color: #fff; }

.hop-link { flex: 0 0 88px; height: 1px; background: var(--line-strong); position: relative; }
.hop-link::after {
  content: ""; position: absolute; right: 0; top: -3.5px;
  border-left: 6px solid var(--line-strong); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.tax {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11px; line-height: 1; white-space: nowrap;
  padding: 4px 7px; border-radius: 999px;
  color: var(--accent-ink); background: var(--accent-soft); border: 1px solid rgba(255, 91, 31, 0.22);
}
.tax.is-fee { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }

@media (max-width: 1000px) {
  .path { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 26px 24px; }
  .path-sum strong { display: inline; font-size: 15px; }
}
@media (max-width: 680px) {
  .path-track { flex-direction: column; align-items: stretch; }
  .hop { flex: none; }
  .hop-link { flex: 0 0 34px; width: 1px; height: 34px; margin-left: 22px; }
  .hop-link::after {
    right: auto; top: auto; bottom: 0; left: -3.5px;
    border-top: 6px solid var(--line-strong); border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 0;
  }
  .tax { bottom: auto; top: 50%; left: 14px; transform: translateY(-50%); }
}

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 56px; border-top: 1px solid var(--line); }
.fact { padding: 24px 24px 0 0; }
.fact + .fact { padding-left: 24px; border-left: 1px solid var(--line); }
.fact .v { font-size: 34px; letter-spacing: -0.04em; font-weight: 600; }
.fact .l { margin-top: 6px; font-size: 14px; color: var(--muted); max-width: 22ch; }
@media (max-width: 860px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .fact:nth-child(3) { padding-left: 0; border-left: 0; }
}

/* ---------- Trust ---------- */
.trust { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 48px; align-items: start; }
.trust-list { border-top: 1px solid var(--line); }
.trust-list li { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.trust-list h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.trust-list p { font-size: 15px; color: var(--muted); }
.honest {
  position: sticky; top: calc(var(--header-h) + 24px);
  background: var(--ink); color: #E9E7E0; border-radius: var(--r-lg); padding: 28px;
}
.honest .eyebrow { color: #A9A79F; margin-bottom: 16px; }
.honest .eyebrow .idx { color: var(--accent); }
.honest h3 { font-size: 22px; letter-spacing: -0.025em; font-weight: 600; color: #fff; line-height: 1.2; }
.honest p { margin-top: 14px; font-size: 15px; color: #B9B7AF; }
.honest p strong { color: #fff; font-weight: 500; }
.honest code { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.12); color: #fff; }
@media (max-width: 960px) {
  .trust { grid-template-columns: minmax(0, 1fr); }
  .honest { position: static; }
  .trust-list li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ---------- API ---------- */
.api { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 40px; align-items: start; }
.spec { border-top: 1px solid var(--line); }
.spec li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.spec .k { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.spec .d { margin-top: 4px; font-size: 14.5px; color: var(--muted); }
@media (max-width: 960px) { .api { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Pricing ---------- */
.price-foot { margin-top: 16px; font-size: 13.5px; color: var(--faint); max-width: 80ch; }

/* ---------- Install ---------- */
.install { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 48px; align-items: start; }
.install .steps li { padding-top: 18px; padding-bottom: 18px; }
.install .steps li::before { top: 20px; }
.install-side .small { margin-top: 20px; color: var(--muted); }
@media (max-width: 960px) { .install { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Calculator ---------- */
.calc { margin-top: 80px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.calc-top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
}
.calc-top h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.calc-top p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
@media (max-width: 480px) {
  .calc-top { padding: 16px; }
  .calc-top .seg { display: flex; width: 100%; }
  .calc-top .seg button { flex: 1 1 0; min-width: 0; padding: 6px 8px; }
}

.seg { display: inline-flex; padding: 3px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; gap: 2px; }
.seg button, .seg label {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  padding: 6px 12px; border-radius: 6px; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1.3;
}
.seg button small { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.seg button.active, .seg label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.field .seg label { display: inline-flex; margin: 0; font-weight: 400; color: var(--muted); }
.field .seg label:has(input:checked) { color: var(--ink); }

.seg { position: relative; }
.seg > button, .seg > label { transition: color 0.25s var(--ease); }
.seg.has-blob > button, .seg.has-blob > label { position: relative; z-index: 1; }
.seg.has-blob > button.active, .seg.has-blob > label:has(input:checked) { background: transparent; box-shadow: none; }
.seg-blob {
  position: absolute; z-index: 0; border-radius: 6px; pointer-events: none;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgba(15, 15, 13, 0.07);
  transform-origin: center;
  transition: left 0.45s cubic-bezier(0.3, 1.3, 0.4, 1), right 0.45s cubic-bezier(0.3, 1.3, 0.4, 1), opacity 0.2s;
}
.seg-blob.to-right { transition: right 0.26s cubic-bezier(0.55, 0, 0.25, 1), left 0.55s cubic-bezier(0.3, 1.35, 0.4, 1) 0.07s, opacity 0.2s; }
.seg-blob.to-left { transition: left 0.26s cubic-bezier(0.55, 0, 0.25, 1), right 0.55s cubic-bezier(0.3, 1.35, 0.4, 1) 0.07s, opacity 0.2s; }
.seg-blob.no-anim { transition: opacity 0.2s; }
.nav { position: relative; }
.nav.has-blob a { position: relative; z-index: 1; }
.nav.has-blob a:hover { background: transparent; }
.nav-blob { background: var(--sunken); box-shadow: none; border-radius: var(--r-sm); opacity: 0; }
.seg-blob.is-flowing { animation: seg-flow 0.6s cubic-bezier(0.3, 0.7, 0.3, 1); }
@keyframes seg-flow {
  0% { transform: none; }
  30% { transform: scaleY(0.84); }
  62% { transform: scaleY(1.05); }
  100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .seg-blob, .seg-blob.to-right, .seg-blob.to-left, .seg-blob.no-anim { transition: none; }
  .seg-blob.is-flowing { animation: none; }
}

.calc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.calc-form { padding: 24px; display: grid; gap: 20px; align-content: start; border-right: 1px solid var(--line); }
.calc-out { padding: 24px; background: var(--paper); }
.field label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 8px; }
.field label .val { font-family: var(--mono); font-weight: 400; color: var(--ink); }
.field .hint { margin-top: 6px; font-size: 12.5px; color: var(--faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.select, .input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px;
}
.select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364635D' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select:disabled { background-color: var(--sunken); color: var(--ink-2); opacity: 1; }
.select:focus, .input:focus { outline: none; border-color: var(--ink); }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.stepper button { height: 38px; color: var(--muted); }
.stepper button:hover { background: var(--sunken); color: var(--ink); }
.stepper input { border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font-family: var(--mono); font-size: 14px; min-width: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--paper); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  font-size: 13px; padding: 6px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
}
.chip-btn:hover { border-color: var(--ink); }
.chip-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.range { width: 100%; height: 20px; appearance: none; background: transparent; }
.range::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
.range::-moz-range-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
.range::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink); }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink); }

.geo { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); }
.geo .mono { font-size: 12px; }
.geo.is-found .mono { color: var(--ok); }

.out-label { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.out-num { font-family: var(--mono); font-size: clamp(40px, 5vw, 56px); letter-spacing: -0.05em; line-height: 1.05; margin-top: 8px; font-variant-numeric: tabular-nums; }
.out-num.is-negative { color: var(--bad); }
.out-sub { font-size: 13px; color: var(--faint); margin-top: 4px; }
.ledger { margin-top: 24px; border-top: 1px solid var(--line); }
.ledger-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.ledger-row span:last-child { font-family: var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.ledger-row.neg span:last-child { color: var(--bad); }
.ledger-row.total { color: var(--ink); font-weight: 500; }
.factors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: 20px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.factor { background: var(--surface); padding: 10px 12px; }
.factor .fl { font-size: 11.5px; color: var(--faint); }
.factor .fv { font-family: var(--mono); font-size: 15px; margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.factor .fv .badge { font-size: 9.5px; padding: 0 5px; }
.warn-box { margin-top: 20px; padding: 14px 16px; border: 1px solid #F1D7AE; background: var(--warn-soft); border-radius: var(--r-sm); }
.warn-box h4 { font-size: 13.5px; font-weight: 600; color: var(--warn); }
.warn-box p { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.warn-fixes { display: grid; gap: 6px; margin-top: 10px; }
.warn-fix {
  display: flex; justify-content: space-between; gap: 12px; width: 100%;
  font-size: 13px; padding: 8px 10px; background: var(--surface); border: 1px solid #F1D7AE; border-radius: 5px; text-align: left;
}
.warn-fix:hover { border-color: var(--warn); }
.warn-fix span:last-child { font-family: var(--mono); font-size: 12px; color: var(--warn); }
.calc-disclaimer { margin-top: 18px; font-size: 12.5px; color: var(--faint); }
@media (max-width: 900px) {
  .calc-body { grid-template-columns: minmax(0, 1fr); }
  .calc-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .factors { grid-template-columns: 1fr 1fr; }
}

/* ---------- Closing band ---------- */
.band { background: var(--ink); color: #fff; padding: clamp(72px, 9vw, 112px) 0; }
.band-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: end; }
.band .eyebrow { color: #A9A79F; margin-bottom: 20px; }
.band .eyebrow .idx { color: var(--accent); }
.band .h-section { max-width: 20ch; }
.band p { margin-top: 18px; color: #B9B7AF; max-width: 56ch; font-size: 17px; }
.band-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.band .btn-primary { background: #fff; color: var(--ink); }
.band .btn-primary:hover { background: #E9E7E0; }
.band .btn-secondary { background: transparent; color: #fff; border-color: #3C3B36; }
.band .btn-secondary:hover { border-color: #fff; }
@media (max-width: 860px) { .band-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Legal pages ---------- */
.legal { padding: 64px 0 112px; }
.legal-head { padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.legal-head h1 { font-size: clamp(34px, 4vw, 46px); letter-spacing: -0.04em; line-height: 1.05; font-weight: 600; }
.legal-head .lede { margin-top: 14px; font-size: 17px; }
.legal-meta { margin-top: 18px; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.legal-callout {
  margin-top: 32px; padding: 18px 20px; border: 1px solid #FFCDB6; border-radius: var(--r);
  background: var(--accent-soft); color: var(--ink-2); font-size: 15px;
}
.legal-callout strong { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 600; }
.legal section { margin-top: 40px; }
.legal h2 { font-size: 21px; letter-spacing: -0.02em; font-weight: 600; }
.legal h2 .n { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--accent-ink); margin-right: 10px; vertical-align: 3px; }
.legal p, .legal li { color: var(--ink-2); font-size: 15.5px; line-height: 1.65; }
.legal p { margin-top: 12px; }
.legal ul { margin-top: 12px; display: grid; gap: 8px; }
.legal ul li { position: relative; padding-left: 20px; }
.legal ul li::before { content: ""; position: absolute; left: 2px; top: 12px; width: 8px; height: 1px; background: var(--accent); }
.legal a:not(.btn) { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.legal a:not(.btn):hover { text-decoration-color: var(--ink); }
.legal .kv-list { margin-top: 14px; border-top: 1px solid var(--line); }
.legal .kv-list > div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.legal .kv-list dt { font-weight: 500; font-size: 14.5px; color: var(--ink); }
.legal .kv-list dd { margin: 0; font-size: 14.5px; color: var(--muted); line-height: 1.6; }
@media (max-width: 640px) {
  .legal { padding-top: 40px; }
  .legal .kv-list > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ---------- Research paper ---------- */
.paper { padding: 56px 0 112px; }
.paper-head { max-width: 880px; padding-bottom: 36px; border-bottom: 1px solid var(--line); }
.paper-kicker { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.paper-kicker .idx { color: var(--accent-ink); }
.paper-head h1 { margin-top: 18px; max-width: 18ch; font-size: clamp(36px, 4.8vw, 58px); line-height: 1.02; letter-spacing: -0.045em; font-weight: 600; }
.paper-sub { margin-top: 20px; max-width: 62ch; font-size: clamp(17px, 1.5vw, 19px); line-height: 1.55; color: var(--muted); }
.paper-meta { display: flex; flex-wrap: wrap; gap: 14px 36px; margin-top: 30px; }
.paper-meta dt { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.paper-meta dd { margin: 3px 0 0; font-size: 14px; font-weight: 500; color: var(--ink); }
.paper-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }

.paper-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 72px; align-items: start; margin-top: 48px; }
.paper-toc { position: sticky; top: calc(var(--header-h) + 28px); max-height: calc(100vh - var(--header-h) - 56px); overflow-y: auto; font-size: 13.5px; }
.paper-toc > p { margin-bottom: 12px; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.paper-toc ol { display: grid; gap: 1px; border-left: 1px solid var(--line); }
.paper-toc a { display: flex; gap: 10px; margin-left: -1px; padding: 5px 0 5px 14px; border-left: 1px solid transparent; line-height: 1.35; color: var(--muted); transition: color 0.15s, border-color 0.15s; }
.paper-toc a span { flex: none; width: 18px; padding-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.paper-toc a:hover { color: var(--ink); }
.paper-toc a.is-active { border-left-color: var(--accent); color: var(--ink); }
.paper-toc a.is-active span { color: var(--accent-ink); }
.toc-mobile { display: none; margin-top: 28px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.toc-mobile summary { padding: 14px 16px; font-size: 14.5px; font-weight: 500; cursor: pointer; }
.toc-mobile ol { display: grid; gap: 2px; padding: 0 16px 14px; }
.toc-mobile a { display: flex; gap: 10px; padding: 6px 0; font-size: 14.5px; color: var(--muted); }
.toc-mobile a span { width: 20px; font-family: var(--mono); font-size: 11.5px; color: var(--faint); padding-top: 2px; }

.paper-body { max-width: 720px; }
.paper-body > section { margin-top: 64px; }
.paper-body > section:first-child { margin-top: 0; }
.paper-body h2 { font-size: clamp(25px, 2.5vw, 30px); line-height: 1.15; letter-spacing: -0.03em; font-weight: 600; }
.paper-body h2 .n { display: block; margin-bottom: 10px; font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--accent-ink); }
.paper-body h3 { margin-top: 36px; font-size: 18px; letter-spacing: -0.015em; font-weight: 600; }
.paper-body p, .paper-body li { font-size: 16.5px; line-height: 1.72; color: var(--ink-2); }
.paper-body p { margin-top: 16px; }
.paper-body h2 + p { margin-top: 20px; }
.paper-body h3 + p { margin-top: 10px; }
.paper-body strong { font-weight: 600; color: var(--ink); }
.paper-body a:not(.btn) { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.paper-body a:not(.btn):hover { text-decoration-color: var(--ink); }
.paper-body code { padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--sunken); font-family: var(--mono); font-size: 0.84em; color: var(--ink); white-space: nowrap; }
.paper-body ul { display: grid; gap: 10px; margin-top: 16px; }
.paper-body ul li { position: relative; padding-left: 22px; }
.paper-body ul li::before { content: ""; position: absolute; left: 2px; top: 13px; width: 9px; height: 1px; background: var(--accent); }
.paper-body ol.list { display: grid; gap: 10px; margin-top: 16px; counter-reset: li; }
.paper-body ol.list > li { position: relative; padding-left: 34px; counter-increment: li; }
.paper-body ol.list > li::before { content: counter(li, decimal-leading-zero); position: absolute; left: 0; top: 4px; font-family: var(--mono); font-size: 12px; color: var(--accent-ink); }

.abstract { padding: 26px 28px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.abstract h2 { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.abstract p { margin-top: 12px; font-size: 17px; line-height: 1.7; }

.key-figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.key-figures > div { padding: 18px 18px 20px; border-left: 1px solid var(--line); }
.key-figures > div:first-child { border-left: 0; }
.key-figures strong { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -0.035em; font-weight: 600; color: var(--ink); }
.key-figures strong small { font-size: 15px; letter-spacing: -0.01em; font-weight: 500; color: var(--muted); }
.key-figures span { display: block; margin-top: 6px; font-size: 13px; line-height: 1.45; color: var(--muted); }

.pnote { margin-top: 26px; padding: 16px 20px; border-left: 2px solid var(--accent); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--accent-soft); }
.pnote strong { display: block; margin-bottom: 4px; font-size: 15px; }
.paper-body .pnote p { margin-top: 0; font-size: 15.5px; line-height: 1.65; }
.pnote.is-plain { border-left-color: var(--ink); background: var(--sunken); }

.formula { margin-top: 22px; padding: 20px 22px; border-radius: var(--r); background: var(--code-bg); color: var(--code-ink); font-family: var(--mono); font-size: 14px; line-height: 1.9; overflow-x: auto; }
.formula .c { color: var(--code-dim); }
.formula .k { color: var(--code-kw); }

.fig { margin-top: 30px; }
.fig-box { padding: 24px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.fig figcaption { margin-top: 12px; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.fig figcaption b { margin-right: 6px; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--ink); }

.flow { display: grid; grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1.2fr) 40px minmax(0, 1fr); align-items: stretch; }
.flow-node { padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.flow-node.is-gw { border-color: var(--ink); background: var(--ink); color: #fff; }
.flow-k { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.flow-node.is-gw .flow-k { color: var(--accent); }
.flow-n { margin-top: 6px; font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.paper-body .flow-d { margin-top: 10px; gap: 5px; }
.paper-body .flow-d li { padding-left: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.paper-body .flow-d li::before { display: none; }
.paper-body .flow-node.is-gw .flow-d li { color: #B9B7AF; }
.flow-link { position: relative; }
.flow-link::before { content: ""; position: absolute; left: 6px; right: 8px; top: 50%; height: 1px; background: var(--line-strong); }
.flow-link::after { content: ""; position: absolute; right: 6px; top: calc(50% - 4px); border: 4px solid transparent; border-left: 6px solid var(--line-strong); border-right: 0; }
.flow-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.flow-legend div { font-size: 13px; line-height: 1.45; color: var(--muted); }
.flow-legend b { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink); }

.rsteps { margin-top: 24px; counter-reset: step; }
.rsteps > li { position: relative; padding: 0 0 22px 48px; counter-increment: step; }
.rsteps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); font-family: var(--mono); font-size: 12px; color: var(--ink); }
.rsteps > li::after { content: ""; position: absolute; left: 14px; top: 32px; bottom: 4px; width: 1px; background: var(--line); }
.rsteps > li:last-child { padding-bottom: 0; }
.rsteps > li:last-child::after { display: none; }
.rsteps h4 { padding-top: 3px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.paper-body .rsteps p { margin-top: 6px; font-size: 15.5px; line-height: 1.65; }

.table-wrap { margin-top: 26px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
.ptable th { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--sunken); font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: var(--muted); text-align: left; white-space: nowrap; }
.ptable td { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: top; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable td:first-child { min-width: 150px; font-weight: 500; color: var(--ink); }
.ptable .num { font-family: var(--mono); font-size: 13.5px; text-align: right; white-space: nowrap; }
.ptable th.num { text-align: right; }
.ptable .is-ours td { background: var(--accent-soft); }
.ptable code { white-space: nowrap; }
@media screen and (max-width: 640px) {
  .ptable.is-labelled thead { display: none; }
  .ptable.is-labelled, .ptable.is-labelled tbody, .ptable.is-labelled tr { display: block; }
  .ptable.is-labelled tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .ptable.is-labelled tr:last-child { border-bottom: 0; }
  .ptable.is-labelled .is-ours { background: var(--accent-soft); }
  .ptable.is-labelled .is-ours td { background: none; }
  .ptable.is-labelled td { display: block; min-width: 0; padding: 4px 0; border: 0; }
  .ptable.is-labelled td::before { content: attr(data-label); display: block; font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--muted); }
  .ptable.is-labelled td:first-child { padding-top: 0; font-size: 15px; }
  .ptable.is-labelled td:first-child::before { content: none; }
  .ptable.is-labelled td.num { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .ptable.is-labelled td.num::before { font-size: 12.5px; }
  .ptable.is-labelled code { white-space: normal; overflow-wrap: anywhere; }
}
.ptag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.ptag.yes { background: var(--ok-soft); color: var(--ok); }
.ptag.no { background: #FBEDED; color: var(--bad); }
.ptag.part { background: var(--warn-soft); color: var(--warn); }

.receipt { margin-top: 26px; max-width: 460px; padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); font-family: var(--mono); font-size: 13.5px; }
.receipt-h { padding-bottom: 12px; border-bottom: 1px dashed var(--line-strong); font-size: 11.5px; color: var(--muted); }
.receipt-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; color: var(--ink-2); }
.receipt-row span:last-child { color: var(--ink); }
.receipt-row.is-total { margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line-strong); font-weight: 500; }
.receipt-row.is-split span:last-child { color: var(--accent-ink); }
.receipt-foot { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--muted); }

.pbars { display: grid; gap: 22px; }
.pbars-group h4 { margin-bottom: 10px; font-size: 14px; font-weight: 600; }
.pbar { display: grid; grid-template-columns: 92px minmax(0, 1fr) 84px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13px; color: var(--muted); }
.pbar-track { height: 10px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.pbar-fill { display: block; height: 100%; border-radius: 999px; background: var(--ink); }
.pbar-fill.is-accent { background: var(--accent); }
.pbar b { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink); text-align: right; }

.gloss { margin-top: 20px; border-top: 1px solid var(--line); }
.gloss > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gloss dt { font-size: 15px; font-weight: 600; color: var(--ink); }
.gloss dd { margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.paper-body ol.refs { display: grid; gap: 10px; margin-top: 18px; counter-reset: ref; }
.paper-body ol.refs li { position: relative; padding-left: 36px; font-size: 14.5px; line-height: 1.6; counter-increment: ref; }
.paper-body ol.refs li::before { content: "[" counter(ref) "]"; position: absolute; left: 0; font-family: var(--mono); font-size: 12.5px; color: var(--faint); top: 1px; }
.cite { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--ink-2); }

@media (max-width: 1000px) {
  .paper-layout { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 36px; }
  .paper-toc { display: none; }
  .toc-mobile { display: block; }
  .paper-body { max-width: none; }
}
@media (max-width: 720px) {
  .paper { padding-top: 40px; }
  .key-figures { grid-template-columns: 1fr 1fr; }
  .key-figures > div:nth-child(3) { border-left: 0; }
  .key-figures > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .flow { grid-template-columns: minmax(0, 1fr); }
  .flow-link { height: 28px; }
  .flow-link::before { left: 50%; right: auto; top: 4px; bottom: 6px; width: 1px; height: auto; }
  .flow-link::after { left: calc(50% - 4px); right: auto; top: auto; bottom: 4px; border: 4px solid transparent; border-top: 6px solid var(--line-strong); border-bottom: 0; }
  .flow-legend { grid-template-columns: minmax(0, 1fr); }
  .gloss > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .pbar { grid-template-columns: 76px minmax(0, 1fr) 72px; }
  .paper-body p, .paper-body li { font-size: 16px; }
}

@media print {
  @page { size: A4; margin: 16mm 15mm 18mm; }
  html { scroll-behavior: auto; }
  body { background: #fff; font-size: 10.5pt; }
  .site-header, .mobile-nav, .site-footer, .paper-toc, .toc-mobile, .paper-actions, .to-top { display: none !important; }
  .container { width: 100%; }
  .paper { padding: 0; }
  .paper-head { max-width: none; padding-bottom: 20px; }
  .paper-head h1 { font-size: 30pt; max-width: 22ch; }
  .paper-sub { font-size: 12pt; }
  .paper-layout { display: block; margin-top: 24px; }
  .paper-body { max-width: none; }
  .paper-body > section { margin-top: 28px; }
  .paper-body h2 { font-size: 17pt; break-after: avoid; }
  .paper-body h3, .rsteps h4 { break-after: avoid; }
  .paper-body p, .paper-body li { font-size: 10.5pt; line-height: 1.6; }
  .paper-body .abstract h2 { font-size: 9pt; }
  .paper-body .pnote p, .paper-body .rsteps p { font-size: 10pt; }
  .fig, .table-wrap, .receipt, .pnote, .formula, .key-figures, .abstract, .rsteps > li, .gloss > div, .cite { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .ptable { font-size: 9.5pt; }
  .paper-body a:not(.btn) { text-decoration: none; }
  .formula { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .flow-node.is-gw, .pbar-fill, .ptag, .pnote, .ptable th, .ptable .is-ours td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Back to top ---------- */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 15, 13, 0.06), 0 6px 18px rgba(15, 15, 13, 0.08);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0.2s, background 0.15s, color 0.15s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--ink); color: #fff; }
.to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.to-top-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.to-top-ring circle { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.to-top-ring .to-top-progress { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.to-top:hover .to-top-ring circle:not(.to-top-progress) { stroke: var(--ink); }
.to-top-arrow { position: relative; width: 16px; height: 16px; transition: transform 0.2s var(--ease); }
.to-top:hover .to-top-arrow { transform: translateY(-2px); }
@media (max-width: 640px) { .to-top { right: 16px; bottom: 16px; } }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .live-dot::after { animation: none; }
  .to-top, .to-top-arrow, .to-top-progress { transition: none; }
}
