/* ============================================================
   知識庫 · Production stylesheet
   Cloudflare Pages / GitHub static — no build step needed.
   ============================================================ */

:root {
  /* Tokens (warm B palette) */
  --bg:        #FAF9F5;
  --bg-soft:   #F2EFE5;
  --fg:        #29261b;
  --fg-soft:   #4a4536;
  --muted:     #8a8474;
  --rule:      #D1CFC5;
  --rule-soft: #E2DFD3;
  --accent:    #D97757;     /* clay */
  --accent-2:  #788C5D;     /* olive */
  --rust:      #B04A3F;
  --tag-bg:    #F2EFE5;
  --tag-fg:    #5a553f;
  --tag-rule:  #D1CFC5;
  --panel-bg:  #FFFEFA;
  --panel-rule:#D1CFC5;

  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --rule-w:    1.5px;

  --font-sans: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Apple Garamond", Baskerville, Georgia, "Times New Roman", "Source Han Serif TC", "Noto Serif TC", serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --ui-font-size: 15px;
  --ui-line-height: 1.72;
}

html.dark {
  --bg:        #1a1814;
  --bg-soft:   #211e18;
  --fg:        #f3efe2;
  --fg-soft:   #c4bfac;
  --muted:     #8b8573;
  --rule:      #34302a;
  --rule-soft: #28251f;
  --accent:    #E89172;
  --accent-2:  #93AB73;
  --tag-bg:    #211e18;
  --tag-fg:    #c4bfac;
  --tag-rule:  #34302a;
  --panel-bg:  #1f1c17;
  --panel-rule:#34302a;
}

/* ─── Reset & base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--ui-font-size);
  line-height: var(--ui-line-height);
  font-feature-settings: "kern" 1, "palt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .2s, color .2s;
}

h1, h2, h3, h4 {
  color: var(--fg);
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0;
  font-weight: 600;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .12s, color .12s;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

button { font: inherit; }

/* ─── Page chrome ────────────────────────────────────────── */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 56px;
}
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 32px 0 24px;
  border-bottom: var(--rule-w) solid var(--rule);
}
.site-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  text-decoration: none;
}
.site-brand .dot {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent); display: inline-block;
  transform: translateY(3px);
}
.site-brand .name { font-weight: 600; font-size: 1.05em; }
.site-brand .name-en {
  color: var(--muted); font-size: 0.92em;
  font-family: var(--font-serif); font-style: italic;
}
.site-nav { display: flex; gap: 22px; font-size: 0.88em; color: var(--fg-soft); align-items: center; }
.site-nav a { text-decoration: none; }
.site-nav button {
  background: transparent; border: 1px solid var(--rule);
  width: 30px; height: 30px; border-radius: 6px;
  color: var(--fg-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .12s, color .12s;
}
.site-nav button:hover { border-color: var(--fg); color: var(--fg); }

.site-footer {
  padding: 40px 0 48px;
  margin-top: 64px;
  border-top: var(--rule-w) solid var(--rule-soft);
  color: var(--muted);
  font-size: 0.82em;
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ─── Utility ────────────────────────────────────────────── */
.num {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.86em;
  letter-spacing: 0.01em;
}
.title-serif { font-family: var(--font-serif); font-style: italic; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.78em;
  color: var(--tag-fg);
  background: var(--tag-bg);
  border: 1px solid var(--tag-rule);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
}

.crumbs {
  font-size: 0.86em;
  color: var(--muted);
  display: flex; gap: 8px; align-items: center;
  flex-wrap: wrap;
  margin-top: 24px;
}
.crumbs .sep { opacity: 0.55; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--fg); }

.panel {
  background: var(--panel-bg);
  border: var(--rule-w) solid var(--panel-rule);
  border-radius: var(--radius-lg);
}

.section-label {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.section-label .num-tag {
  font-family: var(--font-mono); font-size: 0.72em;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.section-label h2 {
  font-size: 0.95em; font-weight: 600; margin: 0;
  display: inline; margin-left: 10px;
}
.section-label .hint {
  font-family: var(--font-mono); font-size: 0.74em;
  color: var(--muted); letter-spacing: 0.04em;
}

/* ─── Index page ────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 48px;
  margin: 36px 0 28px;
  align-items: end;
}
.hero h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 2.2em;
  font-weight: 400;
  line-height: 1.2;
  margin: 10px 0 14px;
}
.hero p { color: var(--fg-soft); max-width: 52ch; margin: 0; }
.stats {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--fg-soft);
}
.stats .row { display: flex; justify-content: space-between; line-height: 1.9; }
.stats .row .k { color: var(--muted); }
.stats .row.accent .v { color: var(--accent); }

.search {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  margin-bottom: 26px;
}
.search input {
  flex: 1; border: none; outline: none; background: transparent;
  color: var(--fg); font: inherit; font-size: 0.95em;
}
.search .kbd {
  font-family: var(--font-mono);
  font-size: 0.72em;
  padding: 2px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--muted);
}
.search svg { color: var(--muted); }

.tag-cloud {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline;
  margin-bottom: 32px;
}
.tag-cloud .tag {
  font-family: var(--font-mono);
  color: var(--fg-soft);
  background: transparent;
  border: 1px solid var(--rule-soft);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all .15s;
}
.tag-cloud .tag .count {
  font-size: 0.7em; margin-left: 4px; color: var(--muted); vertical-align: 1px;
}
.tag-cloud .tag:hover { border-color: var(--accent); color: var(--accent); }
.tag-cloud .tag.active {
  background: var(--accent); color: var(--bg); border-color: var(--accent);
}
.tag-cloud .tag.active .count { color: rgba(255,255,255,0.7); }

.index-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  align-items: start;
}

.cat-card { padding: 18px 20px 14px; }
.cat-card header { margin-bottom: 8px; }
.cat-card .h-row { display: flex; gap: 12px; align-items: baseline; }
.cat-card h3 { font-size: 1.15em; font-weight: 600; color: var(--accent); }
.cat-card .blurb { color: var(--fg-soft); font-size: 0.9em; margin: 6px 0 0; max-width: 60ch; }
.cat-card ul { list-style: none; padding: 0; margin: 10px 0 0; border-top: 1px solid var(--rule-soft); }
.cat-card li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.95em; align-items: baseline;
}
.cat-card li a { text-decoration: none; }
.cat-card li .count { font-family: var(--font-mono); font-size: 0.78em; color: var(--muted); white-space: nowrap; }
.cat-card footer {
  margin-top: 10px;
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.74em; color: var(--muted);
}
.cat-card footer a { text-decoration: none; color: var(--accent); }
.cat-card mark {
  background: rgba(217,119,87,0.18); color: var(--fg);
  padding: 0 2px; border-radius: 3px;
}
.cat-card.hidden { display: none; }
.cat-card li.hidden { display: none; }

.timeline {
  list-style: none; padding: 0; margin: 0;
  border-left: 1.5px solid var(--rule);
  margin-left: 6px;
}
.timeline li { position: relative; padding-left: 18px; padding-bottom: 16px; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rule);
  border: 1.5px solid var(--bg); box-sizing: content-box;
}
.timeline li.recent::before { background: var(--accent); }
.timeline .meta {
  font-family: var(--font-mono); font-size: 0.72em;
  color: var(--muted); letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.timeline .meta .sep { color: var(--accent-2); margin: 0 4px; }
.timeline a {
  font-size: 0.94em; text-decoration: none;
  color: var(--fg); line-height: 1.45;
}

.empty {
  padding: 20px 24px;
  border: 1.5px dashed var(--rule);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.92em;
  text-align: center;
  display: none;
}
.empty.show { display: block; }
.empty code { color: var(--accent); font-family: var(--font-mono); background: transparent; }

/* ─── Series page ───────────────────────────────────────── */
.series-head {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 36px;
  align-items: end;
  padding: 28px 0 24px;
  border-bottom: var(--rule-w) solid var(--rule);
  margin-bottom: 28px;
}
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--rule-soft);
  font-family: var(--font-mono);
  font-size: 0.76em;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.kicker .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); display: inline-block;
}
.series-head h1 {
  font-family: var(--font-serif); font-style: italic;
  font-size: 2.4em; font-weight: 400; line-height: 1.15;
  margin: 14px 0 12px;
}
.series-head p { color: var(--fg-soft); max-width: 56ch; margin: 0; }
.series-stats { padding: 16px 18px; font-family: var(--font-mono); font-size: 0.8em; color: var(--fg-soft); }
.series-stats .progress {
  display: flex; gap: 4px; margin-bottom: 12px;
}
.series-stats .progress > div {
  height: 6px; flex: 1; background: var(--rule); border-radius: 2px;
}
.series-stats .progress > div.done { background: var(--accent); }
.series-stats .row { display: flex; justify-content: space-between; line-height: 1.9; }
.series-stats .row .k { color: var(--muted); }
.series-stats .row.accent .v { color: var(--accent); }

.article-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.article-list li {
  padding: 16px 22px;
  display: grid;
  grid-template-columns: 40px 1fr 130px;
  gap: 18px;
  align-items: center;
}
.article-list .badge {
  font-family: var(--font-mono);
  font-size: 1.4em;
  color: var(--muted);
  font-weight: 500;
  text-align: center;
}
.article-list li.read .badge { color: var(--accent-2); }
.article-list h3 { font-size: 1.04em; font-weight: 600; margin-bottom: 4px; }
.article-list h3 a { text-decoration: none; }
.article-list .summary { color: var(--fg-soft); font-size: 0.92em; margin: 2px 0 8px; max-width: 60ch; }
.article-list .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.article-list .meta {
  font-family: var(--font-mono); font-size: 0.74em; color: var(--muted);
  text-align: right; line-height: 1.8;
}

/* ─── Article page ──────────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 30;
  background: transparent;
  pointer-events: none;
}
.reading-progress > div {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .08s linear;
}

.article-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 48px;
  padding: 32px 0 0;
}
.article-aside {
  position: sticky; top: 24px; align-self: start;
  max-height: calc(100vh - 48px); overflow: auto;
}
.aside-card {
  padding: 14px 16px;
  background: var(--panel-bg);
  border: var(--rule-w) solid var(--panel-rule);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
}
.aside-card .label {
  font-family: var(--font-mono);
  font-size: 0.7em; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent-2);
  margin-bottom: 6px;
}
.aside-card .series-title { font-weight: 600; font-size: 0.95em; margin-bottom: 4px; }
.aside-card .series-title a { text-decoration: none; }
.aside-card .series-pos { font-size: 0.82em; color: var(--muted); }
.aside-card .series-pips { margin-top: 10px; display: flex; gap: 3px; }
.aside-card .series-pips > div {
  height: 4px; flex: 1; background: var(--rule); border-radius: 2px;
}
.aside-card .series-pips > div.cur { background: var(--accent); }

.toc { font-size: 0.85em; line-height: 1.55; }
.toc-title {
  font-family: var(--font-mono);
  font-size: 0.72em;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { padding: 3px 0; }
.toc li.h3 { padding-left: 14px; }
.toc a {
  color: var(--fg-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 8px;
  margin-left: -10px;
  display: block;
  transition: color .12s, border-color .12s;
}
.toc a.active {
  color: var(--fg);
  border-left-color: var(--accent);
}
.toc a:hover { color: var(--fg); }

.footnotes-index {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.78em;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  line-height: 1.8;
}

.article-main { max-width: 680px; }
.article-header { margin: 24px 0 32px; }
.article-header h1 {
  font-family: var(--font-serif); font-style: italic;
  font-size: 2.4em; font-weight: 400; line-height: 1.15;
  margin: 12px 0 12px;
}
.article-header .subtitle {
  color: var(--fg-soft); font-size: 1.08em;
  max-width: 52ch; margin: 0 0 18px; line-height: 1.55;
}
.article-header .meta {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-mono); font-size: 0.78em; color: var(--muted);
  flex-wrap: wrap;
}
.article-header .meta .spacer { flex: 1; }
.article-header .meta .tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* Prose typography */
.prose { color: var(--fg); }
.prose p { margin: 0.7em 0; }
.prose ul, .prose ol { margin: 0.7em 0; padding-left: 1.4em; }
.prose li { margin: 0.25em 0; }
.prose h2 {
  font-size: 1.28em;
  margin-top: 2em; margin-bottom: 0.6em;
  scroll-margin-top: 24px;
  position: relative;
}
.prose h2::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent); border-radius: 50%;
  margin-right: 10px; vertical-align: middle;
  transform: translateY(-3px);
}
.prose h3 {
  font-size: 1.06em; color: var(--fg-soft);
  margin-top: 1.5em; margin-bottom: 0.4em;
  scroll-margin-top: 24px;
  position: relative;
}
.prose code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--bg-soft); padding: 1px 5px;
  border-radius: 3px; border: 1px solid var(--rule-soft);
  color: var(--accent);
}
.prose blockquote {
  border-left: 2px solid var(--accent);
  margin: 1em 0; padding: 0.2em 0 0.2em 1em;
  color: var(--fg-soft); font-style: italic;
}

/* Heading § copy-link button */
.heading-anchor-btn {
  margin-left: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7em;
  cursor: pointer;
  vertical-align: middle;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s, color .15s, background .12s;
}
.prose h2:hover .heading-anchor-btn,
.prose h3:hover .heading-anchor-btn { opacity: 1; }
.heading-anchor-btn:hover { background: var(--bg-soft); color: var(--fg); }
.heading-anchor-btn.copied { opacity: 1; color: var(--accent-2); }

/* Inline footnote */
.fn { position: relative; display: inline; }
.fn .fn-text {
  background: rgba(217,119,87,0.10);
  border-bottom: 1px dashed var(--accent);
  padding: 0 1px;
}
.fn .fn-marker {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--accent);
  border: 1px solid var(--rule-soft);
  font-family: var(--font-mono);
  font-size: 0.66em;
  padding: 0 5px;
  border-radius: 999px;
  margin-left: 2px;
  vertical-align: 2px;
  line-height: 1.6;
  cursor: pointer;
  font-weight: 600;
  transition: all .12s;
}
.fn.open .fn-marker { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.fn .fn-popover {
  position: absolute;
  top: 1.7em; left: 0;
  z-index: 10;
  width: 280px;
  background: var(--panel-bg);
  border: var(--rule-w) solid var(--accent);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(20,20,19,0.10), 0 2px 6px rgba(20,20,19,0.06);
  font-size: 0.88em;
  font-style: normal;
  line-height: 1.55;
  color: var(--fg-soft);
  font-family: var(--font-sans);
  text-align: left;
  display: none;
}
.fn.open .fn-popover { display: block; }
.fn-popover .label {
  font-family: var(--font-mono); font-size: 0.78em;
  color: var(--accent); letter-spacing: 0.04em;
  display: block; margin-bottom: 4px;
}

/* Callouts */
.callout {
  border: var(--rule-w) solid var(--rule);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 1em 0;
  background: var(--panel-bg);
}
.callout > summary {
  cursor: pointer; list-style: none;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.callout > summary::-webkit-details-marker { display: none; }
.callout > summary::before {
  content: "▸";
  font-size: 0.8em;
  color: var(--muted);
  transition: transform 0.15s;
  display: inline-block;
}
.callout[open] > summary::before { transform: rotate(90deg); }
.callout-body { margin-top: 0.6em; color: var(--fg-soft); }

/* Dark code block */
.code-block { margin: 1.2em 0; }
.code-block .code-head {
  background: #1a1814;
  color: #c4bfac;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 0.78em;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  border-bottom: 1px solid #2c2a23;
  display: flex; justify-content: space-between; align-items: center;
  letter-spacing: 0.03em;
}
.code-block .code-head .lang { color: #7e7969; }
.code-block pre {
  margin: 0;
  background: #1a1814;
  color: #ece9df;
  padding: 14px 16px;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.85em;
  line-height: 1.65;
  overflow: auto;
}
.code-block pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-family: inherit;
}
.code-block.no-head pre { border-radius: var(--radius-md); }

/* Hello handshake diagram */
.handshake {
  border: var(--rule-w) solid var(--rule);
  border-radius: var(--radius-md);
  padding: 20px 22px 16px;
  background: var(--panel-bg);
  margin: 1.4em 0;
}
.handshake .routers {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.router-node {
  border: var(--rule-w) solid var(--rule);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: center;
  transition: all .25s;
}
.router-node.active {
  border-color: var(--accent);
  background: rgba(217,119,87,0.06);
}
.router-node .role {
  font-family: var(--font-mono); font-size: 0.72em;
  color: var(--muted); letter-spacing: 0.06em;
  text-transform: uppercase;
}
.router-node .name {
  font-size: 1.6em; font-weight: 500;
  line-height: 1.1; margin: 2px 0;
}
.router-node.active .name { color: var(--accent); }
.router-node .rid { font-family: var(--font-mono); font-size: 0.7em; color: var(--muted); }

.handshake .lane { position: relative; height: 60px; }
.handshake .lane .line {
  position: absolute; top: 18px; left: 8px; right: 8px;
  height: 1px; background: var(--rule);
}
.handshake .lane .dot {
  position: absolute; top: 14px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  transition: all .4s;
  box-shadow: 0 0 0 4px rgba(217,119,87,0.15);
}
.handshake .lane .label {
  position: absolute; top: 28px; left: 0; right: 0;
  text-align: center;
  font-family: var(--font-mono); font-size: 0.74em;
  color: var(--accent); letter-spacing: 0.04em;
}

.handshake .detail {
  font-size: 0.9em; color: var(--fg-soft);
  margin: 0 0 14px; min-height: 2.6em;
}
.handshake .detail .step-tag {
  color: var(--muted); font-family: var(--font-mono); margin-right: 8px;
}
.handshake .controls {
  display: flex; gap: 6px;
  align-items: center; justify-content: space-between;
  border-top: 1px solid var(--rule-soft);
  padding-top: 12px;
}
.handshake .controls button {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg-soft);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono); font-size: 0.74em;
  transition: border-color .12s, color .12s;
}
.handshake .controls button:hover { border-color: var(--fg); color: var(--fg); }
.handshake .controls button:disabled { opacity: 0.45; cursor: default; }
.handshake .pips { display: flex; gap: 5px; }
.handshake .pips button {
  width: 8px; height: 8px; padding: 0;
  border-radius: 50%; border: none;
  background: var(--rule); cursor: pointer;
  transition: background .15s;
}
.handshake .pips button.active { background: var(--accent); }
.handshake figcaption {
  margin-top: 12px;
  font-family: var(--font-mono); font-size: 0.72em;
  color: var(--muted); letter-spacing: 0.04em;
  text-align: center;
}

/* Prev/Next nav */
.prev-next {
  margin-top: 56px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.prev-next .nav-card {
  padding: 14px 18px;
  border: var(--rule-w) solid var(--panel-rule);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  text-decoration: none;
  display: block;
}
.prev-next .nav-card.disabled { opacity: 0.5; pointer-events: none; }
.prev-next .nav-card .nav-label {
  font-family: var(--font-mono); font-size: 0.72em;
  letter-spacing: 0.06em; color: var(--accent-2);
}
.prev-next .nav-card.next { text-align: right; }
.prev-next .nav-card.next .nav-label { color: var(--accent); }
.prev-next .nav-card .nav-title {
  margin-top: 4px; font-size: 0.96em; font-weight: 500;
}
.prev-next .nav-card.disabled .nav-title {
  color: var(--muted); font-weight: 400;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .page { padding: 0 24px; }
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .index-grid { grid-template-columns: 1fr; }
  .series-head { grid-template-columns: 1fr; gap: 16px; }
  .article-layout { grid-template-columns: 1fr; gap: 24px; }
  .article-aside { position: static; max-height: none; }
  .article-list li { grid-template-columns: 32px 1fr; }
  .article-list .meta { grid-column: 1 / -1; text-align: left; }
  .handshake .routers { grid-template-columns: 1fr; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next .nav-card.next { text-align: left; }
}

/* Mermaid diagrams */
pre.mermaid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  border: none;
  padding: 0;
  margin: 1.5rem 0;
}
pre.mermaid svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Scrollbar polish */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ─── Lightbox ───────────────────────────────────────────── */
.prose img { cursor: zoom-in; }

#lightbox-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.82);
  align-items: center; justify-content: center;
  cursor: zoom-out;
  animation: lb-fade-in .15s ease;
}
#lightbox-overlay.open { display: flex; }
#lightbox-overlay img {
  max-width: min(90vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 48px rgba(0,0,0,.5);
  cursor: default;
  animation: lb-scale-in .15s ease;
}
#lightbox-overlay .lb-close {
  position: fixed; top: 16px; right: 20px;
  background: none; border: none;
  color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; opacity: .7; padding: 4px 8px;
}
#lightbox-overlay .lb-close:hover { opacity: 1; }
@keyframes lb-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes lb-scale-in { from { transform: scale(.93); } to { transform: scale(1); } }
