:root {
  --bg: #0c0a12;
  --bg-soft: #130f1d;
  --panel: #171325;
  --panel-hover: #1f1a2f;
  --text: #e7e3f0;
  --text-muted: #938fad;
  --border: #2a2440;
  --primary: #7351cf;
  --primary-hover: #8b6ce6;
  --accent: #f5a0b8;
  --radius: 2px;
  --nav-height: 52px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Menlo", "Consolas", "Noto Sans SC", system-ui, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; }

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  border-bottom: 1px solid var(--border);
  background: rgba(12, 10, 18, 0.85);
  backdrop-filter: blur(10px);
}
.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 28px; image-rendering: pixelated; }
.brand-text { font-weight: 700; letter-spacing: 0.05em; color: var(--primary); }
.nav-links { display: flex; gap: 8px; }
.nav-link {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: .15s;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--panel); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-small { padding: 6px 12px; font-size: 12px; background: var(--panel); color: var(--text); border-color: var(--border); }
.btn-small:hover { background: var(--panel-hover); }

/* Landing */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing-wrap { flex: 1; max-width: 760px; margin: 0 auto; padding: 60px 20px 40px; text-align: center; }
.hero-logo { width: 140px; image-rendering: pixelated; }
.hero-title { margin: 24px 0 8px; font-size: 42px; letter-spacing: 0.08em; color: var(--text); }
.hero-desc { margin: 0; font-size: 16px; color: var(--text-muted); }
.hero-meta { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); }
.hero-actions { margin-top: 40px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.stats-grid { margin-top: 48px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-num { font-size: 36px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { margin-top: 8px; font-size: 13px; color: var(--text-muted); }
.intro { margin-top: 40px; color: var(--text-muted); font-size: 14px; line-height: 1.9; }

/* Page layout */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; }
.page-header { margin-bottom: 28px; }
.page-title { margin: 0 0 8px; font-size: 28px; color: var(--text); }
.page-subtitle { margin: 0; color: var(--text-muted); font-size: 14px; }

/* Articles list */
.articles-toolbar { margin-bottom: 24px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.article-search-input {
  flex: 1;
  min-width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}
.article-search-input:focus { outline: none; border-color: var(--primary); }
.articles-filter { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  background: var(--panel);
}
.filter-chip:hover, .filter-chip.active { border-color: var(--primary); color: var(--text); }
.articles-grid { display: grid; gap: 14px; }
.article-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: .15s;
}
.article-card:hover { border-color: var(--primary); background: var(--panel-hover); }
.article-card-title { margin: 0 0 8px; font-size: 16px; color: var(--text); }
.article-card-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.article-card-excerpt { margin: 10px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* Article detail */
.article-detail { max-width: 840px; }
.article-inner { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.back-link { display: inline-block; margin-bottom: 20px; font-size: 13px; color: var(--text-muted); }
.back-link:hover { color: var(--primary); }
.article-header { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.article-title { margin: 0 0 12px; font-size: 26px; line-height: 1.4; }
.article-meta { font-size: 13px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.article-meta .sep { color: var(--border); }
.article-body { font-size: 15px; color: #d9d4e8; }
.article-body h1 { font-size: 22px; margin: 32px 0 16px; color: var(--text); }
.article-body h2 { font-size: 19px; margin: 28px 0 14px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.article-body h3 { font-size: 16px; margin: 24px 0 12px; color: var(--text); }
.article-body p { margin: 14px 0; line-height: 1.85; }
.article-body a { text-decoration: underline; text-underline-offset: 3px; }
.article-body ul, .article-body ol { margin: 14px 0; padding-left: 24px; }
.article-body li { margin: 6px 0; }
.article-body blockquote { margin: 18px 0; padding-left: 16px; border-left: 3px solid var(--primary); color: var(--text-muted); font-style: italic; }
.article-body code { background: rgba(115,81,207,.15); padding: 2px 5px; border-radius: 2px; font-size: 13px; color: var(--accent); }
.article-body pre { background: var(--bg-soft); padding: 16px; border-radius: var(--radius); overflow-x: auto; }
.article-body pre code { background: transparent; padding: 0; color: var(--text); }
.article-body img { border-radius: var(--radius); margin: 18px 0; }
.article-body table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 13px; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.article-body th { background: var(--bg-soft); }
.article-nav { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 16px; }
.article-nav a { font-size: 13px; color: var(--text-muted); }
.article-nav a:hover { color: var(--primary); }
.article-nav-next { text-align: right; }

/* Graph */
.graph-body { overflow: hidden; }
.graph-main { position: fixed; inset: var(--nav-height) 0 0 0; display: flex; }
.graph-canvas { flex: 1; background: var(--bg); position: relative; }
.graph-ui {
  width: 300px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.graph-panel { padding: 14px; border-bottom: 1px solid var(--border); }
.graph-panel h3 { margin: 0 0 10px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 6px 0; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.graph-search { position: relative; }
#node-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}
#node-search:focus { outline: none; border-color: var(--primary); }
.search-results { position: absolute; top: 100%; left: 0; right: 0; max-height: 220px; overflow-y: auto; background: var(--bg-soft); border: 1px solid var(--border); z-index: 50; margin-top: 4px; }
.search-result { padding: 8px 10px; font-size: 12px; cursor: pointer; color: var(--text); }
.search-result:hover { background: var(--panel-hover); }
.search-result-type { font-size: 10px; color: var(--text-muted); margin-left: 4px; }
.graph-controls { display: flex; gap: 8px; }
.lb-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px; }
.lb-tab { padding: 6px 4px; font-size: 11px; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; border-radius: var(--radius); }
.lb-tab:hover, .lb-tab.active { border-color: var(--primary); color: var(--text); }
.lb-list { display: flex; flex-direction: column; gap: 2px; }
.lb-item { display: flex; align-items: center; gap: 8px; padding: 7px 6px; font-size: 12px; cursor: pointer; border-radius: var(--radius); }
.lb-item:hover { background: var(--panel-hover); }
.lb-rank { width: 20px; text-align: center; color: var(--text-muted); font-size: 11px; }
.lb-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.lb-badge { font-size: 9px; padding: 1px 5px; border-radius: 2px; color: #fff; }
.lb-count { width: 28px; text-align: right; color: var(--text-muted); font-size: 10px; }
.entity-drawer {
  position: fixed;
  top: var(--nav-height);
  right: 300px;
  width: 320px;
  bottom: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 60;
}
.entity-drawer.open { transform: translateX(0); }
.drawer-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; }
.drawer-title { margin: 0 0 6px; font-size: 18px; }
.drawer-type { font-size: 11px; color: #fff; padding: 2px 8px; border-radius: 2px; display: inline-block; margin-bottom: 12px; }
.drawer-desc { font-size: 13px; color: var(--text-muted); line-height: 1.7; margin-bottom: 18px; }
.drawer-stat { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.drawer-section-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 0 8px; }
.drawer-link { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0; color: var(--text); }
.drawer-link span.type { font-size: 10px; color: var(--text-muted); }
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(12,10,18,.92);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
  z-index: 70;
  display: none;
  max-width: 220px;
}
.graph-tooltip .tt-type { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 30px 20px; text-align: center; }
.footer-inner { max-width: 1100px; margin: 0 auto; }
.site-footer p { margin: 0; font-size: 13px; color: var(--text-muted); }
.footer-sub { margin-top: 6px; font-size: 11px; }

/* Responsive */
@media (max-width: 900px) {
  .graph-main { flex-direction: column; }
  .graph-canvas { height: 60vh; flex: none; }
  .graph-ui { width: 100%; height: 40vh; border-left: none; border-top: 1px solid var(--border); }
  .entity-drawer { right: 0; width: 80%; }
  .hero-title { font-size: 32px; }
  .stats-grid { grid-template-columns: 1fr; }
  .article-inner { padding: 20px; }
}
