/* ============================================================
   纸感手作设计系统 —— 认知发展课程站点
   核心规则：底色克制到几乎无色，颜色只发给小元素。
   点缀色（芥末/珊瑚/薄荷/靛蓝/紫丁香/天青/梅红）一章一色，
   只出现在序号、圆点、胶带、hover 反馈这类小元素上。
   ============================================================ */

:root {
  /* 底色三阶：纸、深纸、卡片 —— 卡片比底色更亮，不是更暗 */
  --paper: #faf7f1;
  --paper-deep: #f3eee5;
  --card-bg: #fffdf8;

  /* 墨色开透明度，不用独立的灰；四档差值拉开 */
  --ink: #221d16;
  --ink-soft: rgba(34, 29, 22, 0.64);
  --ink-faint: rgba(34, 29, 22, 0.38);
  --hairline: rgba(34, 29, 22, 0.14);
  --hairline-soft: rgba(34, 29, 22, 0.07);

  /* 点缀色：绝不做大面积背景 */
  --coral: #ff6a55;
  --mustard: #f0b23e;
  --indigo: #4c5bd6;
  --mint: #2f9e78;
  --lilac: #8b62d6;
  --sky: #2b7fa6;
  --plum: #a8437c;
  --accent: var(--indigo);

  /* 字体三分工：衬线管标题，无衬线管正文，等宽管一切元信息。
     首选名与系统兜底并列，因此不需要加载任何外部字体。 */
  --serif: "Fraunces", "Iowan Old Style", "Source Serif 4", Georgia,
           "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC",
           "Songti SC", SimSun, serif;
  --sans: "Noto Sans SC", "PingFang SC", ui-sans-serif, -apple-system,
          "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --wrap: 1240px;
  --pad-inline: clamp(1.1rem, 3.4vw, 2.4rem);
  --measure: 66ch;
  --radius: clamp(0.9rem, 2vw, 1.3rem);

  /* 双层阴影：硬边给厚度，软投影给高度 —— 不能简化成单层 */
  --shadow-sticker:
    0 1px 0 rgba(34, 29, 22, 0.05),
    0 24px 48px -24px rgba(34, 29, 22, 0.28);
  --shadow-lift:
    0 1px 0 rgba(34, 29, 22, 0.05),
    0 30px 56px -26px rgba(34, 29, 22, 0.34);

  /* 两条缓动，分工明确 */
  --ease-settle: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.7, 0.5, 1);

  --noise: 0.045;
}

/* 深色：噪点减半以下、阴影首层暗边换高光、点缀色降饱和提亮 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15120e;
    --paper-deep: #100e0b;
    --card-bg: #1d1a15;

    --ink: #f1ece3;
    --ink-soft: rgba(241, 236, 227, 0.64);
    --ink-faint: rgba(241, 236, 227, 0.38);
    --hairline: rgba(241, 236, 227, 0.14);
    --hairline-soft: rgba(241, 236, 227, 0.07);

    --coral: #f0907c;
    --mustard: #e3bd72;
    --indigo: #929cec;
    --mint: #74c8a9;
    --lilac: #b39ae4;
    --sky: #7cb4d2;
    --plum: #dd90bb;

    --shadow-sticker:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 24px 48px -24px rgba(0, 0, 0, 0.72);
    --shadow-lift:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 30px 56px -26px rgba(0, 0, 0, 0.8);

    --noise: 0.02;
  }
}
:root[data-theme="dark"] {
  --paper: #15120e;
  --paper-deep: #100e0b;
  --card-bg: #1d1a15;

  --ink: #f1ece3;
  --ink-soft: rgba(241, 236, 227, 0.64);
  --ink-faint: rgba(241, 236, 227, 0.38);
  --hairline: rgba(241, 236, 227, 0.14);
  --hairline-soft: rgba(241, 236, 227, 0.07);

  --coral: #f0907c;
  --mustard: #e3bd72;
  --indigo: #929cec;
  --mint: #74c8a9;
  --lilac: #b39ae4;
  --sky: #7cb4d2;
  --plum: #dd90bb;

  --shadow-sticker:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 24px 48px -24px rgba(0, 0, 0, 0.72);
  --shadow-lift:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 30px 56px -26px rgba(0, 0, 0, 0.8);

  --noise: 0.02;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 纸张噪点：inline SVG feTurbulence，零请求零图片 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: var(--noise);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
img { max-width: 100%; }

/* 元信息四件套：小字号 + 大字距 + 淡色 + 等宽，四件缺一不可 */
.meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.skip {
  position: fixed; top: -100px; left: 12px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 99px;
}
.skip:focus { top: 12px; }

kbd {
  font: 500 11px/1 var(--mono);
  border: 1px solid var(--hairline); border-radius: 5px;
  padding: 3px 5px; color: var(--ink-faint); background: var(--paper-deep);
}

/* ============================================================ 页面骨架 */
.progress {
  position: fixed; inset: 0 auto auto 0; height: 2px; width: 0;
  background: var(--accent); z-index: 60; transition: width .1s linear;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--pad-inline);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline-soft);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: var(--ink); color: var(--paper); font: 600 15px/1 var(--serif);
  box-shadow: var(--shadow-sticker);
  transform: rotate(-2deg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text b { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.brand-text small {
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-faint);
}
.topbar-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--mono); font-size: .78rem; letter-spacing: .12em;
  text-transform: uppercase; cursor: pointer; text-decoration: none;
  border-radius: 99px; padding: .7em 1.25em;
  color: var(--ink-soft); background: transparent; border: 1px solid var(--hairline);
  transition: transform .35s var(--ease-spring), background .25s ease, color .25s ease, border-color .25s ease;
}
.btn:hover { color: var(--ink); border-color: var(--ink-faint); transform: translateY(-3px) rotate(-1deg); }
.btn.primary {
  color: var(--paper); background: var(--ink); border-color: var(--ink);
  box-shadow: var(--shadow-sticker);
}
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn .ico { font-size: 15px; line-height: 1; letter-spacing: 0; }
.only-sm { display: none; }

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: clamp(20px, 4vw, 56px);
  max-width: var(--wrap); margin: 0 auto;
  padding: 28px var(--pad-inline) 72px;
}
.sidebar { position: sticky; top: 82px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; }
.sidebar-label { margin: 0 0 12px; }
.sidebar-note { font-size: 13px; color: var(--ink-faint); line-height: 1.7; margin: 0; }

/* 章节行：hover 缩进 + 序号变色 */
.nav { display: flex; flex-direction: column; margin-bottom: 30px; }
.nav-item {
  position: relative;
  display: flex; gap: 12px; align-items: baseline;
  padding: 12px 0; text-decoration: none;
  border-bottom: 1px solid var(--hairline-soft);
  transition: padding-left .4s var(--ease-settle);
}
.nav-item:hover { padding-left: .7rem; }
.nav-num {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .12em;
  color: var(--ink-faint); transition: color .25s ease;
}
.nav-item:hover .nav-num, .nav-item.is-active .nav-num { color: var(--accent); }
.nav-text { display: flex; flex-direction: column; min-width: 0; }
.nav-title { font-size: 14.5px; font-weight: 500; line-height: 1.5; }
.nav-sub {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
}
.nav-item.is-active { padding-left: .7rem; }
.nav-item.is-active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

/* ================================================================ 首页 */
.hero { padding: clamp(28px, 6vw, 56px) 0 8px; max-width: 780px; }
.eyebrow { margin: 0 0 18px; }
.hero h1 {
  font-family: var(--serif); font-size: clamp(34px, 5.6vw, 58px); line-height: 1.16;
  margin: 0 0 20px; font-weight: 600; letter-spacing: -.015em;
}
.hero h1 em { font-style: italic; color: var(--accent); white-space: nowrap; }
.lede {
  font-size: clamp(16px, 1.7vw, 18.5px); color: var(--ink-soft);
  margin: 0 0 30px; max-width: 60ch;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.stats {
  display: flex; flex-wrap: wrap; gap: clamp(24px, 5vw, 48px);
  margin: 44px 0 0; padding: 24px 0 0; border-top: 1px solid var(--hairline);
}
.stats div { margin: 0; }
.stats dt { margin-bottom: 6px; }
.stats dd { margin: 0; font: 600 28px/1 var(--serif); }
.stats dd::after {
  content: ''; display: block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); margin-top: 10px;
}

.cards {
  display: grid; gap: clamp(18px, 2.4vw, 26px); margin: clamp(48px, 8vw, 76px) 0 0;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column;
  margin-top: .85rem; padding: clamp(1.5rem, 2.4vw, 1.9rem);
  text-decoration: none; background: var(--card-bg);
  border-radius: var(--radius); box-shadow: var(--shadow-sticker);
  transition: transform .35s var(--ease-spring), box-shadow .35s var(--ease-settle);
}
.card:hover { transform: translateY(-4px) rotate(-.6deg); box-shadow: var(--shadow-lift); }
.card-num { display: block; margin-bottom: 14px; }
.card h3 { font-family: var(--serif); font-size: 23px; margin: 0 0 8px; font-weight: 600; line-height: 1.35; }
.card-en {
  margin: 0 0 14px; font-family: var(--mono); font-size: 11px;
  letter-spacing: .06em; color: var(--ink-faint); line-height: 1.7;
}
.card-blurb { margin: 0 0 18px; font-size: 14.5px; color: var(--ink-soft); line-height: 1.7; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; margin: 0 0 18px; padding: 0; }
.tags li {
  font-size: 12px; padding: 3px 10px; border-radius: 99px;
  background: var(--paper-deep); color: var(--ink-soft);
}
.card-meta { margin-top: auto; }

/* 和纸胶带：纯 CSS，clip-path 剪出撕口 */
.tape {
  position: absolute; top: -.85rem; left: clamp(1.6rem, 12%, 3.4rem);
  width: 5.6rem; height: 1.55rem;
  background: var(--accent); opacity: .82;
  transform: rotate(-3.5deg); border-radius: 2px;
  box-shadow: 0 2px 6px rgba(34, 29, 22, .12);
}
.tape::before, .tape::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: .45rem;
  background: inherit;
  clip-path: polygon(0 0, 100% 12%, 60% 30%, 100% 52%, 55% 74%, 100% 92%, 0 100%);
}
.tape::before { left: -.4rem; transform: scaleX(-1); }
.tape::after { right: -.4rem; }

.thread {
  position: relative; margin: clamp(52px, 8vw, 88px) 0 0;
  padding: clamp(1.8rem, 4vw, 2.6rem);
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-sticker); max-width: 880px;
}
.thread h2 { font-family: var(--serif); font-size: 24px; margin: 0 0 18px; font-weight: 600; }
.thread-list { margin: 0; padding-left: 1.4rem; color: var(--ink-soft); }
.thread-list li { margin-bottom: 11px; padding-left: .3rem; }
.thread-list li::marker { font-family: var(--mono); font-size: .8rem; color: var(--ink-faint); }
.thread-list b { color: var(--ink); font-weight: 600; }

/* ================================================================ 章节 */
.chapter-head {
  max-width: var(--measure); padding: clamp(24px, 5vw, 44px) 0 30px;
  border-bottom: 1px solid var(--hairline);
}
.chapter-head h1 {
  font-family: var(--serif); font-size: clamp(30px, 4.6vw, 46px); line-height: 1.2;
  margin: 0 0 14px; font-weight: 600; letter-spacing: -.012em;
}
.chapter-en {
  margin: 0 0 18px; font-family: var(--mono); font-size: 11.5px;
  letter-spacing: .08em; color: var(--ink-faint); line-height: 1.8;
}
.chapter-blurb { margin: 0 0 22px; font-size: 16.5px; color: var(--ink-soft); max-width: 58ch; }
.chapter-meta { margin: 0; }
.chapter-meta b { color: var(--accent); font-weight: 400; }

.chapter-body { display: grid; grid-template-columns: minmax(0, 1fr) 224px; gap: clamp(24px, 4vw, 60px); }
.toc { position: sticky; top: 82px; align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; padding-top: 38px; }
.toc-label { margin: 0 0 12px; }
.toc nav { display: flex; flex-direction: column; border-left: 1px solid var(--hairline); }
.toc-item {
  padding: 6px 0 6px 14px; margin-left: -1px; font-size: 12.8px; color: var(--ink-faint);
  text-decoration: none; border-left: 2px solid transparent; line-height: 1.5;
  transition: color .25s ease;
}
.toc-item.d3 { padding-left: 26px; font-size: 12.2px; }
.toc-item:hover { color: var(--ink); }
.toc-item.is-current { color: var(--accent); border-left-color: var(--accent); }

/* ================================================================ 正文 */
.prose { max-width: var(--measure); padding-top: 6px; font-size: 16.5px; }
.prose > *:first-child { margin-top: 30px; }
.prose h2 {
  position: relative;
  font-family: var(--serif); font-size: 28px; line-height: 1.3; font-weight: 600;
  margin: 60px 0 18px; padding-top: 26px; border-top: 1px solid var(--hairline);
}
.prose h2::before {
  content: ''; position: absolute; top: -3px; left: 0;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
/* 首节紧接章节头的分隔线，不再叠一条 */
.prose > h2:first-child { border-top: 0; margin-top: 34px; padding-top: 4px; }
.prose h3 { font-family: var(--serif); font-size: 21px; margin: 38px 0 12px; font-weight: 600; }
.prose h4 { font-size: 16px; margin: 28px 0 10px; font-weight: 700; color: var(--ink); }
.h-anchor { position: relative; }
.h-anchor > a {
  position: absolute; left: -1.1em; top: auto; bottom: 0;
  color: var(--accent); text-decoration: none; opacity: 0;
  font: 400 .62em/2.6 var(--mono); transition: opacity .25s ease;
}
.h-anchor:hover > a, .h-anchor > a:focus { opacity: .55; }

.prose p { margin: 0 0 20px; color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-family: var(--serif); }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose ul, .prose ol { margin: 0 0 22px; padding-left: 1.6rem; color: var(--ink-soft); }
.prose li { margin-bottom: 9px; }
.prose li::marker { color: var(--ink-faint); }
.prose ol > li::marker { font-family: var(--mono); font-size: .82rem; }
.prose li > p { margin-bottom: 9px; }
.prose hr { border: 0; border-top: 1px solid var(--hairline); margin: 48px 0; }

.prose blockquote {
  margin: 26px 0; padding: 2px 0 2px 22px; border-left: 2px solid var(--accent);
  color: var(--ink-soft); font-family: var(--serif); font-size: 17.5px;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font: 400 .84em/1.6 var(--mono);
  background: var(--paper-deep); padding: 2px 6px; border-radius: 5px; color: var(--ink);
}
.prose pre.code, .diagram pre {
  background: var(--paper-deep); border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; margin: 0 0 24px;
}
.prose pre code, .diagram pre code {
  background: none; padding: 0; font-size: 13px; line-height: 1.7; color: var(--ink-soft);
}
.diagram { margin: 28px 0; }
.diagram figcaption { margin-bottom: 10px; }

/* 由 mermaid `flowchart TD` 渲染出的流程 */
.flow { margin: 30px 0; }
.flow-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.flow-row { margin: 0; display: flex; flex-direction: column; }
.flow-row + .flow-row::before {
  content: ''; align-self: center; width: 1px; height: 22px; background: var(--hairline);
}
.flow-row + .flow-row::after {
  content: '▾'; align-self: center; color: var(--ink-faint); font-size: 11px; margin: -6px 0 6px;
}
.flow-card {
  position: relative; background: var(--card-bg); border-radius: 12px;
  box-shadow: var(--shadow-sticker); padding: 15px 18px 15px 40px;
}
.flow-card::before {
  content: ''; position: absolute; left: 18px; top: 21px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.flow-card.is-decision {
  padding-left: 18px; text-align: center; background: var(--paper-deep); box-shadow: none;
  border: 1px dashed var(--hairline);
}
.flow-card.is-decision::before { display: none; }
.flow .flow-title { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.flow .flow-detail { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.65; }
.flow-branches { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.flow-branch { display: flex; flex-direction: column; gap: 7px; }
.flow-cond { font: 400 .72rem/1.6 var(--mono); letter-spacing: .06em; color: var(--ink-faint); }
.flow-branch .flow-card { padding-left: 18px; height: 100%; }
.flow-branch .flow-card::before { display: none; }

.table-scroll {
  overflow-x: auto; margin: 0 0 26px;
  border-radius: var(--radius); background: var(--card-bg); box-shadow: var(--shadow-sticker);
}
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td {
  padding: 12px 16px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--hairline-soft);
}
.prose th {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 400; white-space: nowrap;
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td { color: var(--ink-soft); }

/* 行间公式 */
.math-block {
  margin: 28px 0; padding: 26px 20px; overflow-x: auto;
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-sticker);
  text-align: center; font-family: var(--serif); font-size: 17px; white-space: nowrap;
}
.m-frac { display: inline-flex; flex-direction: column; vertical-align: middle; margin: 0 .28em; text-align: center; }
.m-num { border-bottom: 1px solid currentColor; padding: 0 .35em .12em; }
.m-den { padding: .12em .35em 0; }
.m-brace { display: inline-flex; flex-direction: column; align-items: center; margin: 0 .3em; }
.m-brace > .m-body { border-bottom: 2px solid var(--hairline); padding-bottom: 5px; }
.m-label {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); padding-top: 7px;
}
.m-text { font-family: var(--sans); font-size: .95em; }

/* ================================================================ 页脚 */
.pager {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: var(--measure); margin: 72px 0 0; padding-top: 30px; border-top: 1px solid var(--hairline);
}
.pager-link {
  display: flex; flex-direction: column; gap: 8px; text-decoration: none;
  padding: 16px 20px; border-radius: var(--radius);
  background: var(--card-bg); box-shadow: var(--shadow-sticker); min-width: 200px;
  transition: transform .35s var(--ease-spring), box-shadow .35s var(--ease-settle);
}
.pager-link:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow-lift); }
.pager-link span {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint);
}
.pager-link b { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.pager-link.next { text-align: right; margin-left: auto; }

.footer {
  background: var(--paper-deep); padding: 26px var(--pad-inline); text-align: center;
}
.footer span { font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }

/* ================================================================ 搜索 */
.search-modal {
  position: fixed; inset: 0; z-index: 90; padding: 12vh 16px 16px;
  background: color-mix(in srgb, var(--paper) 60%, transparent); backdrop-filter: blur(7px);
  display: flex; justify-content: center; align-items: flex-start;
}
.search-modal[hidden] { display: none; }
.search-panel {
  width: min(680px, 100%); background: var(--card-bg);
  border-radius: var(--radius); box-shadow: var(--shadow-lift); overflow: hidden;
  display: flex; flex-direction: column; max-height: 74vh;
}
#search-input {
  font: inherit; font-size: 16px; padding: 18px 22px; border: 0;
  border-bottom: 1px solid var(--hairline-soft);
  background: none; color: var(--ink); outline: none; width: 100%;
}
#search-input::placeholder { color: var(--ink-faint); }
.search-results { overflow-y: auto; padding: 8px; }
.search-hit { display: block; padding: 12px 15px; border-radius: 11px; text-decoration: none; cursor: pointer; }
.search-hit:hover, .search-hit.is-active { background: var(--paper-deep); }
.search-hit .hit-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.search-hit .hit-ch {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.search-hit.is-active .hit-ch, .search-hit:hover .hit-ch { color: var(--accent); }
.search-hit .hit-h { font-size: 14.5px; font-weight: 600; }
.search-hit .hit-snip {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 12.8px; color: var(--ink-faint); margin-top: 4px; line-height: 1.6;
}
.search-hit mark { background: none; color: var(--accent); font-weight: 600; }
.search-empty { padding: 28px 18px; text-align: center; color: var(--ink-faint); font-size: 14px; }
.search-foot {
  border-top: 1px solid var(--hairline-soft); padding: 10px 15px;
  font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); display: flex; gap: 7px; align-items: center;
}

/* ============================================================ 入场动画 */
.reveal {
  opacity: 0; transform: translateY(28px);
  transition: opacity .8s var(--ease-settle), transform .8s var(--ease-settle);
}
.reveal.is-in { opacity: 1; transform: none; }

/* 降级：逐条关，并把 reveal 初始态改回可见 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .card, .pager-link, .nav-item, .toc-item, .flow-card { transition: none; }
  .card:hover, .pager-link:hover, .btn:hover { transform: none; }
  .reveal { transition: none; opacity: 1; transform: none; }
}

/* ============================================================== 响应式 */
@media (max-width: 1080px) {
  .chapter-body { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-top: 18px; }
  .only-sm { display: inline-flex; }
  .hide-sm, .brand-text small { display: none; }
  .sidebar {
    position: fixed; inset: 57px 0 auto; z-index: 45; max-height: 72vh;
    background: var(--card-bg); box-shadow: var(--shadow-lift);
    padding: 20px var(--pad-inline); border-radius: 0 0 var(--radius) var(--radius);
  }
  .sidebar:not(.is-open) { display: none; }
  .prose { font-size: 16px; }
  .pager-link { min-width: 0; flex: 1 1 160px; }
  .card { margin-top: 1rem; }
}
