
/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --bg-card: #ffffff;
  --border: #e0e0e0;
  --text: #202122;
  --text-muted: #54595d;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-light: #e8f0fe;
  --green: #1e7e34;
  --red: #c0392b;
  --nav-bg: #1e2a3a;
  --nav-text: #e8eaed;
  --hero-bg: linear-gradient(135deg, #1e2a3a 0%, #2c4a6e 100%);
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.dark {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-card: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-light: #1c2a3c;
  --nav-bg: #010409;
  --nav-text: #e6edf3;
  --hero-bg: linear-gradient(135deg, #010409 0%, #0d1117 100%);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-hover); }

/* ── Nav ────────────────────────────────────────────────────── */
.site-nav {
  background: var(--nav-bg);
  color: var(--nav-text);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.nav-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--nav-text);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo { height: 28px; width: auto; border-radius: 3px; }
.nav-title { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
.nav-links a {
  color: rgba(255,255,255,0.8);
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }

/* More dropdown */
.nav-more { position: relative; display: flex; align-items: center; }
.nav-more-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: inherit;
  font-family: inherit;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
}
.nav-more-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-more-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--nav-bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  padding: 0.35rem 0;
}
.nav-more-dropdown.open { display: block; }
.nav-more-dropdown a {
  display: block;
  padding: 0.45rem 1rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  text-decoration: none;
  transition: background 0.12s;
}
.nav-more-dropdown a:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.mobile-menu-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 0.35rem 0; }

.nav-actions { display: flex; gap: 0.25rem; margin-left: auto; }
.icon-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
#menu-toggle { display: none; }

.mobile-menu {
  background: var(--nav-bg);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 0.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mobile-menu a {
  color: rgba(255,255,255,0.85);
  padding: 0.5rem 0.5rem;
  border-radius: 4px;
  font-size: 0.95rem;
}
.mobile-menu a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }

.search-bar {
  background: var(--nav-bg);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 0.75rem 1rem;
  position: relative;
}
.search-bar input {
  width: 100%;
  max-width: 600px;
  padding: 0.5rem 1rem;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: var(--nav-text);
  font-size: 0.95rem;
  outline: none;
}
.search-bar input:focus { border-color: var(--accent); background: rgba(255,255,255,0.12); }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 1rem;
  right: 1rem;
  max-width: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}
.search-result-item {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result-item:hover { background: var(--bg-alt); }
.search-result-item:last-child { border-bottom: none; }
.sri-title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.sri-meta { font-size: 0.8rem; color: var(--text-muted); }
.sri-snippet { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; line-height: 1.4; }
.sri-snippet mark { background: rgba(59,130,246,0.25); color: var(--text); border-radius: 2px; padding: 0 1px; }
.search-results { max-height: 500px; }

.hidden { display: none !important; }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  background: var(--hero-bg);
  color: #fff;
  padding: 4rem 1rem 3rem;
}
.hero-inner {
  max-width: 900px;
  margin: 0 auto;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero-title {
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  letter-spacing: -0.03em;
}
.hero-author {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 1rem;
}
.hero-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ── Thesis Stats Bar ───────────────────────────────────────── */
.thesis-stats-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem 1.5rem;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}

/* ── Tags ───────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}
.tags-block .tag {
  background: var(--accent-light);
  border: 1px solid rgba(26,115,232,0.3);
  color: var(--accent);
}
.tag-blue {
  background: rgba(26,115,232,0.12);
  border-color: rgba(26,115,232,0.3);
  color: var(--accent);
}

/* ── Layout ─────────────────────────────────────────────────── */
#page-wrapper { min-height: calc(100vh - 56px - 80px); }

.main-content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.content-cols {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

/* ── Wiki Sections ───────────────────────────────────────────── */
.wiki-section {
  margin-bottom: 2.5rem;
}
.wiki-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}

/* ── Chapter Grid ─────────────────────────────────────────────── */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.chapter-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
}
.chapter-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.chapter-num {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.chapter-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.35rem;
}
.chapter-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Results Table ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.results-table th {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
}
.results-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
}
.results-table tr:nth-child(even) td { background: var(--bg-alt); }
.text-muted { color: var(--text-muted); }
.gain { color: var(--green); font-weight: 700; }

/* ── Info Box / Aside ─────────────────────────────────────── */
.info-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.info-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.info-box dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.75rem; font-size: 0.88rem; }
.info-box dt { font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.info-box dd { color: var(--text); }
.quick-links, .contrib-list { list-style: none; font-size: 0.88rem; }
.quick-links li, .contrib-list li { padding: 0.2rem 0; }
.contrib-list li { padding-left: 1rem; position: relative; font-size: 0.85rem; color: var(--text-muted); }
.contrib-list li::before { content: '✓'; position: absolute; left: 0; color: var(--green); font-weight: 700; }

/* ── Chapter Page ─────────────────────────────────────────── */
.chapter-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
  min-height: calc(100vh - 56px);
}
.chapter-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
  min-height: calc(100vh - 56px);
}
.sidebar-sticky {
  position: sticky;
  top: 56px;
  padding: 1.5rem 1rem;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
.chapter-info { margin-bottom: 1rem; }
.chapter-num-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.5rem;
}
.back-link { font-size: 0.85rem; }

.toc { margin-bottom: 1.5rem; }
.toc h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.toc-list { list-style: none; font-size: 0.85rem; }
.toc-list li { margin: 0.15rem 0; }
.toc-list a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.4;
}
.toc-list a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.toc-list a.toc-active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.toc-l3 a { padding-left: 1.25rem; font-size: 0.82rem; }
.toc-l4 a { padding-left: 2rem; font-size: 0.8rem; }

.chapter-nav { display: flex; flex-direction: column; gap: 0.4rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.nav-btn {
  display: block;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.nav-btn:hover { background: var(--accent-light); border-color: var(--accent); text-decoration: none; }

.chapter-main {
  padding: 2rem 2.5rem 3rem;
  max-width: 820px;
}
.chapter-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 3px solid var(--accent);
}
.chapter-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.chapter-header h1 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

/* ── Chapter Content ─────────────────────────────────────── */
.chapter-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.chapter-content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.5rem 0 0.6rem;
  color: var(--text);
}
.chapter-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: var(--text-muted);
}
.chapter-content p {
  margin-bottom: 1rem;
  color: var(--text);
}
.chapter-content ul, .chapter-content ol {
  margin: 0.75rem 0 1rem 1.5rem;
}
.chapter-content li { margin-bottom: 0.4rem; }
.chapter-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-radius: 0 4px 4px 0;
}
.chapter-content strong { font-weight: 700; }
.chapter-content em { font-style: italic; }
.chapter-content code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.chapter-content .math { font-style: italic; }
.chapter-content .math-display {
  overflow-x: auto;
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--bg-alt);
  border-radius: 4px;
  text-align: center;
}

/* Citations */
.cite {
  color: var(--accent);
  font-size: 0.8em;
  text-decoration: none;
  vertical-align: super;
  line-height: 0;
}
.cite:hover { text-decoration: underline; }
.cite-group { white-space: nowrap; }
.internal-ref { color: var(--accent); }

/* Figures */
.thesis-figure {
  margin: 1.5rem 0;
  text-align: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.thesis-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.thesis-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.pdf-figure-note, .img-missing {
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Tables note */
.table-note {
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 1rem 0;
}

/* Nested bullet lists inside table cells */
.cell-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: inherit;
}
.cell-list li {
  padding: 0.1rem 0;
  line-height: 1.5;
}

/* ── Chapter References ───────────────────────────────────── */
.chapter-references {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}
.chapter-references h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  font-weight: 700;
}
.ref-list {
  list-style: decimal;
  margin-left: 1.5rem;
  font-size: 0.88rem;
  line-height: 1.7;
}
.ref-list li { margin-bottom: 0.25rem; }
.ref-list a { color: var(--accent); }

.chapter-nav-bottom {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Paper Page ───────────────────────────────────────────── */
.paper-layout { max-width: 860px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.paper-main { }
.breadcrumb { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--text-muted); }
.paper-article { }
.paper-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.paper-title { font-size: clamp(1.2rem, 2.5vw, 1.8rem); font-weight: 800; line-height: 1.3; margin-bottom: 0.5rem; }
.paper-authors { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.paper-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.75rem; }
.paper-year { font-weight: 700; color: var(--text); }
.paper-venue { color: var(--text-muted); font-style: italic; }
.cite-count { background: var(--accent-light); color: var(--accent); padding: 0.15rem 0.5rem; border-radius: 3px; font-weight: 600; font-size: 0.82rem; }
.paper-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ext-link {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.15s;
}
.ext-link:hover { background: var(--accent-light); text-decoration: none; }
.pdf-link { background: var(--green); border-color: var(--green); color: #fff; }
.pdf-link:hover { background: #155724; }
.abstract-block { margin: 1.5rem 0; }
.abstract-block h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.abstract-block p { font-size: 0.92rem; line-height: 1.7; color: var(--text-muted); }
.cited-in-block { margin: 1.5rem 0; }
.cited-in-block h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.cite-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cite-chip {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
}
.cite-chip:hover { background: var(--accent); color: #fff; text-decoration: none; }
.bibtex-block {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bibtex-block summary {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  background: var(--bg-alt);
  border-radius: var(--radius);
  user-select: none;
}
.bibtex-block[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
.bibtex-block pre {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Thesis Tables ────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.thesis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.5;
  background: var(--bg-card);
}
.thesis-table caption {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  caption-side: top;
}
.thesis-table thead th {
  background: var(--bg-alt);
  font-weight: 700;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.thesis-table tbody td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.thesis-table tbody tr:last-child td { border-bottom: none; }
.thesis-table tbody tr:nth-child(even) td { background: var(--bg-alt); }
.thesis-table tbody tr:hover td { background: var(--accent-light); }
.thesis-table strong { font-weight: 700; }

/* ── Papers Index ─────────────────────────────────────────── */
.papers-page { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }
.papers-header { margin-bottom: 2rem; }
.papers-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.papers-header p { color: var(--text-muted); margin-bottom: 1rem; }
.filter-input {
  width: 100%;
  max-width: 500px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 0.95rem;
  background: var(--bg-alt);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.filter-input:focus { border-color: var(--accent); }
.filter-stats { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.5rem; }

.papers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}
.paper-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.paper-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.paper-card-link { display: block; padding: 0.9rem 1rem; text-decoration: none; }
.paper-card-link:hover { text-decoration: none; }
.paper-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.35rem;
}
.paper-card-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.35rem; align-items: center; }
.pc-author { font-weight: 600; color: var(--text-muted); }
.pc-year { }
.pc-venue { font-style: italic; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc { background: var(--accent-light); color: var(--accent); padding: 0.1rem 0.4rem; border-radius: 3px; font-weight: 600; white-space: nowrap; }
.paper-card-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.mini-chip {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
}
.mini-chip:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ── Abstract ─────────────────────────────────────────────── */
.abstract-text {
  line-height: 1.75;
  font-size: 0.97rem;
  color: var(--text);
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  margin-top: 2rem;
}
.footer-inner {
  max-width: 1300px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer-sub { font-size: 0.78rem; margin-top: 0.25rem; }

/* ── Tags block ───────────────────────────────────────────── */
.tags-block { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags-block .tag {
  background: var(--accent-light);
  border-color: rgba(26,115,232,0.3);
  color: var(--accent);
  font-size: 0.83rem;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .content-cols { grid-template-columns: 1fr; }
  .content-aside { order: -1; }
  .chapter-layout { grid-template-columns: 1fr; }
  .chapter-sidebar { display: none; }
  .chapter-sidebar.open { display: block; border-right: none; border-bottom: 1px solid var(--border); }
  .chapter-main { padding: 1.5rem 1rem; }
  #menu-toggle { display: flex; }
  .nav-links { display: none; }
}
@media (max-width: 600px) {
  .hero { padding: 2.5rem 1rem 2rem; }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .papers-grid { grid-template-columns: 1fr; }
  .paper-layout { padding: 1.5rem 0.75rem; }
}

/* ── Reading Progress Bar ─────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 9999;
  width: 0%;
  transition: width 0.08s linear;
  pointer-events: none;
}

/* ── Citation Hover Card ──────────────────────────────────── */
.cite-card {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.9rem 1rem;
  max-width: 360px;
  min-width: 240px;
  z-index: 1000;
  font-size: 0.84rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1.5;
}
.cite-card.visible { opacity: 1; pointer-events: auto; }
.cite-card-title { font-weight: 700; color: var(--text); margin-bottom: 0.3rem; line-height: 1.4; }
.cite-card-authors { color: var(--text-muted); font-size: 0.79rem; margin-bottom: 0.2rem; }
.cite-card-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.77rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.cite-card-abstract { font-size: 0.79rem; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cite-card-cc { background: var(--accent-light); color: var(--accent); padding: 0.1rem 0.35rem; border-radius: 3px; font-weight: 600; }

/* ── Glossary Term Hover ──────────────────────────────────── */
.glossary-term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  color: inherit;
  text-decoration: none;
}
.glossary-term:hover { color: var(--accent); text-decoration: none; }

.glossary-card {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.9rem 1rem;
  max-width: 340px;
  min-width: 220px;
  z-index: 1001;
  font-size: 0.84rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1.5;
}
.glossary-card.visible { opacity: 1; pointer-events: auto; }
.glossary-card-term { font-weight: 700; font-size: 0.9rem; color: var(--accent); margin-bottom: 0.1rem; }
.glossary-card-full { font-size: 0.77rem; color: var(--text-muted); font-style: italic; margin-bottom: 0.35rem; }
.glossary-card-def { font-size: 0.81rem; color: var(--text); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.glossary-card-link { font-size: 0.77rem; color: var(--accent); margin-top: 0.4rem; display: block; }

/* ── Glossary Page ────────────────────────────────────────── */
.glossary-page { max-width: 860px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.glossary-header { margin-bottom: 1.5rem; }
.glossary-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.glossary-header p { color: var(--text-muted); }
.glossary-alpha-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 2rem; }
.alpha-link {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
}
.alpha-link:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); text-decoration: none; }
.alpha-section { margin-bottom: 2rem; }
.alpha-section > h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.3rem;
  margin-bottom: 1rem;
}
.glossary-entry { margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.glossary-entry:last-child { border-bottom: none; }
.glossary-entry-term { font-size: 1rem; font-weight: 700; color: var(--text); }
.glossary-entry-full { font-size: 0.83rem; color: var(--text-muted); font-style: italic; margin: 0.1rem 0 0.4rem; }
.glossary-entry-def { font-size: 0.92rem; color: var(--text); line-height: 1.65; }
.glossary-entry-cat {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.1rem 0.4rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Figure Gallery ───────────────────────────────────────── */
.gallery-page { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.gallery-header { margin-bottom: 1.5rem; }
.gallery-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.gallery-header p { color: var(--text-muted); }
.gallery-filter-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.5rem; }
.gallery-filter-btn {
  padding: 0.3rem 0.85rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.gallery-filter-btn.active, .gallery-filter-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.gallery-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
}
.gallery-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.gallery-item a { display: block; }
.gallery-item img {
  width: 100%;
  height: 175px;
  object-fit: contain;
  background: var(--bg-alt);
  padding: 0.5rem;
}
.gallery-item-caption {
  padding: 0.55rem 0.75rem;
  font-size: 0.79rem;
  color: var(--text-muted);
  line-height: 1.4;
  border-top: 1px solid var(--border);
}
.gallery-item-chapter {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

/* ── Cited Together ───────────────────────────────────────── */
.cited-together-block { margin: 1.5rem 0; }
.cited-together-block h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem; }
.cited-together-list { list-style: none; font-size: 0.87rem; }
.cited-together-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.cited-together-list li:last-child { border-bottom: none; }
.co-cite-link { color: var(--accent); flex: 1; min-width: 0; }
.co-cite-meta { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; }
.co-cite-count {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── BibTeX Copy Button ───────────────────────────────────── */
.bibtex-mini {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem;
  white-space: pre;
  overflow-x: auto;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}
.bibtex-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  justify-content: center;
}
.bibtex-copy-btn:hover { background: var(--accent-hover); }
.bibtex-copy-btn.copied { background: var(--green); }

/* ── Hatnote ──────────────────────────────────────────────── */
.hatnote {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.9rem;
  border-radius: 0 4px 4px 0;
  margin-bottom: 1.25rem;
}
.hatnote a { color: var(--accent); }

/* ── Reading Time ─────────────────────────────────────────── */
.reading-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ── See Also ─────────────────────────────────────────────── */
.see-also {
  font-size: 0.88rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.55rem 0.9rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
}
.see-also a { color: var(--accent); }

/* ── Did You Know ─────────────────────────────────────────── */
.did-you-know {
  background: var(--accent-light);
  border: 1px solid rgba(26,115,232,0.25);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.did-you-know strong { color: var(--accent); white-space: nowrap; }
.did-you-know span { flex: 1; }
.dyk-next {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.dyk-next:hover { background: var(--accent); color: #fff; }

/* ── Navbox ───────────────────────────────────────────────── */
.navbox {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 2rem 0 1rem;
  background: var(--bg-alt);
  font-size: 0.85rem;
}
.navbox > summary {
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  user-select: none;
}
.navbox-body {
  padding: 0.5rem 0.9rem 0.75rem;
  border-top: 1px solid var(--border);
}
.navbox-group {
  margin: 0.3rem 0;
  line-height: 1.6;
}
.navbox-group a { color: var(--accent); font-size: 0.83rem; }

/* ── Stub Notice ─────────────────────────────────────────── */
.stub-notice {
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
  margin-bottom: 1.25rem;
}

/* ── Back to Top ─────────────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: background 0.15s, opacity 0.2s;
}
#back-to-top:hover { background: var(--accent-hover); }
#back-to-top.visible { display: flex; }

/* ── Heading Anchor ──────────────────────────────────────── */
.heading-anchor {
  margin-left: 0.4rem;
  opacity: 0;
  font-size: 0.75em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
  text-decoration: none;
}
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor { opacity: 1; }

/* ── Search Result Groups ────────────────────────────────── */
.search-result-group {
  padding: 0.25rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

/* ── Graph Page ──────────────────────────────────────────── */
.graph-page { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.graph-header {
  padding: 1rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.graph-header h1 { font-size: 1.4rem; font-weight: 800; margin-bottom: 0.25rem; }
.graph-header p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.78rem; }
.graph-legend-item { display: flex; align-items: center; gap: 0.3rem; color: var(--text-muted); }
.graph-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
#graph-container { flex: 1; overflow: hidden; background: var(--bg-alt); }
.graph-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  pointer-events: none;
  max-width: 280px;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  color: var(--text);
}

/* ── Authors Page ────────────────────────────────────────── */
.authors-page { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.authors-header { margin-bottom: 2rem; }
.authors-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.authors-header p { color: var(--text-muted); margin-bottom: 1rem; }
.authors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.author-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: box-shadow 0.2s;
}
.author-card:hover { box-shadow: var(--shadow-md); }
.author-name { font-weight: 700; font-size: 0.92rem; margin-bottom: 0.2rem; }
.author-count { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.author-papers { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* ── Timeline Page ───────────────────────────────────────── */
.timeline-page { max-width: 900px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.timeline-header { margin-bottom: 2rem; }
.timeline-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.timeline-header p { color: var(--text-muted); }
.timeline-decade { margin-bottom: 2.5rem; }
.decade-label {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.3rem;
  margin-bottom: 1rem;
}
.timeline-year { margin-bottom: 1.25rem; }
.timeline-year-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.timeline-papers { list-style: none; }
.timeline-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item a { color: var(--accent); flex: 1; }
.timeline-meta { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }

/* ── Methods Page ────────────────────────────────────────── */
.methods-page { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.methods-header { margin-bottom: 2rem; }
.methods-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.methods-header p { color: var(--text-muted); }
.methods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.methods-table th {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 700;
}
.methods-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
}
.methods-table tr:nth-child(even) td { background: var(--bg-alt); }
.methods-best { font-weight: 700; color: var(--text); }
.method-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.method-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: box-shadow 0.2s;
}
.method-card:hover { box-shadow: var(--shadow-md); }
.method-card-header { margin-bottom: 0.6rem; }
.method-name { font-weight: 700; font-size: 0.95rem; }
.method-task { font-size: 0.8rem; color: var(--text-muted); }
.method-acc { font-size: 1.1rem; font-weight: 800; color: var(--green); margin: 0.2rem 0; }
.method-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; margin-bottom: 0.75rem; }
.method-link { font-size: 0.83rem; color: var(--accent); font-weight: 600; }
