/* Asterism · 星图：深夜蓝，玻璃，克制。发光只留给那颗星。 */
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/assets/fonts/jbmono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --night: #060a1d;
  --night-2: #0a1131;
  --deep: #040716;
  --ink: #e9eeff;
  --ink-2: #c6d0f0;
  --dim: #9aa6cc;
  --faint: #6a76a0;
  --line: rgba(170, 200, 255, 0.16);
  --line-2: rgba(170, 200, 255, 0.28);
  --star: #eef5ff;
  --cyan: #3fd3ff;
  --bad: #ff6b7a;
  --ok: #5fe0b0;
  --paper: #eef1f8;
  --paper-2: #e4e9f4;
  --p-ink: #0f1634;
  --p-ink-2: #2c365c;
  --p-dim: #535d82;
  --p-line: rgba(15, 25, 70, 0.12);
  --t-scene: #62b4ff;
  --t-draw: #b394ff;
  --t-lit: #f2b866;
  --g: clamp(16px, 4vw, 56px);
  --wrap: 1200px;
  --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--night); color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--night);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
p, h1, h2, h3, figure, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
::selection { background: rgba(58, 116, 255, 0.45); color: #fff; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
.wrap { max-width: calc(var(--wrap) + 2 * var(--g)); margin: 0 auto; padding: 0 var(--g); }

/* ---------- 顶部 ---------- */
.top {
  position: absolute; inset: 0 0 auto 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 28px var(--g);
  max-width: calc(1440px); margin: 0 auto;
}
.home {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; font-size: 12.5px; font-weight: 500; letter-spacing: 0.22em; color: var(--ink);
  padding: 4px 2px;
}
.lang { display: flex; gap: 1.15em; font-size: 12.5px; letter-spacing: 0.08em; }
.lang a { color: var(--dim); text-decoration: none; transition: color 0.2s; }
.lang a:hover { color: var(--ink); }
.lang .here { color: var(--ink); position: relative; }
.lang .here::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--ink); }

/* 章节小导航 */
.toc {
  position: fixed; top: 16px; left: 50%; z-index: 20;
  display: flex; gap: 2px; padding: 5px;
  border-radius: 999px;
  background: rgba(10, 16, 44, 0.72);
  border: 1px solid var(--line-2);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 12px 30px -16px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -80px); opacity: 0;
  transition: transform 0.5s cubic-bezier(.2,.8,.2,1), opacity 0.4s;
}
.toc.show { transform: translate(-50%, 0); opacity: 1; }
.toc a {
  font-size: 12.5px; letter-spacing: 0.04em; color: var(--dim); text-decoration: none;
  padding: 6px 12px; border-radius: 999px; transition: color 0.2s, background-color 0.2s;
}
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); background: rgba(170, 200, 255, 0.12); }

/* ---------- 画框 ---------- */
.frame {
  position: relative; overflow: hidden; border-radius: 14px;
  border: 1px solid rgba(170, 200, 255, 0.24);
  box-shadow: 0 1px 0 rgba(234, 243, 255, 0.06) inset, 0 34px 80px -36px rgba(0, 0, 0, 0.85);
  background: #eef1f6;
}
.frame img { width: 100%; }
.pale .frame { border-color: rgba(15, 25, 70, 0.12); box-shadow: 0 26px 60px -30px rgba(20, 32, 90, 0.35); }
figcaption { font-size: 13px; line-height: 1.75; color: var(--dim); letter-spacing: 0.01em; }
.pale figcaption { color: var(--p-dim); }

/* ---------- 首屏 ---------- */
.hero {
  position: relative; overflow: hidden;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 104px 0 88px;
}
.hero-star {
  position: absolute; z-index: 0; top: 50%; right: max(-5vw, calc(50% - 960px));
  width: min(62vw, 1120px, 104vh);
  transform: translateY(-48%);
  pointer-events: none;
}
.hero-star img {
  width: 100%;
  -webkit-mask-image: radial-gradient(closest-side, #000 52%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 52%, transparent 100%);
  opacity: 0.92;
}
.hero-inner { position: relative; z-index: 1; width: 100%; }
.hero-text { max-width: min(37rem, 47vw); }
.kicker { display: flex; align-items: center; gap: 14px; font-size: 13px; letter-spacing: 0.16em; color: var(--dim); margin-bottom: 26px; }
.app-icon { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 0 0 1px rgba(170, 205, 255, 0.16); }
.kicker .year { color: var(--ink-2); padding-left: 14px; border-left: 1px solid var(--line-2); }
h1 {
  font-size: clamp(56px, 6.6vw, 112px); font-weight: 600; letter-spacing: -0.045em; line-height: 0.92;
  margin-left: -0.05em; color: #f3f6ff;
}
.hero-line { margin-top: 22px; font-size: clamp(22px, 2.1vw, 32px); font-weight: 500; letter-spacing: 0.01em; color: var(--ink); }
.hero-p1 { margin-top: 24px; font-size: 16.5px; line-height: 1.9; color: var(--ink-2); }
.hero-p2 { margin-top: 12px; font-size: 15.5px; line-height: 1.9; color: var(--dim); }

/* ---------- 章的小标 ---------- */
.ch-tag { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 13px; letter-spacing: 0.18em; color: var(--cyan); }
.ch-tag::before { content: ""; width: 18px; height: 1px; background: currentColor; }
.pale .ch-tag { color: #1d5fd6; }

/* ---------- 章节通用 ---------- */
.ch { position: relative; padding: clamp(56px, 5.4vw, 80px) 0; }
@media (min-width: 601px) { .ph { display: inline-block; } }
.dark { background: linear-gradient(180deg, var(--night) 0%, var(--night-2) 55%, var(--night) 100%); }
.deep { background: radial-gradient(1200px 700px at 50% 30%, #0d1747 0%, var(--deep) 70%); }
.pale { background: var(--paper); color: var(--p-ink); color-scheme: light; }
/* 两段深色底接在一起时（第一章下半接第二章），用一条极淡的线分开 */
.dark + .deep { box-shadow: inset 0 1px 0 rgba(170, 200, 255, 0.1); }
.ch-head { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 24px clamp(40px, 6vw, 96px); align-items: start; }
.ch-head h2 {
  font-size: clamp(27px, 2.65vw, 38px); font-weight: 600; line-height: 1.38; letter-spacing: -0.012em;
  color: #f3f6ff; text-wrap: balance;
}
.pale .ch-head h2 { color: var(--p-ink); }
.ch-body { padding-top: 8px; display: grid; gap: 14px; }
.ch-body p { font-size: 16.5px; line-height: 1.95; color: var(--dim); }
.pale .ch-body p { color: var(--p-dim); }
h3 { font-size: 21px; font-weight: 600; line-height: 1.45; letter-spacing: -0.005em; }
.copy-store { display: none; }
.txt { font-size: 16.5px; line-height: 1.95; color: var(--dim); }
.pale .txt { color: var(--p-dim); }
.lead { max-width: 40em; margin: 0 auto; font-size: clamp(18px, 1.45vw, 20px); line-height: 1.9; color: var(--ink); }
.pale .lead { color: var(--p-ink); }
.lead-gap { margin-top: clamp(64px, 6.4vw, 96px); }
.bridge { max-width: 40em; margin: clamp(56px, 5.6vw, 80px) auto 0; color: var(--ink-2); }
/* 正文里的加粗只亮一档；行内代码用等宽字，不加底色 */
.ch strong { font-weight: 500; color: var(--ink-2); }
.pale strong { color: var(--p-ink-2); }
.ch :not(pre) > code { font-family: var(--mono); font-size: 0.9em; letter-spacing: 0; }
.ch strong code { font-weight: 400; }

.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2,.8,.2,1); }
.js .reveal.in { opacity: 1; transform: none; }

.btn {
  appearance: none; font: inherit; font-size: 14px; letter-spacing: 0.02em; color: var(--ink);
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 18px 10px 15px; border-radius: 999px;
  background: rgba(120, 160, 255, 0.06); border: 1px solid var(--line-2);
  cursor: pointer; transition: border-color 0.25s, background-color 0.25s, transform 0.2s;
}
.btn:hover { border-color: rgba(200, 228, 255, 0.62); background: rgba(120, 160, 255, 0.12); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn-ghost {
  appearance: none; font: inherit; font-size: 13px; color: var(--dim); background: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--line-2); }
.btn-ghost[disabled] { opacity: 0.4; cursor: default; }
.btn-ghost[disabled]:hover { color: var(--dim); border-color: var(--line); }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.dot-human { background: var(--ink-2); }
.dot-ai { background: var(--cyan); }
.dot-bad { border: 1.5px solid var(--bad); }

/* ---------- 节点和图文件 ---------- */
.bg-fig { display: grid; gap: 12px; }
.bg-fig .frame { border-radius: 12px; }
.bg-fig figcaption { font-size: 12.5px; }

/* ---------- 第一章：查看器 ---------- */
.viewer { margin-top: clamp(44px, 4.6vw, 64px); }
.vw-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.vw-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--p-line); }
.vw-tabs button {
  appearance: none; font: inherit; font-size: 14px; color: var(--p-dim); background: none; border: 0; cursor: pointer;
  padding: 7px 18px; border-radius: 999px; transition: color 0.2s, background-color 0.2s;
}
.vw-tabs button:hover { color: var(--p-ink); }
.vw-tabs button[aria-selected="true"] { color: var(--p-ink); background: #fff; box-shadow: 0 1px 3px rgba(15, 25, 70, 0.15); }
#viewer .seg { transition: opacity 0.3s; }
#viewer.not-ov .seg { opacity: 0; visibility: hidden; }
.vw-stage { margin-top: 14px; }
.vw-p:not([hidden]) { animation: ev-in 0.5s ease; }
.vw-box { aspect-ratio: 2302 / 1024; display: flex; align-items: center; justify-content: center; }
.vw-box .frame { width: 100%; }
.vw-box .vw-narrow { width: auto; height: 100%; }
.vw-box .vw-narrow img { height: 100%; width: auto; }
.vw-p figcaption { margin-top: 10px; font-size: 12.5px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--p-line); }
.seg button {
  appearance: none; font: inherit; font-size: 13px; color: var(--p-dim); background: none; border: 0;
  padding: 6px 16px; border-radius: 999px; cursor: pointer; transition: color 0.2s, background-color 0.2s;
}
.seg button[aria-checked="true"] { color: var(--p-ink); background: #fff; box-shadow: 0 1px 3px rgba(15, 25, 70, 0.15); }
.ov-frame .ov-dark { position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s ease; }
.ov-frame[data-theme="dark"] .ov-dark { opacity: 1; }

/* ---------- 第一章：引脚和编译 ---------- */
.pins {
  margin-top: clamp(44px, 4.4vw, 60px); padding: clamp(20px, 3vw, 34px); border-radius: 20px;
  background: linear-gradient(180deg, rgba(22, 32, 82, 0.62), rgba(14, 22, 60, 0.5));
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(234, 243, 255, 0.06) inset, 0 40px 90px -50px rgba(0, 0, 0, 0.9);
}
.pins-head { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; flex-wrap: wrap; }
.pins-title { font-size: 17px; font-weight: 500; }
.pins-hint { font-size: 13px; color: var(--faint); }
.pins-board { position: relative; margin-top: 24px; min-height: 270px; display: flex; justify-content: space-between; gap: 18%; }
.pins-wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 2; }
.pins-col { position: relative; z-index: 1; flex: 1 1 0; max-width: 300px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; }
.pn-card {
  border-radius: 11px; background: rgba(30, 44, 100, 0.5); border: 1px solid rgba(170, 200, 255, 0.2);
  padding: 10px 14px 11px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.pn-card .pn-title { font-size: 13.5px; font-weight: 600; letter-spacing: 0.005em; }
.pn-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pins-out .pn-row { justify-content: flex-end; text-align: right; }
.pn-name { font-size: 13px; color: var(--ink-2); }
.pn-type { display: block; font-size: 11.5px; letter-spacing: 0.02em; color: var(--tc); margin-top: 1px; }
.pin {
  --tc: #fff;
  flex: none; position: relative; width: 22px; height: 22px; margin: -2px -26px -2px 0;
  border-radius: 50%; border: 2px solid var(--tc); background: #0b1236; cursor: grab; padding: 0;
  transition: transform 0.2s;
}
.pins-in .pin { margin: -2px 0 -2px -26px; }
.pin::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--tc); opacity: 0; transition: opacity 0.2s; }
.pin.linked::after, .pin.armed::after { opacity: 1; }
.pin:hover { transform: scale(1.15); }
.pin.armed { transform: scale(1.2); }
.pin.target-ok { transform: scale(1.25); }
.pin.target-bad { border-color: var(--bad); }
.pins-wires path { fill: none; stroke-width: 2; stroke-linecap: round; }
.pins-wires .w-drag { stroke-dasharray: 5 6; opacity: 0.85; }
.pins-wires .w-bad { stroke: var(--bad); stroke-dasharray: 5 6; transition: opacity 0.7s ease 0.5s; }
.pins-wires .w-bad.fade { opacity: 0; }
.pins-foot { margin-top: 26px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 18px; }
.pins-msg { flex: 1 1 340px; min-height: 2.9em; font-size: 14px; line-height: 1.6; color: var(--ink-2); display: flex; flex-direction: column; justify-content: center; }
.pins-msg .pm-en { font-family: var(--mono); font-size: 12.5px; color: var(--bad); }
.pins-msg .pm-en:empty { display: none; }
.pins-count { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.pins-count .pc-n { color: var(--ink); }
.pins figcaption { margin-top: 16px; }

.evidence { margin-top: clamp(40px, 4vw, 56px); }
.ev-head { display: flex; justify-content: space-between; align-items: center; gap: 16px 24px; flex-wrap: wrap; }
.ev-intro { font-size: 15px; color: var(--dim); }
.ev-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; border: 1px solid var(--line); background: rgba(10, 16, 44, 0.5); }
.ev-tabs button {
  appearance: none; font: inherit; font-size: 13.5px; color: var(--dim); background: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 15px 7px 11px; border-radius: 999px;
  transition: color 0.2s, background-color 0.2s;
}
.ev-tabs button b { font-weight: 500; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.ev-tabs button:hover { color: var(--ink); }
.ev-tabs button[aria-selected="true"] { color: var(--ink); background: rgba(170, 200, 255, 0.14); }
.ev-tabs button[aria-selected="true"] b { color: var(--ink-2); }
.ev-stage { margin-top: 22px; }
.ev-p { display: grid; gap: 16px; }
.ev-p:not([hidden]) { animation: ev-in 0.5s ease; }
@keyframes ev-in { from { opacity: 0; } to { opacity: 1; } }
.ev-img { min-height: 0; display: flex; align-items: center; justify-content: center; gap: 18px; }
.ev-img img { max-height: 360px; width: auto; max-width: 100%; }
#ev-p4 .ev-img img { max-height: 360px; }
.ev-pair { align-items: center; }
.ev-pair .frame { height: 360px; }
.ev-pair .frame:first-child { height: 200px; }
.ev-pair img { height: 100%; width: auto; max-height: none; }
.ev-p figcaption { font-size: 14.5px; color: var(--ink-2); max-width: 52em; }

/* ---------- 第二章：写路径 ---------- */
.wp {
  margin-top: clamp(44px, 4.4vw, 60px); padding: clamp(20px, 3vw, 36px); border-radius: 22px;
  background: linear-gradient(180deg, rgba(20, 30, 80, 0.55), rgba(10, 16, 48, 0.55));
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(234, 243, 255, 0.06) inset, 0 50px 100px -60px rgba(0, 0, 0, 0.95);
}
.wp-flow { min-height: 216px; align-items: start; display: grid; grid-template-columns: 132px 30px minmax(0, 1fr) 30px minmax(0, 1fr) 30px minmax(0, 1.08fr) 30px minmax(0, 1.12fr); }
.wp-src { display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.src { padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); opacity: 0.55; transition: opacity 0.4s, border-color 0.4s; }
.src b { display: block; font-size: 14px; font-weight: 600; }
.src span { display: block; margin-top: 2px; font-size: 12px; color: var(--dim); }
.src.on { opacity: 1; border-color: rgba(170, 220, 255, 0.55); }
.rail { position: relative; display: flex; align-items: center; height: 1px; margin-top: 54px; }
.rail > i { position: relative; display: block; width: 100%; height: 1px; background: var(--line-2); overflow: hidden; }
.rail > i > i { position: absolute; inset: 0; background: var(--cyan); transform: scaleX(0); transform-origin: left; transition: transform 0.45s ease; }
.rail.on > i > i { transform: scaleX(1); }
.rail.bad > i > i { background: var(--bad); }
.stage {
  position: relative; padding: 16px 16px 18px; border-radius: 14px;
  background: rgba(14, 22, 60, 0.6); border: 1px solid var(--line);
}
.stage::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1px solid rgba(120, 220, 255, 0.6); opacity: 0; transition: opacity 0.4s; pointer-events: none; }
.stage.on::before { opacity: 1; }
.stage.fail::before { border-color: rgba(255, 107, 122, 0.75); opacity: 1; }
.st-n { font-size: 11.5px; color: var(--faint); letter-spacing: 0.1em; font-variant-numeric: tabular-nums; }
.stage h3 { margin-top: 6px; font-size: 15px; line-height: 1.45; }
.st-d { margin-top: 8px; font-size: 13.5px; line-height: 1.72; color: var(--dim); transition: opacity 0.3s; }
.stage.on .st-d, .stage.fail .st-d { color: var(--ink-2); }
.stage.fail .st-d { color: #ffc9cf; }
.gate-star {
  position: absolute; top: 14px; right: 16px; width: 20px; height: 20px; fill: var(--ink-2);
}
.stage-gate.pass .gate-star { animation: star-pass 1s ease-out; }
.stage-gate.fail .gate-star { fill: var(--bad); animation: star-fail 0.7s ease-out; }
@keyframes star-pass { 0% { transform: scale(1) rotate(0); } 30% { transform: scale(1.5) rotate(45deg); } 100% { transform: scale(1) rotate(90deg); } }
@keyframes star-fail { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.outs { margin-top: 8px; display: grid; gap: 8px; }
.out { padding: 8px 11px; border-radius: 10px; border: 1px solid var(--line); opacity: 0.6; transition: opacity 0.4s, border-color 0.4s; }
.out b { display: block; font-size: 14px; font-weight: 600; }
.out span { display: block; font-size: 12px; color: var(--dim); }
.stage-out.ok .out-ok { opacity: 1; border-color: rgba(95, 224, 176, 0.6); }
.stage-out.ok .out-bad { display: none; }
.stage-out.bad .out-bad { opacity: 1; border-color: rgba(255, 107, 122, 0.7); }
.stage-out.bad .out-ok { display: none; }
.stage-out .st-d { min-height: 0; }

.wp-controls { margin-top: 28px; display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.wp-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.wp-buttons[aria-busy="true"] .btn { cursor: progress; }
.stepper { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--dim); cursor: pointer; margin-left: auto; }
.stepper input { width: 16px; height: 16px; accent-color: var(--cyan); margin: 0; }
.btn-next { border-color: rgba(120, 220, 255, 0.6); }

.wp-lower { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 18px; }
.panel { border-radius: 16px; border: 1px solid var(--line); background: rgba(8, 13, 40, 0.55); padding: 16px 18px 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-title { font-size: 12.5px; letter-spacing: 0.14em; color: var(--faint); }
.panel-tools { display: flex; gap: 8px; }
.mini { position: relative; height: 250px; margin-top: 14px; }
.mini-wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.mini-wires path { fill: none; stroke: rgba(180, 205, 255, 0.45); stroke-width: 1.4; }
.mini-wires path.badw { stroke: var(--bad); stroke-dasharray: 4 4; stroke-width: 1.6; }
.mn {
  position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); width: 16.5%;
  padding: 7px 9px 8px; border-radius: 9px;
  background: rgba(30, 44, 100, 0.6); border: 1px solid rgba(170, 200, 255, 0.2);
}
.mn::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1.5px solid var(--bad); opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.mn::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1.5px solid var(--cyan); opacity: 0; transition: opacity 0.6s; pointer-events: none; }
.mn.err::before { opacity: 1; }
.mn.fresh::after { opacity: 1; }
.mn.flash::before { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 50% { opacity: 1; } 100% { opacity: 0; } }
.mn b { display: block; font-size: 12px; font-weight: 600; line-height: 1.35; }
.mn-pin { display: block; margin-top: 4px; font-size: 10.5px; line-height: 1.4; color: var(--dim); }
.mn-pin em { font-style: normal; color: var(--ink-2); }
/* 中文的值很短（「原来的」「没有描述」），整个换到下一行，不在最后一行剩一个字 */
:root:lang(zh) .mn-pin em { white-space: nowrap; }
.mn-pin em.bad { color: var(--bad); }
.mn-pin em.new { color: var(--cyan); }
.panel-msg { margin-top: 10px; min-height: 3.2em; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.panel-msg.bad { color: #ffc9cf; }
.chron { margin-top: 12px; display: grid; gap: 2px; }
.chron li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; padding: 9px 2px; border-bottom: 1px solid rgba(170, 200, 255, 0.08); }
.chron li.new { animation: row-in 0.55s cubic-bezier(.2,.8,.2,1); }
.chron li.old { opacity: 0.55; }
@keyframes row-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.ci { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 12px; line-height: 1; color: var(--ink-2); }
.ci.ok { border-color: rgba(95, 224, 176, 0.55); color: var(--ok); }
.ci.bad { border-color: rgba(255, 107, 122, 0.6); color: var(--bad); }
.ci.chg { border-color: rgba(242, 184, 102, 0.55); color: var(--t-lit); }
.chron b { display: block; font-size: 13.5px; font-weight: 600; }
.chron b.bad { color: #ff9aa5; }
.chron span { display: block; font-size: 12px; line-height: 1.55; color: var(--dim); }

.wp-title { font-size: 13px; letter-spacing: 0.16em; color: var(--faint); margin-bottom: 18px; }

/* ---------- 第二章：设置、Chronicle 和 AI 面板 ---------- */
.mcp-set { margin-top: 30px; }
.mcp-set figcaption { margin-top: 10px; font-size: 12.5px; }
.mcp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.46fr); gap: clamp(32px, 3.6vw, 52px) clamp(32px, 4.5vw, 72px); align-items: center; }
.mcp-text { grid-column: 1; grid-row: 1; font-size: 17.5px; line-height: 1.95; color: #434d72; }
.pale .mcp-text strong { color: #1f2850; }
.mcp-ai { grid-column: 2; grid-row: 1; }
.chron-fig { grid-column: 1 / -1; grid-row: 2; }
.mcp figcaption { margin-top: 12px; }
.mcp-ai figcaption { font-size: 12.5px; }

/* ---------- 第三章：两层 Harness ---------- */
.hn {
  margin-top: clamp(48px, 5vw, 72px); border-radius: 22px; overflow: hidden;
  border: 1px solid var(--line); background: rgba(8, 13, 40, 0.4);
  box-shadow: 0 1px 0 rgba(234, 243, 255, 0.05) inset, 0 50px 100px -60px rgba(0, 0, 0, 0.9);
}
.hn-row { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: clamp(28px, 4vw, 64px); align-items: center; padding: clamp(24px, 3.2vw, 44px); }
.hn-row .txt { font-size: 15.5px; line-height: 1.95; }
.hn-in { background: linear-gradient(180deg, rgba(58, 96, 210, 0.12), rgba(58, 96, 210, 0.05)); }
.hn-out { border-top: 1px solid var(--line); }
.hn-label { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 13px; letter-spacing: 0.16em; color: var(--ink-2); }
.hn-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--cyan); }
.hn-out .hn-label::before { border-color: var(--ink-2); }
.hn-chain { position: relative; display: grid; align-items: stretch; }
.hn-3 { grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr); }
.hn-4 { grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr); padding-bottom: 30px; }
.hn-node { padding: 14px 14px 15px; border-radius: 14px; background: rgba(14, 22, 60, 0.72); border: 1px solid var(--line-2); }
.hn-node b { display: block; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.hn-node span { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.7; color: var(--dim); }
.hn-rail, .hn-loop { --c: rgba(170, 200, 255, 0.42); }
.hn-rail { position: relative; align-self: center; height: 1px; background: var(--c); }
.hn-rail::after { content: ""; position: absolute; right: 0; top: -3px; width: 6px; height: 6px; border-top: 1px solid var(--c); border-right: 1px solid var(--c); transform: rotate(45deg); }
/* 从 BugFix 下面绕回 Dev */
.hn-loop { position: absolute; bottom: 6px; height: 24px; left: calc((100% - 84px) * 0.375 + 28px); right: calc((100% - 84px) / 8); border: 1px solid var(--c); border-top: 0; border-radius: 0 0 12px 12px; }
.hn-loop::after { content: ""; position: absolute; left: -4px; top: -1px; width: 7px; height: 7px; border-top: 1px solid var(--c); border-left: 1px solid var(--c); transform: rotate(45deg); }

/* ---------- 第四章：判断 ---------- */
.jd-row { margin-top: clamp(48px, 5vw, 72px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 4.5vw, 72px); align-items: center; }
.jd-flip .txt { order: 2; }
.jd { padding: clamp(22px, 2.6vw, 34px); border-radius: 20px; background: #fbfcfe; border: 1px solid var(--p-line); box-shadow: 0 30px 60px -44px rgba(20, 32, 90, 0.4); }
.jd-title { padding-bottom: 14px; border-bottom: 1px solid var(--p-line); font-size: 13px; letter-spacing: 0.16em; color: var(--p-dim); }
.jd-pair { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 0.82fr) 44px minmax(0, 1.18fr); align-items: center; gap: 10px; }
.jd-pair span { display: block; margin-bottom: 8px; font-size: 12.5px; letter-spacing: 0.08em; }
.jd-pair b { display: block; font-size: 16.5px; line-height: 1.65; }
.jd-from span { color: #a0a7c0; }
.jd-from b { font-weight: 400; color: #8f97b4; }
.jd-to span { color: #1d5fd6; }
.jd-to b { font-weight: 600; color: var(--p-ink); }
.jd-arrow { --c: #a3abc6; position: relative; justify-self: center; width: 26px; height: 1px; background: var(--c); }
.jd-arrow::after { content: ""; position: absolute; right: 0; top: -3px; width: 6px; height: 6px; border-top: 1px solid var(--c); border-right: 1px solid var(--c); transform: rotate(45deg); }
.jd-real { margin-top: clamp(64px, 6.4vw, 96px); display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr); gap: clamp(28px, 3.6vw, 56px); align-items: center; }
/* 同一处拆成两份：左边只有谁连着谁，右边只有位置 */
.sp { --sp-gap: 14px; --sp-line: #8a93b3; margin-top: -12px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; column-gap: var(--sp-gap); }
.sp-fork { grid-column: 1 / -1; position: relative; height: 30px; }
.sp-fork::before { content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 15px; background: var(--sp-line); }
.sp-fork::after { content: ""; position: absolute; top: 15px; bottom: 0; left: calc((100% - var(--sp-gap)) / 4); right: calc((100% - var(--sp-gap)) / 4); border: 1px solid var(--sp-line); border-bottom: 0; border-radius: 9px 9px 0 0; }
.sp-card {
  grid-row: 2 / span 3; display: grid; grid-template-rows: subgrid; min-width: 0;
  border-radius: 14px; border: 1px solid var(--p-line); background: #fbfcfe; overflow: hidden;
  box-shadow: 0 30px 60px -44px rgba(20, 32, 90, 0.4);
}
.sp-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; padding: 11px 16px 12px; background: #121a3e; color: #eef1f8; }
.sp-head b { font-size: 13.5px; font-weight: 600; letter-spacing: 0.06em; }
.sp-file { font: 12px/1.4 var(--mono); color: #9fe6ff; }
.sp-graph { display: flex; flex-direction: column; align-items: flex-start; padding: 18px 16px 16px; }
.sp-node { display: inline-block; max-width: 100%; padding: 5px 12px 6px; border-radius: 999px; border: 1px solid; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--p-ink); }
.sp-n1 { background: #f8e0e6; border-color: #e9b2bf; }
.sp-n2 { background: #dce8f9; border-color: #a9c4ec; }
.sp-edge { position: relative; display: flex; flex-direction: column; gap: 1px; margin-left: 22px; padding: 9px 0 11px 14px; border-left: 1.5px solid #8a93b3; }
.sp-edge::after { content: ""; position: absolute; left: -4.75px; bottom: 1px; width: 6px; height: 6px; border-right: 1.5px solid #8a93b3; border-bottom: 1.5px solid #8a93b3; transform: rotate(45deg); }
.sp-pin { font-size: 12.5px; line-height: 1.4; color: var(--p-ink-2); }
.sp-type { font: 11.5px/1.4 var(--mono); color: #1d5fd6; }
.sp-grid {
  position: relative; min-height: 120px; margin: 16px 16px 16px; border-radius: 10px; border: 1px solid var(--p-line);
  background-color: #f3f5fa; background-image: radial-gradient(circle, rgba(15, 25, 70, 0.22) 1px, transparent 1.4px); background-size: 14px 14px; background-position: 6px 6px;
}
.sp-box { position: absolute; display: flex; align-items: center; gap: 8px; width: 60%; }
.sp-box i { position: relative; flex: 1 1 auto; height: 28px; border-radius: 8px; border: 1.5px solid #5d6790; background: #fbfcfe; }
.sp-box i::before { content: ""; position: absolute; left: -4.5px; top: -4.5px; width: 7px; height: 7px; border-radius: 50%; background: #1d5fd6; }
.sp-box span { flex: none; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--p-line); background: #fbfcfe; font: 11px/1 var(--mono); color: var(--p-dim); }
.sp-b1 { left: 9%; top: 20%; }
.sp-b2 { left: 33%; top: 58%; }
.sp-tags { display: flex; flex-wrap: wrap; align-content: start; gap: 6px; padding: 0 16px 12px; }
.sp-tags li { padding: 3px 10px 4px; border-radius: 999px; border: 1px solid var(--p-line); background: var(--paper); font-size: 12px; line-height: 1.45; color: var(--p-ink-2); }
.sp-foot { display: grid; align-content: start; }
/* 右卡少一行字：不跟左卡对行，让点阵把多出来的高度占满 */
.sp-view { display: flex; flex-direction: column; }
.sp-view .sp-grid { flex: 1 1 auto; }
.sp-view .sp-tags { padding-bottom: 16px; }
.sp-no { display: flex; align-items: center; gap: 8px; padding: 0 16px 16px; font-size: 13.5px; font-weight: 600; line-height: 1.4; color: #1d5fd6; }
.sp-no::before { content: ""; flex: none; width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; background: linear-gradient(45deg, transparent 44%, currentColor 44%, currentColor 56%, transparent 56%); }
.tree { border-radius: 16px; border: 1px solid var(--p-line); background: #fbfcfe; padding: 16px 20px; box-shadow: 0 30px 60px -44px rgba(20, 32, 90, 0.4); }
.tree li { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr); gap: 12px; padding: 8px 0; font-size: 13.5px; line-height: 1.55; align-items: baseline; }
.tree li + li { border-top: 1px solid rgba(15, 25, 70, 0.06); }
.tree .tn { font-family: var(--mono); font-size: 12.5px; color: var(--p-ink-2); overflow-wrap: anywhere; }
.tree .td { color: var(--p-dim); }
.tree .t-dir .tn { color: var(--p-ink); }
.tree .t-sub .tn { padding-left: 16px; position: relative; }
.tree .t-sub .tn::before { content: ""; position: absolute; left: 4px; top: 0.75em; width: 7px; height: 1px; background: #8a93b3; }
.tree .t-key .tn { color: #1d5fd6; }

/* ---------- 尾声 ---------- */
.epi { position: relative; padding: clamp(104px, 10vw, 160px) 0 clamp(28px, 3vw, 44px); text-align: center; background: radial-gradient(900px 520px at 50% 0%, #0d1747 0%, var(--night) 72%); }
.epi-inner { max-width: calc(40rem + 2 * var(--g)); }
.epi-tag { justify-content: center; margin-bottom: 28px; }
.epi-tag::after { content: ""; width: 18px; height: 1px; background: currentColor; }
.epi-big .ph { display: inline-block; }
.epi-big { font-size: clamp(24px, 2.3vw, 33px); font-weight: 500; line-height: 1.6; letter-spacing: 0.005em; color: #f3f6ff; text-wrap: balance; }
.epi-p { margin-top: 26px; font-size: 16.5px; line-height: 2; color: var(--dim); text-wrap: balance; }

/* ---------- 结尾 ---------- */
.end { position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 0 clamp(72px, 7vw, 104px); background: var(--night); }
.plumb { width: 1px; height: clamp(72px, 7vw, 104px); background: linear-gradient(180deg, rgba(170, 205, 255, 0), rgba(170, 205, 255, 0.5)); }
.end-star { width: 14px; height: 14px; margin: 14px 0 16px; fill: var(--star); }
.home-end { letter-spacing: 0.12em; }

/* ---------- 截图与减弱动效 ---------- */
.shot *, .shot *::before, .shot *::after { animation: none !important; transition: none !important; }
.shot .reveal { opacity: 1 !important; transform: none !important; }
.shot { scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) {
  .toc { display: none; }
  .wp-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; min-height: 0; align-items: stretch; }
  .wp-src { grid-column: 1 / -1; flex-direction: row; }
  .wp-src .src { flex: 1; }
  .rail { display: none; }
  .sp-head { flex-direction: column; align-items: flex-start; }
  .st-d { min-height: 0; }
}
@media (max-width: 860px) {
  .ch-head, .mcp, .hn-row, .jd-row, .jd-real { grid-template-columns: minmax(0, 1fr); }
  .mcp-text, .mcp-ai, .chron-fig { grid-column: auto; grid-row: auto; }
  .jd-flip .txt { order: 0; }
  .ev-stage { height: auto; }
  .ev-img img, #ev-p4 .ev-img img { max-height: none; width: 100%; }
  .ev-pair { display: grid; grid-template-columns: minmax(0, 0.55fr) minmax(0, 1fr); align-items: start; gap: 10px; }
  .ev-pair .frame, .ev-pair .frame:first-child { height: auto; }
  .ev-pair img { height: auto; width: 100%; }
  .wp-lower { grid-template-columns: minmax(0, 1fr); }
  .vw-box { aspect-ratio: auto; }
  .vw-box .vw-narrow { width: 100%; height: auto; }
  .vw-box .vw-narrow img { width: 100%; height: auto; }
  .mcp-ai .frame { max-width: 360px; }
  .mcp-set { margin-top: 24px; }
}
@media (max-width: 600px) {
  .hero { justify-content: flex-start; padding: 0 0 56px; }
  .hero-star { width: 124vw; right: -44vw; top: 44px; transform: none; opacity: 0.55; }
  .hero-text { max-width: none; }
  .ev-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; border-radius: 14px; }
  .ev-tabs button { flex-direction: column; gap: 1px; padding: 7px 2px; border-radius: 10px; font-size: 12.5px; }
  .hero-inner { padding-top: 132px; margin-top: auto; }
  .ch-body p, .txt { font-size: 16px; }
  .lead { font-size: 17.5px; }
  .mcp-text { font-size: 16.5px; }
  .pins-board { gap: 10%; min-height: 360px; }
  .pn-card { padding: 9px 10px 10px; }
  .pn-card .pn-title { font-size: 12.5px; }
  .pn-name { font-size: 12px; }
  .pn-type { font-size: 10.5px; }
  .wp-flow { grid-template-columns: minmax(0, 1fr); }
  .stage-gate .gate-star { top: 14px; }
  .stepper { margin-left: 0; }
  .mini { height: 300px; }
  .mn { left: calc(var(--mx) * 1%); top: calc(var(--my) * 1%); width: 48%; }
  .hn-row { padding: 22px 18px 24px; }
  .hn-row .txt { font-size: 15.5px; }
  /* 链条竖排：每格一样高，绕回的线走右边 */
  .hn-3, .hn-4 { grid-template-columns: minmax(0, 1fr); }
  .hn-4 { grid-template-rows: 1fr 18px 1fr 18px 1fr 18px 1fr; padding: 0 32px 0 0; }
  .hn-rail { align-self: stretch; justify-self: start; width: 1px; height: 18px; margin-left: 24px; }
  .hn-rail::after { right: -3px; top: auto; bottom: 1px; transform: rotate(135deg); }
  .hn-loop { left: auto; right: 8px; width: 24px; height: auto; top: calc((100% - 54px) * 0.375 + 18px); bottom: calc((100% - 54px) / 8); border: 1px solid var(--c); border-left: 0; border-radius: 0 12px 12px 0; }
  .hn-loop::after { left: 0; top: -4px; border-top: 0; border-bottom: 1px solid var(--c); }
  .jd-pair { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .jd-arrow { justify-self: start; width: 1px; height: 20px; margin-left: 10px; }
  .jd-arrow::after { right: -3px; top: auto; bottom: 1px; transform: rotate(135deg); }
  .tree li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .sp { --sp-gap: 10px; }
  .sp-head { padding: 10px 12px 11px; }
  .sp-head b { font-size: 13px; }
  .sp-file { font-size: 11px; }
  .sp-graph { padding: 14px 12px 12px; }
  .sp-node { font-size: 12px; padding: 4px 10px 5px; }
  .sp-edge { margin-left: 16px; padding-left: 11px; }
  .sp-grid { margin: 12px; min-height: 104px; }
  .sp-box { width: 66%; gap: 5px; }
  .sp-b1 { left: 8%; }
  .sp-b2 { left: 26%; }
  .sp-tags { padding: 0 12px 10px; gap: 5px; }
  .sp-tags li { font-size: 11.5px; padding: 2px 8px 3px; }
  .sp-no { padding: 0 12px 12px; font-size: 13px; }
  .epi-p { text-align: left; }
  .epi-big { font-size: 22px; }
  .hero-line { font-size: 20px; }
}

/* 正文的换行：尽量不让最后一行只剩一个字（tools/check-typo.mjs 会量）。已经指定了 balance 的标题不受影响 */
p, li, figcaption, dd, dt, blockquote, td, th { text-wrap: pretty; }
h3, h4 { text-wrap: balance; }

/* ---------- Languages: English and Japanese pages (the Chinese page is not affected) ---------- */
:root:lang(ja) {
  --sans: "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}
:lang(en) .kicker { letter-spacing: 0.06em; }
:lang(en) .ch-tag { letter-spacing: 0.06em; }
:lang(en) .wp-title, :lang(en) .panel-title { letter-spacing: 0.06em; }
:lang(en) .toc a { letter-spacing: 0.02em; }
:lang(en) .hero-line { letter-spacing: 0; }
:lang(en) .ch-head h2 { font-size: clamp(26px, 2.3vw, 32px); line-height: 1.3; }
:lang(en) .epi-big { font-size: clamp(22px, 2.1vw, 30px); }
:lang(en) .ch-body p { line-height: 1.75; }
:lang(en) .hn-label, :lang(en) .jd-title { letter-spacing: 0.06em; }
:lang(en) .sp-head b { letter-spacing: 0.02em; }
:lang(ja) .sp-head b { letter-spacing: 0.04em; }
/* Japanese: break headings and short labels between phrases, not inside words; looser tracking on labels */
:lang(ja) h1, :lang(ja) h2, :lang(ja) h3, :lang(ja) .hero-line,
:lang(ja) .btn, :lang(ja) .src, :lang(ja) .ev-tabs, :lang(ja) .vw-tabs, :lang(ja) .out, :lang(ja) .td, :lang(ja) .pins-title,
:lang(ja) .hn-label, :lang(ja) .hn-node span, :lang(ja) .jd-title, :lang(ja) .jd-pair b, :lang(ja) .epi-big,
:lang(ja) .sp-head b, :lang(ja) .sp-tags li { word-break: auto-phrase; }
:lang(ja) .kicker { letter-spacing: 0.08em; }
:lang(ja) .ch-head h2 { font-size: clamp(26px, 2.45vw, 35px); }
/* Japanese values in the mini graph are short too: keep each value on one line, as on the Chinese page */
:root:lang(ja) .mn-pin em { white-space: nowrap; }
/* Japanese node notes in the four-step loop: a little more room per line so short words are not split */
:lang(ja) .hn-node { padding-left: 11px; padding-right: 11px; }
:lang(ja) .hn-node span { font-size: 12px; }
:lang(ja) .ch-tag { letter-spacing: 0.1em; }
@media (max-width: 600px) {
  :lang(ja) .epi-big .ph { display: inline; }
}
