/* ============================================================
   拾光 · JavaScript 学习站
   小清新文艺风格设计系统
   ============================================================ */

/* ---------- 1. 设计变量 ---------- */
:root {
  --bg: #f7f4ee;
  --bg-soft: #fffdf8;
  --bg-tint: #f1ede4;
  --ink: #2c352e;
  --ink-soft: #5c6a5f;
  --ink-mute: #8b968c;
  --line: rgba(74, 100, 82, 0.15);
  --line-strong: rgba(74, 100, 82, 0.28);

  --sage: #7ba58a;
  --sage-deep: #4f7a60;
  --sage-soft: #e4eee6;
  --peach: #e3a98f;
  --peach-soft: #faeee7;
  --sky: #8fadc4;
  --sky-soft: #e8f0f5;
  --lilac: #a99bc4;
  --lilac-soft: #efecf6;
  --gold: #c2a066;
  --gold-soft: #f7f0e1;
  --rose: #c98f8f;
  --rose-soft: #f8ebeb;

  --code-bg: #25312a;
  --code-bg-soft: #2e3c34;
  --code-text: #e6eee7;
  --code-mute: #8fa596;

  --radius-s: 10px;
  --radius: 18px;
  --radius-l: 26px;
  --shadow-s: 0 2px 10px rgba(60, 76, 64, 0.05);
  --shadow: 0 14px 40px -22px rgba(50, 68, 56, 0.35);
  --shadow-l: 0 30px 70px -40px rgba(50, 68, 56, 0.45);

  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;

  --header-h: 68px;
  --page-max: 1240px;
}

html[data-theme="dark"] {
  --bg: #161c19;
  --bg-soft: #1d2521;
  --bg-tint: #212a25;
  --ink: #e7eee8;
  --ink-soft: #b3c0b6;
  --ink-mute: #7e8d82;
  --line: rgba(200, 222, 206, 0.12);
  --line-strong: rgba(200, 222, 206, 0.22);

  --sage: #8dba9d;
  --sage-deep: #a8cfb6;
  --sage-soft: rgba(141, 186, 157, 0.14);
  --peach: #d9a68d;
  --peach-soft: rgba(217, 166, 141, 0.14);
  --sky: #9cbcd2;
  --sky-soft: rgba(156, 188, 210, 0.14);
  --lilac: #b4a6cd;
  --lilac-soft: rgba(180, 166, 205, 0.16);
  --gold: #d2b47a;
  --gold-soft: rgba(210, 180, 122, 0.14);
  --rose: #cf9a9a;
  --rose-soft: rgba(207, 154, 154, 0.14);

  --code-bg: #101613;
  --code-bg-soft: #18201b;
  --code-text: #dce8de;
  --code-mute: #7f9788;

  --shadow-s: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow: 0 16px 44px -24px rgba(0, 0, 0, 0.65);
  --shadow-l: 0 34px 80px -44px rgba(0, 0, 0, 0.8);
}

/* ---------- 2. 基础重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(123, 165, 138, 0.13), transparent 38%),
    radial-gradient(circle at 88% 14%, rgba(227, 169, 143, 0.11), transparent 34%),
    radial-gradient(circle at 70% 82%, rgba(143, 173, 196, 0.1), transparent 40%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 0.6em;
}

p { margin: 0 0 1.1em; }
ul, ol { margin: 0 0 1.2em; padding-left: 1.35em; }
li { margin-bottom: 0.4em; }
li::marker { color: var(--sage); }
strong { font-weight: 600; color: var(--ink); }
em { font-style: normal; color: var(--sage-deep); }
small { color: var(--ink-mute); }

a {
  color: var(--sage-deep);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}
a:hover { color: var(--sage); }

img, svg { max-width: 100%; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }
::selection { background: rgba(123, 165, 138, 0.28); }

/* ---------- 3. 滚动进度 & 头部 ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 90;
  background: transparent;
  pointer-events: none;
}
.scroll-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sage), var(--peach), var(--lilac));
  border-radius: 0 3px 3px 0;
  transition: width 0.1s linear;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 26px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  flex-shrink: 0;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--sage), var(--sage-deep));
  color: #fdfbf6;
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 16px -8px rgba(79, 122, 96, 0.9);
}
.brand-text {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.03em;
  display: flex;
  flex-direction: column;
}
.brand-text small {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-top: 3px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-link {
  position: relative;
  padding: 7px 11px;
  font-size: 14px;
  color: var(--ink-soft);
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease;
}
.nav-link:hover { color: var(--sage-deep); background: var(--sage-soft); }
.nav-link.is-active {
  color: var(--sage-deep);
  font-weight: 600;
}
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--sage), var(--peach));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.mini-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}
.mini-progress-bar {
  width: 42px;
  height: 4px;
  background: var(--bg-tint);
  border-radius: 999px;
  overflow: hidden;
}
.mini-progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage), var(--sage-deep));
  transition: width 0.4s ease;
}
.mini-progress-num { font-variant-numeric: tabular-nums; color: var(--sage-deep); font-weight: 600; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
}
.icon-btn:hover { color: var(--sage-deep); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }
.nav-toggle { display: none; }

/* ---------- 4. 页面骨架 ---------- */
.page-wrap {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 52px 26px 96px;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 54px;
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--header-h) + 34px);
  max-height: calc(100vh - var(--header-h) - 60px);
  overflow-y: auto;
  padding: 4px 0 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.toc-title {
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 14px;
  padding-left: 4px;
}
.toc-links { display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--line); }
.toc-link {
  position: relative;
  display: block;
  padding: 6px 0 6px 15px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  border-left: 2px solid transparent;
  margin-left: -1.5px;
  transition: all 0.2s ease;
}
.toc-link:hover { color: var(--sage-deep); padding-left: 18px; }
.toc-link.is-active {
  color: var(--sage-deep);
  border-left-color: var(--sage);
  font-weight: 600;
  background: linear-gradient(90deg, var(--sage-soft), transparent);
}
.toc-link span { color: var(--ink-mute); font-size: 11px; margin-right: 5px; font-variant-numeric: tabular-nums; }

.toc-progress {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  padding-left: 4px;
}
.toc-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 7px;
}
.toc-progress-num { color: var(--sage-deep); font-weight: 600; font-size: 12px; }
.toc-progress-bar {
  height: 5px;
  background: var(--bg-tint);
  border-radius: 999px;
  overflow: hidden;
}
.toc-progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage), var(--peach));
  transition: width 0.4s ease;
}

.toc-note {
  margin-top: 26px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg-soft);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-mute);
}
.toc-note strong { display: block; color: var(--ink-soft); margin-bottom: 4px; font-size: 12px; }

.content { min-width: 0; }

/* ---------- 5. 页面头部 ---------- */
.page-hero {
  position: relative;
  padding: 12px 0 42px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--sage-deep);
  margin-bottom: 16px;
}
.page-kicker::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--sage);
}
.page-hero h1 {
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.28;
  margin: 0 0 16px;
  letter-spacing: 0.015em;
  isolation: isolate;
}
.page-hero h1 em {
  font-style: normal;
  color: var(--sage-deep);
  position: relative;
  white-space: nowrap;
}
.page-hero h1 em::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 3px;
  height: 9px;
  background: linear-gradient(90deg, rgba(123, 165, 138, 0.3), rgba(227, 169, 143, 0.26));
  border-radius: 4px;
  z-index: -1;
}
.page-desc {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.95;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 0 0 20px;
}
.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--ink-soft);
}
.chip--sage { background: var(--sage-soft); border-color: transparent; color: var(--sage-deep); }
.chip--peach { background: var(--peach-soft); border-color: transparent; color: #b06f4f; }
.chip--sky { background: var(--sky-soft); border-color: transparent; color: #537a94; }
.chip--lilac { background: var(--lilac-soft); border-color: transparent; color: #6f6190; }

/* ---------- 6. 章节 ---------- */
.chapter {
  padding-top: 52px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.chapter-head { margin-bottom: 34px; }
.chapter-index {
  display: block;
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--peach);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.chapter-title {
  font-size: clamp(23px, 3vw, 30px);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.chapter-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}
.chapter-desc {
  font-size: 14.5px;
  color: var(--ink-mute);
  max-width: 700px;
  margin: 0;
}

/* ---------- 7. 知识点卡片 ---------- */
.topic {
  position: relative;
  padding: 28px 30px 30px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  box-shadow: var(--shadow-s);
  scroll-margin-top: calc(var(--header-h) + 20px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}
.topic:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.topic.is-learned { border-color: rgba(123, 165, 138, 0.5); }
.topic.is-learned::after {
  content: "已学";
  position: absolute;
  top: 0;
  right: 24px;
  transform: translateY(-50%);
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #fdfbf6;
  background: var(--sage);
}

.topic-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}
.topic-num {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--peach);
  letter-spacing: 0.06em;
  font-weight: 600;
}
.topic-title {
  font-size: 19px;
  margin: 0;
  flex: 0 1 auto;
}
.level {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.lv-1 { background: var(--sage-soft); color: var(--sage-deep); }
.lv-2 { background: var(--sky-soft); color: #537a94; }
.lv-3 { background: var(--peach-soft); color: #b06f4f; }
.lv-4 { background: var(--lilac-soft); color: #6f6190; }

.learn-btn {
  margin-left: auto;
  padding: 4px 13px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.22s ease;
  white-space: nowrap;
}
.learn-btn:hover { color: var(--sage-deep); border-color: var(--sage); background: var(--sage-soft); }
.learn-btn.is-done { color: #fdfbf6; background: var(--sage); border-color: var(--sage); }

.topic-body > *:last-child { margin-bottom: 0; }
.topic-body h4 {
  font-size: 15.5px;
  margin: 26px 0 10px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topic-body h4::before {
  content: "";
  width: 5px;
  height: 15px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--sage), var(--peach));
  flex-shrink: 0;
}
.topic-body p { font-size: 15px; color: var(--ink-soft); }
.topic-body > p:first-of-type { font-size: 15.5px; }

/* ---------- 8. 提示框 ---------- */
.note {
  position: relative;
  padding: 14px 18px 14px 46px;
  margin: 18px 0;
  border-radius: var(--radius-s);
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-soft);
  background: var(--bg-tint);
  border-left: 3px solid var(--line-strong);
}
.note::before {
  position: absolute;
  left: 15px;
  top: 12px;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 600;
}
.note strong { color: inherit; }
.note p { margin: 0 0 6px; font-size: 14px; }
.note p:last-child { margin: 0; }
.note ul, .note ol { margin: 6px 0 0; padding-left: 1.2em; }
.note--tip { background: var(--sage-soft); border-left-color: var(--sage); color: #3f6450; }
.note--tip::before { content: "提示"; color: var(--sage-deep); }
.note--warn { background: var(--peach-soft); border-left-color: var(--peach); color: #8f5638; }
.note--warn::before { content: "注意"; color: #b06f4f; }
.note--info { background: var(--sky-soft); border-left-color: var(--sky); color: #41657e; }
.note--info::before { content: "延伸"; color: #537a94; }
.note--deep { background: var(--lilac-soft); border-left-color: var(--lilac); color: #5f5379; }
.note--deep::before { content: "深入"; color: #6f6190; }

html[data-theme="dark"] .note--tip { color: #b9d6c4; }
html[data-theme="dark"] .note--warn { color: #e3bfa9; }
html[data-theme="dark"] .note--info { color: #b6cede; }
html[data-theme="dark"] .note--deep { color: #c8bddd; }

/* ---------- 9. 代码块 ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(123, 165, 138, 0.15);
  color: var(--sage-deep);
  word-break: break-word;
}
html[data-theme="dark"] code { background: rgba(141, 186, 157, 0.16); color: var(--sage-deep); }

.code-block {
  position: relative;
  margin: 18px 0 22px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: 0 18px 36px -26px rgba(20, 30, 24, 0.9);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 15px;
  background: var(--code-bg-soft);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.code-lang {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--code-mute);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.code-lang::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage);
}
.copy-btn {
  padding: 3px 10px;
  font-size: 11px;
  color: var(--code-mute);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.copy-btn:hover { color: var(--code-text); border-color: rgba(255, 255, 255, 0.3); }
.copy-btn.is-copied { color: var(--sage); border-color: var(--sage); }

pre.code {
  margin: 0;
  padding: 18px 20px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.2px;
  line-height: 1.78;
  color: var(--code-text);
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
pre.code::-webkit-scrollbar { height: 7px; }
pre.code::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 7px; }
pre.code code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  white-space: pre;
  word-break: normal;
}
.cm { color: #8ba08f; font-style: italic; }
.cm-str { color: #d9c79a; }
.cm-kw { color: #a9c8d8; }
.cm-fn { color: #b4d3b0; }
.cm-num { color: #dfab95; }
.cm-out { color: #8fa596; }

/* ---------- 10. 表格 ---------- */
.table-wrap {
  margin: 18px 0 22px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
  min-width: 480px;
}
table.table th {
  text-align: left;
  padding: 11px 16px;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-tint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  vertical-align: top;
}
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: rgba(123, 165, 138, 0.06); }

/* ---------- 11. 演示区 ---------- */
.demo {
  margin: 20px 0 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(123, 165, 138, 0.07), rgba(227, 169, 143, 0.06));
  overflow: hidden;
}
.demo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px dashed var(--line);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.demo-head span { display: inline-flex; align-items: center; gap: 8px; }
.demo-head span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--peach);
  transform: rotate(45deg);
}
.demo-body {
  padding: 18px 18px 20px;
  font-size: 14px;
  color: var(--ink-soft);
}
.demo-body > *:last-child { margin-bottom: 0; }
.demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* ---------- 12. 控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--sage), var(--sage-deep));
  color: #fdfbf6;
  font-size: 13.5px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 10px 22px -14px rgba(63, 100, 80, 0.9);
}
.btn:hover { transform: translateY(-2px); color: #fdfbf6; box-shadow: 0 16px 30px -16px rgba(63, 100, 80, 0.9); }
.btn:active { transform: translateY(0); }
.btn--ghost {
  background: transparent;
  color: var(--sage-deep);
  border-color: var(--line-strong);
  box-shadow: none;
}
.btn--ghost:hover { background: var(--sage-soft); color: var(--sage-deep); box-shadow: none; }
.btn--sm { padding: 6px 14px; font-size: 12.5px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(123, 165, 138, 0.14);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.demo-row .input { flex: 1 1 180px; width: auto; }

.output {
  min-height: 42px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.7);
  border: 1px dashed var(--line-strong);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
html[data-theme="dark"] .output { background: rgba(20, 27, 23, 0.6); }

.tag-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 14px; }
.tag {
  font-size: 11.5px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-tint);
  color: var(--ink-mute);
  font-family: var(--font-mono);
}

/* ---------- 13. 卡片网格 ---------- */
.grid-2, .grid-3, .grid-4 {
  display: grid;
  gap: 16px;
  margin: 18px 0 22px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  padding: 18px 19px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg-soft);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card h4 { margin: 0 0 7px; font-size: 15px; }
.card h4::before { display: none; }
.card p { margin: 0; font-size: 13.5px; color: var(--ink-mute); line-height: 1.75; }
.card .tag-row { margin: 10px 0 0; }

/* ---------- 14. 页脚 ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-soft) 60%, transparent);
}
.footer-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 38px 26px 42px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-serif);
  font-size: 14.5px;
  color: var(--ink-soft);
}
.footer-brand .brand-mark { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.footer-note { font-size: 12px; color: var(--ink-mute); letter-spacing: 0.04em; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; }
.footer-links a { color: var(--ink-mute); }
.footer-links a:hover { color: var(--sage-deep); }

/* ---------- 15. 首页专用 ---------- */
.hero {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 84px 26px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 60px;
  align-items: center;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  letter-spacing: 0.26em;
  color: var(--sage-deep);
  margin-bottom: 22px;
}
.hero-kicker::before { content: ""; width: 32px; height: 1px; background: var(--sage); }
.hero h1 {
  font-size: clamp(36px, 5.4vw, 60px);
  line-height: 1.24;
  margin: 0 0 22px;
  letter-spacing: 0.01em;
  isolation: isolate;
}
.hero h1 .accent {
  position: relative;
  color: var(--sage-deep);
  white-space: nowrap;
}
.hero h1 .accent::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 6px;
  height: 12px;
  background: linear-gradient(90deg, rgba(227, 169, 143, 0.34), rgba(123, 165, 138, 0.26));
  border-radius: 6px;
  z-index: -1;
}
.hero-desc {
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 2;
  color: var(--ink-soft);
  max-width: 500px;
  margin: 0 0 30px;
}
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.hero-actions .btn { padding: 12px 26px; font-size: 14px; }
.hero-hint { font-size: 12px; color: var(--ink-mute); letter-spacing: 0.06em; }

.hero-visual {
  position: relative;
  display: flex;
  justify-content: center;
}
.hero-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 24px 24px 26px;
  border-radius: var(--radius-l);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-l);
  transform: rotate(-1.2deg);
}
.hero-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px dashed var(--line);
  border-radius: 19px;
  pointer-events: none;
}
.hero-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.hero-card-head i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--peach); opacity: 0.75;
}
.hero-card-head i:nth-child(2) { background: var(--gold); }
.hero-card-head i:nth-child(3) { background: var(--sage); }
.hero-card-head span {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
}
.hero-code {
  font-family: var(--font-mono);
  font-size: 12.6px;
  line-height: 1.95;
  color: var(--ink-soft);
  white-space: pre-wrap;
  margin: 0;
}
.hero-code b { color: var(--sage-deep); font-weight: 500; }
.hero-code u { color: var(--peach); text-decoration: none; }
.hero-code i { color: var(--lilac); font-style: normal; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(38px);
  opacity: 0.5;
  z-index: -1;
}
.blob--sage { width: 260px; height: 260px; background: rgba(123, 165, 138, 0.26); top: -40px; right: -20px; }
.blob--peach { width: 200px; height: 200px; background: rgba(227, 169, 143, 0.24); bottom: -40px; left: -30px; }

.section {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 72px 26px;
}
.section + .section { padding-top: 36px; }
.section-head {
  max-width: 640px;
  margin-bottom: 38px;
}
.section-head .page-kicker { margin-bottom: 14px; }
.section-head h2 {
  font-size: clamp(25px, 3.2vw, 34px);
  margin: 0 0 12px;
}
.section-head p {
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--ink-mute);
  margin: 0;
  line-height: 1.95;
}

/* 学习路线 */
.path-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  counter-reset: step;
}
.path-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 26px 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--ink);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
}
.path-card::before {
  counter-increment: step;
  content: "0" counter(step);
  position: absolute;
  top: 14px;
  right: 18px;
  font-family: var(--font-serif);
  font-size: 34px;
  color: var(--line-strong);
  line-height: 1;
}
.path-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.path-card:hover .path-title { color: var(--sage-deep); }
.path-step {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--peach);
  margin-bottom: 12px;
}
.path-title {
  font-family: var(--font-serif);
  font-size: 19px;
  margin: 0 0 6px;
  transition: color 0.25s ease;
}
.path-sub { font-size: 12.5px; color: var(--ink-mute); margin: 0 0 14px; }
.path-list { list-style: none; padding: 0; margin: 0 0 18px; }
.path-list li {
  position: relative;
  padding-left: 15px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.path-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sage);
}
.path-more {
  margin-top: auto;
  font-size: 12.5px;
  color: var(--sage-deep);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.path-more::after { content: "→"; transition: transform 0.25s ease; }
.path-card:hover .path-more::after { transform: translateX(4px); }

/* 特色 */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.feature {
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-soft) 80%, transparent);
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.feature:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.feature-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--sage-soft);
  color: var(--sage-deep);
  margin-bottom: 16px;
}
.feature:nth-child(2) .feature-icon { background: var(--peach-soft); color: #b06f4f; }
.feature:nth-child(3) .feature-icon { background: var(--sky-soft); color: #537a94; }
.feature:nth-child(4) .feature-icon { background: var(--lilac-soft); color: #6f6190; }
.feature:nth-child(5) .feature-icon { background: var(--gold-soft); color: #96794a; }
.feature:nth-child(6) .feature-icon { background: var(--rose-soft); color: #a86a6a; }
.feature-icon svg { width: 20px; height: 20px; }
.feature h3 { font-size: 16.5px; margin: 0 0 8px; }
.feature p { font-size: 13.5px; color: var(--ink-mute); margin: 0; line-height: 1.8; }

/* 数据条 */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  padding: 26px 18px;
  background: var(--bg-soft);
  text-align: center;
}
.stat-num {
  font-family: var(--font-serif);
  font-size: 30px;
  color: var(--sage-deep);
  line-height: 1.2;
  letter-spacing: 0.02em;
}
.stat-label { font-size: 12px; color: var(--ink-mute); letter-spacing: 0.1em; margin-top: 4px; }

/* 引用 */
.quote {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  padding: 34px 40px;
  border-radius: var(--radius-l);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 2;
  color: var(--ink-soft);
  text-align: center;
}
.quote::before {
  content: "“";
  position: absolute;
  top: -6px;
  left: 26px;
  font-family: var(--font-serif);
  font-size: 70px;
  color: var(--line-strong);
  line-height: 1;
}
.quote cite {
  display: block;
  margin-top: 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-style: normal;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
}

/* ---------- 16. 练习场 ---------- */
.playground {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 26px;
}
.editor-pane, .result-pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
  min-height: 460px;
}
.pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-tint);
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.08em;
}
.pane-head strong { color: var(--ink-soft); font-weight: 600; font-family: var(--font-serif); }
.pane-head .spacer { margin-left: auto; }
.editor-pane textarea {
  flex: 1;
  width: 100%;
  min-height: 380px;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 13.2px;
  line-height: 1.8;
  tab-size: 2;
}
.result-pane iframe {
  flex: 1;
  width: 100%;
  min-height: 300px;
  border: none;
  background: #fffdf8;
  border-bottom: 1px solid var(--line);
}
.console-out {
  height: 150px;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12.4px;
  line-height: 1.7;
  background: var(--bg-tint);
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.console-line { padding: 2px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.04); }
.console-line.err { color: #b06f4f; }
.console-line .c-tag {
  display: inline-block;
  min-width: 52px;
  color: var(--ink-mute);
  font-size: 10.5px;
  letter-spacing: 0.06em;
}
.playground-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.playground-toolbar .spacer { margin-left: auto; }
select.select { width: auto; min-width: 170px; padding: 8px 12px; }

/* ---------- 17. 速查表 ---------- */
.cheat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.cheat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
}
.cheat-card h3 {
  margin: 0;
  padding: 13px 18px;
  font-size: 15px;
  background: var(--bg-tint);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cheat-card h3::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--peach);
}
.cheat-card ul { list-style: none; margin: 0; padding: 8px 0; }
.cheat-card li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 1px dashed var(--line);
  margin: 0;
  align-items: baseline;
}
.cheat-card li:last-child { border-bottom: none; }
.cheat-card li code { flex-shrink: 0; }
.cheat-card li span { color: var(--ink-mute); font-size: 12.5px; }

/* ---------- 18. 动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 0.68, 0.36, 1);
}
.reveal.in-view { opacity: 1; transform: none; }

@keyframes floaty {
  0%, 100% { transform: rotate(-1.2deg) translateY(0); }
  50% { transform: rotate(-0.4deg) translateY(-8px); }
}
.hero-card { animation: floaty 9s ease-in-out infinite; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 19. 响应式 ---------- */
@media (max-width: 1120px) {
  .page-wrap { grid-template-columns: 196px minmax(0, 1fr); gap: 36px; }
  .hero { gap: 40px; }
  .path-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 56px; gap: 44px; }
  .hero-card { max-width: 460px; }
  .page-wrap { grid-template-columns: 1fr; padding-top: 32px; }
  .toc { display: none; }
  .nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 16px 18px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  body.nav-open .nav { transform: none; opacity: 1; visibility: visible; }
  .nav-link { padding: 12px 8px; font-size: 15px; border-bottom: 1px dashed var(--line); border-radius: 0; }
  .nav-link.is-active::after { display: none; }
  .nav-toggle { display: grid; }
  .mini-progress { display: none; }
  .playground { grid-template-columns: 1fr; }
  .cheat-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 0 18px; gap: 12px; }
  .brand-text small { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .hero { padding: 44px 18px 40px; }
  .section { padding: 48px 18px; }
  .page-wrap { padding: 26px 18px 64px; }
  .topic { padding: 22px 18px 24px; }
  .topic-head { gap: 9px; }
  .learn-btn { margin-left: 0; }
  .path-grid, .feature-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { padding: 28px 18px 34px; }
  pre.code { font-size: 12.4px; padding: 16px; }
  .quote { padding: 26px 20px; font-size: 15.5px; }
  .code-head { padding: 8px 12px; }
  .brand-text { font-size: 15px; }
}

/* ---------- 20. 可访问性 & 打印 ---------- */
:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .site-footer, .toc, .scroll-progress, .learn-btn, .copy-btn { display: none !important; }
  body { background: #fff; }
  .page-wrap { display: block; padding: 0; }
  .topic { break-inside: avoid; box-shadow: none; }
}
