/* ============================================================
   轻重急缓 · 自在掌握  —— v8
   ------------------------------------------------------------
   设计语言：Claude (Anthropic)
     · 羊皮纸暖底 #f5f4ed，所有中性色都带黄棕底调，全程无冷灰
     · 衬线承担全部标题（weight 500），无衬线只管 UI，等宽只管代码
     · 深度用「环状阴影 0 0 0 1px」与暖色面层差，不用重投影、不用渐变
     · 浅色章节 / 近黑章节交替，像书里的章节
     · 赤陶 #c96442 只留给主 CTA 与最高信号的时刻

   两点刻意偏离（附数值理由，见文末注释）：
     ① 小字用的赤陶/石灰各深一档 —— 原始色在羊皮纸上只有 3.54 / 3.31，
        低于 AA 小字要求的 4.5
     ② 主 CTA 底色压深到 #b35434 —— 原始 #c96442 配象牙字只有 3.70
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  /* 品牌 */
  --terracotta: #c96442;        /* 图形、分隔、插画、大色块（3.54:1，够大字/非文本） */
  --terracotta-deep: #b35434;   /* 主 CTA 底色：象牙字 4.71:1 */
  --terracotta-ink: #a94f2f;    /* 小字赤陶：羊皮纸 4.95:1 */
  --coral: #d97757;             /* 深色底上的强调：近黑 5.90:1 */
  --coral-light: #e08a6e;       /* 深表面上：5.06:1 */
  --moss: #7d8a5c;              /* 插画里的柔绿 */

  /* 语义 / 唯一冷色 */
  --crimson: #b53333;           /* 5.46:1 */
  --focus-blue: #3898ec;

  /* 浅色面 */
  --parchment: #f5f4ed;
  --ivory: #faf9f5;
  --white: #ffffff;
  --sand: #e8e6dc;
  --sand-hover: #e0ded3;

  /* 中性文字（全部暖调） */
  --near-black: #141413;
  --charcoal: #4d4c48;
  --olive: #5e5d59;
  --stone: #87867f;             /* 仅大字 / 装饰 */
  --stone-ink: #66655f;         /* 小字石灰：羊皮纸 5.30:1 */
  --dark-warm: #3d3d3a;

  /* 深色面 */
  --deep-dark: #141413;
  --dark-surface: #30302e;
  --silver: #b0aea5;

  /* 边框 / 环 */
  --border-cream: #f0eee6;
  --border-warm: #e8e6dc;
  --ring-warm: #d1cfc5;
  --ring-deep: #c2c0b6;

  /* 章节上下文 —— 组件一律读这几个，浅深章节各覆盖一次 */
  --s-bg: var(--parchment);
  --s-surface: var(--ivory);
  --s-surface-2: var(--sand);
  --s-fg: var(--near-black);
  --s-fg-2: var(--olive);
  --s-fg-3: var(--stone-ink);
  --s-accent: var(--terracotta-ink);
  --s-accent-bg: var(--terracotta-deep);
  --s-on-accent: var(--ivory);
  --s-ring: var(--border-cream);
  --s-ring-warm: var(--ring-warm);
  --s-ring-deep: var(--ring-deep);
  --s-divider: var(--border-warm);
  --s-invert-bg: var(--near-black);
  --s-invert-fg: var(--ivory);
  --s-field: var(--white);
  --s-hover: rgba(20, 20, 19, .04);

  /* 字体 */
  --serif: "Anthropic Serif", "Source Han Serif SC", "Noto Serif SC", Georgia,
           "Songti SC", "STZhongsong", "SimSun", serif;
  --sans: "Anthropic Sans", "Segoe UI", system-ui, -apple-system,
          "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
          Arial, sans-serif;
  --mono: "Anthropic Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* 衬线统一一个字重（设计语言：所有衬线标题同一个字重，形成一致的「声音」）。
     本机思源宋体只装了 Regular 与 Heavy 两个字面，请求 500 会被解析成 Heavy
     —— 视觉上等同 700+，与「衬线不加粗、500 是上限」直接冲突。故取 Regular。 */
  --w-serif: 400;

  /* 动效 */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --d-press: 160ms;
  --d-hover: 180ms;
  --d-enter: 320ms;
  --d-editorial: 620ms;

  /* 布局 */
  --nav-h: 68px;
  --container: 1200px;
}

/* 近黑章节：只换这一组上下文令牌，所有组件自动适配 */
.chapter-dark {
  --s-bg: var(--deep-dark);
  --s-surface: var(--dark-surface);
  --s-surface-2: rgba(250, 249, 245, .06);
  --s-fg: var(--ivory);
  --s-fg-2: var(--silver);
  --s-fg-3: var(--silver);
  --s-accent: var(--coral);
  --s-accent-bg: var(--coral);
  --s-on-accent: var(--near-black);
  --s-ring: rgba(250, 249, 245, .10);
  --s-ring-warm: rgba(250, 249, 245, .18);
  --s-ring-deep: rgba(250, 249, 245, .30);
  --s-divider: var(--dark-surface);
  --s-invert-bg: var(--ivory);
  --s-invert-fg: var(--near-black);
  --s-field: rgba(250, 249, 245, .05);
  --s-hover: rgba(250, 249, 245, .06);
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { max-width: 100%; }
html { overflow-x: clip; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;                 /* 编辑式行高，比常见 1.4–1.5 松 */
  color: var(--near-black);
  background: var(--parchment);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  text-wrap: pretty;
}

/* ---------- 可达性 ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible {
  outline: 2px solid var(--focus-blue);
  outline-offset: 3px;
  border-radius: 4px;
}
a { color: inherit; }

/* ---------- 进度条 + 粒子 ---------- */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 600;
  background: var(--terracotta);
  transform: scaleX(0); transform-origin: left center;
}
.particle-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 300; pointer-events: none;
}

/* ============================================================
   顶部导航（sticky，暖底，细边框）
   ============================================================ */
.nav {
  position: sticky; top: 0; z-index: 500;
  background: var(--parchment);
  border-bottom: 1px solid var(--border-cream);
}
.nav-inner {
  display: flex; align-items: center; gap: 32px;
  height: var(--nav-h);
  max-width: var(--container); margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
}
.nav-brand {
  font-family: var(--serif); font-weight: var(--w-serif); font-size: 20px;
  letter-spacing: -0.01em; text-decoration: none; color: var(--near-black);
  flex-shrink: 0;
}
.nav-links { display: flex; align-items: center; gap: 26px; flex: 1; }
.nav-link {
  font-size: 15px; color: var(--olive); text-decoration: none;
  padding: 6px 0; white-space: nowrap;
  transition: color var(--d-hover) ease;
}
@media (hover: hover) and (pointer: fine) {
  .nav-link:hover { color: var(--near-black); }   /* 悬停只换色，不加装饰 */
}
.nav-link.is-active { color: var(--near-black); font-weight: 500; }
.nav-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.mode-switch {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--sand);
  border-radius: 999px;
}
.mode-btn {
  border: none; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--charcoal); padding: 6px 13px; border-radius: 999px;
  min-height: 30px; white-space: nowrap;
  transition: background-color var(--d-hover) ease, color var(--d-hover) ease,
              transform var(--d-press) var(--ease-out);
}
.mode-btn.is-active { background: var(--near-black); color: var(--ivory); }
@media (hover: hover) and (pointer: fine) {
  .mode-btn:not(.is-active):hover { background: var(--sand-hover); }
}
.mode-btn:active { transform: scale(0.97); }
.nav-config {
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--charcoal); background: var(--white);
  border: none; border-radius: 8px; padding: 8px 12px; min-height: 32px;
  cursor: pointer; box-shadow: 0 0 0 1px var(--ring-warm);
  transition: box-shadow var(--d-hover) ease, transform var(--d-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .nav-config:hover { box-shadow: 0 0 0 1px var(--ring-deep); }
}
.nav-config:active { transform: scale(0.97); }

/* ============================================================
   章节容器：内容居中 1200px，背景铺满全宽
   ============================================================ */
.stage { display: block; }
.screen {
  background: var(--s-bg);
  color: var(--s-fg);
  padding: 96px max(20px, calc((100% - var(--container)) / 2));
}
.chapter-dark { background: var(--s-bg); color: var(--s-fg); }

/* ============================================================
   文字层级
   ============================================================ */
/* Overline：10px 是给纯拉丁大写的值，中英混排放到 11px + 0.12em 才读得清 */
.overline {
  font-family: var(--sans); font-size: 11px; font-weight: 400;
  letter-spacing: 0.12em; text-transform: uppercase;
  line-height: 1.6; color: var(--s-accent);
  margin-bottom: 20px;
}

.sec-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding-bottom: 20px; margin-bottom: 36px;
  border-bottom: 1px solid var(--s-divider);
}
.sec-num {
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  letter-spacing: 0.12px; color: var(--s-accent);
}
.sec-h { font-family: var(--serif); font-weight: var(--w-serif); font-size: 25.6px; line-height: 1.2; }
.sec-hint { margin-left: auto; font-size: 14px; line-height: 1.43; color: var(--s-fg-3); }

/* ============================================================
   1. HERO
   ============================================================ */
.hero {
  min-height: calc(100svh - var(--nav-h));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  align-items: center; gap: 48px;
  position: relative; overflow: hidden;
}
.hero-inner { max-width: 640px; }
.hero-h1 {
  font-family: var(--serif); font-weight: var(--w-serif);
  font-size: clamp(38px, 6.4vw, 64px);
  line-height: 1.10; letter-spacing: normal;
  text-wrap: balance;
}
.hero-h1 .ln { display: block; overflow: hidden; padding-bottom: .06em; }
.hero-h1 .ln > span { display: block; }
.hero-p {
  margin-top: 28px; font-size: 20px; line-height: 1.6;
  color: var(--olive); max-width: 26em; line-break: strict;
}
.hero-actions { margin-top: 40px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.hero-meta { font-size: 14px; line-height: 1.43; color: var(--stone-ink); }

.hero-figure { display: flex; justify-content: center; align-items: center; }
.hero-figure svg { width: min(100%, 500px); height: auto; }

.scroll-cue {
  position: absolute; left: max(20px, calc((100% - var(--container)) / 2));
  bottom: 40px; display: flex; align-items: center; gap: 12px;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--stone-ink);
}
.scroll-cue i {
  display: block; width: 54px; height: 1px; background: var(--border-warm);
  position: relative; overflow: hidden;
}
.scroll-cue i::after {
  content: ""; position: absolute; left: -54px; top: 0; width: 54px; height: 100%;
  background: var(--terracotta);
  animation: cueSlide 2.4s linear infinite;   /* 循环必须 linear */
}
@keyframes cueSlide { 0% { transform: translateX(0); } 55%, 100% { transform: translateX(108px); } }

/* ---------- Hero 入场：纯 CSS 关键帧 ---------- */
.hero-intro [data-hero-line] {
  animation: lineUp 900ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 100ms);
}
@keyframes lineUp { from { transform: translateY(110%); } }
.hero-intro [data-hero-fade] {
  animation: fadeUp var(--d-editorial) var(--ease-out) both;
  animation-delay: calc(300ms + var(--i, 0) * 100ms);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } }

/* ============================================================
   2. 过滤演示
   ============================================================ */
.filter-screen { min-height: 300vh; padding-top: 0; padding-bottom: 0; }
.filter-sticky {
  position: sticky; top: var(--nav-h);
  height: calc(100dvh - var(--nav-h));
  display: flex; align-items: center; overflow: hidden;
}
.filter-copy { position: relative; z-index: 2; max-width: 520px; }
.filter-h2 {
  font-family: var(--serif); font-weight: var(--w-serif);
  font-size: clamp(30px, 4.6vw, 52px); line-height: 1.20;
  text-wrap: balance;
}
.filter-p { margin-top: 24px; font-size: 16px; line-height: 1.6; color: var(--olive); max-width: 26em; }

.pipe { margin-top: 40px; display: flex; flex-direction: column; list-style: none; }
.pipe-row {
  display: flex; align-items: baseline; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--s-divider);
  transition: opacity var(--d-editorial) var(--ease-out);
}
.pipe-row:last-child { border-bottom: none; }
.pipe-n {
  font-family: var(--serif); font-weight: var(--w-serif); font-size: 25.6px;
  min-width: 68px; flex-shrink: 0; color: var(--s-fg);
  font-variant-numeric: tabular-nums;
}
.pipe-row.minus .pipe-n { color: var(--s-fg-3); font-size: 20px; }
.pipe-body { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pipe-body b { font-size: 16px; font-weight: 500; color: var(--s-fg); }
.pipe-row.minus .pipe-body b { color: var(--s-fg-2); font-weight: 400; }
.pipe-body em { font-style: normal; font-size: 14px; color: var(--s-fg-3); }
.pipe-row.final {
  margin-top: 10px; padding: 16px 20px;
  background: var(--terracotta-deep); border: none; border-radius: 12px;
  align-items: center;
}
.pipe-row.final .pipe-n { color: var(--ivory); font-size: 32px; }
.pipe-row.final .pipe-body b { color: var(--ivory); }
.pipe-row.final .pipe-body em { color: rgba(250, 249, 245, .78); }
.filter-foot { margin-top: 28px; font-size: 15px; line-height: 1.6; color: var(--s-fg-3); }

/* ---------- 碎片：位置由 fragments.js 算，环状阴影代替边框 ---------- */
.fragments { position: absolute; inset: 0; z-index: 1; }
.frag {
  position: absolute; padding: 9px 14px; border-radius: 8px;
  background: var(--ivory); color: var(--olive);
  font-family: var(--sans); font-size: 12.5px; line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--border-cream);
  transition: opacity var(--d-editorial) ease, box-shadow var(--d-hover) ease;
}
.frag.keep {
  background: var(--near-black); color: var(--ivory);
  box-shadow: 0 0 0 1px var(--near-black);
  font-weight: 500;
}
.frag.keep .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--terracotta); margin-right: 8px; vertical-align: 1px;
}
.fragments.is-live .frag { will-change: transform, opacity; }

/* ============================================================
   3. 工作台
   ============================================================ */
.console {
  background: var(--s-surface);
  border: 1px solid var(--s-ring);
  border-radius: 8px;
  padding: 28px; margin-bottom: 24px;
  transition: border-color var(--d-enter) var(--ease-out);
}
.console-lg { border-radius: 16px; padding: 32px; }
.console:focus-within { border-color: var(--s-ring-warm); }
.console-label {
  display: block; font-family: var(--sans); font-size: 15px; font-weight: 500;
  color: var(--s-fg); margin-bottom: 14px;
}

textarea,
input[type="text"],
input[type="url"] {
  width: 100%; font-family: var(--sans); font-size: 16px; line-height: 1.6;
  color: var(--s-fg); background: var(--s-field);
  border: 1px solid var(--s-ring); border-radius: 12px;
  padding: 14px 16px; resize: vertical; min-height: 64px;
  transition: border-color var(--d-hover) ease, box-shadow var(--d-hover) ease;
}
textarea { min-height: 156px; }
textarea::placeholder, input::placeholder { color: var(--s-fg-3); }
textarea:focus, input[type="text"]:focus, input[type="url"]:focus {
  outline: none;
  border-color: var(--focus-blue);                       /* 系统里唯一一处冷色 */
  box-shadow: 0 0 0 3px rgba(56, 152, 236, .16);
}

.chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.chips-label { font-size: 12px; letter-spacing: 0.12px; color: var(--s-fg-3); }
.chip {
  font-family: var(--sans); font-size: 13px; font-weight: 400;
  color: var(--charcoal); background: var(--white);
  border: none; border-radius: 24px; padding: 9px 16px; min-height: 38px;
  cursor: pointer; box-shadow: 0 0 0 1px var(--border-warm);
  transition: box-shadow var(--d-hover) ease, color var(--d-hover) ease,
              transform var(--d-hover) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .chip:hover { color: var(--terracotta-ink); box-shadow: 0 0 0 1px var(--ring-deep); transform: translateY(-1px); }
}
.chip:active { transform: scale(0.97); }

.console-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--s-divider);
}
.console-note { font-size: 14px; line-height: 1.43; color: var(--s-fg-3); }
.console-btns { display: flex; gap: 10px; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 16px; font-weight: 500;
  text-decoration: none; cursor: pointer; border: none;
  min-height: 48px; padding: 12px 20px; border-radius: 8px;
  transition: background-color var(--d-hover) ease, box-shadow var(--d-hover) ease,
              color var(--d-hover) ease, transform var(--d-press) var(--ease-out);
}
/* Warm Sand：日常次级按钮 */
.btn-sand {
  background: var(--sand); color: var(--charcoal);
  box-shadow: 0 0 0 1px var(--ring-warm);
}
@media (hover: hover) and (pointer: fine) {
  .btn-sand:hover { background: var(--sand-hover); box-shadow: 0 0 0 1px var(--ring-deep); }
}
/* 主 CTA：全站唯一的彩色按钮 */
.btn-primary {
  background: var(--s-accent-bg); color: var(--s-on-accent);
  border-radius: 12px; padding: 13px 24px;
  box-shadow: 0 0 0 1px var(--s-accent-bg);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--terracotta-ink); box-shadow: 0 0 0 1px var(--terracotta-ink); color: var(--ivory); }
}
.chapter-dark .btn-primary:hover { background: var(--coral-light); box-shadow: 0 0 0 1px var(--coral-light); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ============================================================
   处理中
   ============================================================ */
.processing { padding: 64px 0; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.proc-num {
  font-family: var(--serif); font-weight: var(--w-serif); font-size: 64px; line-height: 1.10;
  color: var(--s-fg); font-variant-numeric: tabular-nums;
}
.proc-num em { font-size: 25.6px; font-style: normal; color: var(--s-fg-3); margin-left: 2px; }
.proc-label { font-size: 15px; color: var(--s-fg-2); }
.proc-track { width: min(400px, 86%); height: 2px; background: var(--s-divider); overflow: hidden; }
.proc-track i { display: block; height: 100%; width: 0; background: var(--terracotta); }
.proc-wave { display: flex; gap: 5px; align-items: flex-end; height: 30px; }
.proc-wave span {
  width: 4px; background: var(--s-fg); border-radius: 24px;
  animation: waveUp 1.05s var(--ease-in-out) infinite;
}
.proc-wave span:nth-child(1) { height: 30%; animation-delay: 0s; }
.proc-wave span:nth-child(2) { height: 60%; animation-delay: .09s; }
.proc-wave span:nth-child(3) { height: 90%; animation-delay: .18s; }
.proc-wave span:nth-child(4) { height: 100%; animation-delay: .27s; }
.proc-wave span:nth-child(5) { height: 70%; animation-delay: .36s; }
.proc-wave span:nth-child(6) { height: 45%; animation-delay: .45s; }
.proc-wave span:nth-child(7) { height: 25%; animation-delay: .54s; }
@keyframes waveUp { 50% { transform: scaleY(.3); opacity: .45; } }

/* ============================================================
   空状态 / 错误
   ============================================================ */
.empty {
  padding: 56px 24px; text-align: center;
  background: var(--s-surface); border-radius: 16px;
  border: 1px dashed var(--s-ring-warm);
}
.empty p { font-family: var(--serif); font-weight: var(--w-serif); font-size: 20.8px; line-height: 1.2; color: var(--s-fg); }
.empty-s { font-size: 14px; line-height: 1.6; color: var(--s-fg-3); margin-top: 10px; }
.error-box {
  padding: 24px 28px; border-radius: 12px;
  background: rgba(181, 51, 51, .07);
  border: 1px solid rgba(181, 51, 51, .28);
}
.error-t { font-family: var(--serif); font-weight: var(--w-serif); font-size: 20.8px; line-height: 1.2; color: var(--crimson); }
.error-s { font-size: 15px; color: var(--s-fg-2); margin-top: 8px; }
.chapter-dark .error-t { color: #d97a7a; }

/* ============================================================
   结果
   ============================================================ */
.results { margin-top: 48px; }
.link-notice {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--s-invert-bg); color: var(--s-invert-fg);
  border-radius: 12px; padding: 18px 22px; margin-bottom: 24px;
  font-size: 15px; line-height: 1.6;
  animation: noticeIn var(--d-enter) var(--ease-out) both;
}
.link-notice-ico {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--terracotta); margin-top: 8px;
}
@keyframes noticeIn { from { opacity: 0; transform: translateY(10px); } }

.results-actions {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--s-divider);
}
.results-note { font-size: 14px; line-height: 1.43; color: var(--s-fg-3); }

.task-list { display: flex; flex-direction: column; gap: 16px; }
/* 卡片可交互 → 用环状阴影（Level 2），不是边框 */
.task-card {
  position: relative; padding: 24px 28px;
  background: var(--s-surface); border-radius: 8px;
  box-shadow: 0 0 0 1px var(--s-ring);
  transition: box-shadow var(--d-hover) ease, transform var(--d-hover) var(--ease-out);
}
.task-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--bar); border-radius: 8px 0 0 8px;
}
.task-card.p-hi { --bar: var(--terracotta); }
.task-card.p-mid { --bar: var(--olive); }
.task-card.p-lo { --bar: var(--stone); }
.chapter-dark .task-card.p-hi { --bar: var(--coral); }
.chapter-dark .task-card.p-mid { --bar: var(--silver); }
.chapter-dark .task-card.p-lo { --bar: rgba(250, 249, 245, .35); }
@media (hover: hover) and (pointer: fine) {
  .task-card:hover { box-shadow: 0 0 0 1px var(--s-ring-deep); transform: translateY(-2px); }
}
.task-card.is-done { opacity: .45; }
.task-card.is-done .task-title { text-decoration: line-through; text-decoration-color: var(--s-fg-3); }
.task-card::after {
  content: ""; position: absolute; inset: -1px; border-radius: 9px;
  box-shadow: 0 0 0 2px var(--terracotta); opacity: 0; pointer-events: none;
}
.task-card.flash::after { animation: flashRing 700ms var(--ease-out); }
@keyframes flashRing { 0% { opacity: .85; } 100% { opacity: 0; } }
.task-card.is-new { animation: cardIn var(--d-enter) var(--ease-out) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } }

.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.task-title { font-family: var(--serif); font-weight: var(--w-serif); font-size: 20.8px; line-height: 1.2; }
.task-badge {
  flex-shrink: 0; font-family: var(--sans); font-size: 12px; font-weight: 500;
  letter-spacing: 0.12px; padding: 4px 12px; border-radius: 24px;
}
.p-hi .task-badge { background: var(--terracotta-deep); color: var(--ivory); }
.p-mid .task-badge { background: var(--sand); color: var(--charcoal); }
.p-lo .task-badge { background: transparent; color: var(--stone-ink); box-shadow: 0 0 0 1px var(--ring-warm); }
.chapter-dark .p-hi .task-badge { background: var(--coral); color: var(--near-black); }
.chapter-dark .p-mid .task-badge { background: rgba(250, 249, 245, .14); color: var(--ivory); }
.chapter-dark .p-lo .task-badge { color: var(--silver); box-shadow: 0 0 0 1px rgba(250, 249, 245, .22); }

.task-meta { font-size: 14px; line-height: 1.43; color: var(--s-fg-2); margin-top: 8px; }
.task-link {
  display: inline-block; font-size: 12px; font-weight: 500; letter-spacing: 0.12px;
  background: var(--terracotta-ink); color: var(--ivory);
  border-radius: 24px; padding: 3px 10px; margin-left: 8px; vertical-align: 1px;
}
.chapter-dark .task-link { background: var(--coral); color: var(--near-black); }
.task-reason {
  margin-top: 16px; padding: 16px 20px;
  background: var(--s-surface-2); border-radius: 8px;
  font-size: 15px; line-height: 1.6; color: var(--s-fg-2);
}
.task-reason strong { color: var(--s-fg); font-weight: 500; }

/* 命中证据链：把「为什么」拆成可核对的小块 */
.task-evidence { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ev {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 12px; letter-spacing: 0.12px; padding: 4px 10px; border-radius: 24px;
  background: transparent; color: var(--s-fg-2);
  box-shadow: 0 0 0 1px var(--s-ring-warm);
}
.ev b { font-family: var(--sans); font-size: 12px; font-weight: 500; letter-spacing: 0.12px; color: var(--s-fg); }
.ev-time b { color: var(--s-accent); }
.ev-action b { color: var(--s-fg); }
.ev-mention b { color: var(--s-fg-2); }
.ev-down { border-style: none; box-shadow: 0 0 0 1px var(--s-ring); color: var(--s-fg-3); }
.ev-down b { color: var(--s-fg-3); }

.task-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.task-btn {
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--charcoal); background: var(--white);
  border: none; border-radius: 8px; padding: 10px 16px; min-height: 40px;
  cursor: pointer; box-shadow: 0 0 0 1px var(--border-warm);
  transition: box-shadow var(--d-hover) ease, background-color var(--d-hover) ease,
              color var(--d-hover) ease, transform var(--d-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .task-btn:hover { box-shadow: 0 0 0 1px var(--ring-deep); }
}
.task-btn:active { transform: scale(0.97); }
.task-btn.done { background: var(--s-invert-bg); color: var(--s-invert-fg); box-shadow: 0 0 0 1px var(--s-invert-bg); }
.chapter-dark .task-btn { background: transparent; color: var(--silver); box-shadow: 0 0 0 1px rgba(250, 249, 245, .18); }
@media (hover: hover) and (pointer: fine) {
  .chapter-dark .task-btn:hover { box-shadow: 0 0 0 1px rgba(250, 249, 245, .34); color: var(--ivory); }
}

/* ============================================================
   对话
   ============================================================ */
.chat-console { margin-top: 40px; }
.sec-head.in-console { border-bottom: none; padding-bottom: 0; margin-bottom: 22px; }
.chat-row { display: flex; gap: 12px; }
.chat-row input { flex: 1; min-width: 0; }
.chat-log { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-log:empty { display: none; }
.chat-msg {
  font-size: 15px; line-height: 1.6; padding: 14px 18px;
  border-radius: 12px; max-width: 92%;
  animation: cardIn var(--d-enter) var(--ease-out) both;
}
.chat-msg.user { background: var(--s-invert-bg); color: var(--s-invert-fg); align-self: flex-end; }
.chat-msg.sys {
  background: var(--s-surface-2); color: var(--s-fg-2);
  align-self: flex-start; box-shadow: 0 0 0 1px var(--s-ring);
}

/* ============================================================
   筛选 / 备注
   ============================================================ */
.task-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-btn {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--s-fg-2); background: transparent;
  border: none; border-radius: 24px; padding: 8px 16px; min-height: 36px;
  cursor: pointer; box-shadow: 0 0 0 1px var(--s-ring-warm);
  transition: box-shadow var(--d-hover) ease, background-color var(--d-hover) ease,
              color var(--d-hover) ease, transform var(--d-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .filter-btn:hover { box-shadow: 0 0 0 1px var(--s-ring-deep); color: var(--s-fg); }
}
.filter-btn:active { transform: scale(0.97); }
.filter-btn.is-active { background: var(--s-invert-bg); color: var(--s-invert-fg); box-shadow: 0 0 0 1px var(--s-invert-bg); }

.section-note {
  margin-top: 32px; padding: 24px 28px; border-radius: 12px;
  background: var(--s-surface-2); color: var(--s-fg-2);
  font-size: 16px; line-height: 1.6;
}
.section-note b { color: var(--s-accent); font-weight: 500; }

/* ============================================================
   画像
   ============================================================ */
.panel {
  background: var(--s-surface); border: 1px solid var(--s-ring);
  border-radius: 8px; padding: 32px; margin-bottom: 20px;
}
.panel h3 { font-family: var(--serif); font-weight: var(--w-serif); font-size: 20.8px; line-height: 1.2; margin-bottom: 18px; }
.panel-sub { font-size: 14px; line-height: 1.6; color: var(--s-fg-3); margin-bottom: 16px; }
.panel-sub code {
  font-family: var(--mono); font-size: 13px; letter-spacing: -0.32px;
  background: var(--s-surface-2); padding: 2px 6px; border-radius: 4px;
}
.panel-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-group { display: flex; flex-direction: column; gap: 2px; border: 0; }
.radio-group label {
  display: flex; align-items: center; gap: 12px;
  font-size: 16px; line-height: 1.6; color: var(--s-fg);
  min-height: 48px; padding: 2px 10px; border-radius: 8px; cursor: pointer;
  transition: background-color var(--d-hover) ease;
}
@media (hover: hover) and (pointer: fine) {
  .radio-group label:hover { background: var(--s-hover); }
}
.radio-group input { width: 18px; height: 18px; accent-color: var(--terracotta); flex-shrink: 0; }
.rule-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rule-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-size: 15px; padding: 16px 20px; border-radius: 8px;
  background: var(--s-surface-2); color: var(--s-fg);
  border-left: 2px solid var(--terracotta);
}
.rule-count {
  flex-shrink: 0; font-size: 12px; font-weight: 500; letter-spacing: 0.12px;
  background: var(--s-invert-bg); color: var(--s-invert-fg);
  border-radius: 24px; padding: 4px 12px;
}
.api-row { display: flex; gap: 10px; }
.api-row input { flex: 1; min-width: 0; }
.api-status { font-size: 14px; line-height: 1.43; color: var(--s-fg-3); margin-top: 12px; }

/* ============================================================
   结尾（近黑章节）
   ============================================================ */
.outro { padding-bottom: 0; }
.outro-figure { margin-bottom: 56px; }
.outro-figure svg { width: min(100%, 640px); height: auto; }
.outro-h2 {
  font-family: var(--serif); font-weight: var(--w-serif);
  font-size: clamp(28px, 3.6vw, 36.8px); line-height: 1.30;
  margin-bottom: 48px; max-width: 18em; text-wrap: balance;
}
.outro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 32px; }
.outro-item { border-top: 1px solid var(--s-ring-warm); padding-top: 22px; }
.outro-item > span {
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  letter-spacing: 0.12px; color: var(--s-accent);
}
.outro-item h3 { font-family: var(--serif); font-weight: var(--w-serif); font-size: 20.8px; line-height: 1.2; margin: 12px 0 10px; }
.outro-item p { font-size: 15px; line-height: 1.6; color: var(--s-fg-2); }

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 36px 0 40px; margin-top: 64px;
  border-top: 1px solid var(--s-ring);
  font-size: 12px; letter-spacing: 0.12px; color: var(--s-fg-3);
}

/* ============================================================
   toast
   ============================================================ */
.toast {
  position: fixed; bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translate(-50%, 16px);
  background: var(--near-black); color: var(--ivory);
  border-radius: 12px; padding: 14px 24px; font-size: 14px;
  z-index: 700; opacity: 0; pointer-events: none;
  max-width: min(86vw, 520px);
  transition: opacity var(--d-enter) var(--ease-out), transform var(--d-enter) var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   区块显现（进视口播一次）
   ============================================================ */
.reveal { opacity: 0; }
.reveal-in {
  animation: revealUp var(--d-editorial) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes revealUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1024px) {
  .hero { grid-template-columns: 1fr; gap: 40px; }
  .hero-figure { display: none; }              /* 插画在窄屏让位给文字 */
  .scroll-cue { display: none; }
}

@media (max-width: 900px) {
  /* --nav-h 由 JS 运行时量（窄屏导航会折成两行），这里不再写死 */
  .nav-inner { flex-wrap: wrap; height: auto; gap: 8px 16px; padding: 10px 20px; align-items: center; }
  .nav-brand { order: 1; font-size: 18px; }
  .nav-actions { order: 2; margin-left: auto; }
  .nav-links {
    order: 3; flex-basis: 100%; gap: 20px; flex: none;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-config { display: none; }
  /* 触控目标抬到 40px：30px 虽过 WCAG 2.2 的 24px 下限，但拇指点着费劲 */
  .mode-btn { min-height: 40px; padding: 8px 14px; font-size: 13px; }

  .screen { padding-top: 72px; padding-bottom: 72px; }
  .hero { min-height: auto; padding-top: 56px; padding-bottom: 72px; }
  .filter-screen { padding-top: 0; padding-bottom: 0; }
  .filter-sticky {
    position: relative; top: auto; height: auto;
    padding: 72px 0 24px; display: block; overflow: visible;
  }
  .filter-copy { max-width: none; }
  .fragments { position: relative; inset: auto; height: 500px; margin-top: 20px; }
}

@media (max-width: 640px) {
  .screen { padding-left: 20px; padding-right: 20px; }
  .sec-head { margin-bottom: 28px; }
  .sec-hint { margin-left: 0; flex-basis: 100%; }
  .console, .panel { padding: 22px; }
  .console-lg { padding: 22px; }
  .console-foot { flex-direction: column; align-items: stretch; }
  .console-btns { flex-direction: column; }
  .console-btns .btn { width: 100%; }
  .chat-row { flex-direction: column; }
  .chat-row .btn { width: 100%; }
  .api-row { flex-direction: column; }
  .task-card { padding: 20px; }
  .toast { left: 20px; right: 20px; max-width: none; transform: translateY(16px); text-align: center; }
  .toast.show { transform: translateY(0); }
  .outro-grid { grid-template-columns: 1fr; }
  .fragments { height: 460px; }
  .frag { font-size: 11.5px; padding: 7px 11px; }
  .chat-msg { max-width: 100%; }
  .hero-h1 { font-size: clamp(34px, 10vw, 44px); }
}

/* ============================================================
   验证模式（?flat=1 平铺 / ?noanim=1）
   ============================================================ */
.flat .reveal { opacity: 1; animation: none; }
.flat .hero { min-height: auto; padding: 70px 0 50px; }
.flat .filter-screen { min-height: auto; padding-bottom: 40px; }
.flat .filter-sticky {
  position: relative; top: auto; height: auto; min-height: 640px;
  padding: 40px 0; display: block; overflow: visible;
}
.flat .filter-copy { max-width: 620px; }
.flat .fragments { position: absolute; inset: 0; height: auto; }
.flat .screen { padding-top: 46px; padding-bottom: 46px; }

.noanim *, .noanim *::before, .noanim *::after { animation: none !important; transition: none !important; }
.noanim .hero-h1 .ln > span { transform: none !important; opacity: 1 !important; }
.noanim .frag { opacity: 1 !important; }
.noanim .reveal { opacity: 1 !important; }

/* 打印 / 导出 PDF */
@media print {
  .reveal { opacity: 1 !important; }
  .nav, .progress, .particle-canvas, .toast, .fragments { display: none !important; }
}

/* ============================================================
   减弱动效：更少更温和，而不是全灭
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-cue i::after { animation: none; background: var(--border-warm); }
  .proc-wave span { animation: none; }
  .reveal { opacity: 1; }
  .filter-screen { min-height: auto; }
  .filter-sticky {
    position: relative; top: auto; height: auto;
    padding: 60px 0 30px; display: block; overflow: visible;
  }
  .filter-copy { max-width: none; }
  .fragments { position: relative; inset: auto; height: 460px; margin-top: 20px; }

  .btn, .chip, .task-btn, .filter-btn, .mode-btn, .nav-config, .nav-link, .radio-group label {
    transition: color 200ms ease, background-color 200ms ease, border-color 200ms ease,
                box-shadow 200ms ease;
  }
  .btn:active, .chip:active, .task-btn:active,
  .filter-btn:active, .mode-btn:active, .nav-config:active { transform: none; }
  .task-card { transition: box-shadow 200ms ease; }
  .task-card:hover { transform: none; }
  .chip:hover { transform: none; }
  .task-card.is-new, .link-notice, .chat-msg { animation: none; }
  .toast, .toast.show { transform: none; }
  .toast { transform: translateX(-50%); }
  .toast.show { transform: translateX(-50%); }
}
