/* Munsell → RGB：一本色彩图册。页面上除了数据里的颜色，只有中性灰。 */

@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; }

:root {
  /* 全部是 R = G = B 的中性灰 */
  --page: #cdcdcd;
  --leaf: #d9d9d9;
  --dark: #232323;
  --dark-2: #2d2d2d;
  --ink: #161616;
  --ink-2: #4a4a4a;
  --line: rgba(0, 0, 0, 0.26);
  --line-soft: rgba(0, 0, 0, 0.13);
  --on-dark: #ececec;
  --on-dark-2: #a6a6a6;
  --line-dark: rgba(255, 255, 255, 0.18);

  --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "Menlo", "Consolas", monospace;
  --pad-x: clamp(20px, 5vw, 80px);
  --max: 1280px;

  --cell: clamp(30px, 2.75vw, 42px);
  --gap: 6px;
  --axis: 44px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--page);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
p, h1, h2, h3, figure, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }
button, select { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.86em; }
/* 叙述正文里的代码：等宽、略小、极淡的底，长的标识符在窄屏上可以断开 */
:is(.intro, .ch-text > p, .body, .lg-col p, .lg-col h3) code {
  font-size: 0.84em; padding: 0.06em 0.32em; border-radius: 3px;
  background: rgba(0, 0, 0, 0.06); overflow-wrap: anywhere;
}
/* 电脑宽度下栏够宽：一段代码不拆成两行（「7.5YR 9/8」「The maximum chroma is N!」这类带空格的） */
@media (min-width: 900px) {
  :is(.intro, .ch-text > p, .body, .lg-col p, .lg-col h3) code { white-space: nowrap; }
}
.ch.dark :is(.ch-text > p, .body) code { background: rgba(255, 255, 255, 0.065); color: var(--on-dark); }
:is(.intro, .ch-text > p, .body, .lg-col p, .lg-col h3) strong { font-weight: 600; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: calc(var(--max) + 2 * var(--pad-x)); margin: 0 auto; padding: 0 var(--pad-x); }
.ar { display: inline-block; transition: transform .25s ease; }

/* ---------- 页眉 ---------- */
.top {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 26px 0 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 500; letter-spacing: 0.14em;
}
.home { text-decoration: none; font-weight: 600; letter-spacing: 0.2em; }
.home:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.langs { display: flex; gap: 1.2em; }
.langs a { text-decoration: none; color: var(--ink-2); padding-bottom: 2px; }
.langs a[aria-current] { color: var(--ink); border-bottom: 1.5px solid var(--ink); }
.langs a:hover { color: var(--ink); }

/* 跟着滚动的章节目录：过了首屏才出来 */
.toc {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  background: rgba(205, 205, 205, 0.94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
  transform: translateY(-101%);
  transition: transform .3s ease;
}
.toc.on { transform: none; }
.toc-in { display: flex; justify-content: space-between; align-items: center; height: 46px; }
.toc-name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.toc ol { display: flex; gap: 22px; font-size: 13px; }
.toc a { text-decoration: none; color: var(--ink-2); padding: 4px 0; border-bottom: 1.5px solid transparent; }
.toc a:hover { color: var(--ink); }
.toc a.cur { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- 首屏 ---------- */
.hero {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  align-items: center;
  /* 首屏到第一章的分界线大约落在第一屏的底边 */
  min-height: clamp(600px, calc(100vh - 96px), 900px);
  padding-top: 0; padding-bottom: 40px;
}
.hero-text { grid-column: 1 / span 6; position: relative; z-index: 1; }
h1 {
  font-size: clamp(3.6rem, 5.8vw, 5.9rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 0.92;
  margin-left: -0.05em;
  white-space: nowrap;
}
h1 .arrow { font-weight: 400; letter-spacing: 0; margin: 0 0.03em; position: relative; top: -0.05em; }
h1 .year {
  display: inline-block; vertical-align: top;
  margin: 0.22em 0 0 16px;
  font-size: 13px; font-weight: 500; letter-spacing: 0.12em;
  color: var(--ink-2);
}
.lede { margin-top: 26px; font-size: clamp(22px, 1.9vw, 27px); font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; }
.intro { margin-top: 18px; max-width: 36em; font-size: 16px; line-height: 1.8; color: #262626; text-wrap: pretty; }
.intro + .intro { margin-top: 12px; color: #3d3d3d; }
.hero-links { margin-top: 28px; display: flex; gap: 28px; flex-wrap: wrap; }
.ext, .inner {
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}
.ext:hover .ar { transform: translate(2px, -2px); }
.inner:hover .ar { transform: translateY(2px); }

.solid { grid-column: 7 / -1; display: flex; flex-direction: column; align-items: center; }
.solid-stage { width: min(100%, 680px); aspect-ratio: 4 / 3; position: relative; }
#solid { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
#solid:active { cursor: grabbing; }
#solid:focus-visible { outline-offset: -2px; }
.solid .cap { width: min(100%, 620px); text-align: center; margin-top: 4px; }
.cap { font-size: 13px; line-height: 1.65; color: var(--ink-2); }
.hint { white-space: nowrap; }

/* ---------- 章节的共用部分 ---------- */
.ch { padding: 120px 0; }
.ch.dark { background: var(--dark); color: var(--on-dark); }
.ch.dark .cap, .ch.dark .plate-no { color: var(--on-dark-2); }
.ch.leaf { background: var(--leaf); }
.plate-no {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.12em; color: var(--ink-2);
  margin-bottom: 22px;
}
.plate-no::before { content: ""; width: 28px; height: 1.5px; background: currentColor; }
.ch h2 {
  font-size: clamp(27px, 2.4vw, 36px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.32;
  text-wrap: balance;
}
/* 叙述正文：每行 34 到 42 个字 */
.ch-text > p:not(.plate-no), .body { font-size: 16.5px; line-height: 1.85; }
.body { max-width: 38em; }
.ch-text > p + p { margin-top: 14px; }
.ch-text h2 + p, .ch-lead h2 + .body { margin-top: 26px; }
.ch.dark .body { color: #d4d4d4; }
/* 一章的下半条色带没有章头，直接用一段正文开场 */
.ch-open { margin-bottom: 52px; }
#engine, #atlas { padding-top: 100px; }
/* 首屏「查看交互色卡」跳过来时，段落和图册的上半都在视口里（上方空白藏在目录条后面） */
#atlas { scroll-margin-top: -50px; }

/* ---------- 1 是什么 ---------- */
.ch-what { display: grid; grid-template-columns: minmax(0, 34em) minmax(0, 1fr); column-gap: 56px; align-items: start; }
.ch-what .ch-text { padding-top: 4px; }
.ch-what .ch-text > p:not(.plate-no) { color: #d4d4d4; font-size: 15.5px; }
.ch-what .shot { margin-top: 8px; }
.keys { margin-top: 30px; border-top: 1px solid var(--line-dark); }
.keys li { display: flex; gap: 14px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--line-dark); font-size: 14px; color: #d4d4d4; }
.k, .pin {
  flex: none;
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--on-dark); color: var(--dark);
  font-size: 12px; font-weight: 600; line-height: 1;
}
.shot-frame { position: relative; }
.shot-frame img { display: block; width: 100%; height: auto; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; font-size: 13px;
  box-shadow: 0 0 0 3px rgba(35, 35, 35, 0.55);
}
.shot .cap { margin-top: 14px; max-width: 46em; }

/* ---------- 第三章 下：图册 ---------- */
.plate { background: var(--leaf); }
.plate-top { padding: 30px 40px 34px calc(40px + var(--axis)); }
.tabs { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); column-gap: 12px; }
.fam { display: flex; flex-direction: column; min-width: 0; }
.fam-lab {
  font-size: 11px; font-weight: 500; letter-spacing: 0.12em; color: var(--ink-2);
  padding-bottom: 5px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.fam.on .fam-lab { color: var(--ink); border-bottom-color: var(--ink); }
.fam-sw { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
.tab {
  appearance: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  height: 24px; position: relative; border-radius: 0;
  transition: transform .2s ease;
}
.tab::after {
  content: ""; position: absolute; left: 50%; top: calc(100% + 5px);
  border: 5px solid transparent; border-top: 0; border-bottom: 6px solid var(--ink);
  transform: translateX(-50%) scale(0); transform-origin: 50% 100%;
  transition: transform .2s ease;
}
.tab[aria-selected="true"]::after { transform: translateX(-50%) scale(1); }
.tab:hover { transform: translateY(-2px); }
.tab[aria-selected="true"]:hover { transform: none; }
.tab:focus-visible { outline-offset: 2px; outline-color: var(--ink); }

.plate-body {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(48px, 1fr) 19.5rem;
  grid-template-rows: auto 1fr;
  padding: 8px 40px 36px;
}
.page-title {
  grid-column: 1; grid-row: 1;
  display: flex; align-items: baseline; gap: 16px;
  padding-left: var(--axis);
  margin-bottom: 22px;
}
.page-hue { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.page-name { font-size: 13px; color: var(--ink-2); }
.page-nav { margin-left: auto; display: flex; gap: 8px; align-self: center; }
.pg {
  appearance: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  transition: background-color .2s ease, border-color .2s ease;
}
.pg:hover { border-color: var(--ink); }
.pg:disabled { opacity: 0.35; cursor: default; }

.chart {
  grid-column: 1; grid-row: 2; align-self: start;
  display: grid;
  grid-template-columns: 14px calc(var(--axis) - 14px) auto;
  align-items: start;
}
.ylab {
  grid-column: 1; grid-row: 1; align-self: center;
  writing-mode: vertical-rl;
  font-size: 12px; letter-spacing: 0.3em; color: var(--ink-2);
}
.yticks, .xticks { font-size: 12px; color: var(--ink-2); line-height: 1; }
.yticks {
  grid-column: 2; grid-row: 1;
  display: grid; grid-template-rows: repeat(9, var(--cell)); row-gap: var(--gap);
  justify-items: end; padding-right: 12px;
}
.yticks span { align-self: center; }
.xticks {
  grid-column: 3; grid-row: 2;
  display: grid; grid-template-columns: repeat(13, var(--cell)); column-gap: var(--gap);
  padding-top: 11px;
}
.xticks span { text-align: center; }
.xlab { grid-column: 3; grid-row: 3; padding-top: 10px; font-size: 12px; letter-spacing: 0.3em; color: var(--ink-2); }

.grid {
  grid-column: 3; grid-row: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(13, var(--cell));
  grid-template-rows: repeat(9, var(--cell));
  gap: var(--gap);
}
.cell {
  appearance: none; border: 0; margin: 0; padding: 0; border-radius: 0;
  width: 100%; height: 100%; cursor: pointer; position: relative;
}
.cell:focus-visible { outline: none; }
.cell.clip { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%); }
.cell.miss { background: transparent; border: 1px dashed rgba(0, 0, 0, 0.5); }
.cell.miss:hover { border-color: var(--ink); }
/* 表里没有的位置：只画一个小十字 */
.cell.empty { background: transparent; }
.cell.empty::before, .cell.empty::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  background: rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%);
}
.cell.empty::before { width: 7px; height: 1px; }
.cell.empty::after { width: 1px; height: 7px; }
.cell.empty:hover::before, .cell.empty:hover::after { background: var(--ink); }

.grid.turn .cell:not(.empty) { animation: chip .42s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes chip { from { opacity: 0; transform: translateX(var(--dx, 10px)); } to { opacity: 1; transform: none; } }

.leader { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.leader rect, .leader path { fill: none; stroke: var(--ink); }
.leader .frame { stroke-width: 2.5; }
.leader .wire { stroke-width: 1; }
.leader .dot { fill: var(--ink); stroke: none; }
.leader .land { stroke-width: 1.5; stroke-dasharray: none; }
.leader .walkline { stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.cell.walked { border-color: rgba(0, 0, 0, 0.7); }

.readout { grid-column: 3; grid-row: 1 / span 2; min-width: 0; padding-top: 6px; }
.swatch { width: 100%; aspect-ratio: 5 / 3; max-height: 170px; }
.swatch.miss { background: transparent !important; border: 1px dashed rgba(0, 0, 0, 0.5); }
.swatch.empty { background: transparent !important; border: 1px solid var(--line); }
.notation { margin-top: 18px; font-size: 34px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; white-space: nowrap; }
.notation .vc { margin-left: 0.22em; }
.numbers { margin-top: 20px; border-top: 1px solid var(--ink); }
.nrow {
  display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 4.3em);
  align-items: baseline; padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.nrow > span:not(.nlab) { text-align: right; }
.nrow.nhead { padding: 5px 0 4px; font-size: 11px; font-weight: 500; letter-spacing: 0.12em; color: var(--ink-2); border-bottom-color: var(--line-soft); }
.nlab { font-size: 12.5px; line-height: 1.4; color: var(--ink-2); padding-right: 8px; }
.nrow.lin { font-weight: 600; }
.note { margin-top: 12px; font-size: 13.5px; line-height: 1.65; }
.clip-note { display: flex; gap: 10px; align-items: baseline; }
.clip-note .sym { position: relative; top: 2px; }
.try {
  appearance: none; background: none; border: 0; padding: 0 0 1px; cursor: pointer;
  margin-top: 20px; font-size: 13px; font-weight: 500; text-align: left;
  border-bottom: 1px solid currentColor;
}
.try:hover .ar { transform: translateX(2px); }
.fix:hover .ar { transform: translateX(-2px); }
/* 「查到」和「没查到」叠在同一格里，另放两份按最长内容排好的隐形副本撑住高度，切换时下面不动 */
.states { display: grid; }
.states > * { grid-area: 1 / 1; min-width: 0; }
.states > .ghost { visibility: hidden; pointer-events: none; }
.verdict { margin-top: 18px; border-top: 1px solid var(--ink); padding-top: 12px; }
.vd-why { font-size: 13.5px; line-height: 1.6; }
.vd-lab { margin-top: 12px; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.walk { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; font-family: var(--mono); font-size: 12px; line-height: 1; }
.walk span { padding: 4px 6px; border: 1px dashed rgba(0, 0, 0, 0.45); border-radius: 2px; color: var(--ink-2); }
.walk span.x { text-decoration: line-through; }
.walk span.ok { border: 1px solid var(--ink); background: var(--ink); color: var(--leaf); font-weight: 600; }
.errbox {
  margin-top: 14px; padding: 12px 14px 13px;
  background: #1b1b1b; color: #f1f1f1; border-radius: 4px;
  display: flex; flex-direction: column; gap: 5px;
}
.err-k { font-size: 11.5px; letter-spacing: 0.12em; color: #a6a6a6; }
/* 引擎弹出的报错原话：前面一个小的警告记号，正文字体（图册的报错框和编译面板的第三步共用） */
.err-line { display: flex; align-items: flex-start; gap: 8px; margin: 0; }
.err-mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-top: 0.12em;
  border: 1.5px solid currentColor; border-radius: 50%; font-size: 10.5px; font-weight: 600; line-height: 1;
}
.err-mark::before { content: "!"; }
.err { font-size: 15px; font-weight: 600; line-height: 1.35; }
.err-out { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #bdbdbd; }
.err-out::before { content: ""; width: 12px; height: 12px; background: #000; box-shadow: 0 0 0 1px #5a5a5a; flex: none; }

/* 照着截图画的节点：页面上唯一有圆角和深色的小东西 */
.node {
  margin-top: 22px; width: 168px;
  border-radius: 5px; background: #111; border: 1.5px solid #000;
  overflow: hidden; color: #f1f1f1; line-height: 1.2;
  font-family: "Inter", "Helvetica Neue", sans-serif;
}
.node-head {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 9px;
  background: linear-gradient(180deg, #4a4a4a 0%, #2e2e2e 100%);
  border-bottom: 1px solid #000;
}
.node-title { font-size: 11.5px; font-weight: 600; }
.node-sub { font-size: 10.5px; font-style: italic; color: #a8a8a8; }
.node-body { display: flex; justify-content: space-between; align-items: flex-start; padding: 6px 9px 8px 6px; }
.node-sw { width: 74px; height: 74px; display: block; }
.node-pin { margin-top: 4px; width: 9px; height: 9px; border-radius: 50%; background: #f1f1f1; position: relative; }
.node-pin::after { content: ""; position: absolute; left: 10px; top: 1.5px; border: 3px solid transparent; border-left: 4px solid #f1f1f1; border-right: 0; }

.legend {
  display: grid; grid-template-columns: 0.8fr 1fr 1.5fr 1.15fr; column-gap: 28px;
  padding: 0 40px 34px calc(40px + var(--axis));
}
.legend li {
  display: flex; gap: 11px; align-items: flex-start;
  padding-top: 13px; border-top: 1px solid var(--line);
  font-size: 13px; line-height: 1.55;
}
.sym { display: inline-block; width: 15px; height: 15px; flex: none; margin-top: 3px; }
.sym-ok { background: var(--ink); }
.sym-clip { background: var(--ink); clip-path: polygon(0 0, 9px 0, 100% 6px, 100% 100%, 0 100%); }
.sym-miss { border: 1px dashed rgba(0, 0, 0, 0.6); }
.sym-empty { position: relative; }
.sym-empty::before, .sym-empty::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--ink-2); transform: translate(-50%, -50%); }
.sym-empty::before { width: 9px; height: 1px; }
.sym-empty::after { width: 1px; height: 9px; }
.sym-rim { background: #8a8a8a; border-top: 3px solid var(--ink); }

/* ---------- 第二章 上：数据链路 ---------- */
.ch-lead { margin-bottom: 52px; }
/* 下面三张卡里的数都是这一格的 */
.lg-sel { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; }
.lg-sel-sw { width: 26px; height: 26px; flex: none; }
.lg-sel-name { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.lineage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 64px; row-gap: 64px; align-items: start; }
.lg-col { min-width: 0; border-top: 1px solid var(--line); padding-top: 18px; }
.lg-bg { grid-column: 1; }
.lg-rit { grid-column: 2; }
.lg-mine { grid-column: 1 / -1; border-top: 3px solid var(--ink); padding-top: 18px; }
.lg-col h3 { font-size: 18px; font-weight: 600; line-height: 1.45; }
.lg-mine h3 { font-size: 23px; letter-spacing: -0.01em; }
.lg-col p { max-width: 38em; margin-top: 12px; font-size: 15.5px; line-height: 1.8; color: #2a2a2a; }
.lg-vals { margin-top: 18px; font-size: 13px; line-height: 1.6; }
.lg-vals .row { display: flex; justify-content: space-between; gap: 6px; max-width: 13em; border-bottom: 1px solid var(--line-soft); padding: 2px 0; }
.lg-vals .row b { font-weight: 500; color: var(--ink-2); }
.lg-vals .row i { font-style: normal; }
.lg-vals .sw { display: block; width: 100%; max-width: 13em; height: 12px; margin-bottom: 8px; }

/* 第三张卡：左边是一段话和公式，右边是曲线，底下一行是这一格的线性值和查找表的三层 */
.mine { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
.mine-text { grid-column: 1 / span 7; max-width: 38em; }
.mine-text .formula { margin-top: 18px; width: fit-content; max-width: 100%; }
.formula {
  display: grid; grid-template-columns: auto auto; justify-content: start; column-gap: 24px; row-gap: 3px;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  padding: 10px 16px; border-left: 2px solid var(--ink); background: rgba(0, 0, 0, 0.045);
}
.formula span:nth-child(odd) { color: var(--ink-2); }
.curve-fig { grid-column: 9 / span 4; max-width: 260px; padding-top: 14px; }
.curve { display: block; width: 100%; height: auto; overflow: visible; }
.curve .cv-frame { fill: none; stroke: var(--ink-2); stroke-width: 1; }
.curve .cv-diag { fill: none; stroke: rgba(0, 0, 0, 0.18); stroke-width: 1; stroke-dasharray: 3 3; }
.curve .cv-line { fill: none; stroke: var(--ink); stroke-width: 2; }
.curve .cv-drop { fill: none; stroke: var(--ink-2); stroke-width: 0.8; stroke-dasharray: 2 2.5; }
.curve .cv-dot { fill: var(--ink); }
.curve .cv-t { font-family: var(--sans); font-size: 10.5px; fill: var(--ink-2); }
.curve .cv-k { font-family: var(--sans); font-size: 11px; font-weight: 600; fill: var(--ink); }
.curve-cap { margin-top: 8px; font-size: 12.5px; }
.lg-out {
  grid-column: 1 / -1;
  margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 11em minmax(0, 1fr); column-gap: 28px; align-items: start;
}
.lg-out .lg-vals { margin-top: 0; }
.lin-name { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
/* 查找表的三层：色相、明度两格圈在一片淡底里（先用它们取到一张小表），彩度是小表里的键，最后是这一格的颜色 */
.lg-lut { max-width: 40em; }
.lut { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.lut-hv { display: flex; align-items: flex-end; gap: 12px; padding: 8px 12px 10px; background: rgba(0, 0, 0, 0.06); }
.lut-c, .lut-out { padding-bottom: 10px; }
.lut-k { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.lut-t { font-size: 12px; line-height: 1.3; color: var(--ink-2); white-space: nowrap; }
.lut-val {
  display: flex; align-items: center; justify-content: center; min-width: 3.4em; height: 36px; padding: 0 10px;
  border: 1px solid var(--ink); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
}
.lut-sep, .lut-arr { height: 36px; display: flex; align-items: center; font-size: 15px; color: var(--ink-2); }
.lut > .lut-sep, .lut-arr { margin-bottom: 10px; }
.lut-sw { display: block; width: 72px; height: 36px; }
.lg-lut-cap { margin-top: 12px; }

/* ---------- 第三章 上：色域 ---------- */
.ch-gamut { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
.ch-gamut .ch-text { grid-column: 1 / span 6; }
.wheel-wrap { grid-column: 8 / -1; }
.tally { margin: 34px 0 30px; border-top: 1px solid var(--ink); }
.tally div { display: grid; grid-template-columns: 5.2em 1fr; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tally dt { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.tally dd { font-size: 14px; color: var(--ink-2); }

.wheel-plate { position: relative; background: var(--leaf); padding: 26px; }
.ch.leaf .wheel-plate { background: #e4e4e4; }
.gamut-cap { margin-top: 12px; }
.wheel { display: block; width: 100%; height: auto; max-width: 640px; margin: 0 auto; overflow: visible; }
.wheel .cellp { cursor: pointer; }
.wheel .cellp:focus { outline: none; }
.wheel .rim { fill: none; stroke: var(--ink); stroke-width: 3.2; pointer-events: none; }
.wheel .mis { fill: transparent; stroke: rgba(0, 0, 0, 0.6); stroke-width: 1; stroke-dasharray: 3 2.5; }
.wheel .ring { fill: none; stroke: rgba(0, 0, 0, 0.1); stroke-width: 0.7; }
.wheel .fl { font-family: var(--sans); font-size: 13px; font-weight: 600; fill: var(--ink); }
.wheel .tk { font-family: var(--sans); font-size: 10px; fill: var(--ink-2); }
.wheel .hot { fill: none; stroke: var(--ink); stroke-width: 2.4; pointer-events: none; }
.wheel .cv { font-family: var(--sans); font-size: 30px; font-weight: 600; fill: var(--ink); letter-spacing: -0.02em; }
.wheel .cvs { font-family: var(--sans); font-size: 11px; fill: var(--ink-2); }
.wheel-read {
  position: absolute; left: 26px; top: 22px;
  display: flex; gap: 10px; align-items: center;
  font-size: 13px; line-height: 1.35;
  min-height: 34px;
}
.wr-sw { width: 30px; height: 30px; flex: none; border: 1px solid transparent; }
.wr-sw.none { border-color: var(--line); }
.wr-text { display: flex; flex-direction: column; }
.wr-name { font-weight: 600; font-size: 15px; }
.wr-sub { color: var(--ink-2); font-size: 12.5px; }

.vpick { margin-top: 22px; }
.vpick-lab { font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.vbars { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); column-gap: 8px; align-items: end; }
.vb {
  appearance: none; background: transparent; border: 0; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  text-align: left;
}
.vb .bar { display: block; height: calc(var(--h) * 64px); background: rgba(0, 0, 0, 0.2); transition: background-color .2s ease; position: relative; }
.vb .bar i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--c) * 100%); background: rgba(0, 0, 0, 0.42); }
.vb .vn { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 5px; }
.vb .vn small { font-size: 11.5px; font-weight: 400; color: var(--ink-2); }
.vb:hover .bar { background: rgba(0, 0, 0, 0.32); }
.vb[aria-checked="true"] .bar { background: var(--ink); }
.vb[aria-checked="true"] .bar i { background: #6a6a6a; }
.vb[aria-checked="true"] .vn { border-top-color: var(--ink); }
.vb:focus-visible { outline-offset: 4px; }
.wheel-legend { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-top: 22px; font-size: 13px; }
.wheel-legend li { display: flex; gap: 9px; align-items: flex-start; }

/* ---------- 第二章 下：编译时查表 ---------- */
.ch.dark code { color: var(--on-dark); }
.engine { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: start; }
.eng-main { grid-column: 1 / span 7; }
.eng-main .body { margin-bottom: 44px; }.compile {
  background: var(--dark-2); padding: 28px 30px 10px;
  border-radius: 4px;
}
.cp-sel { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line-dark); }
.cp-sw { width: 30px; height: 30px; flex: none; }
.cp-sw.none { border: 1px dashed #777; }
.cp-name { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.cp-sel .cc-change { margin-left: auto; font-size: 13px; text-decoration: none; border-bottom: 1px solid currentColor; color: var(--on-dark-2); }
.cp-sel .cc-change:hover { color: var(--on-dark); }
.flow { position: relative; padding-left: 22px; }
.flow::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 30px; width: 1px; background: var(--line-dark); }
.fl { position: relative; padding: 0 0 22px; transition: opacity .25s ease; }
.fl::before { content: ""; position: absolute; left: -22px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--dark-2); border: 1px solid var(--on-dark-2); }
.fl.on::before { background: var(--on-dark); border-color: var(--on-dark); }
.fl.off { opacity: 0.3; }
.fl-k { display: block; font-size: 13.5px; color: var(--on-dark-2); margin-bottom: 5px; }
.fl.on .fl-k { color: var(--on-dark); }
/* 每一步下面一排小格子（和第二章上查找表三层的格子同一种做法，换成深色底） */
.fl-vals { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fl-val {
  display: inline-flex; align-items: center; justify-content: center; min-width: 3.4em; height: 30px; padding: 0 9px;
  border: 1px solid var(--on-dark-2); color: var(--on-dark); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.fl-sw { width: 30px; height: 30px; flex: none; }
.fl-sw.none { border: 1px dashed #777; }
.fl-err { font-size: 14px; font-weight: 500; line-height: 1.45; color: var(--on-dark); }

.crops { grid-column: 9 / -1; display: flex; flex-direction: column; gap: 30px; padding-top: 8px; }
.crops img { display: block; width: 100%; height: auto; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
.crops .crop-stats img { max-width: 320px; }
.crops .cap { margin-top: 10px; }

/* ---------- 结尾 ---------- */
.end { background: var(--dark); color: var(--on-dark); padding: 72px 0 96px; }
.end a { border-top-color: var(--on-dark) !important; }
.end .end-k { color: var(--on-dark-2); }
.end-in { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; }
.end a { display: block; text-decoration: none; padding: 20px 0 24px; border-top: 1.5px solid var(--ink); }
.end-k { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.end-v { font-size: clamp(22px, 2.2vw, 30px); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.end a:hover .end-v > span:first-child { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
.end-repo:hover .ar { transform: translate(3px, -3px); }
.end-home:hover .ar { transform: translateX(-3px); }

/* 入场：滚到了再浮上来 */
.rv { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.rv.in { opacity: 1; transform: none; }

/* ---------- 动效开关 ---------- */
.shot *, .shot *::before, .shot *::after { animation: none !important; transition: none !important; }
.shot .rv { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rv { opacity: 1; transform: none; }
}

/* ---------- 窄一些的桌面 ---------- */
@media (max-width: 1280px) {
  .plate-body { grid-template-columns: auto minmax(32px, 1fr) 18rem; padding-left: 28px; padding-right: 28px; }
  .plate-top { padding-left: calc(28px + var(--axis)); padding-right: 28px; }
  .legend { padding-left: calc(28px + var(--axis)); padding-right: 28px; column-gap: 20px; }
  .eng-main { grid-column: 1 / span 8; }
  .crops { grid-column: 9 / -1; }
  .toc ol { gap: 16px; }
}
@media (max-width: 1180px) {
  :root { --cell: clamp(26px, 2.7vw, 34px); }
  .ch-what { grid-template-columns: minmax(0, 30em) minmax(0, 1fr); column-gap: 40px; }
}

/* ---------- 平板和手机 ---------- */
@media (max-width: 900px) {
  .toc-name { display: none; }
  .toc ol { gap: 14px; font-size: 12.5px; overflow-x: auto; }
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; row-gap: 20px; padding-top: 32px; }
  .hero-text, .solid { grid-column: 1; }
  .ch { padding: 84px 0; }
  #engine, #atlas { padding-top: 72px; }
  .ch-lead, .ch-open { margin-bottom: 36px; }
  .ch-what, .ch-gamut, .engine { grid-template-columns: 1fr; row-gap: 36px; }
  .ch-what .ch-text, .ch-what .shot, .ch-gamut .ch-text, .wheel-wrap,
  .eng-main, .crops { grid-column: 1; }
  .crops .crop-stats { max-width: 320px; }
  .plate-body { grid-template-columns: 1fr; padding: 8px 20px 28px; row-gap: 26px; }
  .page-title, .chart, .readout { grid-column: 1; grid-row: auto; }
  .page-title { padding-left: 0; margin-bottom: 0; }
  .readout { display: grid; grid-template-columns: 120px 1fr; column-gap: 18px; align-items: start; }
  .readout .swatch { grid-column: 1; grid-row: 1 / span 2; aspect-ratio: 1; }
  .readout .notation { grid-column: 2; margin-top: 0; font-size: 28px; }
  .readout .states { grid-column: 1 / -1; }
  .readout .node { display: none; }
  .leader .wire, .leader .dot { display: none; }
  .plate-top { padding: 22px 20px 26px; }
  .tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 18px; column-gap: 10px; }
  .legend { grid-template-columns: 1fr 1fr; padding: 0 20px 26px; row-gap: 4px; }
  .lineage { grid-template-columns: minmax(0, 1fr); row-gap: 40px; }
  .lg-bg, .lg-rit, .lg-mine { grid-column: 1 / -1; }
  .mine { grid-template-columns: 1fr; row-gap: 22px; }
  .mine-text, .curve-fig, .lg-out { grid-column: 1; }
  .curve-fig { padding-top: 0; }
  .lg-out { margin-top: 8px; grid-template-columns: 1fr; row-gap: 16px; }
}
@media (max-width: 600px) {
  :root { --axis: 30px; --gap: 3px; --cell: calc((100vw - 2 * var(--pad-x) - 40px - var(--axis) - 12 * var(--gap)) / 13); }
  body { font-size: 15.5px; }
  .toc { display: none; }
  h1 { font-size: 2.85rem; }
  h1 .year { margin-left: 10px; font-size: 12px; }
  .lede { margin-top: 22px; font-size: 20px; }
  .intro { font-size: 15.5px; }
  .ch h2 { font-size: 24px; }
  .ch-text > p:not(.plate-no), .body { font-size: 15.5px; }
  .pin { width: 20px; height: 20px; font-size: 11px; box-shadow: 0 0 0 2px rgba(35, 35, 35, 0.55); }
  .chart { grid-template-columns: 0 var(--axis) auto; }
  .ylab { display: none; }
  .yticks { padding-right: 8px; }
  .xticks { font-size: 9.5px; }
  .xticks span:nth-child(even) { visibility: hidden; }
  .cell.clip { clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%); }
  .page-hue { font-size: 32px; }
  .page-title { flex-wrap: wrap; row-gap: 6px; }
  .page-name { font-size: 12px; order: 3; flex-basis: 100%; white-space: nowrap; }
  .readout { grid-template-columns: 96px 1fr; }
  .nrow { grid-template-columns: minmax(0, 1fr) repeat(3, 3.9em); font-size: 14px; }
  .legend { grid-template-columns: 1fr; }
  .tab { height: 20px; }
  .lg-mine h3 { font-size: 20px; }
  .formula { column-gap: 14px; font-size: 12.5px; padding: 10px 12px; }
  /* 查找表的三层在手机上仍排成一行：格子、间距收窄 */
  .lut { column-gap: 7px; }
  .lut-hv { gap: 7px; padding-left: 8px; padding-right: 8px; }
  .lut-val { min-width: 2.6em; padding: 0 7px; font-size: 15px; }
  .lut-sw { width: 100%; min-width: 48px; }
  .wheel-plate { padding: 12px; }
  .wheel-read { position: static; margin: 4px 4px 10px; }
  .wheel .fl { font-size: 21px; }
  .wheel .cv { font-size: 40px; }
  .wheel .cvs { font-size: 17px; }
  .vbars { column-gap: 4px; }
  .vb .vn { font-size: 12px; flex-direction: column; }
  .compile { padding: 18px 18px 4px; }
  .end-in { grid-template-columns: 1fr; }
  .end .ar { display: inline; } /* 让箭头跟着仓库名换行，不单独掉到下一行 */
  .tally dt { font-size: 26px; }
}

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

/* ---------- 英文版、日文版（/projects/munsell/、/ja/projects/munsell/）：只换字体和字距，中文版不受影响 ---------- */
/* 日文：系统的日文字体排在中文字体前面，不然汉字会显示成中文的字形。语言切换上的「中」标了 lang="zh-CN"，仍用中文字体 */
:root:lang(ja) {
  --sans: "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
}
:root:lang(ja) [lang|="zh"] { font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
/* 英文：为汉字加的大字距收回来 */
.ylab:lang(en), .xlab:lang(en) { letter-spacing: 0.06em; }
/* 日文的标题和短句按词组换行，不在「オフ / ライン」「シェーダ / ー」这种地方断开 */
:is(h1, h2, h3, .lede):lang(ja) { word-break: auto-phrase; }
/* 整页的等宽数字（tabular-nums）会把连字符撑宽，「8-bit」「1625-color」看起来像「8 - bit」：英文、日文的句子里改回比例数字，表格和读数照旧等宽 */
:is(p, h1, h2, h3, li, dd, figcaption):is(:lang(en), :lang(ja)) { font-variant-numeric: normal; }
.plate-no:lang(en), .err-k:lang(en) { letter-spacing: 0.04em; }
/* 日文正文：小写假名（ャ、ッ）和长音符（ー）不放在行首 */
:root:lang(ja) body { line-break: strict; }
/* 英文、日文的首屏导语更长，窄一些的桌面上内容会撑满首屏：标题和页眉之间留出空 */
.hero:is(:lang(en), :lang(ja)) { padding-top: 40px; }
@media (max-width: 900px) { .hero:is(:lang(en), :lang(ja)) { padding-top: 32px; } }
/* 日文：读数的标签和图例在窄栏里按词组换行（「ノードの出力 / （リニア）」） */
:is(.nlab, .legend li > span):lang(ja) { word-break: auto-phrase; }
