
:root {
  --bg: #0b0b0c;
  --bg-elev: #141416;
  --bg-card: #1a1a1d;
  --border: #2a2a2e;
  --text: #e8e8e8;
  --text-dim: #9ca3af;
  --accent: #ff2a2a;
  --accent-glow: rgba(255, 42, 42, 0.35);
  --cyan: #00f0ff;
  --gold: #ffd166;
  --purple: #b56bff;
  --radius: 6px;
  --maxw: 1180px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

.container { width: min(var(--maxw), 92vw); margin: 0 auto; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11,11,12,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 1.1rem;
  box-shadow: 0 0 14px var(--accent-glow);
}
.brand-text { color: var(--text); }
.nav-links { display: flex; gap: 28px; }
.nav-links a {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  position: relative;
  transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -8px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }

@media (max-width: 640px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 64px; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 4vw; border-bottom: 1px solid var(--border); }
  .nav-toggle { display: block; }
}

/* Hero / Page headers */
.page-hero { padding: 64px 0 40px; }
.page-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.page-hero p {
  margin: 0;
  color: var(--text-dim);
  font-size: 1.1rem;
  max-width: 640px;
}
.home-hero {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 0 60px;
}
.home-hero h1 {
  font-size: clamp(3rem, 10vw, 7rem);
  margin: 0;
  line-height: 0.95;
  letter-spacing: -0.06em;
}
.home-hero h1 .red { color: var(--accent); text-shadow: 0 0 40px var(--accent-glow); }
.home-hero .tagline {
  margin: 28px 0 0;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  color: var(--text-dim);
  max-width: 720px;
}
.home-hero .cta {
  margin-top: 40px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  transition: transform .15s, box-shadow .15s, background .15s;
  border: 1px solid transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 22px var(--accent-glow);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 64px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.stat-card:nth-child(2)::before { background: var(--cyan); box-shadow: 0 0 12px rgba(0,240,255,.35); }
.stat-card:nth-child(3)::before { background: var(--gold); box-shadow: 0 0 12px rgba(255,209,102,.35); }
.stat-card .num {
  font-family: var(--mono);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1;
}
.stat-card .label { color: var(--text-dim); font-size: 0.9rem; margin-top: 8px; }
@media (max-width: 640px) { .stats { grid-template-columns: 1fr; } }

/* Sections */
section { padding: 48px 0; }
.section-title {
  font-size: 1.6rem;
  margin: 0 0 20px;
  letter-spacing: -0.02em;
}
.section-lead { color: var(--text-dim); margin: 0 0 28px; max-width: 720px; }

/* Cards / Article list */
.searchbar {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 24px;
}
.searchbar:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.article-list { display: grid; gap: 14px; }
.article-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color .2s, transform .15s, box-shadow .2s;
}
.article-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.article-card h3 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.35; }
.article-card .meta { color: var(--text-dim); font-size: 0.85rem; font-family: var(--mono); }
.list-count { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 14px; }

/* Article detail */
.article-header { padding: 56px 0 28px; border-bottom: 1px solid var(--border); margin-bottom: 36px; }
.article-header h1 { margin: 0 0 14px; font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.15; }
.article-meta { color: var(--text-dim); font-family: var(--mono); font-size: 0.95rem; display: flex; gap: 18px; flex-wrap: wrap; }
.article-meta .author { color: var(--accent); }
.article-content {
  font-size: 1.08rem;
  max-width: 760px;
}
.article-content h1, .article-content h2, .article-content h3, .article-content h4 {
  margin: 1.6em 0 0.6em;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.article-content h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.article-content h3 { font-size: 1.25rem; }
.article-content p { margin: 0 0 1.1em; }
.article-content ul, .article-content ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.article-content li { margin: 0.25em 0; }
.article-content blockquote {
  margin: 1.4em 0;
  padding: 12px 20px;
  border-left: 4px solid var(--accent);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-style: italic;
}
.article-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.article-content code {
  font-family: var(--mono);
  background: rgba(255,255,255,.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.article-content pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
}
.article-content pre code { background: none; padding: 0; }
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.95em;
}
.article-content th, .article-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article-content th { background: var(--bg-elev); }
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 48px 0;
}
.article-nav a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .2s;
}
.article-nav a:hover { border-color: var(--accent); }
.article-nav .label { color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.article-nav .title { font-weight: 700; margin-top: 6px; }
@media (max-width: 640px) { .article-nav { grid-template-columns: 1fr; } }

/* Graph */
.graph-section { padding: 0; }
.graph-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.graph-stage { background: var(--bg); position: relative; min-height: 70vh; }
#graph-container { width: 100%; height: 70vh; }
#graph-container svg { display: block; width: 100%; height: 100%; }
.graph-controls {
  position: absolute;
  top: 14px; left: 14px;
  display: flex; gap: 8px; flex-wrap: wrap;
  z-index: 10;
}
.graph-controls input {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  min-width: 180px;
}
.graph-controls input:focus { outline: none; border-color: var(--accent); }
.graph-controls button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}
.graph-controls button:hover { border-color: var(--accent); color: var(--accent); }
.node-panel {
  background: var(--bg-elev);
  padding: 20px;
  overflow-y: auto;
  max-height: 70vh;
}
.node-panel.hidden { display: none; }
.node-panel h3 { margin: 0 0 12px; font-size: 1.25rem; }
.node-panel .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: var(--border);
}
.node-panel p { color: var(--text-dim); font-size: 0.95rem; margin: 0 0 14px; }
.node-panel .metric { font-family: var(--mono); font-size: 0.9rem; color: var(--text-dim); margin-bottom: 6px; }
.node-panel .related { margin-top: 18px; }
.node-panel .related h4 { margin: 0 0 10px; font-size: 0.95rem; color: var(--text); }
.node-panel .related a { display: block; color: var(--text-dim); font-size: 0.9rem; padding: 4px 0; border-bottom: 1px solid var(--border); }
.node-panel .related a:hover { color: var(--accent); }
.node-panel .related .rel-type { color: var(--text); font-weight: 700; }
.legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-top: 12px;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-dim); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
@media (max-width: 900px) {
  .graph-layout { grid-template-columns: 1fr; }
  .node-panel { max-height: none; border-top: 1px solid var(--border); }
}

/* Leaderboards */
.leaderboards-section { padding: 56px 0 80px; }
.leaderboards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.lb-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lb-card header { padding: 16px; border-bottom: 1px solid var(--border); }
.lb-card h3 { margin: 0; font-size: 1.1rem; }
.lb-card .count { color: var(--text-dim); font-size: 0.8rem; font-family: var(--mono); }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.lb-item:last-child { border-bottom: none; }
.lb-rank { font-family: var(--mono); color: var(--text-dim); font-weight: 700; }
.lb-name { font-weight: 600; }
.lb-score { font-family: var(--mono); color: var(--text-dim); font-size: 0.8rem; text-align: right; }
.lb-item:hover .lb-name { color: var(--accent); cursor: pointer; }
@media (max-width: 1080px) { .leaderboards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .leaderboards-grid { grid-template-columns: 1fr; } }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; text-align: center; color: var(--text-dim); font-size: 0.9rem; }

/* Utility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
