/* ─── claude-hunt 디자인 차용 ─── */

/* Theme Variables (Light) */
:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-card: #ffffff;
  --bg-elevated: #f5f5f5;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #0a0a0a;
  --text-muted: #525252;
  --text-subtle: #a1a1aa;
  --primary: #171717;
  --primary-soft: #f5f5f5;
  --primary-hover: #404040;
  --accent: #f5f5f5;
  --accent-fg: #171717;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --tip: #16a34a;
  --tip-soft: #dcfce7;
  --abstract: #7c3aed;
  --abstract-soft: #ede9fe;
  --example: #db2777;
  --example-soft: #fce7f3;
  --code-bg: #f5f5f5;
  --code-text: #18181b;
  --max-w: 1440px;
  --content-w: 720px;
  --sidebar-w: 220px;
  --toc-w: 130px;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --rail: #f4f4f5;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-soft: #141414;
  --bg-card: #171717;
  --bg-elevated: #262626;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --primary: #fafafa;
  --primary-soft: #262626;
  --primary-hover: #e5e5e5;
  --accent: #262626;
  --accent-fg: #fafafa;
  --code-bg: #1c1c1c;
  --code-text: #fafafa;
  --rail: #111111;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
}

/* ─── Top Nav ─── */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .nav { background: rgba(10, 10, 10, 0.8); }

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 24px;
}

.nav-brand {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-brand span {
  color: var(--text-muted);
  font-weight: 400;
}

.nav-links { display: flex; gap: 24px; }

.nav-links a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}

.nav-links a:hover { color: var(--text); }

.nav-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.theme-toggle svg { width: 18px; height: 18px; }

[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon { display: none; }

/* ─── Page Layout ─── */
.page {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 900px) var(--toc-w);
  gap: 24px;
  max-width: var(--max-w);
  margin: 0 auto 0 0;
  padding: 0 24px 48px 16px;
}

/* Full-height gray rail for sidebar column — extends to viewport left */
.page::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(var(--sidebar-w) + 16px);
  background: var(--rail);
  border-right: 1px solid var(--border);
  box-shadow: -2000px 0 0 var(--rail);
  z-index: 0;
  pointer-events: none;
}

/* ─── Sidebar (Left) ─── */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 16px 12px 8px;
  z-index: 1;
}

.sidebar-section {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-footer {
  position: fixed;
  bottom: 20px;
  left: 32px;
  margin: 0;
  padding: 0;
  border-top: none;
  display: flex;
  align-items: center;
  z-index: 2;
}

.sidebar-home {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.sidebar-home:hover { color: var(--text-muted); }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sidebar-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}
.sidebar-back svg { width: 15px; height: 15px; }
.sidebar-back:hover { color: var(--text); }

.sidebar-brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.sidebar-brand:hover { color: var(--text-muted); }

.sidebar-toggle, .sidebar-reopen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-toggle:hover, .sidebar-reopen:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar-toggle svg, .sidebar-reopen svg { width: 17px; height: 17px; }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-subtle);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.sidebar-search:hover { border-color: var(--border-strong); color: var(--text-muted); }
.sidebar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-search span { flex: 1; text-align: left; }
.sidebar-search kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-subtle);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Collapsed sidebar state — floating toolbar (reopen + search) */
.sidebar-float {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 40;
  display: none;
  gap: 6px;
}
.sidebar-float .float-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.sidebar-float .float-btn:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar-float .float-btn svg { width: 17px; height: 17px; }

/* Keep the sidebar column reserved (empty) so content does not shift */
.page.sidebar-collapsed > .sidebar { visibility: hidden; }
.page.sidebar-collapsed::before { display: none; }
.page.sidebar-collapsed > .sidebar-float { display: flex; }

.sidebar-group {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  line-height: 1.4;
}

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-list a {
  display: block;
  padding: 7px 12px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 1px;
  line-height: 1.5;
  transition: background 0.15s, color 0.15s;
}

.sidebar-list a:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.sidebar-list a.active {
  color: var(--text);
  font-weight: 500;
  background: var(--accent);
}

.sidebar-section-label {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-muted);
  margin: 20px 8px 6px;
}

.sidebar-section-label:first-of-type {
  margin-top: 4px;
}

/* ─── Sidebar accordion (multi-series) ─── */
.sidebar-acc {
  margin-bottom: 4px;
}

.acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  padding: 7px 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.acc-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.sidebar-acc.external .acc-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 500;
}

.acc-ext-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-subtle);
}

.sidebar-list .ext-note {
  font-size: 11.5px;
  color: var(--text-subtle);
  padding: 2px 12px 6px;
  line-height: 1.4;
}

.sidebar-list a.ext-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ext-arrow {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.6;
}

.grp-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.sidebar-acc[data-state="closed"] .grp-chevron {
  transform: rotate(-90deg);
}

.sidebar-acc[data-state="closed"] > .sidebar-list {
  display: none;
}

.sidebar-acc > .sidebar-list {
  padding-left: 2px;
  margin-top: 2px;
}

.sidebar-acc.disabled .acc-head {
  cursor: default;
}

.sidebar-acc.disabled .acc-title {
  color: var(--text-muted);
}

.acc-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  flex-shrink: 0;
}

/* ─── Content (Main) ─── */
.content {
  min-width: 0;
  padding: 48px 40px 0;
}

.breadcrumb {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--text); }

.breadcrumb .sep { margin: 0 8px; color: var(--text-subtle); }

.breadcrumb .current {
  color: var(--text);
  font-weight: 500;
}

.content .page-eyebrow {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.content h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 12px;
  color: var(--text);
}

.content .page-subtitle {
  font-size: 18px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 0;
  max-width: none;
  font-weight: 400;
}

.content .page-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0 32px;
}

.content h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.333;
  margin: 32px 0 16px;
  color: var(--text);
}

.content h3 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.6;
  margin: 26px 0 10px;
  color: var(--text);
}

.content h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

.content p {
  margin: 0 0 16px;
  line-height: 1.75;
  color: var(--text);
  font-size: 16px;
}

.content ul, .content ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.content li {
  margin-bottom: 6px;
  line-height: 1.75;
  font-size: 16px;
}

.content li > strong:first-child { color: var(--text); }

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.content strong { color: var(--text); font-weight: 600; }
.content em { font-style: italic; color: var(--text); }

.content a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text-subtle);
  text-underline-offset: 3px;
}

.content a:hover { text-decoration-color: var(--text); }

.content a.wikilink {
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  border: 1px solid var(--border);
  font-size: 0.95em;
}

.content a.wikilink:hover {
  background: var(--accent);
  border-color: var(--border-strong);
}

.content figure { margin: 24px 0; }

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

.content code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  border: 1px solid var(--border);
}

.content pre.code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--border);
}

.content pre.code code {
  background: none;
  padding: 0;
  border: none;
  font-size: 13px;
  line-height: 1.65;
}

.content blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-muted);
}

.content blockquote p { margin: 0 0 8px; }

/* Tables */
.table-wrap { margin: 16px 0 24px; overflow-x: auto; }

.content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

.content th, .content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  line-height: 1.6;
}

.content th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text);
}

/* Callouts */
.callout {
  margin: 20px 0;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.callout-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}

.callout-body { font-size: 14px; color: var(--text-muted); }
.callout-body p { margin: 0 0 8px; color: var(--text-muted); line-height: 1.6; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-body strong { color: var(--text); }
.callout-body ul, .callout-body ol { margin: 4px 0 0; padding-left: 20px; }
.callout-body li { font-size: 14px; line-height: 1.6; }

.callout-info { border-left: 3px solid var(--info); }
.callout-info .callout-title { color: var(--info); }

.callout-tip { border-left: 3px solid var(--tip); }
.callout-tip .callout-title { color: var(--tip); }

.callout-warning { border-left: 3px solid var(--warning); }
.callout-warning .callout-title { color: var(--warning); }

.callout-success { border-left: 3px solid var(--success); }
.callout-success .callout-title { color: var(--success); }

.callout-abstract { border-left: 3px solid var(--abstract); }
.callout-abstract .callout-title { color: var(--abstract); }

.callout-example { border-left: 3px solid var(--example); }
.callout-example .callout-title { color: var(--example); }

/* Pagination */
.pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pag-link {
  display: block;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s, background 0.15s;
}

.pag-link:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.pag-link.disabled { opacity: 0.4; cursor: default; }
.pag-link.next { text-align: right; }

.pag-label { font-size: 12px; color: var(--text-subtle); margin-bottom: 4px; }
.pag-title { font-size: 14px; font-weight: 500; color: var(--text); }

/* TOC (Right) */
.toc {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding-top: 48px;
  font-size: 13px;
}

.toc-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 12px;
}

.toc ul { list-style: none; padding: 0; margin: 0; }

.toc li { margin: 0; }

.toc a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.55;
  border-left: 1px solid var(--border);
  margin-left: 0;
  transition: color 0.15s, border-color 0.15s;
}

.toc a:hover { color: var(--text); border-left-color: var(--text-muted); }

.toc li.lvl-3 a { padding-left: 24px; font-size: 12px; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-subtle);
}

/* Landing (index) */
.hero {
  padding: 80px 0 64px;
}

.hero-tag {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 16px;
}

.hero-tag .dot { margin: 0 8px; }

.hero-title {
  font-size: clamp(40px, 7vw, 84px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.04;
  margin: 0 0 24px;
  color: var(--text);
  max-width: 920px;
}

.hero-title em { font-style: normal; color: var(--text); }

.hero-subtitle {
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 0 0 24px;
  max-width: 720px;
}

.hero-desc {
  font-size: 18px;
  line-height: 1.625;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 0 16px;
}

.hero-cta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-meta { font-size: 13px; color: var(--text-subtle); }

.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }

.section { padding: 48px 0 96px; border-top: 1px solid var(--border); }

.section-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 16px;
}

.section-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
  max-width: 760px;
  color: var(--text);
}

.section-desc {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-muted);
  margin: 0 0 56px;
  max-width: 640px;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.part-card {
  display: block;
  padding: 28px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.part-card:hover:not(.disabled) {
  border-color: var(--text-muted);
  background: var(--bg-soft);
}

.part-card.disabled {
  opacity: 0.55;
  cursor: default;
}

.part-card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.part-card-num {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.part-card-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.part-card-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 0 0 12px;
  color: var(--text);
}

.part-card-desc {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  margin: 0;
}

.part-card-badge {
  display: inline-block;
  margin-top: 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
}

@media (max-width: 960px) {
  .parts-grid { grid-template-columns: 1fr; }
}

.series {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.series-number {
  font-family: ui-monospace, monospace;
  font-size: 14px;
  color: var(--text-subtle);
}

.series-number .num {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.series-content { min-width: 0; }

.series-tag {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 8px;
}

.series-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--text);
}

.series-desc {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
  margin: 0 0 24px;
  max-width: 640px;
}

.series-overview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 24px;
  font-weight: 500;
}

.series-overview::after { content: '→'; }
.series-overview:hover { text-decoration: underline; }

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

.chapter-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.chapter-row:hover {
  background: var(--bg-soft);
  border-color: var(--border);
}

.chapter-num {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-subtle);
}

.chapter-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.chapter-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.chapter-row .arrow {
  font-size: 14px;
  color: var(--text-subtle);
}

.coming {
  padding: 32px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  margin-top: 16px;
}

.coming-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 12px;
}

.coming-text {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 24px;
}

.coming-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.coming-item {
  padding: 16px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  text-align: left;
}

.coming-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.coming-item-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 1100px) {
  .page {
    grid-template-columns: 220px 1fr;
    gap: 24px;
  }
  .page::before { width: calc(220px + 16px); }
  .toc { display: none; }
}

@media (max-width: 768px) {
  .page {
    grid-template-columns: 1fr;
    padding: 24px 16px 64px;
  }
  .page::before { display: none; }
  .sidebar { display: none; }
  .nav-links { display: none; }
}

/* ─── Search trigger (nav) ─────────────────────── */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 14px; min-width: 240px;
  border: 1px solid var(--border); background: var(--bg-card);
  border-radius: var(--radius-md, 8px); cursor: pointer;
  color: var(--text-muted); font-size: 13px; transition: border-color .15s, color .15s;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger svg { width: 15px; height: 15px; }
.search-trigger-text { font-weight: 500; }
.search-trigger-kbd {
  margin-left: auto;
  font-family: inherit; font-size: 11px; line-height: 1;
  padding: 3px 5px; border: 1px solid var(--border-strong);
  border-radius: 5px; color: var(--text-subtle); background: var(--bg-soft);
}

/* ─── Search overlay / modal ───────────────────── */
.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
}
.search-overlay[hidden] { display: none; }
[data-theme="dark"] .search-overlay { background: rgba(0,0,0,0.6); }
.search-box {
  width: 100%; max-width: 580px;
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius, 12px); overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.24);
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 14px; border-bottom: 1px solid var(--border);
}
svg.search-input-icon, .search-input-icon { width: 18px; height: 18px; flex: none; color: var(--text-subtle); }
.search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text); font-family: inherit;
}
.search-input::placeholder { color: var(--text-subtle); }
.search-esc {
  font-family: inherit; font-size: 11px; line-height: 1;
  padding: 3px 6px; border: 1px solid var(--border-strong);
  border-radius: 5px; color: var(--text-subtle);
}
.search-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-md, 8px);
  text-decoration: none; color: var(--text);
}
.search-result.active, .search-result:hover { background: var(--accent, var(--bg-soft)); }
.search-result-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-soft); color: var(--text-muted);
}
.search-result-icon svg { width: 16px; height: 16px; }
.search-result-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.search-result-title {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result-meta { font-size: 12px; color: var(--text-subtle); }
.search-result mark { background: transparent; color: var(--primary); font-weight: 700; }
.search-empty {
  padding: 32px 16px; text-align: center;
  font-size: 13px; color: var(--text-subtle);
}
@media (max-width: 768px) {
  .search-trigger-text, .search-trigger-kbd { display: none; }
  .search-trigger { padding: 0 9px; }
}

/* ─── Diagrams (inline SVG) ─── */
.diagram {
  margin: 36px 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  /* content is centered per-diagram via viewBox x-offset (≈28px internal side margin),
     so sides use a small CSS pad. Top/bottom use a larger CSS pad to reach a
     comfortable, roughly-even breathing room around the whole content block. */
  padding: 24px 8px 28px;
}
.diagram svg {
  width: 100%; height: auto; display: block;
  font-family: inherit;
  padding: 0;
}
.diagram figcaption {
  margin-top: 12px; text-align: center;
  font-size: 13.5px; line-height: 1.5; color: var(--text-muted);
}
.diagram figcaption strong { color: var(--text); font-weight: 700; }
/* boxes */
.dgm-box { fill: var(--bg-card); stroke: var(--border-strong); stroke-width: 1.5; }
.dgm-box-soft { fill: var(--bg-elevated); stroke: var(--border); stroke-width: 1.5; }
.dgm-box-dashed { fill: none; stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 7 6; }
.dgm-box-accent { fill: var(--info-soft); stroke: var(--info); stroke-width: 1.5; }
.dgm-box-green { fill: var(--success-soft); stroke: var(--success); stroke-width: 1.5; }
.dgm-panel { fill: var(--bg); stroke: var(--border); stroke-width: 1.5; }
.dgm-pill { fill: var(--bg-card); stroke: var(--border-strong); stroke-width: 1.5; }
.dgm-note { fill: var(--bg-card); stroke: var(--border); stroke-width: 1.2; }
.dgm-note-on { fill: var(--info-soft); stroke: var(--info); stroke-width: 1.5; }
/* text */
.dgm-text { fill: var(--text); font-size: 15px; font-weight: 500; }
.dgm-title { fill: var(--text); font-size: 14.5px; font-weight: 600; }
.dgm-sub { fill: var(--text-muted); font-size: 12.5px; font-weight: 400; }
.dgm-label { fill: var(--text-subtle); font-size: 12.5px; font-weight: 500; letter-spacing: 0.02em; }
.dgm-head { fill: var(--text); font-size: 14.5px; font-weight: 600; }
.dgm-mini { fill: var(--text-muted); font-size: 12px; font-weight: 400; }
.dgm-mini-green { fill: var(--success); font-size: 12px; font-weight: 600; }
.dgm-mini-red { fill: var(--danger); font-size: 12px; font-weight: 700; }
/* connectors */
.dgm-arrow { fill: none; stroke: var(--border-strong); stroke-width: 1.8; }
.dgm-arrow-accent { fill: none; stroke: var(--info); stroke-width: 2; }
.dgm-arrow-green { fill: none; stroke: var(--success); stroke-width: 2.2; }
.dgm-arrow-red { fill: none; stroke: var(--danger); stroke-width: 2.2; }
.dgm-edge { stroke: var(--border-strong); stroke-width: 1.5; }
.dgm-bar { fill: var(--border-strong); stroke: none; }
.dgm-bracket { fill: none; stroke: var(--border-strong); stroke-width: 1.3; }
.dgm-divider { stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 7 7; }
.dgm-arrow-faint { fill: none; stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .55; }
.dgm-ah-fill { fill: var(--border-strong); }
.dgm-ah-accent-fill { fill: var(--info); }
.dgm-ah-green-fill { fill: var(--success); }
.dgm-ah-red-fill { fill: var(--danger); }
.dgm-ah-faint-fill { fill: var(--border-strong); opacity: .55; }
@media (max-width: 768px) {
  .dgm-text { font-size: 16px; }
  .dgm-sub, .dgm-mini, .dgm-mini-green, .dgm-label { font-size: 13px; }
}
