/* ============================================================
   Harness 实战教程 · 文档站样式
   主题策略: CSS 变量双主题, 默认跟随系统, 可手动切换
   圆角规则: 卡片/图 12px · 代码块 10px · 小标签 pill
   ============================================================ */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --sidebar-bg: #f4f4f2;
  --ink: #1c1e21;
  --muted: #5a6472;
  --faint: #8a919c;
  --line: #e4e4e7;
  --line-soft: #ececee;
  --accent: #047857;
  --accent-ink: #065f46;
  --accent-soft: rgba(4, 120, 87, 0.08);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.07);
  --code-bg: #f4f4f5;
  --code-ink: #1f2328;
  --mark-bg: rgba(4, 120, 87, 0.12);
  --shadow: 0 1px 2px rgba(28, 30, 33, 0.05), 0 8px 24px rgba(28, 30, 33, 0.07);
  --sans: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "SF Mono", ui-monospace, Consolas, "Courier New", monospace;
  --r-card: 12px;
  --r-code: 10px;
}

html[data-theme="dark"] {
  --bg: #101113;
  --surface: #17181b;
  --sidebar-bg: #131417;
  --ink: #e8eaec;
  --muted: #9aa2ac;
  --faint: #6b7280;
  --line: #26282c;
  --line-soft: #1f2125;
  --accent: #34d399;
  --accent-ink: #6ee7b7;
  --accent-soft: rgba(52, 211, 153, 0.09);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.08);
  --code-bg: #1d1f23;
  --code-ink: #dfe3e8;
  --mark-bg: rgba(52, 211, 153, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--mark-bg); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-underline-offset: 4px; text-decoration: underline; }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- 阅读进度条 (CSS 滚动驱动, 渐进增强) ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 90;
  background: var(--accent); transform-origin: 0 50%; transform: scaleX(0);
  pointer-events: none;
}
@supports (animation-timeline: scroll()) {
  .progress { animation: progress-grow linear both; animation-timeline: scroll(root); }
}
@keyframes progress-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: sticky; top: 0;
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  letter-spacing: 0.02em;
}
html[data-theme="dark"] .brand-mark { color: #0c1418; }
.brand-text { min-width: 0; }
.brand-text .t { font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-text .s { font-size: 12px; color: var(--faint); line-height: 1.4; }

.theme-btn {
  margin-left: auto;
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: color .15s, border-color .15s, transform .15s;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn:active { transform: scale(0.94); }
.theme-btn .icon { width: 16px; height: 16px; }
.theme-btn .i-sun { display: none; }
html[data-theme="dark"] .theme-btn .i-sun { display: block; }
html[data-theme="dark"] .theme-btn .i-moon { display: none; }

.nav { padding: 4px 12px 28px; }
.nav-group-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  color: var(--faint); padding: 14px 10px 6px;
}
.nav a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted); font-size: 14px; line-height: 1.5;
  transition: background .12s, color .12s;
}
.nav a:hover { color: var(--ink); background: var(--line-soft); text-decoration: none; }
.nav a.home-link { font-weight: 600; color: var(--ink); }
.nav a .num {
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  margin-right: 8px;
}
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav .sub { margin: 2px 0 6px 26px; }
.nav .sub a { font-size: 13px; padding: 4px 10px; color: var(--faint); }
.nav .sub a.active { color: var(--accent); }
.nav .sub a::before { content: ""; display: inline-block; width: 10px; height: 1px; background: var(--line); vertical-align: middle; margin-right: 8px; }

/* ---------- 主区域 ---------- */
.main {
  min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 50;
  height: 56px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  align-items: center; gap: 10px; padding: 0 16px;
}
.topbar .t { font-weight: 700; font-size: 15px; }
.topbar .menu-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: grid; place-items: center;
}
.topbar .theme-btn { margin-left: 0; }

.page {
  width: 100%; max-width: 860px;
  margin: 0 auto;
  padding: 56px 48px 40px;
  flex: 1;
}

/* 载入动画 (仅一次, 尊重减弱动态) */
@media (prefers-reduced-motion: no-preference) {
  .page { animation: page-in .45s cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes page-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ---------- 章节页头 ---------- */
.chap-head { margin-bottom: 44px; }
.chap-num {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.16em;
  color: var(--accent); margin-bottom: 10px;
}
.chap-head h1 {
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.3; letter-spacing: 0.01em;
  margin: 0 0 12px; font-weight: 700;
}
.chap-head .desc { color: var(--muted); max-width: 60ch; margin: 0; font-size: 15.5px; }

/* ---------- 正文排版 ---------- */
.section { margin-bottom: 56px; }
.section > h2 {
  font-size: 22px; font-weight: 700;
  margin: 0 0 18px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.01em;
  scroll-margin-top: 70px;
}
.prose h4 {
  font-size: 16.5px; font-weight: 700;
  margin: 34px 0 10px;
  color: var(--ink);
}
.prose h4::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; background: var(--accent);
  margin-right: 9px; vertical-align: 1px; opacity: .85;
}
.prose p { margin: 12px 0; max-width: 72ch; }
.prose ul, .prose ol { margin: 12px 0; padding-left: 6px; max-width: 70ch; list-style: none; }
.prose li { margin: 7px 0; padding-left: 22px; position: relative; }
.prose ul > li::before {
  content: ""; position: absolute; left: 4px; top: .82em;
  width: 6px; height: 6px; border-radius: 2px;
  background: var(--accent); opacity: .8;
}
.prose ol { counter-reset: oli; }
.prose ol > li { counter-increment: oli; padding-left: 34px; }
.prose ol > li::before {
  content: counter(oli, decimal-leading-zero);
  position: absolute; left: 0; top: .28em;
  font-family: var(--mono); font-size: 12.5px;
  color: var(--accent); font-weight: 600;
}
.prose strong { font-weight: 700; }
.prose li p, .prose li > ul, .prose li > ol { margin: 4px 0; }

/* 行内代码 */
.prose code, .note code, .quote code {
  font-family: var(--mono); font-size: .88em;
  background: var(--code-bg); color: var(--code-ink);
  border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 1.5px 6px;
  word-break: break-all;
}

/* ---------- 命令块 ---------- */
.cmd {
  margin: 16px 0; border-radius: var(--r-code);
  border: 1px solid var(--line); background: var(--code-bg);
  overflow: hidden; max-width: 640px;
}
.cmd-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px; color: var(--faint);
  font-family: var(--mono); letter-spacing: .06em;
}
.cmd-head .label { flex: 1; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-family: var(--sans);
  padding: 3px 10px 3px 8px; cursor: pointer;
  transition: color .15s, border-color .15s, transform .12s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn:active { transform: scale(0.95); }
.copy-btn .icon { width: 13px; height: 13px; }
.copy-btn .i-check { display: none; color: var(--accent); }
.copy-btn.done .i-check { display: block; }
.copy-btn.done .i-copy { display: none; }
.cmd pre {
  margin: 0; padding: 12px 14px;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7;
  color: var(--code-ink); overflow-x: auto;
}

/* ---------- 提示框 ---------- */
.note {
  margin: 20px 0; padding: 14px 18px 14px 16px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow);
  max-width: 70ch;
}
.note.note-warn { border-left-color: var(--warn); }
.note-chip {
  display: inline-block;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px; padding: 1px 10px;
  margin-bottom: 6px;
}
.note.note-warn .note-chip { color: var(--warn); background: var(--warn-soft); }
.note .note-title { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.note .note-body p { margin: 6px 0; font-size: 14.5px; color: var(--muted); }
.note .note-body { color: var(--muted); font-size: 14.5px; }

/* ---------- 引文块 ---------- */
.quote {
  margin: 20px 0; padding: 16px 20px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted); font-size: 14.5px; line-height: 1.9;
  max-width: 72ch;
}
.quote::before {
  content: "润色后的提示词";
  display: block;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.12em;
  color: var(--accent); margin-bottom: 6px;
}

/* ---------- 截图 ---------- */
.fig { margin: 20px 0 26px; }
.fig-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.fig figure { margin: 0; min-width: 0; }
.fig img {
  display: block; width: 100%; height: auto;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  transition: transform .18s cubic-bezier(0.16, 1, 0.3, 1), border-color .18s;
}
.fig img:hover { border-color: var(--accent); transform: translateY(-2px); }
.fig figcaption {
  margin-top: 8px; font-size: 12.5px; color: var(--faint);
  font-family: var(--mono); letter-spacing: 0.02em;
}

/* ---------- 灯箱 ---------- */
.lightbox {
  border: none; border-radius: 0; padding: 0;
  max-width: min(94vw, 1200px); max-height: 92dvh;
  background: transparent;
}
.lightbox::backdrop { background: rgba(10, 12, 14, 0.82); backdrop-filter: blur(4px); }
.lightbox img { display: block; max-width: 94vw; max-height: 88dvh; border-radius: var(--r-card); margin: 0 auto; }
.lightbox .lb-cap {
  text-align: center; color: rgba(255, 255, 255, 0.75);
  font-size: 13px; padding: 10px 0 2px;
  font-family: var(--mono);
}

/* ---------- 上一章 / 下一章 ---------- */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 64px; padding-top: 24px;
  border-top: 1px solid var(--line);
}
.pager a {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 14px 16px;
  color: var(--ink); background: var(--surface);
  transition: border-color .15s, transform .15s;
}
.pager a:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.pager a.next { text-align: right; align-items: flex-end; }
.pager .dir { font-size: 12px; color: var(--faint); font-family: var(--mono); letter-spacing: .08em; }
.pager .pt { font-weight: 700; font-size: 14.5px; color: var(--accent); }

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 22px 48px;
  font-size: 13px; color: var(--faint);
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
}
.footer a { color: var(--muted); }

/* ---------- 首页 ---------- */
.home-hero { padding: 72px 0 26px; }
.kicker {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.2em; color: var(--accent);
  margin-bottom: 18px;
}
.home-hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.25; margin: 0 0 20px;
  font-weight: 750; letter-spacing: 0.01em;
  max-width: 21ch;
}
.home-hero .lead {
  font-size: 17px; color: var(--muted);
  max-width: 62ch; margin: 0 0 26px;
}
.home-meta {
  display: flex; flex-wrap: wrap; gap: 10px 26px;
  font-family: var(--mono); font-size: 12.5px; color: var(--faint);
  margin-bottom: 34px;
}
.btn-primary {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--accent); color: #fff;
  font-weight: 650; font-size: 15px;
  border-radius: 999px; padding: 11px 26px;
  transition: transform .15s, background .15s;
}
html[data-theme="dark"] .btn-primary { color: #0c1418; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; text-decoration: none; transform: translateY(-1px); }
html[data-theme="dark"] .btn-primary:hover { color: #0c1418; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary .icon { width: 16px; height: 16px; }

.chap-index { padding: 34px 0 10px; }
.chap-index > h2 {
  font-size: 13px; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.2em; color: var(--faint);
  margin: 0 0 6px;
}
.toc-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 28px;
  gap: 18px; align-items: center;
  padding: 24px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  transition: background .15s;
}
.toc-row:first-of-type { border-top: 1px solid var(--line); }
.toc-row:hover { text-decoration: none; background: var(--accent-soft); }
.toc-row .n {
  font-family: var(--mono); font-size: 30px; font-weight: 700;
  color: var(--line); transition: color .15s;
}
html[data-theme="dark"] .toc-row .n { color: #33373d; }
.toc-row:hover .n { color: var(--accent); }
.toc-row .tt { font-weight: 700; font-size: 17.5px; margin-bottom: 3px; }
.toc-row .td { font-size: 14px; color: var(--muted); line-height: 1.7; }
.toc-row .arrow { color: var(--faint); transition: transform .18s, color .15s; }
.toc-row:hover .arrow { transform: translateX(4px); color: var(--accent); }

.rev-note { margin: 46px 0 20px; }

/* ---------- 移动端 ---------- */
.scrim {
  display: none; position: fixed; inset: 0; z-index: 70;
  background: rgba(12, 14, 16, 0.5);
}
@media (max-width: 1023px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 80;
    width: min(84vw, 320px);
    transform: translateX(-102%);
    transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.25);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .page { padding: 30px 20px 32px; }
  .footer { padding: 20px; }
  .pager { grid-template-columns: 1fr; }
  .home-hero { padding-top: 44px; }
  .toc-row { grid-template-columns: 52px minmax(0, 1fr) 24px; gap: 12px; }
  .toc-row .n { font-size: 24px; }
  .fig-grid { grid-template-columns: 1fr; }
}

/* ---------- 减弱动态 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .topbar, .pager, .footer, .progress, .copy-btn { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .page { max-width: none; padding: 0; }
  .fig img { box-shadow: none; }
}
