:root {
  --bg: #050a10;
  --bg-elevated: #0b1219;
  --bg-card: rgba(255, 255, 255, 0.03);
  --ink: #ffffff;
  --ink-muted: rgba(255, 255, 255, 0.78);
  --ink-soft: rgba(255, 255, 255, 0.52);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --signal: #00f5a0;
  --signal-dim: rgba(0, 245, 160, 0.15);
  --signal-ink: #050a10;
  --font: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 72rem;
  --prose: 46rem;
  --header-h: 4rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 40% at 80% -10%, rgba(0, 245, 160, 0.08), transparent 55%),
    var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.wrap {
  width: min(var(--max), calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  background: rgba(5, 10, 16, 0.72);
  backdrop-filter: blur(14px);
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
  background: rgba(5, 10, 16, 0.92);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__mark {
  width: 2rem;
  height: 2rem;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav a {
  padding: 0.45rem 0.7rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
}

.nav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.nav .nav__cta {
  color: var(--signal);
  background: var(--signal-dim);
  font-weight: 600;
}

.hero {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 2rem 2.5rem;
  align-items: center;
}

.hero__copy {
  max-width: 40rem;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.9rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal);
}

.hero h1 {
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  max-width: 22ch;
  margin-bottom: 1rem;
}

.hero h1 em {
  font-style: normal;
  color: var(--signal);
}

.hero__lead {
  color: var(--ink-muted);
  font-size: 1.05rem;
  max-width: 36rem;
  margin-bottom: 1.5rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 500;
}

/* Hero diagram */
.hero-diagram {
  margin: 0;
  padding: 1rem 1rem 0.85rem;
  border-radius: 1.15rem;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse 80% 60% at 70% 30%, rgba(0, 245, 160, 0.08), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 50%),
    rgba(255, 255, 255, 0.02);
  animation: schema-rise 0.7s ease both;
}

.hero-diagram__head {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
}

.hero-diagram__eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--signal);
}

.hero-diagram__step {
  font-size: 0.82rem;
  color: var(--ink-soft);
  min-height: 2.4em;
}

.hero-diagram__step strong {
  color: var(--ink);
  font-weight: 600;
}

.hero-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.hero-panel {
  fill: rgba(11, 18, 25, 0.75);
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1;
}

.hero-panel--signal {
  fill: rgba(0, 245, 160, 0.04);
  stroke: rgba(0, 245, 160, 0.22);
}

.hero-kicker {
  fill: rgba(255, 255, 255, 0.4);
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hero-kicker--signal {
  fill: var(--signal);
}

.hero-panel-title {
  fill: rgba(255, 255, 255, 0.88);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
}

.hero-node {
  fill: rgba(11, 18, 25, 0.95);
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.2;
  transition: stroke 0.25s ease, filter 0.25s ease;
}

.hero-node.is-active {
  stroke: var(--signal);
  filter: drop-shadow(0 0 8px rgba(0, 245, 160, 0.35));
}

.hero-node-label {
  fill: #fff;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
}

.hero-node-sub {
  fill: rgba(255, 255, 255, 0.5);
  font-family: var(--font);
  font-size: 9px;
  text-anchor: middle;
}

.hero-edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.hero-edge.is-active {
  stroke: var(--signal);
  stroke-dasharray: 4 6;
  animation: dash-flow 0.65s linear infinite;
}

.hero-edge--back {
  opacity: 0.35;
}

.hero-transition {
  fill: none;
  stroke: rgba(0, 245, 160, 0.55);
  stroke-width: 1.5;
  stroke-dasharray: 3 5;
  animation: dash-flow 1s linear infinite;
}

.hero-transition-label {
  fill: var(--signal);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
}

.hero-packet {
  fill: var(--signal);
  opacity: 0;
}

.hero-packet.is-on {
  opacity: 1;
  animation: packet-pulse 0.85s ease;
}

.hero-diagram__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.hero-chip {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.68rem;
  color: var(--ink-soft);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.hero-chip.is-active {
  border-color: rgba(0, 245, 160, 0.45);
  color: var(--signal);
  background: var(--signal-dim);
}

@media (max-width: 900px) {
  .hero__grid {
    grid-template-columns: 1fr;
  }

  .hero-diagram {
    order: -1;
    max-width: 28rem;
  }
}

.layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2.5rem;
  padding: 2.5rem 0 4rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.toc h2 {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 0.85rem;
}

.toc ol {
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.toc a {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.35;
  padding: 0.25rem 0;
}

.toc a:hover,
.toc a.is-active {
  color: var(--signal);
}

.prose {
  max-width: var(--prose);
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 2.75rem 0 1rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.prose h3 {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  margin: 2rem 0 0.75rem;
  color: rgba(255, 255, 255, 0.95);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.prose h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.6rem;
  color: var(--signal);
}

.prose p {
  color: var(--ink-muted);
  margin-bottom: 1.05rem;
  font-size: 0.98rem;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.prose em {
  color: rgba(255, 255, 255, 0.88);
}

.prose ul,
.prose ol {
  margin: 0 0 1.2rem 1.15rem;
  color: var(--ink-muted);
  display: grid;
  gap: 0.55rem;
}

.prose li::marker {
  color: var(--signal);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.25rem 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--signal);
  background: var(--signal-dim);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

.prose pre {
  margin: 1.25rem 0 1.5rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: #03070b;
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.45;
}

.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.75rem;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.prose th {
  color: var(--signal);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.prose td:first-child {
  white-space: nowrap;
  width: 42%;
}

.cite {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.82em;
}

.cite-link {
  color: rgba(0, 245, 160, 0.75);
  text-decoration: none;
  border-bottom: 1px dotted rgba(0, 245, 160, 0.35);
}

.cite-link:hover {
  color: var(--signal);
  border-bottom-color: var(--signal);
}

.sources {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.sources h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
}

.sources__lead {
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.sources__list {
  list-style: none;
  display: grid;
  gap: 0.85rem;
  counter-reset: source;
}

.sources__list > li {
  counter-increment: source;
  padding: 0.95rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  scroll-margin-top: calc(var(--header-h) + 1rem);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.sources__list > li.is-target {
  border-color: rgba(0, 245, 160, 0.45);
  background: rgba(0, 245, 160, 0.06);
}

.sources__item {
  display: grid;
  gap: 0.35rem;
}

.sources__title {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

.sources__title::before {
  content: "[" counter(source) "] ";
  color: var(--signal);
  font-variant-numeric: tabular-nums;
}

.sources__title a {
  color: inherit;
  border-bottom: 1px solid rgba(0, 245, 160, 0.35);
}

.sources__title a:hover {
  color: var(--signal);
}

.sources__meta {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.sources__cites {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.5;
}

.sources__cite {
  color: rgba(0, 245, 160, 0.8);
  margin-right: 0.15rem;
}

.sources__cite:hover {
  color: var(--signal);
}

.schema__caption {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}

.schema__flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin: 0.5rem 0 0.75rem;
}

.schema__node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
  font-weight: 600;
}

.schema__node--signal {
  border-color: var(--signal);
  background: var(--signal-dim);
  color: var(--signal);
}

.schema__arrow {
  color: var(--signal);
  font-weight: 700;
}

.schema__note {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ——— Animated schemas ——— */
.schema {
  margin: 1.5rem 0 2rem;
  padding: 1rem 1rem 0.85rem;
  border-radius: 1.1rem;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(0, 245, 160, 0.05), transparent 42%),
    rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.schema__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.schema__title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal);
}

.schema__step {
  font-size: 0.8rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.schema__step strong {
  color: var(--ink);
  font-weight: 600;
}

.schema svg {
  display: block;
  width: 100%;
  height: auto;
}

.schema .node {
  fill: rgba(11, 18, 25, 0.92);
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.25;
}

.schema .node.is-active {
  stroke: var(--signal);
  filter: drop-shadow(0 0 10px rgba(0, 245, 160, 0.35));
}

.schema .node.danger.is-active {
  stroke: #ff6b6b;
  filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.35));
}

.schema .node-label {
  fill: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
}

.schema .node-sub {
  fill: rgba(255, 255, 255, 0.55);
  font-family: var(--font);
  font-size: 9.5px;
  text-anchor: middle;
}

.schema .edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.75;
  stroke-linecap: round;
}

.schema .edge.is-active {
  stroke: var(--signal);
  stroke-dasharray: 5 7;
  animation: dash-flow 0.65s linear infinite;
}

.schema .edge.danger.is-active {
  stroke: #ff6b6b;
}

.schema .edge.muted.is-active {
  stroke: rgba(0, 245, 160, 0.45);
}

.schema .packet {
  fill: var(--signal);
  opacity: 0;
  pointer-events: none;
}

.schema .packet.is-on {
  opacity: 1;
  animation: packet-pulse 0.85s ease;
}

.schema .packet.danger {
  fill: #ff6b6b;
}

.schema .glow-ring {
  fill: none;
  stroke: var(--signal);
  stroke-width: 1.2;
  stroke-dasharray: 4 6;
  opacity: 0;
}

.schema .glow-ring.is-on {
  opacity: 0.85;
  animation: dash-flow 1s linear infinite;
}

.schema__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.schema__chip {
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.7rem;
  color: var(--ink-soft);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.schema__chip.is-active {
  border-color: rgba(0, 245, 160, 0.45);
  color: var(--signal);
  background: var(--signal-dim);
}

.schema__chip.danger.is-active {
  border-color: rgba(255, 107, 107, 0.5);
  color: #ff8f8f;
  background: rgba(255, 107, 107, 0.12);
}

.prose pre.schema-replaced {
  display: none;
}

@keyframes dash-flow {
  to { stroke-dashoffset: -24; }
}

@keyframes packet-pulse {
  0% { opacity: 0; transform: scale(0.6); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.35; transform: scale(0.9); }
}

@keyframes schema-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.schema.is-visible {
  animation: schema-rise 0.55s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .schema .edge.is-active,
  .schema .glow-ring.is-on,
  .schema .packet.is-on,
  .schema.is-visible,
  .hero-edge.is-active,
  .hero-transition,
  .hero-packet.is-on,
  .hero-diagram {
    animation: none !important;
  }

  .schema .packet.is-on,
  .hero-packet.is-on {
    opacity: 1;
  }
}

@media print {
  .schema {
    break-inside: avoid;
    border-color: #ccc;
    background: #f7f7f7;
  }
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0;
  background: #03070b;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.site-footer p,
.site-footer a {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.site-footer a:hover {
  color: var(--signal);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }
}

@media (max-width: 640px) {
  .nav a:not(.nav__cta) {
    display: none;
  }

  .hero {
    padding-top: 2.5rem;
  }
}

@media print {
  .site-header,
  .toc,
  .site-footer {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .prose p,
  .prose ul,
  .prose ol,
  .hero__lead {
    color: #222;
  }

  .layout {
    display: block;
    padding: 0;
  }

  .prose {
    max-width: none;
  }
}
