/* SI4World 设计系统
   paper  : 纯净的白
   ink    : 墨蓝，正文与线条
   red    : 红笔批注，用于"注意""算错了"、反向的梯度
   marker : 荧光笔，只用于"一句话记住"和正在计算的格子
*/
/* 标题字体：思源宋体（Noto Serif SC，SIL OFL 许可）的子集，只含本站用到的约 1100 个字符。
   新增内容用到新字时，运行 tools/subset-font.py 重新生成。 */
@font-face {
  font-family: "SI Serif";
  src: url("../fonts/NotoSerifSC-subset.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --sheet: #ffffff;
  --grid: #eef1f3;
  --rule: #dde3e7;
  --ink: #1c2a43;
  --ink-2: #3a4862;
  --graphite: #5a626d;
  --faint: #8a929c;
  --red: #c23a2e;
  --marker: #ffe36e;

  --lane-rules: #7d848f;
  --lane-learn: #2c5aa6;
  --lane-vision: #0f8577;
  --lane-lang: #6a4cb0;
  --lane-gen: #b8730e;
  --lane-sys: #b03f69;
  --lane-sci: #5d7d1e;

  --f-hand: "SI Serif", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
  --f-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --f-num: "SF Mono", "Cascadia Mono", "Consolas", "Menlo", monospace;

  --measure: 40em;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  color: var(--ink);
  font: 17px/1.85 var(--f-body);
  background: var(--paper);
}
@media (max-width: 640px) { body { font-size: 16px; } }

a { color: var(--lane-learn); text-underline-offset: 3px; }
/* 正文里的链接：和文字同色，只留一条淡下划线，不打断阅读 */
.lesson main p a:not(.btn), .lesson main li a:not(.btn), .lesson main dd a:not(.btn), .lesson main td a:not(.btn) { color: inherit; text-decoration-color: #b8c2cc; text-decoration-thickness: 1px; }
.lesson main p a:not(.btn):hover, .lesson main li a:not(.btn):hover, .lesson main dd a:not(.btn):hover, .lesson main td a:not(.btn):hover { text-decoration-color: currentColor; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2.5px solid var(--lane-learn); outline-offset: 2px; border-radius: 3px; }
img, svg, canvas { max-width: 100%; }
p { margin: 0 0 1em; }
strong { font-weight: 650; }

h1, h2, h3, .hand { font-family: var(--f-hand); font-weight: 700; letter-spacing: .02em; }
h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); line-height: 1.25; margin: 0 0 .4em; }
h2 { font-size: 1.75rem; line-height: 1.35; margin: 2.6em 0 .6em; }
h3 { font-size: 1.28rem; line-height: 1.4; margin: 1.8em 0 .5em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(6px);
}
.brand { font-family: var(--f-hand); font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; color: var(--ink); text-decoration: none; }
.brand small { font-size: .78rem; color: var(--graphite); margin-left: 8px; font-weight: 400; }
.topnav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.topnav a { color: var(--ink-2); text-decoration: none; font-size: .95rem; white-space: nowrap; }
@media (max-width: 640px) {
  .topbar { gap: 12px; }
  .brand small { display: none; }
  .topnav { gap: 12px; }
  .topnav a { font-size: .88rem; }
  .mode-switch button { padding: 3px 9px; }
}
@media (max-width: 400px) {
  .topbar { gap: 8px; padding-inline: 14px; }
  .brand { font-size: 1.12rem; }
  .topnav { gap: 9px; }
  .topnav a { font-size: .84rem; }
}
@media (max-width: 340px) {
  .topbar { padding-inline: 10px; }
  .brand { font-size: 1rem; }
  .topnav { gap: 7px; }
  .topnav a { font-size: .78rem; }
}
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

/* 速读 / 精读 */
.mode-switch { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.mode-switch button {
  font: inherit; font-size: .88rem; border: 0; background: transparent; color: var(--ink);
  padding: 3px 14px; cursor: pointer;
}
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
body.mode-quick .deep { display: none !important; }
body.mode-quick .quick-hint { display: block; }
.quick-hint { display: none; }

/* ---------- buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .92rem; line-height: 1.2;
  padding: 8px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #eef2f6; color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); color: var(--paper); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.ctrl { display: grid; grid-template-columns: 7.5em 1fr 4.2em; align-items: center; gap: 10px; font-size: .92rem; }
.ctrl output { font-family: var(--f-num); font-size: .9rem; text-align: right; }
input[type="range"] { width: 100%; accent-color: var(--ink); }

/* ---------- layout: home ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.col { max-width: var(--measure); }

/* ---------- layout: lesson ---------- */
.lesson {
  display: grid;
  grid-template-columns: 220px minmax(0, 720px);
  gap: 56px;
  max-width: 1080px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 120px;
}
@media (max-width: 960px) {
  .lesson { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rail { display: none; }
}
.rail { position: sticky; top: 76px; align-self: start; font-size: .9rem; }
.rail .crumb { color: var(--graphite); margin-bottom: 14px; }
.rail .crumb a { color: var(--graphite); }
.rail ol { list-style: none; margin: 0; padding: 0; counter-reset: s; border-left: 1.5px solid var(--rule); }
.rail li { counter-increment: s; }
.rail li a {
  display: block; padding: 5px 0 5px 16px; margin-left: -1.5px;
  border-left: 3px solid transparent; color: var(--graphite); text-decoration: none; line-height: 1.45;
}
.rail li a::before { content: counter(s) "  "; font-family: var(--f-num); font-size: .8rem; color: var(--faint); }
.rail li a.on { color: var(--ink); border-left-color: var(--ink); font-weight: 600; }
.rail li.deep-step a { font-style: normal; }
.rail .rail-foot { margin-top: 20px; color: var(--faint); font-size: .82rem; line-height: 1.6; }

.lesson-head { margin-bottom: 8px; }
.lesson-head .where { color: var(--graphite); font-size: .9rem; margin-bottom: 8px; }
.lesson-head .where .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.big-q { font-family: var(--f-hand); font-size: 1.3rem; line-height: 1.6; color: var(--ink-2); margin: 0 0 18px; }
.lesson-facts { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--graphite); font-size: .88rem; margin-bottom: 22px; }
.lesson-facts b { color: var(--ink); font-weight: 600; }

.quick-hint {
  border-left: 3px solid var(--lane-learn); background: #f5f8fc; border-radius: 0 6px 6px 0;
  padding: 10px 14px; font-size: .9rem; color: var(--ink-2); margin: 14px 0;
}
.quick-hint button { font: inherit; color: var(--lane-learn); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

/* 精读块：推导、手算 */
.deep { position: relative; border-left: 2px dashed var(--lane-learn); padding-left: 18px; margin-left: -20px; }
.deep > .deep-tag {
  display: inline-block; font-size: .78rem; color: var(--lane-learn); border: 1px solid var(--lane-learn);
  border-radius: 3px; padding: 0 6px; margin-bottom: 6px; background: var(--sheet); line-height: 1.6;
}
@media (max-width: 960px) { .deep { margin-left: 0; padding-left: 12px; } }

/* 一句话记住：一段安静的小结，不用荧光底 */
.remember { margin: 28px 0; padding: 4px 0 4px 16px; border-left: 3px solid var(--ink); }
.remember .label { font-size: .82rem; color: var(--graphite); display: block; margin-bottom: 4px; }
.remember p { font-family: var(--f-hand); font-weight: 600; font-size: 1.12rem; line-height: 1.8; margin: 0; color: var(--ink); }

/* 红笔批注 */
.note-red { font-family: var(--f-hand); color: var(--red); font-size: 1.05rem; }
.aside {
  font-size: .92rem; color: var(--graphite); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: 10px 0; margin: 18px 0;
}

/* 交互实验台 */
.lab {
  background: #fafbfc; border: 1px solid var(--rule); border-radius: 10px;
  padding: 20px 20px 16px; margin: 24px 0 28px;
}
.lab-title { font-family: var(--f-hand); font-weight: 700; font-size: 1.1rem; margin: 0 0 4px; }
.lab-sub { font-size: .88rem; color: var(--graphite); margin: 0 0 12px; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 720px) { .lab-grid { grid-template-columns: 1fr; } }
.lab .readout { font-family: var(--f-num); font-size: .88rem; color: var(--ink-2); line-height: 1.7; }
.lab .readout b { color: var(--ink); }
.lab .say { font-size: .92rem; background: #fff; border: 1px solid var(--rule); border-radius: 6px; padding: 8px 12px; margin-top: 10px; min-height: 2.6em; }
.lab svg { display: block; width: 100%; height: auto; }

/* 手算表 */
.calc { overflow-x: auto; margin: 14px 0 20px; }
.calc table { border-collapse: collapse; font-size: .9rem; min-width: 100%; background: var(--sheet); }
.calc th, .calc td { border: 1px solid var(--rule); padding: 5px 10px; text-align: center; white-space: nowrap; }
.calc th { font-weight: 600; background: #f0f4f6; }
.calc td.num { font-family: var(--f-num); }
.calc tr.sum td { border-top: 2px solid var(--ink); font-weight: 650; }
.calc caption { caption-side: bottom; text-align: left; font-size: .84rem; color: var(--graphite); padding-top: 6px; }

.steps-calc { counter-reset: c; list-style: none; padding: 0; margin: 12px 0 20px; }
.steps-calc li { counter-increment: c; position: relative; padding: 6px 0 6px 34px; border-bottom: 1px dotted var(--rule); }
.steps-calc li::before {
  content: counter(c); position: absolute; left: 0; top: 8px; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--ink); font-size: .75rem; text-align: center; line-height: 19px; font-family: var(--f-num);
}

/* 小测 */
.check { border: 1px solid var(--rule); border-radius: 10px; background: #fafbfc; padding: 14px 16px; margin: 22px 0; }
.check .q { font-weight: 600; margin-bottom: 8px; }
.check .opts { display: grid; gap: 6px; }
.check .opts button { text-align: left; font: inherit; font-size: .95rem; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 4px; background: #fbfcfd; cursor: pointer; color: var(--ink); }
.check .opts button:hover { border-color: var(--ink); }
.check .opts button.right { border-color: var(--lane-vision); background: #e6f4f1; }
.check .opts button.wrong { border-color: var(--red); background: #fbeceb; }
.check .why { display: none; margin-top: 10px; font-size: .93rem; }
.check.done .why { display: block; }

/* 历史卡 */
.history { border-top: 2px solid var(--ink); margin-top: 40px; padding-top: 12px; }
.history h3 { margin-top: .4em; }
.timeline-mini { list-style: none; padding: 0; margin: 0; }
.timeline-mini li { display: grid; grid-template-columns: 4.5em 1fr; gap: 14px; padding: 7px 0; border-bottom: 1px dotted var(--rule); font-size: .95rem; }
.timeline-mini .yr { font-family: var(--f-num); color: var(--graphite); }

/* 下一课 */
.next {
  margin-top: 40px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  border: 1px solid var(--rule); border-radius: 10px; padding: 18px 20px; background: #fafbfc;
}
.next .t { font-family: var(--f-hand); font-size: 1.2rem; }
.next .s { color: var(--graphite); font-size: .9rem; }
.done-row { margin-top: 28px; display: flex; gap: 12px; align-items: center; color: var(--graphite); font-size: .9rem; }

/* 数学 */
.katex { font-size: 1.06em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* 通用小矩阵（交互用） */
.mat { display: inline-grid; gap: 2px; font-family: var(--f-num); font-size: .82rem; vertical-align: middle; }
.mat span { min-width: 3.1em; padding: 3px 4px; text-align: center; background: #f1f4f7; border-radius: 2px; }
.mat span.hot { background: var(--marker); }
.mat span.src { outline: 2px solid var(--lane-lang); }
.mat-label { font-size: .8rem; color: var(--graphite); text-align: center; margin-top: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; color: var(--graphite); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

footer.site { border-top: 1px solid var(--rule); color: var(--faint); font-size: .84rem; padding: 26px clamp(16px, 4vw, 40px); text-align: left; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ================= 组件：主图常驻的分步讲解（scrolly） =================
   用法：<section class="scrolly"><div class="scrolly-text"><div class="step" data-step="名字">…</div>…</div>
         <div class="scrolly-stage"><div class="stage-card">…</div></div></section>
   common.js 的 SI.scrolly(section, fn) 会在每一步滚到屏幕中间时调用 fn(名字)。 */
.lesson.wide { grid-template-columns: 200px minmax(0, 980px); gap: 44px; max-width: 1260px; }
.lesson.wide main > :not(.scrolly) { max-width: 720px; }
.scrolly { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 40px; margin: 10px 0 30px; }
.scrolly-text { padding-bottom: 22vh; }
.scrolly .step {
  min-height: 50vh; display: flex; flex-direction: column; justify-content: center;
  opacity: .6; transition: opacity .35s;
}
.scrolly .step.on { opacity: 1; }
.scrolly .step:first-child { min-height: 46vh; justify-content: flex-start; padding-top: 6vh; }
.step-no { font-size: .8rem; color: var(--graphite); margin-bottom: 4px; }
.step h3 { margin: 0 0 8px; font-size: 1.3rem; }
.scrolly-stage { position: relative; }
.stage-card {
  position: sticky; top: 76px; border: 1px solid var(--rule); border-radius: 12px; background: #fafbfc; padding: 16px 18px 14px;
}
.stage-cap { font-size: .86rem; color: var(--graphite); min-height: 1.5em; margin-bottom: 6px; }
.stage-cap b { color: var(--ink); }
@media (max-width: 960px) {
  .lesson.wide { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .scrolly { grid-template-columns: 1fr; gap: 0; }
  /* 手机：图跟着正文走，不吸顶；正文一次一步，用上一步 / 下一步翻（见 common.js） */
  .scrolly-stage { order: -1; position: static; }
  .stage-card { position: static; padding: 10px 12px 8px; }
  .scrolly .step { min-height: 0; opacity: 1; display: block; padding-top: 0; }
  .scrolly .step:first-child { min-height: 0; padding-top: 0; }
  .scrolly-text { padding-bottom: 0; }
  .scrolly.paged .step-no { display: none; }
  .scrolly.paged .step h3 { margin-top: 6px; }
}
.step-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; }
.step-pager .sp-pos { font: .86rem var(--f-num); color: var(--graphite); }
.step-pager .btn:disabled { opacity: .35; cursor: default; }
.scrolly-text > .step-pager { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule); }

/* ================= 组件：先猜一猜 =================
   <div class="guess"><p class="gq">问题</p><div class="gopts"><button>A</button><button data-right>B</button></div>
   <p class="greveal">揭晓后才出现的解释</p></div> */
.guess { border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; margin: 14px 0; background: #fafbfc; }
.guess .gq { margin: 0 0 8px; font-weight: 600; }
.guess .gq::before { content: "先猜一猜　"; color: var(--graphite); font-weight: 400; font-size: .86rem; }
.guess .gopts { display: flex; flex-wrap: wrap; gap: 6px; }
.guess .gopts button { font: inherit; font-size: .92rem; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--rule); background: #fff; cursor: pointer; color: var(--ink); }
.guess .gopts button:hover { border-color: var(--ink); }
.guess .gopts button.right { background: #e6f4f1; border-color: var(--lane-vision); }
.guess .gopts button.wrong { background: #fbeceb; border-color: var(--red); }
.guess .greveal { display: none; margin: 10px 0 0; font-size: .95rem; }
.guess.done .greveal { display: block; }
.guess .gverdict { font-weight: 700; margin-right: 4px; }

/* ================= 组件：原地展开计算 =================
   <details class="more"><summary>展开：这一步怎么算</summary>…</details> */
details.more { border-left: 2px solid var(--lane-learn); margin: 12px 0 16px; padding: 0 0 0 14px; }
details.more > summary { cursor: pointer; color: var(--lane-learn); font-size: .92rem; list-style: none; padding: 2px 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "＋ "; }
details.more[open] > summary::before { content: "－ "; }
details.more[open] > summary { margin-bottom: 8px; }

/* ================= 组件：带反馈的小任务 ================= */
.tasks { list-style: none; padding: 0; margin: 10px 0 0; }
.tasks li { display: grid; grid-template-columns: 1.4em 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px dotted var(--rule); font-size: .94rem; }
.tasks li::before { content: "○"; color: var(--faint); }
.tasks li.ok::before { content: "●"; color: var(--lane-vision); }
.tasks li .fb { display: none; grid-column: 2; color: var(--ink-2); font-size: .9rem; background: #f0f7f5; border-radius: 6px; padding: 6px 10px; margin-top: 4px; }
.tasks li.ok .fb { display: block; }

/* ================= 全局框架图 ================= */
.fw-figure svg { display: block; width: 100%; height: auto; }
.fw-tag { font: 12px var(--f-body); }
.fw-title { font: 700 17px var(--f-hand); fill: var(--ink); }
.fw-sub { font: 13px var(--f-body); fill: var(--ink-2); }
.fw-where { font: 12px var(--f-body); fill: var(--lane-learn); }
.fw-where.soon { fill: var(--faint); }
.fw-link { cursor: pointer; }
.fw-link:hover rect, .fw-link:focus-visible rect { stroke-width: 2.4; }
.fw-mini { display: block; text-decoration: none; margin-top: 22px; }
.fw-mini svg { width: 100%; height: auto; display: block; }
.fw-mini-cap { font-size: .8rem; color: var(--graphite); margin-bottom: 6px; }
.fw-mini:hover .fw-mini-cap { color: var(--ink); text-decoration: underline; }
.lesson-head .fw-mini { display: none; max-width: 220px; margin: 0 0 18px; }
@media (max-width: 960px) { .lesson-head .fw-mini { display: block; } }

/* ================= 词典：正文里的词和解释气泡 ================= */
.term { border-bottom: 1.5px dotted var(--lane-learn); cursor: help; }
.term:hover, .term:focus-visible { background: #eef3fb; border-radius: 2px; }
.term-tip {
  position: absolute; z-index: 50; display: none; background: #fff; border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(28, 42, 67, .14); padding: 12px 14px; font-size: .9rem; line-height: 1.7;
}
.term-tip .tt-t { font-family: var(--f-hand); font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.term-tip .tt-t small { font-family: var(--f-body); font-weight: 400; font-size: .78rem; color: var(--graphite); margin-left: 8px; }
.term-tip .tt-d { color: var(--ink-2); }
.term-tip .tt-m { margin-top: 6px; font-size: .82rem; }

/* ================= 三层：说人话 / 推公式 / 写代码 ================= */
.lens { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 22px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: #fafbfc; }
.lens-label { font-size: .85rem; color: var(--graphite); }
.lens-switch { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.lens-switch button { font: inherit; font-size: .86rem; border: 0; background: #fff; color: var(--ink); padding: 3px 13px; cursor: pointer; }
.lens-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.lens-hint { font-size: .82rem; color: var(--graphite); flex: 1 1 18em; }
.layers { margin: 12px 0 16px; }
.layer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 6px; }
.layer-bar button { font: inherit; font-size: .9rem; padding: 2px 0; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.layer-bar button::before { content: "▸ "; color: var(--graphite); }
.layer-bar button[aria-expanded="true"]::before { content: "▾ "; }
.layer-bar button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.layer { display: none; margin-top: 8px; padding-left: 14px; border-left: 2px solid var(--rule); }

.layer.open { display: block; }
pre.code { margin: 0 0 8px; background: #f6f8fa; border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font: .82rem/1.65 var(--f-num); }
pre.code code { font: inherit; }
.c-com { color: #6a737d; } .c-str { color: #0f8577; } .c-kw { color: #6a4cb0; font-weight: 600; } .c-num { color: #b8730e; }
.code-out { margin: 0 0 12px; font-size: .8rem; }
.code-out span { display: inline-block; color: var(--graphite); margin-bottom: 2px; }
.code-out pre { margin: 0; padding: 8px 14px; background: #1c2a43; color: #e6edf5; border-radius: 8px; font: .82rem/1.6 var(--f-num); overflow-x: auto; }
.download { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; margin: 34px 0 0; padding: 16px 18px; border: 1px solid var(--rule); border-radius: 10px; background: #f3faf8; }
.download b { display: block; font-family: var(--f-hand); font-size: 1.05rem; }
.download span { font-size: .88rem; color: var(--ink-2); }
@media (max-width: 560px) { .download { grid-template-columns: 1fr; } }

/* ---------- 手算填空 ---------- */
.pen { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 8px; background: #fafbfc; }
.pen .cq { margin: 0 0 10px; }
.pen .cq::before { content: "算一算　"; color: var(--graphite); font-size: .86rem; }
.pen .crow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pen input { font: 1rem var(--f-num); width: 9em; padding: 5px 9px; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; }
.pen.ok input { border-color: #2f8f6a; background: #eef8f3; }
.pen.no input { border-color: #c23a2e; }
.pen .cfb { font-size: .9rem; min-height: 1.2em; margin-top: 6px; color: var(--ink-2); }
.pen.ok .cfb { color: #2f8f6a; }
.pen.no .cfb { color: #c23a2e; }
.pen .csol { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rule); }
.pen.open .csol { display: block; }

/* ---------- 矩阵可视化 ---------- */
.mv { margin: 18px 0; padding: 14px 14px 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); overflow-x: auto; }
.mv-row { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; width: max-content; }
.mv-b { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mv-name { font: 600 .92rem var(--f-hand); color: var(--ink); }
.mv-shape { font: .74rem var(--f-num); color: var(--graphite); background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 0 7px; }
.mv-op { font: 1.2rem var(--f-num); color: var(--graphite); }
.mv-m { border-collapse: separate; border-spacing: 3px; }
.mv-m td { min-width: 2.3em; height: 2.1em; text-align: center; font: .92rem var(--f-num); background: #fff; border: 1px solid #d5dce1; border-radius: 4px; padding: 0 5px; transition: background .2s, border-color .2s; }
.mv-m th { font: .72rem var(--f-body); color: var(--graphite); font-weight: 400; padding: 0 4px; white-space: nowrap; }
.mv-m.mv-a td.on { background: #e6eefb; border-color: #2c5aa6; }
.mv-m.mv-bb td.on { background: #fdf3cf; border-color: #b58a00; }
.mv-m.mv-c td { cursor: pointer; background: #fbfcfd; }
.mv-m.mv-c td.done { background: #fff; }
.mv-m.mv-c td.hit, .mv-m td.hit { background: #fde7e4; border-color: #c23a2e; font-weight: 700; }
.mv-say { margin-top: 10px; font-size: .9rem; color: var(--ink-2); min-height: 2.6em; }
.mv-say .mv-t { font-family: var(--f-num); white-space: nowrap; }
.mv-say .mv-why { display: block; font-size: .8rem; color: var(--graphite); margin-top: 2px; }
.mv-ctl { margin-top: 6px; }
@media (max-width: 700px) {
  .mv { padding: 10px 8px 8px; }
  .mv-row { flex-wrap: wrap; width: auto; gap: 6px; }
  .mv-m { border-spacing: 2px; }
  .mv-m td { min-width: 1.9em; height: 1.8em; font-size: .82rem; padding: 0 3px; }
  .mv-m th { font-size: .66rem; padding: 0 2px; }
}

/* ---------- 动笔推导块 ---------- */
.pentrack { margin: 14px 0 26px; border: 1px solid var(--rule); border-radius: 10px; padding: 0 16px; background: #fff; }
.pentrack .pt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 0; }
.pentrack .pt-tag { display: none; }
.pentrack .pt-t { font-weight: 600; flex: 1 1 12em; }
.pentrack .pt-time { font-size: .82rem; color: var(--graphite); }
.pentrack > :not(.pt-head) { display: none; }
.pentrack.open > :not(.pt-head) { display: block; }
.pentrack.open { padding-bottom: 6px; }
.pentrack.open .pt-head { border-bottom: 1px dashed var(--rule); margin-bottom: 8px; }

/* ---------- 同一个量，全站同一种颜色 ---------- */
:root { --c-w: #2c5aa6; --c-loss: #c23a2e; --c-grad: #c8781a; }
.q-w { color: var(--c-w); }
.q-loss { color: var(--c-loss); }
.q-grad { color: var(--c-grad); }
.qlegend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--graphite); margin: 2px 0 4px; }
.qlegend span::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; background: currentColor; }
.qlegend .q-w, .qlegend .q-loss, .qlegend .q-grad { font-weight: 600; }
.stage-ctrl { display: none; margin-top: 8px; border-top: 1px solid var(--rule); padding-top: 8px; }
.stage-ctrl.on { display: block; }
.stage-ctrl .ok-note { font-size: .86rem; color: #2f8f6a; min-height: 1.2em; margin-top: 4px; }
.tasks li .try { margin-left: 8px; font-size: .78rem; padding: 0 8px; }

/* ---------- 计算图 ---------- */
svg.cg { display: block; width: 100%; height: auto; }
.cg .cg-n { cursor: pointer; }
.cg .cg-n:focus { outline: none; }
.cg .cg-n:focus rect { stroke-width: 3; }
.cg .cg-name { font: 600 13px var(--f-num); }
.cg .cg-op { font: 600 13px var(--f-num); fill: #1c2a43; }
.cg .cg-v { font: 14px var(--f-num); fill: #1c2a43; }
.cg .cg-g { font: 600 14px var(--f-num); }
.cg .cg-d { font: 600 12.5px var(--f-num); }
.cg-say { min-height: 3.6em; }
.cg-box { margin: 18px 0; padding: 12px 14px 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); }
@media (max-width: 700px) {
  .cg .cg-pre { display: none; }
  .cg .cg-v, .cg .cg-g { font-size: 21px; }
  .cg .cg-name, .cg .cg-op { font-size: 16px; }
  .cg .cg-d { font-size: 15px; }
}
.cg-host, .cg-scroll { max-width: 100%; min-width: 0; }
.scrolly-stage, .stage-card, .scrolly-text { min-width: 0; }
.next .nx-wide { flex: 1; }
.next .exits { list-style: none; margin: 10px 0 0; padding: 0; }
.next .exits li { padding: 8px 0; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 2px; }
.next .exits a { color: var(--ink); text-decoration: none; }
.next .exits a b { border-bottom: 1px solid var(--ink); }
.next .exits span { font-size: .88rem; color: var(--graphite); }
.next .exits .unavailable { color: var(--graphite); font-size: .9rem; }
.next .exits .unavailable span { margin-left: .5em; font-size: .78rem; }
.next .catalog-return { display: inline-block; margin-top: 18px; font-size: .9rem; }
.math-bridge { margin: 15px 0 20px; padding: 11px 15px; background: #f1f5f9; border-radius: 8px; font-size: .86rem; }
.math-bridge summary { cursor: pointer; color: #45627e; }
.math-bridge > div { display: flex; flex-wrap: wrap; gap: 10px 18px; padding-top: 12px; }
.math-bridge span { color: var(--graphite); font-size: .78rem; }
.math-return { display: inline-block; margin: 0 0 20px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 7px; font-size: .88rem; }
.python-mini { padding: 20px; border: 1px solid var(--rule); background: #f8fafc; border-radius: 12px; margin: 20px 0; }
.python-mini .py-cells { display: flex; flex-wrap: wrap; gap: 7px; margin: 15px 0; }
.py-cells span { padding: 9px 14px; border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; font: .95rem var(--f-num); }
.py-cells span.active { background: #fff1ce; border-color: #bb7b25; }
.python-mini label { margin-right: 18px; font-size: .88rem; }
.python-mini select { padding: 5px; font: inherit; }
.python-mini output { display: block; padding: 12px; background: #eaf0f8; border-radius: 7px; font: .86rem/1.7 var(--f-num); overflow-wrap: anywhere; }
.python-mini .py-note { min-height: 3em; font-size: .86rem; color: var(--ink-2); }

/* 阅读书签：保持封面安静，只在有记录时出现。 */
.reading-resume { margin-top: 22px; padding: 12px 0 0; border-top: 1px solid rgba(198, 212, 238, .18); max-width: 25em; }
.reading-resume-link { display: grid; gap: 3px; color: #e8ecf2; text-decoration: none; border-radius: 4px; }
.reading-resume-k { font-size: .76rem; color: #b8c7e0; letter-spacing: .06em; }
.reading-resume-link b { font: 500 .9rem/1.5 var(--f-body); overflow-wrap: anywhere; }
.reading-resume-at { font-size: .8rem; line-height: 1.55; color: #b4bdcc; overflow-wrap: anywhere; }
.reading-resume-link:hover b { text-decoration: underline; text-underline-offset: 4px; }
.reading-resume-note { display: flex; gap: 12px; align-items: center; margin-top: 5px; color: #8e9aaf; font-size: .7rem; }
.reading-resume-note button { padding: 6px 9px; min-height: 28px; border: 0; border-radius: 3px; background: transparent; font: inherit; color: #b4bdcc; cursor: pointer; }
.reading-resume-note button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.reading-resume a:focus-visible, .reading-resume button:focus-visible { outline: 2px solid #c6d8ff; outline-offset: 4px; }
.math-bridge summary:focus-visible, .math-bridge a:focus-visible, .math-return:focus-visible { outline: 2px solid var(--lane-learn); outline-offset: 4px; }
@media (max-width: 560px) { .reading-resume { max-width: none; margin-top: 18px; } }
@media (min-width: 861px) { .sky.has-reading-resume { min-height: 740px; } }

/* ---------- 对照表（MATLAB 对照等） ---------- */
.matlab { margin: 22px 0; padding: 14px 18px 8px; border: 1px solid var(--rule); border-radius: 10px; background: #fafbfc; }
.matlab-t { font-family: var(--f-hand); font-weight: 700; font-size: 1.05rem; margin: 0 0 6px; }
table.cmp { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.cmp th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--graphite); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--ink); }
table.cmp td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.cmp tr:last-child td { border-bottom: 0; }
table.cmp td:first-child { color: var(--ink-2); white-space: nowrap; }
details.more > .matlab { margin-top: 8px; }

/* ---------- 科学线：快车道提示与课末副线 ---------- */
.sci-lane { margin: 14px 0 0; padding: 7px 14px; font-size: .88rem; line-height: 1.7; color: var(--ink-2); border-left: 3px solid var(--lane-vision); background: #f6faf9; border-radius: 0 6px 6px 0; max-width: 46em; }
.sci-side { margin: 44px 0 10px; padding: 22px 26px 10px; border: 1px solid #cfe3de; border-radius: 12px; background: #fbfdfc; max-width: 720px; }
.sci-side .ss-tag { margin: 0 0 2px; font-size: .78rem; letter-spacing: .08em; color: var(--lane-vision); font-weight: 600; }
.sci-side h3 { margin: 0 0 10px; font-size: 1.25rem; }
.sci-side .ss-foot { font-size: .86rem; color: var(--graphite); margin-top: 14px; }
.sci-side .pen { margin-top: 14px; }

/* 已经不用的开头信息块 */
.lesson-facts, .lens, .sci-lane, .math-bridge, .ci-reading-path { display: none !important; }
.scrolly.paged .step[hidden] { display: none !important; }
.lesson-head .where a { color: var(--graphite); text-decoration: none; }
.lesson-head .where a:hover { color: var(--ink); text-decoration: underline; }

/* 正文里的宽表格在手机上横向滑动，不撑破页面 */
main table.cmp, main table.shape-tab { display: block; max-width: 100%; overflow-x: auto; position: relative; }

/* KaTeX 给读屏用的 MathML 不占版面宽度（否则手机上会撑出横向滚动） */
.katex .katex-mathml { width: 1px; height: 1px; overflow: hidden; }
