:root {
  --s1: #3B82F6;
  --s2: #F59E0B;
  --s3: #10B981;
  --s4: #8B5CF6;
  --ink: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --bg: #fafaf7;
  --card: #ffffff;
  --out: #0F766E;
  --slate: #475569;
  --read: #2563EB;
  --write: #EA580C;
  --mix: #7C3AED;
  --route: #DB2777;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

article { position: relative; max-width: 760px; margin: 0 auto; padding: 64px 24px 120px; }

.lang-switch { position: absolute; top: 22px; right: 24px; display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 13.5px; line-height: 1; }
.lang-switch a, .lang-switch span { padding: 6px 10px; border-radius: 7px; text-decoration: none; }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { color: var(--ink); background: #f1f5f9; }
.lang-switch span { background: var(--ink); color: #fff; }

header.hero { margin-bottom: 48px; }
header.hero h1 { font-size: 36px; line-height: 1.3; margin: 0 0 12px; letter-spacing: .5px; }
header.hero .subtitle { font-size: 19px; color: var(--muted); margin: 0 0 10px; }
header.hero .meta { font-size: 14px; color: var(--faint); }

h2 { font-size: 25px; line-height: 1.4; margin: 64px 0 14px; padding-top: 18px; border-top: 1px solid var(--line); }
h3 { font-size: 19px; margin: 36px 0 8px; }
p { margin: 12px 0; }
ul, ol { padding-left: 1.4em; margin: 10px 0; }
li { margin: 4px 0; }
a { color: var(--read); }

.toc { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 22px; margin: 28px 0; }
.toc ol { margin: 0; }

/* inline math */
.m { font-family: "Times New Roman", "STIX Two Text", "Cambria Math", serif; font-style: italic; font-size: 1.08em; white-space: nowrap; }
.m .up { font-style: normal; }
.m sub, .m sup { font-size: .72em; }

/* superscript stacked over subscript, e.g. H^⊤_post, K^(e)_pre */
.ss { display: inline-flex; flex-direction: column; vertical-align: .38em; line-height: 1; margin-right: 1px; }
.ss > sup, .ss > sub { display: block; line-height: 1.1; vertical-align: baseline; position: static; }

.eq {
  margin: 20px 0;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
  font-family: "Times New Roman", "STIX Two Text", "Cambria Math", serif;
  font-size: 21px;
  line-height: 1.8;
  overflow-x: auto;
  white-space: nowrap; /* Keep a base and its stacked scripts on the same line. */
}
.eq i { font-style: italic; }
.eq sub, .eq sup { font-size: .68em; }
.eq.eq-left { text-align: left; padding-left: 12%; }
.eq .note { white-space: normal; display: block; font-family: -apple-system, "PingFang SC", sans-serif; font-size: 14px; color: var(--muted); font-style: normal; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* figures */
.figure {
  margin: 30px -130px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .04);
}
@media (max-width: 1060px) { .figure { margin: 30px 0; } }
.figure .fig-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }

.stage-wrap { position: relative; width: 100%; overflow: hidden; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.caption { margin: 10px 2px 0; min-height: 84px; }
.cap-step { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .5px; }
.cap-text { font-size: 16px; line-height: 1.75; }

.controls { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: 14px; line-height: 1;
  padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); min-width: 86px; }
.btn.primary:hover { background: #111827; }
.dots { display: flex; gap: 6px; margin-left: 8px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: none; padding: 0; background: #e5e7eb; cursor: pointer; }
.dot.past { background: #94a3b8; }
.dot.on { background: var(--ink); transform: scale(1.15); }

/* formula panel under a figure */
.fpanel {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #f8fafc;
  font-family: "Times New Roman", "STIX Two Text", "Cambria Math", serif; font-size: 19px; line-height: 2;
  overflow-x: auto;
}
.fpanel .row { white-space: nowrap; }
.fpanel .row + .row { margin-top: 4px; }
.fpanel .ftag { display: inline-block; width: 78px; font-family: -apple-system, "PingFang SC", sans-serif; font-size: 13px; color: var(--muted); }
:lang(en) .fpanel .ftag { width: 100px; }
.fpanel sub, .fpanel sup { font-size: .68em; }
.term { display: inline-block; white-space: nowrap; vertical-align: baseline; line-height: 1.8; padding: 2px 5px; border-radius: 6px; transition: background-color .35s, box-shadow .35s; }
.term.on[data-c="read"] { background: rgba(37, 99, 235, .14); box-shadow: 0 0 0 1px rgba(37, 99, 235, .35); }
.term.on[data-c="write"] { background: rgba(234, 88, 12, .14); box-shadow: 0 0 0 1px rgba(234, 88, 12, .35); }
.term.on[data-c="mix"] { background: rgba(124, 58, 237, .14); box-shadow: 0 0 0 1px rgba(124, 58, 237, .35); }
.term.on[data-c="f"] { background: rgba(15, 118, 110, .14); box-shadow: 0 0 0 1px rgba(15, 118, 110, .35); }
.term.on[data-c="route"] { background: rgba(219, 39, 119, .13); box-shadow: 0 0 0 1px rgba(219, 39, 119, .35); }
.term.on[data-c="all"] { background: rgba(15, 23, 42, .07); box-shadow: 0 0 0 1px rgba(15, 23, 42, .2); }

/* ---------- animated elements ---------- */
.stage > div {
  position: absolute; left: 0; top: 0;
  transition: transform var(--t, .7s) cubic-bezier(.45, 0, .2, 1), opacity .45s ease, background-color .4s, box-shadow .3s, width .6s cubic-bezier(.45, 0, .2, 1);
  will-change: transform, opacity;
}
.stage svg.wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wire { fill: none; stroke-linecap: round; transition: stroke-dashoffset .55s ease, opacity .45s ease; }
.wire.static { stroke: #cbd5e1; }
.ahead { transition: opacity .3s ease .45s; }
.instant, .instant > div, .instant .wire, .instant * { transition: none !important; animation: none !important; }

.cell {
  width: 40px; height: 40px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  font-family: -apple-system, "PingFang SC", sans-serif;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .15);
  overflow: hidden;
}
.cell sub { font-size: 10px; margin-top: 6px; }
.cell.ghost { background: transparent; border: 2px dashed; box-shadow: none; opacity: .45; }
.cell.ucell { background: var(--slate); padding-bottom: 8px; }
.cell.ocell { background: var(--out); }
.cell.dcell { background: var(--out); }
.cell.mcell { padding-bottom: 8px; }
.cell.scell { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(15, 23, 42, .18); }
.cell.glow { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--s1), 0 0 18px 4px rgba(59, 130, 246, .55); }
.cell.flash { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--read); }
.cell.flash-w { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--write); }
.cell.flash-m { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--mix); }

.mixbar { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 6px; display: flex; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 255, 255, .85); }
.mixbar i { display: block; height: 100%; }

.lbl { font-size: 15px; color: var(--muted); white-space: nowrap; }
.lbl.rt { width: 78px; text-align: right; }
.rowlbl { width: 126px; text-align: right; font-size: 14px; color: var(--muted); white-space: nowrap; }
.rowlbl sub { font-size: 10px; }
.hdr { font-size: 15px; color: var(--ink); font-weight: 600; white-space: nowrap; font-family: "Times New Roman", "STIX Two Text", serif; }
.hdr.cn { font-family: -apple-system, "PingFang SC", sans-serif; font-weight: 500; color: var(--muted); font-size: 14px; }
.hdr sub { font-size: 11px; }
.pos { width: 40px; text-align: center; font-size: 13px; line-height: 20px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pos.hot { color: var(--s1); font-weight: 700; font-size: 15px; }
.bracket { height: 18px; border-top: 2px solid #d1d5db; text-align: center; font-size: 12px; color: var(--muted); line-height: 18px; }

.tag {
  font-size: 13.5px; padding: 3px 9px; border-radius: 8px; white-space: nowrap;
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  font-family: -apple-system, "PingFang SC", sans-serif;
}
.tag sub { font-size: 10px; }
.tag.kt { display: flex; align-items: center; gap: 7px; }
.tag.read { border-color: rgba(37, 99, 235, .45); color: var(--read); }
.tag.write { border-color: rgba(234, 88, 12, .45); color: var(--write); }
.tag.mix { border-color: rgba(124, 58, 237, .45); color: var(--mix); }

.window { border: 3px solid var(--read); border-radius: 12px; background: rgba(37, 99, 235, .05); }
.window.write { border-color: var(--write); background: rgba(234, 88, 12, .05); }
.window.mix { border-color: var(--mix); background: rgba(124, 58, 237, .05); }

.kernel {
  display: flex; align-items: center; gap: 8px; padding: 5px 9px; border-radius: 10px;
  background: #fff; border: 2px solid var(--read); box-shadow: 0 4px 14px rgba(37, 99, 235, .18);
  font-size: 14px; white-space: nowrap;
}
.kernel b { font-family: "Times New Roman", serif; font-style: italic; font-size: 16px; }
.kernel b sub { font-size: 11px; font-style: normal; }
.kernel.write { border-color: var(--write); box-shadow: 0 4px 14px rgba(234, 88, 12, .18); }
.kernel.mix { border-color: var(--mix); box-shadow: 0 4px 14px rgba(124, 58, 237, .18); }

.kern { display: flex; gap: 3px; }
.kern span { width: 22px; height: 22px; border-radius: 5px; display: block; }
.kern.sm span { width: 18px; height: 18px; border-radius: 4px; }
.kern.xs { gap: 2px; }
.kern.xs span { width: 12px; height: 12px; border-radius: 3px; }
.kern.lg span { width: 26px; height: 26px; border-radius: 6px; }
.mat { display: grid; grid-template-columns: repeat(4, 11px); gap: 2px; }
.mat span { width: 11px; height: 11px; border-radius: 2px; display: block; }
.mat.sm { grid-template-columns: repeat(4, 7px); gap: 1px; }
.mat.sm span { width: 7px; height: 7px; }
.mat.lg { grid-template-columns: repeat(4, 13px); }
.mat.lg span { width: 13px; height: 13px; }

.icon { padding: 6px; border-radius: 10px; background: #fff; border: 2px solid var(--mix); }
.icon.lit { box-shadow: 0 0 0 4px rgba(124, 58, 237, .18), 0 6px 18px rgba(124, 58, 237, .25); }

.fbox {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 12px; border: 2px solid var(--out); background: #f0fdfa; color: var(--out);
  font-size: 15px; font-family: -apple-system, "PingFang SC", sans-serif;
}
.fbox i { font-family: "Times New Roman", serif; font-size: 22px; }
.fbox.lit { background: #ccfbf1; box-shadow: 0 0 0 5px rgba(15, 118, 110, .15); }

.plus { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; background: #fff; }

/* experts scene */
.token {
  width: 80px; height: 34px; border-radius: 17px; border: 1.5px solid var(--line); background: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--muted);
}
.token.cur { border-color: var(--route); color: var(--route); font-weight: 700; box-shadow: 0 0 0 4px rgba(219, 39, 119, .12); }
.token.done { color: var(--ink); }
.router {
  display: flex; align-items: center; justify-content: center; border-radius: 12px;
  border: 2px solid var(--route); background: #fdf2f8; color: var(--route); font-size: 15px;
}
.router i { font-family: "Times New Roman", serif; font-size: 18px; margin-left: 6px; }
.router sub { font-size: 11px; }
.router.lit { box-shadow: 0 0 0 6px rgba(219, 39, 119, .14); background: #fce7f3; }
.bank { border-radius: 14px; border: 1.5px solid var(--line); background: #fcfcfd; }
.bank-h { font-size: 14.5px; font-weight: 600; white-space: nowrap; }
.bank-h sub { font-size: 10px; }
.bank-h.read { color: var(--read); }
.bank-h.write { color: var(--write); }
.bank-h.mix { color: var(--mix); }
.erow { width: 266px; height: 40px; border-radius: 10px; border: 1.5px solid transparent; }
.erow.sel { border-color: var(--route); background: #fff; box-shadow: 0 2px 10px rgba(219, 39, 119, .15); }
.erow.dim { opacity: .35; }
.ename { font-size: 12.5px; color: var(--muted); width: 28px; }
.track { width: 76px; height: 10px; border-radius: 5px; background: #eef2f7; overflow: hidden; }
.track > span { display: block; height: 100%; width: 0; background: var(--route); border-radius: 5px; transition: width .6s cubic-bezier(.45, 0, .2, 1); opacity: .75; }
.gval { font-size: 13px; color: var(--route); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slot { border-radius: 12px; border: 1.5px dashed #cbd5e1; background: #fff; }
.slot-l { font-size: 13px; color: var(--muted); white-space: nowrap; }
.pbox {
  border-radius: 12px; border: 2px solid; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 13px; line-height: 1.25; white-space: nowrap;
}
.pbox.read { border-color: var(--read); color: var(--read); }
.pbox.write { border-color: var(--write); color: var(--write); }
.pbox.mix { border-color: var(--mix); color: var(--mix); }
.pbox.lit { box-shadow: 0 0 0 5px rgba(219, 39, 119, .13); }
.mini { display: flex; gap: 2px; }
.mini span { width: 11px; height: 11px; border-radius: 2px; display: block; }
.mini span.gap { margin-left: 5px; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--route); box-shadow: 0 0 0 5px rgba(219, 39, 119, .2); }

/* numeric check */
.numcheck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1060px) { .numcheck { grid-template-columns: 1fr; } }
.nc-block { background: #f8fafc; border-radius: 12px; padding: 10px 12px; }
.nc-title { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; line-height: 1.5; }
.nc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.nc-grid div, .nc-strip div {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; text-align: center;
  padding: 4px 0; border-radius: 6px; color: #fff; font-variant-numeric: tabular-nums;
}
.nc-strip { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; margin-top: 12px; }
.nc-strip div { font-size: 11px; padding: 4px 0; }
.nc-strip div.gs { margin-left: 6px; }
/* Preserve interleaving in groups of four without squeezing numeric glyphs. */
@media (max-width: 1060px) {
  .nc-strip { grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: 8px; }
  .nc-strip div:nth-child(8n + 1) { margin-left: 0; }
}
@media (max-width: 600px) {
  .nc-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nc-strip div.gs { margin-left: 0; }
  .fpanel .ftag { display: block; width: auto; line-height: 1.5; margin-bottom: 4px; }
  .fpanel .row + .row { margin-top: 10px; }
  .eq.eq-left { padding-left: 18px; }
  table { font-size: 13.5px; display: block; overflow-x: auto; }
  th, td { padding: 8px 5px; }
}
.nc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.nc-status { font-size: 15px; }
.nc-status b { color: var(--s3); }

pre {
  background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 16px 18px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; line-height: 1.65;
}
pre .c { color: #94a3b8; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; background: #f1f5f9; padding: 1px 5px; border-radius: 5px; }
pre code { background: none; padding: 0; font-size: inherit; }

table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 15.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 14px; }
.summary { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 22px; }
.refs { font-size: 14.5px; color: var(--muted); }
.refs li { margin: 6px 0; }
