/* ============================================
   葬AI Web4 — Redesigned Static Theme
   Dark purple editorial · brand #7351cf
   ============================================ */

:root {
  --bg: #0c0814;
  --bg-2: #130e1f;
  --bg-card: #18122a;
  --bg-hover: #1f1838;
  --border: #2a2142;
  --border-light: #3a2f56;
  --text: #e6ddf2;
  --text-muted: #9485b0;
  --text-dim: #6a5e84;
  --primary: #7351cf;
  --primary-light: #9d7ef0;
  --primary-glow: rgba(115, 81, 207, 0.35);
  --accent: #e05599;
  --accent-glow: rgba(224, 85, 153, 0.3);
  --cyan: #4ec9e8;
  --amber: #f0a838;
  --green: #4ed88a;
  --red: #e8554e;
  --radius: 4px;
  --radius-lg: 8px;
  --max-w: 1200px;
  --header-h: 56px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Menlo", "Consolas", monospace;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

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

a { color: var(--primary-light); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }

::selection { background: var(--primary); color: #fff; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(12, 8, 20, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--max-w);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo:hover { color: var(--primary-light); }
.logo-mark {
  display: inline-block;
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius);
  position: relative;
}
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--bg);
  border-radius: 2px;
}
.main-nav {
  display: flex;
  gap: 4px;
}
.main-nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius);
  transition: all .2s;
}
.main-nav a:hover { color: var(--text); background: var(--bg-hover); }
.main-nav a.active { color: var(--primary-light); background: rgba(115, 81, 207, 0.12); }

/* ===== Layout ===== */
.page-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ===== Homepage Hero ===== */
.hero {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 60%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
}
.hero::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  top: 30%; left: 60%;
  pointer-events: none;
  z-index: 0;
}
.hero-content { position: relative; z-index: 1; }
.hero-tagline-top {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--primary-light) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin-bottom: 8px;
}
.hero-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.hero-desc {
  color: var(--text-dim);
  font-size: 0.85rem;
  max-width: 480px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 640px;
  margin: 0 auto 40px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  text-align: center;
  transition: all .3s;
}
.stat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.stat-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-light);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* CTA buttons */
.cta-group {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  transition: all .25s;
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-light);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
}

/* Recent articles on homepage */
.recent-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: '';
  width: 3px; height: 18px;
  background: var(--primary);
  border-radius: 2px;
}
.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 32px;
}
.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary-light); }
.breadcrumb span { margin: 0 6px; }

/* ===== Graph Page ===== */
.graph-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.graph-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .2s;
}
.graph-search:focus { border-color: var(--primary); }
.graph-search::placeholder { color: var(--text-dim); }

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}
.chip:hover { border-color: var(--border-light); color: var(--text); }
.chip.active { color: #fff; border-color: transparent; }
.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.graph-wrapper {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 600px;
}
#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
#graph-canvas:active { cursor: grabbing; }

.graph-overlay-controls {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.graph-btn {
  width: 32px; height: 32px;
  background: rgba(24, 18, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.graph-btn:hover { color: var(--text); border-color: var(--border-light); }

.graph-loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Node detail panel */
.node-detail {
  position: absolute;
  bottom: 12px; left: 12px;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: rgba(24, 18, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  font-size: 0.85rem;
  display: none;
}
.node-detail.visible { display: block; }
.node-detail h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.node-detail .type-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.node-detail p {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.6;
  margin-bottom: 8px;
}
.node-detail .meta-line {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.node-detail-close {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.node-detail-close:hover { color: var(--text); }

/* Graph legend */
.graph-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

/* ===== Leaderboards ===== */
.leaderboard-section {
  margin-top: 48px;
}
.lb-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.lb-tab {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font-sans);
  margin-bottom: -1px;
}
.lb-tab:hover { color: var(--text); }
.lb-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
}
.lb-panel { display: none; }
.lb-panel.active { display: block; }

.lb-table {
  width: 100%;
  border-collapse: collapse;
}
.lb-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.lb-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: middle;
}
.lb-table tr:hover td { background: var(--bg-hover); }
.lb-rank {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dim);
  width: 40px;
}
.lb-table tr:nth-child(1) .lb-rank { color: var(--amber); }
.lb-table tr:nth-child(2) .lb-rank { color: var(--cyan); }
.lb-table tr:nth-child(3) .lb-rank { color: var(--accent); }
.lb-name {
  font-weight: 600;
  color: var(--text);
}
.lb-desc {
  color: var(--text-muted);
  font-size: 0.78rem;
  max-width: 320px;
  line-height: 1.5;
}
.lb-num {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--primary-light);
}
.lb-bar {
  width: 60px;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.lb-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
}

/* ===== Article List ===== */
.article-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box input::placeholder { color: var(--text-dim); }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.author-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.article-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  transition: all .2s;
}
.article-card:hover { padding-left: 8px; }
.article-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 36px;
  padding-top: 2px;
}
.article-body { flex: 1; min-width: 0; }
.article-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.5;
}
.article-card:hover .article-title { color: var(--primary-light); }
.article-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.article-author {
  color: var(--accent);
  font-weight: 500;
}
.article-excerpt {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-date { font-family: var(--font-mono); }

.no-results {
  text-align: center;
  padding: 48px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ===== Article Detail ===== */
.article-detail {
  max-width: 760px;
  margin: 0 auto;
}
.article-detail-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.article-detail-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.article-detail-title {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 12px;
}
.article-detail-meta {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  align-items: center;
}
.article-detail-meta .author {
  color: var(--accent);
  font-weight: 600;
}

/* Markdown rendered content */
.article-content {
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--text);
}
.article-content h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 32px 0 16px;
  line-height: 1.4;
}
.article-content h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 28px 0 14px;
}
.article-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 24px 0 12px;
}
.article-content p {
  margin-bottom: 16px;
}
.article-content ul, .article-content ol {
  margin: 0 0 16px 20px;
}
.article-content li {
  margin-bottom: 6px;
}
.article-content strong {
  color: var(--primary-light);
  font-weight: 600;
}
.article-content em {
  font-style: italic;
  color: var(--text-muted);
}
.article-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 8px 16px;
  margin: 16px 0;
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
}
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--cyan);
}
.article-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}
.article-content pre code {
  background: none;
  padding: 0;
  color: var(--text);
}
.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}
.article-content a {
  color: var(--primary-light);
  text-decoration: underline;
  text-decoration-color: var(--border-light);
  text-underline-offset: 2px;
}
.article-content a:hover {
  text-decoration-color: var(--primary-light);
}
.article-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 16px 0;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}
.article-content th, .article-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  font-size: 0.875rem;
}
.article-content th {
  background: var(--bg-card);
  font-weight: 600;
}

/* Entities box */
.entities-box {
  margin-top: 40px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.entities-box h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}
.entity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.entity-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.entity-tag .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

/* Prev/Next nav */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.article-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all .2s;
  max-width: 48%;
}
.article-nav a:hover {
  border-color: var(--primary);
}
.article-nav .nav-label {
  font-size: 0.72rem;
  color: var(--text-dim);
}
.article-nav .nav-title {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}
.article-nav .next { text-align: right; margin-left: auto; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.site-footer a { color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .header-inner { padding: 0 16px; }
  .main-nav a { padding: 6px 10px; font-size: 0.8rem; }
  .page-container { padding: 32px 16px 64px; }
  .graph-wrapper { height: 400px; }
  .node-detail { width: calc(100% - 24px); }
  .lb-desc { display: none; }
  .recent-list { grid-template-columns: 1fr; }
  .article-card { gap: 12px; }
  .hero h1 { font-size: 2.5rem; }
}
