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

/* Black theme (default) */
:root {
  --bg: #000000;
  --bg-sidebar: #050505;
  --bg-card: #0a0a0a;
  --bg-card-hover: #111111;
  --bg-code: #0a0a0a;
  --bg-callout: #0a0a0a;
  --bg-diagram: #050505;
  --border: #1a1a1a;
  --border-light: #252525;
  --border-diagram: #222222;
  --text: #d4d4d4;
  --text-muted: #808080;
  --text-dim: #4a4a4a;
  --accent: #f0f0f0;
  --accent-muted: #c0c0c0;
  --link: #a0a0a0;
  --link-hover: #ffffff;
  --diagram-line: #606060;
  --diagram-label: #b0b0b0;
  --diagram-box-bg: #0a0a0a;
  --diagram-box-border: #2a2a2a;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  --sidebar-w: 280px;
  --content-max: 900px;
  --jepa-green: #62DE61;
  --jepa-green-dim: #2a5a2a;
  --jepa-green-bg: rgba(98,222,97,0.08);
}

/* White theme */
body.light {
  --bg: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-card: #f5f5f5;
  --bg-card-hover: #eeeeee;
  --bg-code: #f5f5f5;
  --bg-callout: #f5f5f5;
  --bg-diagram: #fafafa;
  --border: #e0e0e0;
  --border-light: #d0d0d0;
  --border-diagram: #ccc;
  --text: #111111;
  --text-muted: #555555;
  --text-dim: #999999;
  --accent: #000000;
  --accent-muted: #222222;
  --link: #333333;
  --link-hover: #000000;
  --diagram-line: #999;
  --diagram-label: #444;
  --diagram-box-bg: #fff;
  --diagram-box-border: #ccc;
}

body.light .logo-jepa { color: #16a34a; }
body.light .prog-stat-green { color: #16a34a; }
body.light .prog-bar-accepted { background: #16a34a; }
body.light .prog-bar-written { background: rgba(22, 163, 74, 0.25); }
body.light .prog-score-high { color: #16a34a; }
body.light .ch-meta-score-pass { color: #16a34a; }
body.light .ch-meta-val a:hover { color: #16a34a; }

body.light .vcard {
  background: rgba(22, 163, 74, 0.04);
  border-color: rgba(22, 163, 74, 0.15);
}
body.light .vcard:hover {
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(22, 163, 74, 0.3);
}

/* Light theme: code blocks */
body.light .article pre { background: #f0f0f0; border-color: #d0d0d0; }
body.light .article pre code { color: #1a1a1a; }
body.light .article code { background: #e8e8e8; color: #1a1a1a; border-color: #d0d0d0; }

/* Light theme: Prism */
body.light pre[class*="language-"],
body.light code[class*="language-"] { color: #1a1a1a; text-shadow: none; }
body.light .token.comment, body.light .token.prolog, body.light .token.doctype, body.light .token.cdata { color: #6a737d; }
body.light .token.punctuation { color: #333; }
body.light .token.property, body.light .token.tag, body.light .token.boolean,
body.light .token.number, body.light .token.constant, body.light .token.symbol { color: #005cc5; }
body.light .token.selector, body.light .token.attr-name, body.light .token.string,
body.light .token.char, body.light .token.builtin { color: #22863a; }
body.light .token.operator, body.light .token.entity, body.light .token.url { color: #d73a49; }
body.light .token.atrule, body.light .token.attr-value, body.light .token.keyword { color: #d73a49; }
body.light .token.function, body.light .token.class-name { color: #6f42c1; }

/* Light theme: tables */
body.light .article thead th { background: rgba(22, 163, 74, 0.08); color: #16a34a; border-bottom-color: rgba(22, 163, 74, 0.2); }
body.light .article tbody td { color: #2a4a2a; border-bottom-color: rgba(22, 163, 74, 0.1); }
body.light .article tbody tr:hover { background: rgba(22, 163, 74, 0.05); }

/* Light theme: callouts */
body.light .callout { background: #f0f0f0; border-left-color: #999; }
body.light .callout-important { border-left-color: #333; }
body.light .callout-success { border-left-color: #16a34a; }

/* Light theme: bibtex */
body.light .bibtex { background: #f0f0f0; border-color: #d0d0d0; }
body.light .bibtex code { color: #1a1a1a; }

/* Light theme: diagrams stay dark for readability */
body.light .article svg.jepa-diagram { background: #0e0e0e; border-color: #333; border-radius: 8px; }

/* Light theme: meta card */
body.light .ch-meta-card { background: rgba(22, 163, 74, 0.06); border-color: rgba(22, 163, 74, 0.18); }
body.light .ch-meta-key { color: #2d6a2d; }
body.light .ch-meta-val { color: #3a5a3a; }

/* Light theme: nav status */
body.light .nav-status { color: #888; }

/* Light theme: buttons */
body.light .theme-toggle, body.light .mobile-menu-btn {
  background: #fff; border-color: #d0d0d0; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Light theme: lineage SVG */
body.light .lineage-svg { background: #f8f8f8; }
body.light .lineage-svg .lg-node { fill: #f0f8f0; stroke: #2a8a2a; }

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.sidebar-header {
  padding: 20px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--accent);
  text-decoration: none;
}

.logo-jepa { color: #4ade80; }
.logo-dot { color: var(--text-dim); }

.sidebar-toggle {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: 4px; display: none;
}
.sidebar-toggle:hover { color: var(--accent); background: var(--bg-card); }

.sidebar-search { padding: 12px 16px; }
.sidebar-search input {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  font-size: 13px; font-family: var(--font-body);
  outline: none; transition: border-color 0.15s;
}
.sidebar-search input::placeholder { color: var(--text-dim); }
.sidebar-search input:focus { border-color: var(--text-muted); }

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 8px 0 12px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px;
}
.sidebar-footer a { color: var(--text-muted); text-decoration: none; transition: color 0.1s; }
.sidebar-footer a:hover { color: var(--accent); }
.sidebar-license { color: var(--text-dim); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.5px; }

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); cursor: pointer; user-select: none; list-style: none;
}
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title .nav-count {
  font-size: 10px; color: var(--text-dim); background: var(--bg);
  padding: 1px 6px; border-radius: 10px; font-family: var(--font-mono);
}

.nav-list { list-style: none; padding: 0 8px 8px; }
.nav-list li a {
  display: block; padding: 5px 12px; font-size: 13px;
  color: var(--text-muted); text-decoration: none; border-radius: 4px;
  transition: all 0.1s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-list li a:hover { color: var(--text); background: var(--bg-card); }
.nav-list li.active a { color: var(--accent); background: var(--bg-card); font-weight: 500; }

.nav-status { font-family: var(--font-mono); font-size: 10px; margin-left: 4px; }
.nav-status.pending { color: var(--text-dim); }
.nav-status.wip { color: #deca3e; }
.nav-status.review { color: #3e8cde; }

/* Main content */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 48px 0;
}

.article { max-width: var(--content-max); width: 100%; }

/* Typography */
.article h1 {
  font-family: var(--font-body); font-size: 2rem; font-weight: 700;
  color: var(--accent); margin-bottom: 8px; line-height: 1.2; letter-spacing: -0.025em;
}
.article h2 {
  font-family: var(--font-body); font-size: 1.3rem; font-weight: 600;
  color: var(--accent-muted); margin-top: 48px; margin-bottom: 16px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border); letter-spacing: -0.01em;
}
.article h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-top: 32px; margin-bottom: 12px; }
.article h4 { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-top: 24px; margin-bottom: 8px; }
.article p { margin-bottom: 16px; color: var(--text); }
.article a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-light); transition: all 0.1s; }
.article a:hover { color: var(--link-hover); text-decoration-color: var(--text-muted); }
.article strong { color: var(--accent); font-weight: 600; }
.article em { color: var(--text-muted); font-style: italic; }
.article ul, .article ol { margin-bottom: 16px; padding-left: 24px; }
.article li { margin-bottom: 4px; color: var(--text); }
.article li::marker { color: var(--text-dim); }
.article hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* Tables */
.article table { width: 100%; border-collapse: collapse; margin: 16px 0 24px; font-size: 13px; }
.article thead th {
  background: var(--jepa-green-bg); color: var(--jepa-green);
  font-weight: 600; text-align: left; padding: 10px 12px;
  border-bottom: 2px solid rgba(98,222,97,0.2);
  white-space: nowrap; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
}
.article tbody td { padding: 8px 12px; border-bottom: 1px solid rgba(98,222,97,0.08); color: #8aa88a; }
.article tbody tr:hover { background: rgba(98,222,97,0.04); }
.table-wrap { overflow-x: auto; margin: 16px 0 24px; border-radius: 8px; border: 1px solid var(--border); }
.table-wrap table { margin: 0; }

/* Code */
.article pre {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px 20px; margin: 16px 0 24px;
  overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.article pre code { background: transparent; border: none; padding: 0; font-size: inherit; color: var(--text); }
.article code {
  background: var(--bg-code); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px; font-size: 0.85em;
  font-family: var(--font-mono); color: var(--text);
}

/* Callouts */
.callout {
  background: var(--bg-callout); border-left: 3px solid var(--text-dim);
  border-radius: 0 6px 6px 0; padding: 16px 20px; margin: 16px 0 24px;
}
.callout p { margin-bottom: 8px; }
.callout p:last-child { margin-bottom: 0; }
.callout-info { border-left-color: #3e8cde; }
.callout-warning { border-left-color: #deca3e; }
.callout-important { border-left-color: var(--accent); }
.callout-success { border-left-color: var(--jepa-green); }
.callout-summary {
  border-left-color: var(--jepa-green);
  background: rgba(98,222,97,0.04);
}

/* Algorithm blocks (academic pseudocode style) */
.algorithm-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 24px 0;
  overflow: hidden;
}
.algorithm-header {
  background: var(--jepa-green-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--jepa-green);
}
.algorithm-body {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.9;
}
.algo-line {
  position: relative;
  padding-left: 36px;
  min-height: 1.8em;
}
.algo-line.indent-1 { padding-left: 56px; }
.algo-line.indent-2 { padding-left: 76px; }
.algo-line.indent-3 { padding-left: 96px; }
.algo-lineno {
  position: absolute;
  left: 0;
  width: 28px;
  text-align: right;
  color: var(--text-dim);
  font-size: 11px;
  user-select: none;
}
.algo-keyword {
  color: var(--jepa-green);
  font-weight: 700;
}
.algo-comment {
  color: var(--text-dim);
  font-style: italic;
}
body.light .algorithm-block { background: #f5f5f5; border-color: #e0e0e0; }
body.light .algorithm-header { background: rgba(22, 163, 74, 0.06); border-color: #e0e0e0; color: #16a34a; }
body.light .algo-keyword { color: #16a34a; }
body.light .algo-lineno { color: #bbb; }

/* Key contribution box */
.key-contribution {
  background: rgba(98,222,97,0.06);
  border: 1px solid rgba(98,222,97,0.2);
  border-radius: 8px; padding: 20px 24px; margin: 24px 0;
}

/* Chapter meta card */
.ch-meta-card {
  background: rgba(98,222,97,0.04);
  border: 1px solid rgba(98,222,97,0.15);
  border-radius: 8px; padding: 16px 20px; margin-bottom: 32px;
}
.ch-meta-row { display: flex; align-items: baseline; padding: 4px 0; font-size: 13px; }
.ch-meta-key { color: var(--jepa-green-dim); font-weight: 600; min-width: 100px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.ch-meta-val { color: var(--text-muted); }
.ch-meta-val a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.ch-meta-val a:hover { color: var(--jepa-green); }
.ch-meta-score-pass { color: var(--jepa-green); font-weight: 600; }
.ch-meta-score-draft { color: #deca3e; }

/* Tags */
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; font-family: var(--font-mono);
  letter-spacing: 0.3px;
}
.tag-foundation { background: rgba(98,222,97,0.12); color: #62DE61; border: 1px solid rgba(98,222,97,0.25); }
.tag-vision { background: rgba(98,222,97,0.12); color: #62DE61; border: 1px solid rgba(98,222,97,0.25); }
.tag-video { background: rgba(62,140,222,0.10); color: #3e8cde; border: 1px solid rgba(62,140,222,0.2); }
.tag-audio { background: rgba(222,200,62,0.10); color: #deca3e; border: 1px solid rgba(222,200,62,0.2); }
.tag-3d { background: rgba(222,100,62,0.10); color: #de6a3e; border: 1px solid rgba(222,100,62,0.2); }
.tag-robot { background: rgba(180,62,222,0.10); color: #b43ede; border: 1px solid rgba(180,62,222,0.2); }
.tag-world { background: rgba(62,222,180,0.10); color: #3edeb4; border: 1px solid rgba(62,222,180,0.2); }
.tag-theory { background: rgba(138,168,138,0.10); color: #8aa88a; border: 1px solid rgba(138,168,138,0.2); }
.tag-skeleton { background: rgba(222,138,62,0.10); color: #de8a3e; border: 1px solid rgba(222,138,62,0.2); }
.tag-trajectory { background: rgba(62,168,222,0.10); color: #3ea8de; border: 1px solid rgba(62,168,222,0.2); }

/* Status badges */
.status-pending { color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; }
.status-wip { color: #deca3e; font-family: var(--font-mono); font-size: 11px; }
.status-review { color: #3e8cde; font-family: var(--font-mono); font-size: 11px; }
.status-complete { color: var(--jepa-green); font-family: var(--font-mono); font-size: 11px; }

/* ================================
   INDEX PAGE
   ================================ */

.index-hero {
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.index-hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--jepa-green);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.5px;
  margin-bottom: 16px !important;
}

.index-hero p { color: var(--text-muted); font-size: 14px; line-height: 1.7; }

.hero-meta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.hero-meta a { color: var(--text-muted); text-decoration: underline; }
.hero-meta a:hover { color: var(--accent); }

.index-section { margin-bottom: 48px; }
.index-section h2 {
  font-size: 1.2rem; font-weight: 600; color: var(--accent-muted);
  margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.section-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* Progress dashboard */
.prog-dashboard { margin-top: 16px; }
.prog-stats { display: flex; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.prog-stat { text-align: center; min-width: 80px; }
.prog-stat-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; color: var(--accent); }
.prog-stat-value .prog-stat-dim { color: var(--text-dim); font-size: 0.8em; }
.prog-stat-green { color: var(--jepa-green) !important; }
.prog-stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

.prog-overall { margin-bottom: 24px; }
.prog-overall-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; }
.prog-overall-label span:first-child { color: var(--text-muted); font-weight: 500; }
.prog-overall-pct { color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; }

.prog-bar { height: 6px; background: var(--bg-card); border-radius: 3px; overflow: hidden; display: flex; }
.prog-bar-lg { height: 8px; }
.prog-bar-fill { height: 100%; }
.prog-bar-accepted { background: var(--jepa-green); }
.prog-bar-written { background: rgba(98,222,97,0.25); }

.prog-parts { margin-top: 16px; }
.prog-parts-header {
  display: grid; grid-template-columns: 70px 1fr 120px 60px 50px;
  gap: 8px; padding: 6px 0;
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); border-bottom: 1px solid var(--border);
}
.prog-row {
  display: grid; grid-template-columns: 70px 1fr 120px 60px 50px;
  gap: 8px; padding: 8px 0; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.prog-label { font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.prog-name { font-size: 13px; color: var(--text-muted); }
.prog-bar-wrap { display: flex; align-items: center; }
.prog-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); text-align: center; }
.prog-score { font-family: var(--font-mono); font-size: 12px; text-align: right; }
.prog-score-high { color: var(--jepa-green); }
.prog-score-mid { color: #deca3e; }
.prog-score-low { color: #de6a3e; }
.prog-score-none { color: var(--text-dim); }

/* Variant cards grid */
.vcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.vcard {
  display: block;
  background: rgba(98,222,97,0.03);
  border: 1px solid rgba(98,222,97,0.12);
  border-radius: 10px;
  padding: 18px 20px;
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid var(--cat-color, var(--jepa-green));
}
.vcard:hover {
  background: rgba(98,222,97,0.07);
  border-color: rgba(98,222,97,0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(98,222,97,0.08);
}

.vcard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.vcard-title { font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.vcard-status {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.5px;
}
.vcard-status.status-pending { background: rgba(85,85,85,0.2); color: var(--text-dim); }
.vcard-status.status-wip { background: rgba(222,202,62,0.15); color: #deca3e; }
.vcard-status.status-review { background: rgba(62,140,222,0.15); color: #3e8cde; }
.vcard-status.status-complete { background: rgba(98,222,97,0.15); color: var(--jepa-green); }

.vcard-full { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; font-family: var(--font-mono); }
.vcard-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.vcard-footer { display: flex; align-items: center; gap: 10px; }
.vcard-date { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.vcard-score { font-family: var(--font-mono); font-size: 12px; color: var(--jepa-green); font-weight: 600; margin-left: auto; }
.vcard-derives { font-size: 11px; color: var(--text-dim); margin-top: 8px; font-family: var(--font-mono); }

/* Lineage SVG */
.lineage-svg {
  width: 100%;
  max-width: 800px;
  margin: 16px auto;
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.lineage-svg .lg-node { cursor: pointer; transition: all 0.15s; }
.lineage-svg .lg-node:hover { filter: brightness(1.3); }
.lineage-svg a:hover .lg-node { stroke-width: 2; }

/* Chapter part label */
.chapter-part {
  font-size: 13px; color: var(--text-dim);
  font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 16px !important;
}

/* About page */
.about-page h1 { margin-bottom: 16px; }
.about-section { margin-top: 32px; }
.about-section h2 { font-size: 1.15rem; color: var(--accent-muted); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 12px; }

/* ================================
   HISTORY PAGE
   ================================ */

.page-history { width: 100%; }
.page-history h1 { margin-bottom: 4px; }

.ph-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.ph-section { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.ph-section h2 { font-size: 1.2rem; font-weight: 600; color: var(--accent-muted); margin-bottom: 4px; border-bottom: none; padding-bottom: 0; margin-top: 0; }
.ph-desc { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

.ph-summary { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.ph-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; min-width: 0; }
.ph-card-label { font-family: var(--font-mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 6px; }
.ph-card-value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: var(--accent); line-height: 1; }
.ph-card-sub { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.ph-chart-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; overflow-x: auto; }

.ph-table-wrap { overflow-x: auto; }
.ph-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ph-table thead th {
  background: var(--bg-card); color: var(--text-muted); font-weight: 600; text-align: left;
  padding: 8px 12px; border-bottom: 2px solid var(--border);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-family: var(--font-mono); white-space: nowrap;
}
.ph-table tbody td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ph-table tbody tr:hover { background: var(--bg-card); }

.ph-ch-id { font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.ph-ch-id a { color: inherit; text-decoration: none; transition: color 0.1s; }
.ph-ch-id a:hover { color: #4ade80; }

.ph-ch-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-ch-title a { color: inherit; text-decoration: none; transition: color 0.1s; }
.ph-ch-title a:hover { color: #4ade80; }

.ph-score { white-space: nowrap; min-width: 120px; }
.ph-score-val { font-family: var(--font-mono); font-weight: 600; font-size: 13px; display: inline-block; width: 42px; }
.ph-score.high .ph-score-val { color: #c0c0c0; }
.ph-score.mid .ph-score-val { color: #808080; }
.ph-score.low .ph-score-val { color: #666; }
.ph-score.dim .ph-score-val { color: var(--text-dim); }

.ph-bar { display: inline-block; width: 60px; height: 4px; background: var(--border); border-radius: 2px; vertical-align: middle; margin-left: 8px; }
.ph-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.ph-bar-fill.high { background: #a0a0a0; }
.ph-bar-fill.mid { background: #606060; }
.ph-bar-fill.low { background: #404040; }

.ph-first-score { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); text-align: center; }
.ph-revisions { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-align: center; }
.ph-delta-col { white-space: nowrap; }
.ph-delta { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.ph-delta.positive { color: #4ade80; }
.ph-delta.negative { color: #666; }

body.light .ph-delta.positive { color: #16a34a; }
body.light .ph-bar-fill.high { background: #16a34a; }
body.light .ph-bar-fill.mid { background: #888; }
body.light .ph-ch-id a:hover, body.light .ph-ch-title a:hover { color: #16a34a; }

/* Lineage page */
.lineage-page h1 { margin-bottom: 8px; }
.lineage-page > p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* SVG diagrams in articles */
.article svg.jepa-diagram {
  width: 100%; max-width: 100%;
  margin: 20px 0; display: block;
  background: var(--bg-diagram);
  border: 1px solid var(--border-diagram);
  border-radius: 8px;
}

/* Diagram container divs */
.diagram-container {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-diagram);
  border: 1px solid var(--border-diagram);
  border-radius: 8px;
}
.diagram-caption {
  text-align: center; font-size: 12px; color: var(--text-dim);
  margin-top: 8px; font-style: italic;
}

/* Two-column layout for dual explanations */
.dual-level {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 24px 0;
}
.dual-level-col {
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.dual-level-col.accessible { background: rgba(62,140,222,0.04); border-color: rgba(62,140,222,0.15); }
.dual-level-col.phd { background: rgba(98,222,97,0.04); border-color: rgba(98,222,97,0.15); }
.dual-level-col h3 { margin-top: 0 !important; }

/* Footer */
.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--border);
  padding: 32px 0 48px;
  width: 100%;
  max-width: var(--content-max);
}

.footer-inner {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px;
}

.footer-heading {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 12px;
}

.footer-inner p { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.footer-inner strong { color: var(--accent); }

.bibtex {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 4px; padding: 10px 14px; font-size: 11px;
  overflow-x: auto;
}
.bibtex code { font-family: var(--font-mono); color: var(--text-muted); background: transparent; border: none; padding: 0; }

.license-text { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }

.footer-links { display: flex; gap: 16px; margin-top: 8px; }
.footer-links a { font-size: 13px; color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* Theme toggle */
.theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  background: #ffffff; border: 2px solid #ffffff;
  border-radius: 50%; width: 38px; height: 38px;
  cursor: pointer; color: #000000;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 16px rgba(255,255,255,0.15);
  transition: all 0.2s;
}
.theme-toggle:hover { box-shadow: 0 2px 24px rgba(255,255,255,0.3); transform: scale(1.1); }
body.light .theme-toggle {
  background: #000000; border-color: #000000; color: #ffffff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.2);
}
body.light .theme-toggle:hover { box-shadow: 0 2px 24px rgba(0,0,0,0.4); }
.icon-black, .icon-white {
  font-family: var(--font-mono); font-size: 14px; font-weight: 800; letter-spacing: 0; line-height: 1;
}
.icon-white { display: none; }
body.light .icon-black { display: none; }
body.light .icon-white { display: block; }

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 16px; left: 16px; z-index: 200;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; cursor: pointer;
  color: var(--text-muted);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.mobile-menu-btn:hover { color: var(--accent); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.5);
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar-toggle { display: block; }
  .mobile-menu-btn { display: flex; }

  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }

  .content { margin-left: 0; padding: 48px 20px 0; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .vcard-grid { grid-template-columns: 1fr; }
  .dual-level { grid-template-columns: 1fr; }
  .prog-parts-header, .prog-row { grid-template-columns: 50px 1fr 80px 50px 40px; }
  .ph-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .index-hero h1 { font-size: 1.8rem; }
  .prog-stats { gap: 16px; }
  .prog-stat-value { font-size: 1.2rem; }
}
