* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #1a1a2e;
  --paper: #f7f5f0;
  --accent: #c44b2b;
  --accent-light: #e8d5cf;
  --accent-glow: #ff6b45;
  --branch-green: #2d6a4f;
  --branch-blue: #1d3557;
  --branch-purple: #6c4ab6;
  --branch-amber: #b5651d;
  --muted: #6b6b7b;
  --border: #d4d0c8;
  --code-bg: #2b2b3d;
  --code-text: #e0def4;
  --card-bg: #ffffff;
  --highlight: #fff3cd;
}

body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.85;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

.page-wrapper {
  max-width: 780px;
  margin: 0 auto;
  padding: 60px 28px 100px;
}

.hero {
  text-align: center;
  margin-bottom: 56px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.hero-label {
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 20px;
}

.hero h1 {
  font-family: 'Noto Serif TC', serif;
  font-size: 2.5em;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 16px;
  color: var(--ink);
}

.hero h1 span { color: var(--accent); }

.hero-sub {
  font-size: 1.05em;
  color: var(--muted);
  font-weight: 300;
  max-width: 520px;
  margin: 0 auto;
}

/* Part divider */
.part-divider {
  text-align: center;
  margin: 72px 0 48px;
  padding: 40px 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--border);
}

.part-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 12px;
}

.part-divider h2 {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.8em;
  font-weight: 900;
  margin-bottom: 8px;
}

.part-divider p {
  font-size: 0.95em;
  color: var(--muted);
  margin-bottom: 0;
}

/* Sticky nav */
.sticky-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  margin: 0 -28px 40px;
  padding-left: 28px;
  padding-right: 28px;
  display: flex;
  gap: 8px;
}

.nav-btn {
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 0.85em;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* TOC */
.toc {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 48px;
}

.toc-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.05em;
  font-weight: 700;
  margin-bottom: 14px;
}

.toc-section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 16px;
  margin-bottom: 8px;
}

.toc-section-label:first-child { margin-top: 0; }

.toc ol {
  list-style: none;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
  padding: 4px 0;
  font-size: 0.92em;
  color: var(--muted);
}

.toc li::before {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: var(--accent);
  margin-right: 12px;
  font-weight: 500;
}

.toc-git { counter-reset: toc; }
.toc-git li::before { content: "0" counter(toc); }

.toc-github { counter-reset: toc 8; }
.toc-github li::before {
  content: counter(toc);
}

/* Section */
.section { margin-bottom: 56px; }

.section-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.section h2 {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.6em;
  font-weight: 900;
  margin-bottom: 20px;
  line-height: 1.35;
}

.section h3 {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.15em;
  font-weight: 700;
  margin-top: 32px;
  margin-bottom: 12px;
}

p { margin-bottom: 16px; }
strong { font-weight: 700; }

code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.88em;
}

.analogy {
  background: linear-gradient(135deg, #fff9f0, #fff5eb);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 20px 24px;
  margin: 24px 0;
  font-size: 0.95em;
}

.analogy-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  line-height: 1.7;
  overflow-x: auto;
}

.code-block .comment { color: #6e6a86; }
.code-block .cmd { color: #9ccfd8; }
.code-block .flag { color: #f6c177; }
.code-block .string { color: #c4a7e7; }

.prompt {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px 16px 48px;
  margin: 16px 0;
  position: relative;
}

.prompt::before {
  content: "💬";
  position: absolute;
  left: 16px;
  top: 16px;
  font-size: 18px;
}

.prompt-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.prompt p { margin: 0; font-size: 0.95em; }

.naming-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.92em;
}

.naming-table th {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 0.9em;
}

.naming-table th:first-child { border-radius: 8px 0 0 0; }
.naming-table th:last-child { border-radius: 0 8px 0 0; }

.naming-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.naming-table tr:nth-child(even) { background: #faf9f6; }

.naming-table code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
  white-space: nowrap;
}

.diagram {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  margin: 28px 0;
  text-align: center;
  overflow-x: auto;
}

.diagram svg { max-width: 100%; height: auto; }

.diagram-caption {
  font-size: 0.85em;
  color: var(--muted);
  margin-top: 12px;
}

.key-point {
  background: linear-gradient(135deg, #f0f4f8, #e8ecf0);
  border-radius: 12px;
  padding: 24px 28px;
  margin: 24px 0;
}

.key-point-title {
  font-family: 'Noto Serif TC', serif;
  font-weight: 700;
  font-size: 1em;
  margin-bottom: 8px;
  color: var(--branch-blue);
}

.warning {
  background: #fff8f0;
  border: 1px solid #f0c89a;
  border-radius: 10px;
  padding: 20px 24px 20px 48px;
  margin: 24px 0;
  position: relative;
}

.warning::before {
  content: "⚠️";
  position: absolute;
  left: 16px;
  top: 20px;
}

.tip {
  background: #f0f7f4;
  border: 1px solid #b7d8c6;
  border-radius: 10px;
  padding: 20px 24px 20px 48px;
  margin: 24px 0;
  position: relative;
}

.tip::before {
  content: "💡";
  position: absolute;
  left: 16px;
  top: 20px;
}

.flow-list {
  list-style: none;
  margin: 20px 0;
  padding: 0;
}

.flow-list li {
  position: relative;
  padding: 12px 0 12px 44px;
  border-left: 2px solid var(--border);
  margin-left: 12px;
}

.flow-list li:last-child { border-left-color: transparent; }

.flow-list li::before {
  content: attr(data-step);
  position: absolute;
  left: -13px;
  top: 10px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}

.compare-card {
  border-radius: 10px;
  padding: 20px;
  font-size: 0.92em;
}

.compare-card.good, .compare-card.b {
  background: #f0f7f4;
  border: 1px solid #b7d8c6;
}

.compare-card.bad {
  background: #fdf2f2;
  border: 1px solid #f0b8b8;
}

.compare-card.a {
  background: #f0f4f8;
  border: 1px solid #c0cfe0;
}

.compare-label {
  font-weight: 700;
  font-size: 0.85em;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.compare-card.good .compare-label, .compare-card.b .compare-label { color: var(--branch-green); }
.compare-card.bad .compare-label { color: var(--accent); }
.compare-card.a .compare-label { color: var(--branch-blue); }
.compare-card p { margin-bottom: 8px; font-size: 0.95em; }

.compare-card code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  display: block;
  margin: 4px 0;
}

.repo-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  margin: 24px 0;
}

.repo-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.repo-card-icon {
  width: 20px;
  height: 20px;
  background: var(--ink);
  border-radius: 4px;
}

.repo-card-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1em;
  color: var(--branch-blue);
  font-weight: 500;
}

.repo-card-desc {
  font-size: 0.92em;
  color: var(--muted);
  margin-bottom: 16px;
}

.repo-card-stats {
  display: flex;
  gap: 20px;
  font-size: 0.85em;
  color: var(--muted);
}

.repo-card-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.repo-screenshot {
  margin: 24px 0;
}

.repo-screenshot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.repo-screenshot figcaption {
  margin-top: 10px;
  font-size: 0.88em;
  color: var(--muted);
  text-align: center;
}

.sep {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 48px 0;
}


@media (max-width: 600px) {
  .page-wrapper { padding: 36px 18px 60px; }
  .hero h1 { font-size: 1.9em; }
  .compare-grid { grid-template-columns: 1fr; }
  .naming-table { font-size: 0.82em; }
  .sticky-nav { gap: 6px; margin: 0 -18px 32px; padding-left: 18px; padding-right: 18px; overflow-x: auto; }
  .nav-btn { font-size: 0.8em; padding: 6px 12px; }
}

/* ============================================================
   EDITORIAL HAUS — Design System Override
   Cream paper + Deep Forest + Sage Mint, italic serif emphasis,
   capsule interactive elements, generously rounded containers.
   ============================================================ */
:root {
  --ink: #1F3A2E;           /* Deep Forest */
  --paper: #F5F1EA;         /* Cream Paper */
  --surface: #FAFAF7;       /* Bone White */
  --sage: #B8D9A8;          /* Sage Mint */
  --sage-dark: #A5CC93;
  --muted: #5A6B5C;         /* Sage Grey */
  --aged: #E8E3D8;          /* Aged Cream */
  --border: #1F3A2E;
  --accent: #1F3A2E;
  --accent-light: #E8E3D8;
  --card-bg: #FAFAF7;
  --code-bg: #1F3A2E;
  --code-text: #F5F1EA;
  --branch-green: #1F3A2E;
  --branch-blue: #1F3A2E;
  --highlight: #B8D9A8;
}

html, body { background: var(--paper); color: var(--ink); }
body {
  font-family: 'Inter', 'Noto Sans TC', system-ui, sans-serif;
  line-height: 1.7;
}

/* Serif display stack — DM Serif Display for Latin, Noto Serif TC for CJK
   Latin 用 DM Serif Display 400（本身字重已偏粗）；CJK 用 Noto Serif TC 700 加粗。
   font-synthesis: none 防止瀏覽器對缺少粗體的字型做 faux-bold。*/
.hero h1,
.part-divider h2,
.section h2,
.section h3,
.toc-title,
.key-point-title {
  font-family: 'DM Serif Display', 'Noto Serif TC', Georgia, serif;
  font-weight: 600;
  font-synthesis: none;
  letter-spacing: -0.01em;
}

.page-wrapper {
  max-width: 860px;
  padding: 72px 32px 120px;
  position: relative;
}

/* Asterisk flourish — top-right brand signature */
.page-wrapper::before {
  content: "✽";
  position: absolute;
  top: 36px;
  right: 32px;
  font-family: 'DM Serif Display', serif;
  font-size: 2.25rem;
  color: var(--ink);
  line-height: 1;
  pointer-events: none;
}

/* HERO */
.hero {
  text-align: left;
  padding: 48px 0 56px;
  margin-bottom: 64px;
  border-bottom: 1px solid var(--ink);
}
.hero-label {
  display: inline-block;
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: 9999px;
  background: var(--surface);
  margin-bottom: 28px;
}
.hero-label::before { content: "[ "; }
.hero-label::after { content: " ]"; }

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  line-height: 0.98;
  color: var(--ink);
  margin-bottom: 24px;
}
.hero h1 span {
  font-style: italic;
  color: var(--ink);
  font-family: 'DM Serif Display', 'Noto Serif TC', serif;
}

.hero-sub {
  font-family: 'DM Serif Display', 'Noto Serif TC', serif;
  font-style: italic;
  color: var(--ink);
  opacity: 0.78;
  font-size: 1.25rem;
  max-width: 620px;
  margin: 0;
  line-height: 1.5;
}

/* STICKY NAV — pill buttons（只有手機版顯示，桌機改用側邊 TOC） */
.sticky-nav {
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  padding: 14px 0;
  margin: 0 -32px 48px;
  padding-left: 32px;
  padding-right: 32px;
  z-index: 40;
  display: none;
}
@media (max-width: 600px) {
  .sticky-nav { display: block; }
}
.sticky-nav-pills {
  display: flex;
  gap: 8px;
  align-items: center;
}
.nav-btn {
  border-radius: 9999px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 10px 18px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82em;
  font-weight: 500;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* Chevron — desktop hidden, mobile shown */
.nav-chevron {
  display: none;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.22s ease-out;
}
.nav-btn.is-expanded .nav-chevron {
  transform: rotate(-135deg) translate(-1px, -1px);
}

/* Mobile sub-section dropdown panel */
.sticky-nav-submenu { display: none; }
.sticky-nav-submenu[hidden] { display: none !important; }
.nav-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.nav-btn.active {
  background: var(--sage);
  color: var(--ink);
  border-color: var(--ink);
}

/* Inner pieces: anchor for text-jump, button for chevron-toggle.
   Both transparent — pill looks like a single unit, no divider, no extra padding. */
.nav-btn-link {
  color: inherit;
  text-decoration: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
}
.nav-btn-toggle {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  display: none; /* desktop: hidden */
  align-items: center;
  font: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn-toggle:focus-visible {
  outline: 1px dashed currentColor;
  outline-offset: 3px;
  border-radius: 2px;
}

/* TOC */
.toc {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 36px 40px;
  margin-bottom: 56px;
  position: relative;
}
.toc-title {
  font-size: 1.6rem;
  font-style: italic;
  margin-bottom: 20px;
  color: var(--ink);
}
.toc-section-label {
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.2em;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--ink);
  border-radius: 9999px;
  display: inline-block;
  background: var(--sage);
  margin-top: 20px;
  margin-bottom: 14px;
}
.toc-section-label::before { content: "[ "; }
.toc-section-label::after { content: " ]"; }
.toc li { color: var(--ink); opacity: 0.85; font-family: 'Inter', 'Noto Sans TC', sans-serif; }
.toc li::before { color: var(--ink); opacity: 0.55; }

/* PART DIVIDER */
.part-divider {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 24px;
  padding: 64px 40px;
  margin: 96px 0 64px;
  position: relative;
}
.part-divider::after {
  content: "✽";
  position: absolute;
  top: 20px;
  right: 28px;
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  color: var(--sage);
}
.part-label {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  color: var(--paper);
  border: 1px solid var(--paper);
  padding: 4px 14px;
  border-radius: 9999px;
  margin-bottom: 18px;
}
.part-label::before { content: "[ "; }
.part-label::after { content: " ]"; }
.part-divider h2 {
  color: var(--paper);
  font-size: 2.6rem;
  font-style: italic;
  line-height: 1;
}
.part-divider p { color: var(--sage); font-family: 'DM Serif Display','Noto Serif TC',serif; font-style: italic; font-size: 1.1rem; margin-top: 10px; }

/* SECTIONS */
.section { margin-bottom: 72px; scroll-margin-top: 90px; }
.part-divider { scroll-margin-top: 80px; }
.section-number {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--aged);
  margin-bottom: 14px;
}
.section-number::before { content: "[ "; }
.section-number::after { content: " ]"; }
.section h2 {
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 24px;
}
.section h2 em, .section h2 i { font-style: italic; }
.section h3 {
  font-size: 1.85rem;
  font-style: italic;
  color: var(--ink);
  margin-top: 56px;
  margin-bottom: 18px;
}

p { color: var(--ink); }
strong { color: var(--ink); font-weight: 600; }

/* 內文原生 list（排除 .flow-list / .step-flow / .flow-notes 等已自訂的清單） */
.section ol:not([class]),
.section ul:not([class]) {
  padding-left: 28px;
  margin: 12px 0;
}
.section ol:not([class]) li,
.section ul:not([class]) li {
  margin-bottom: 8px;
  line-height: 1.7;
}

/* Inline code */
code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--aged);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 9999px;
  padding: 1px 10px;
  font-size: 0.82em;
}

/* Analogy card */
.analogy {
  background: var(--sage);
  border: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
  border-radius: 24px;
  padding: 28px 32px;
  color: var(--ink);
  position: relative;
}
.analogy::before {
  content: "✽";
  position: absolute;
  top: -14px;
  left: 24px;
  background: var(--paper);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border: 1px solid var(--ink);
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
}
.analogy-label {
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 14px;
  display: block;
}
.analogy-label::before { content: "[ "; }
.analogy-label::after { content: " ]"; }

/* Code block — Deep Forest ink */
.code-block {
  background: var(--ink);
  color: var(--paper);
  border-radius: 24px;
  padding: 28px 32px;
  border: 1px solid var(--ink);
}
.code-block .comment { color: #8FA890; }
.code-block .cmd { color: var(--sage); }
.code-block .flag { color: #E8D89A; }
.code-block .string { color: #F5F1EA; font-style: italic; }

/* Prompt card */
.prompt {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 22px 28px 22px 60px;
}
.prompt-label {
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: inline-block;
}
.prompt-label::before { content: "[ "; }
.prompt-label::after { content: " ]"; }

/* Naming table */
.naming-table { border: 1px solid var(--ink); border-radius: 24px; overflow: hidden; }
.naming-table th {
  background: var(--ink);
  color: var(--paper);
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75em;
  padding: 16px 20px;
}
.naming-table th:first-child,
.naming-table th:last-child { border-radius: 0; }
.naming-table td { border-bottom: 1px solid var(--ink); padding: 14px 20px; color: var(--ink); }
.naming-table tr:last-child td { border-bottom: none; }
.naming-table tr:nth-child(even) { background: var(--aged); }
.naming-table code { white-space: nowrap; }

/* Diagram */
.diagram {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 36px 28px;
}
.diagram svg { max-width: 100%; height: auto; margin: 0 auto; }
.diagram-svg-desktop { display: block; }
.diagram-svg-mobile { display: none; }
.diagram-caption { color: var(--ink); font-style: italic; font-family: 'DM Serif Display','Noto Serif TC',serif; margin-top: 14px; text-align: center; }

/* 抽出 SVG 的重點提示框，改用 HTML 讓文字能正常 reflow */
.diagram-note {
  margin: 24px auto 0;
  max-width: 520px;
  padding: 18px 24px;
  background: var(--sage);
  border: 1px solid var(--ink);
  border-radius: 16px;
  text-align: center;
  color: var(--ink);
  line-height: 1.5;
}
.diagram-note strong { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.95rem; }
.diagram-note span { color: var(--ink); opacity: 0.88; font-size: 0.95rem; }

/* Section 11 — 手機版 Push/Pull/Clone：兩張卡片 + 線段式箭頭 + 註腳 */
.flow-mobile { display: none; }

/* 卡片：暖色（local）vs 冷色（remote）對比 */
.flow-card {
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  padding: 16px 20px;
}
.flow-card--local { background: var(--aged); }
.flow-card--remote { background: var(--sage); }
.flow-card-title {
  font-family: 'DM Serif Display', 'Noto Serif TC', serif;
  font-size: 1.3rem;
  color: var(--ink);
  line-height: 1.2;
}
.flow-card-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 4px 0 14px;
}
.flow-card-items { display: flex; flex-direction: column; gap: 6px; }
.flow-card-items span {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.88rem;
  color: var(--ink);
  text-align: center;
}

/* 中間：三條垂直箭頭並排，每條下方搭配動作名 */
.flow-arrows {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 28px 16px 24px;
  align-items: end;
  justify-items: center;
}
.flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.flow-arrow-stem {
  width: 2px;
  height: 52px;
  background: currentColor;
  position: relative;
}
.flow-arrow-name {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.flow-arrow-name sup {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 0.7em;
  margin-left: 1px;
  color: var(--muted);
}
/* 箭頭三角形：down 在 stem 底部，up 在 stem 頂部 */
.flow-arrow--push .flow-arrow-stem::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid currentColor;
}
.flow-arrow--pull .flow-arrow-stem::before,
.flow-arrow--clone .flow-arrow-stem::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid currentColor;
}
/* 三種動作的色階區隔（與 desktop SVG 同步：push=Deep Forest, pull=extended-4, clone=extended-2） */
.flow-arrow--push { color: #1F3A2E; }
.flow-arrow--pull { color: #4A6B54; }
.flow-arrow--clone { color: #8FB578; }

/* 註腳區 */
.flow-notes {
  list-style: none;
  margin: 18px 0 0;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px dashed var(--muted);
  border-radius: 12px;
}
.flow-notes li {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 8px;
}
.flow-notes li:last-child { margin-bottom: 0; }
.flow-notes-mark {
  display: inline-block;
  min-width: 16px;
  color: var(--ink);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.flow-notes strong {
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* Section 15 — Vibe Coding 流程：純 HTML 卡片，桌面 / 手機共用 */
.diagram--steps { padding: 28px 24px; }
.step-flow { list-style: none; padding: 0; margin: 0; counter-reset: none; }
.step-flow-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 14px;
  margin-bottom: 8px;
  position: relative;
}
.step-flow-item::after {
  content: "";
  position: absolute;
  left: 44px;
  bottom: -8px;
  width: 1px;
  height: 8px;
  background: var(--muted);
  opacity: 0.5;
}
.step-flow-item:last-child { margin-bottom: 0; }
.step-flow-item:last-child::after { display: none; }
.step-flow-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 8px 0;
  background: var(--paper);
}
.step-flow-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.4;
  margin-bottom: 4px;
}
.step-flow-desc {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}
.step-flow-item.is-highlight { background: var(--sage); }
.step-flow-item.is-highlight .step-flow-num { background: var(--surface); }
.step-flow-item.is-accent {
  background: var(--aged);
  border-style: dashed;
}

@media (max-width: 600px) {
  .diagram { padding: 24px 16px; }
  .diagram-svg-desktop { display: none; }
  .diagram-svg-mobile { display: block; }
  .diagram-note { padding: 14px 18px; }
  .diagram-note strong { font-size: 0.92rem; }
  .diagram-note span { font-size: 0.92rem; }

  /* Section 11：手機顯示 HTML 卡片版 */
  .flow-mobile { display: block; }

  /* Section 15：步驟卡在手機下緊湊一點 */
  .diagram--steps { padding: 20px 14px; }
  .step-flow-item { grid-template-columns: 48px 1fr; gap: 14px; padding: 14px 16px; }
  .step-flow-num { font-size: 0.92rem; padding: 7px 0; }
  .step-flow-title { font-size: 1.05rem; }
  .step-flow-desc { font-size: 0.95rem; }
}

/* Key point */
.key-point {
  background: var(--sage);
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 28px 32px;
  color: var(--ink);
}
.key-point-title {
  color: var(--ink);
  font-style: italic;
  font-size: 1.2rem;
}

/* Warning / Tip */
.warning,
.tip {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 24px 28px 24px 60px;
  color: var(--ink);
}
.warning { background: var(--aged); }
.tip { background: var(--sage); }

/* Flow list */
.flow-list li { border-left: 1px solid var(--ink); color: var(--ink); padding-top: 14px; padding-bottom: 14px; }
.flow-list li::before {
  background: var(--sage);
  color: var(--ink);
  border: 1px solid var(--ink);
  width: 28px;
  height: 28px;
  left: -15px;
  font-weight: 600;
}
/* 最後一項：自身 border 維持透明，改用 ::after 補一段 24px 短線（從 li 頂部
   延伸到圓圈中央），剛好接續前一項的線。圓圈 ::before 設 z-index 確保
   蓋在線之上，避免線穿過數字。 */
.flow-list li::before { z-index: 1; }
.flow-list li:last-child::after {
  content: "";
  position: absolute;
  left: -1px;
  top: 0;
  width: 1px;
  height: 24px;
  background: var(--ink);
  z-index: 0;
}

/* Compare cards */
.compare-card {
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 24px 26px;
  color: var(--ink);
}
.compare-card p { font-size: 0.95em; line-height: 1.75; }
.compare-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.compare-list li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 4px;
  font-size: 1.1em;
  line-height: 1.75;
}
.compare-list li:last-child { margin-bottom: 0; }
.compare-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--ink);
}

/* Key-point 內的列點：間距較緊，跟 .compare-list 使用相同的圓點樣式 */
.key-point-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.key-point-list li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 4px;
  font-size: 1em;
  line-height: 1.75;
}
.key-point-list li:last-child { margin-bottom: 0; }
.key-point-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--ink);
}
.compare-card.good, .compare-card.b { background: var(--sage); border-color: var(--ink); }
.compare-card.bad { background: var(--aged); border-color: var(--ink); }
.compare-card.a { background: var(--surface); border-color: var(--ink); }
.compare-card.good .compare-label,
.compare-card.b .compare-label,
.compare-card.bad .compare-label,
.compare-card.a .compare-label { color: var(--ink); font-family: 'Inter', sans-serif; }
.compare-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: inline-block;
}
.compare-label::before { content: "[ "; }
.compare-label::after { content: " ]"; }

/* Repo card */
.repo-card {
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 24px;
  padding: 28px 32px;
}
.repo-card-icon { background: var(--sage); border: 1px solid var(--ink); border-radius: 9999px; }
.repo-card-name { color: var(--ink); }
.repo-card-desc, .repo-card-stats { color: var(--muted); }

/* Desktop flow legend（push/pull/clone 簡短說明） */
.flow-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 28px;
  list-style: none;
  margin: 14px 0 0;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px dashed var(--muted);
  border-radius: 12px;
  font-size: 0.95em;
  color: var(--muted);
}
.flow-legend li {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  line-height: 1.5;
}
.flow-legend-text {
  /* code 與冒號緊貼，不被 li 的 flex gap 撐開 */
  display: inline;
}
.flow-legend code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95em;
  color: var(--ink);
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
}
.flow-legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
}
.flow-legend-dot--push { background: #1F3A2E; }
.flow-legend-dot--pull { background: #4A6B54; }
.flow-legend-dot--clone { background: #8FB578; }
@media (max-width: 600px) {
  .flow-legend { display: none; }
}

/* Repo screenshot — clickable to enlarge */
.repo-screenshot img {
  cursor: zoom-in;
  transition: filter 0.2s ease, transform 0.2s ease;
}
.repo-screenshot img:hover { filter: brightness(0.98); }

/* Lightbox overlay */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(31, 58, 46, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  /* padding-top 預留：close 按鈕高 36 + top 16 = 底邊 52，再留 8px 給圖片 = 60 */
  padding: 60px 24px 24px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  cursor: zoom-out;
}
.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 84px);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9999px;
  background: rgba(250, 250, 247, 0.95);
  color: #1F3A2E;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.lightbox-close:hover { background: #fff; }
@media (max-width: 600px) {
  /* 行動版：close 32 + top 12 = 底 44，圖片在下方 8px = padding-top 52 */
  .lightbox { padding: 52px 16px 16px; }
  .lightbox img { max-height: calc(100vh - 68px); }
  .lightbox-close { top: 12px; right: 14px; width: 32px; height: 32px; font-size: 18px; }
}

.sep {
  background: var(--ink);
  opacity: 0.25;
  margin: 64px 0;
}

/* 推薦學習資源（最後一個 section） */
.section-resources .footer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.section-resources .footer-list li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  font-size: 1em;
  line-height: 1.8;
}
.section-resources .footer-list li:last-child { margin-bottom: 0; }
.section-resources .footer-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.78em;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--ink);
}
.section-resources .footer-list a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* 頁面結尾的小 footer：裝飾性收尾 */
.page-end {
  margin-top: 96px;
  padding-top: 40px;
  text-align: center;
  color: var(--muted);
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
}
.page-end-mark {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 14px;
  line-height: 1;
}
.page-end p {
  margin: 0;
  font-size: 0.88em;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Links in body/footer */
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { font-style: italic; }

/* Focus states */
a:focus-visible, button:focus-visible, .nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

@media (max-width: 600px) {
  /* 防止任何寬元素把整頁撐橫向捲動 */
  html, body { overflow-x: clip; }
  body { font-size: 18px; }

  .page-wrapper { padding: 56px 20px 80px; }
  .page-wrapper::before { top: 20px; right: 20px; font-size: 1.6rem; }
  .hero h1 { font-size: 2.2rem; line-height: 1.05; }
  .hero-sub { font-size: 1.05rem; }
  .part-divider { padding: 44px 24px; margin: 64px 0 48px; }
  .part-divider h2 { font-size: 1.9rem; }
  .toc { padding: 28px 24px; }

  /* 手機版：hero 與 sticky nav 之間的分隔線拿掉，間距收緊 */
  .hero {
    border-bottom: none;
    padding-bottom: 24px;
    margin-bottom: 24px;
  }

  /* Sticky nav：pills 在窄螢幕橫向滾動，不擠破版面 */
  .sticky-nav {
    margin: 0 -20px 32px;
    padding-left: 20px;
    padding-right: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sticky-nav::-webkit-scrollbar { display: none; }
  .nav-btn { flex-shrink: 0; font-size: 0.82rem; padding: 8px 14px; min-height: 36px; }

  /* Naming table：讓表格自己橫向滾動，不要撐破視窗 */
  .naming-table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
  }
  .naming-table th,
  .naming-table td { padding: 12px 14px; font-size: 0.9rem; }
  .naming-table th { font-size: 0.7rem; padding: 12px 14px; }

  /* 避免左側 floating TOC rail 遮到內容（留安全距離） */
  .floating-toc { left: 6px; }

  /* 手機：顯示 chevron toggle 按鈕 + sub-section 下拉面板 */
  .nav-btn-toggle { display: inline-flex; }
  .nav-chevron { display: inline-block; }

  .sticky-nav-submenu {
    display: block;
    margin: 14px -20px -14px;
    padding: 6px 0;
    border-top: 1px solid var(--ink);
    background: var(--paper);
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: submenu-slide 0.18s ease-out;
  }
  @keyframes submenu-slide {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .submenu-item {
    display: block;
    padding: 12px 24px;
    color: var(--ink);
    text-decoration: none;
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    font-size: 0.92rem;
    line-height: 1.4;
    border-bottom: 1px solid rgba(31, 58, 46, 0.1);
    position: relative;
    padding-left: 40px;
  }
  .submenu-item:last-child { border-bottom: none; }
  .submenu-item::before {
    content: "";
    position: absolute;
    left: 24px;
    top: 50%;
    width: 8px;
    height: 1.5px;
    background: var(--ink);
    opacity: 0.4;
    transform: translateY(-50%);
  }
  .submenu-item:active,
  .submenu-item.is-active { background: var(--aged); }
  .submenu-item.is-active::before { opacity: 1; width: 12px; }
}

/* ============================================================
   Floating TOC (Notion/Substack-style)
   - Rail: always-visible evenly spaced dashes on the left
   - Panel: full-height menu card that appears on hover
   ============================================================ */
.floating-toc {
  position: fixed;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
}

/* Rail — always-visible dash column */
.floating-toc-rail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
}
.floating-toc-dash {
  display: block;
  width: 12px;
  height: 1.5px;
  background: var(--ink);
  opacity: 0.3;
  border-radius: 1px;
  transition: opacity 0.2s ease-out;
}
/* Part 大標的 dash 略長，僅以長度建立階層；顏色與 Section 一致 */
.floating-toc-dash.is-part {
  width: 18px;
  height: 2px;
}
/* Active / hover 只變色（不變長度） */
.floating-toc-dash.is-active,
.floating-toc-dash:hover { opacity: 1; }

/* Panel — hidden by default, fades in on .floating-toc hover.
   不做 translateX 滑入：hover 觸發後若 panel 從左滑進來，
   游標可能短暫落在 panel 即將到達的位置上，造成 hover 失準、選單來回開合震盪。*/
.floating-toc-panel {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 280px;
  max-width: 340px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
  scrollbar-width: thin;
}
/* 透明 hover bridge — 補上 rail 與 panel 之間的縫隙，
   滑鼠橫跨時不會誤觸發 mouseleave 而把選單關掉 */
.floating-toc-panel::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  left: -48px;
  width: 48px;
  pointer-events: auto;
}
.floating-toc:hover .floating-toc-panel,
.floating-toc:focus-within .floating-toc-panel,
.floating-toc.is-open .floating-toc-panel {
  opacity: 1;
  pointer-events: auto;
}

.floating-toc-panel-title {
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.floating-toc-panel-item {
  display: block;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 8px 6px 14px;
  margin: 1px 0;
  border-radius: 4px;
  position: relative;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}
.floating-toc-panel-item:hover {
  background: var(--accent-light);
  color: var(--ink);
}

/* Part — thick left bar indicator, strong ink color */
.floating-toc-panel-item.is-part {
  font-weight: 600;
  color: var(--ink);
  margin-top: 10px;
  padding-left: 14px;
}
.floating-toc-panel-item.is-part:first-of-type { margin-top: 0; }
.floating-toc-panel-item.is-part::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--ink);
  border-radius: 1px;
}

/* Active item — darker color, subtle highlighted bg */
.floating-toc-panel-item.is-active {
  color: var(--ink);
  font-weight: 600;
  background: var(--accent-light);
}
.floating-toc-panel-item.is-active::before {
  background: var(--accent);
}

@media (max-width: 900px) {
  .floating-toc { display: none; }
}
