:root {
  --bg: #0b0e17;
  --bg-2: #10141f;
  --panel: #151a28;
  --panel-2: #1a2031;
  --border: #232b40;
  --border-2: #2e3852;
  --text: #e7ecf5;
  --muted: #94a0b8;
  --faint: #66708a;
  --accent: #6d8dff;
  --accent-2: #9d6dff;
  --cyan: #4ad3d9;
  --green: #4ade80;
  --amber: #fbbf24;
  --pink: #f472b6;
  --red: #f87171;
  --radius: 14px;
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Consolas", "Menlo", monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(700px 400px at 15% -5%, rgba(109,141,255,.18), transparent 60%),
    radial-gradient(700px 500px at 90% 5%, rgba(157,109,255,.16), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, rgba(74,211,217,.08), transparent 60%);
}

/* ---------- hero ---------- */
.hero { padding: 72px 0 40px; text-align: center; }
.hero-badge {
  display: inline-block; font-size: 13px; color: var(--accent);
  border: 1px solid var(--border-2); padding: 6px 14px; border-radius: 999px;
  background: rgba(109,141,255,.06); letter-spacing: .5px; margin-bottom: 22px;
}
.hero h1 { font-size: clamp(30px, 5vw, 54px); margin: 0 0 18px; letter-spacing: -1px; font-weight: 800; }
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { max-width: 780px; margin: 0 auto 30px; color: var(--muted); font-size: 16.5px; }
.hero-sub strong { color: var(--text); }
.hero-stats { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 22px; min-width: 118px;
}
.stat .num { font-size: 26px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat .lab { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- toc ---------- */
.toc {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 4px; justify-content: center; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 8px;
  background: rgba(11,14,23,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.toc a { padding: 6px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.toc a:hover { color: var(--text); background: var(--panel); text-decoration: none; }

/* ---------- sections ---------- */
.section { padding: 42px 0 10px; }
.sec-title { font-size: 25px; margin: 0 0 18px; font-weight: 800; letter-spacing: -.5px; }
.sec-title .en { font-size: 14px; color: var(--faint); font-weight: 500; margin-left: 10px; }

/* ---------- narrative ---------- */
.narrative {
  background: linear-gradient(160deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 28px;
  font-size: 15.5px; color: #cbd3e2;
}
.narrative p { margin: 0 0 14px; }
.narrative p:last-child { margin-bottom: 0; }
.narrative strong { color: var(--accent); }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border-2); }
.tl-year { position: relative; margin: 0 0 26px; }
.tl-year::before {
  content: ""; position: absolute; left: -23px; top: 10px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(109,141,255,.18);
}
.tl-label { font-size: 19px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.tl-label span { font-size: 12px; color: var(--faint); font-weight: 500; margin-left: 8px; }
.tl-items { display: flex; flex-wrap: wrap; gap: 8px; }
.tl-chip {
  display: inline-block; text-decoration: none; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 12px; font-size: 13.5px; color: #cdd6e6;
  transition: .15s;
}
.tl-chip:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.tl-chip .yr { color: var(--faint); margin-right: 6px; font-size: 11.5px; }

/* ---------- controls ---------- */
.controls { margin-bottom: 22px; }
.searchbox {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 16px; margin-bottom: 16px; max-width: 640px;
}
.searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,141,255,.12); }
.searchbox svg { color: var(--muted); flex: 0 0 auto; }
.searchbox input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 15px; font-family: var(--font); }
.searchbox input::placeholder { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  cursor: pointer; user-select: none; border-radius: 999px; padding: 6px 14px;
  font-size: 13.5px; border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  transition: .15s;
}
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on-tag { background: rgba(74,211,217,.14); border-color: var(--cyan); color: var(--cyan); }
.resultline { font-size: 13.5px; color: var(--faint); margin-bottom: 6px; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
.card {
  display: block; color: inherit; text-decoration: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.card-head { padding: 18px 20px 16px; cursor: pointer; }
.card-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.cat-badge { font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 3px 9px; border-radius: 6px; }
.cat-groundwork { background: rgba(74,222,128,.13); color: var(--green); }
.cat-recent { background: rgba(109,141,255,.15); color: var(--accent); }
.cat-benchmark { background: rgba(251,191,36,.13); color: var(--amber); }
.read-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.read-badge.unread { background: rgba(251,191,36,.16); color: var(--amber); border: 1px solid rgba(251,191,36,.3); }
.read-badge.read { background: rgba(74,222,128,.13); color: var(--green); border: 1px solid rgba(74,222,128,.3); }
.venue { font-size: 12px; color: var(--faint); }
.card-title { font-size: 18.5px; font-weight: 700; line-height: 1.35; margin: 0 0 4px; }
.card-title .zh { color: var(--muted); font-weight: 500; font-size: 15.5px; margin-left: 8px; }
.card-blurb { color: var(--muted); font-size: 14.5px; margin: 6px 0 0; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--faint); margin-top: 11px; }
.card-meta b { color: var(--muted); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.tag { font-size: 11.5px; color: var(--cyan); background: rgba(74,211,217,.08); border: 1px solid rgba(74,211,217,.18); padding: 2px 8px; border-radius: 6px; }
.expand-hint { margin-top: 10px; font-size: 12.5px; color: var(--accent); }

.card-body { border-top: 1px solid var(--border); padding: 20px 22px 22px; display: none; }
.card.open .card-body { display: block; }
.card-body h3.detail {
  font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--accent);
  margin: 20px 0 8px; border-left: 3px solid var(--accent); padding-left: 10px;
}
.card-body h3.detail:first-child { margin-top: 0; }
.card-body p { margin: 0 0 12px; color: #d3dae8; font-size: 15px; }
.card-body ul { margin: 0 0 12px; padding-left: 20px; }
.card-body li { margin: 4px 0; color: #d3dae8; font-size: 14.5px; }
.card-body .rich h4 { font-size: 15px; color: #c8d2ff; margin: 16px 0 8px; }
.card-body .rich p { margin: 0 0 12px; }
.card-body .rich ul { margin: 0 0 12px; padding-left: 20px; }
.card-body .rich li { margin: 4px 0; }
.card-body code { font-family: var(--mono); font-size: 13px; background: var(--bg-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; color: #ffd38a; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }
.abstract { font-size: 13.5px; color: var(--muted); font-style: italic; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 18px; margin: 6px 0 4px; }
.meta-grid .mi { font-size: 13.5px; color: var(--muted); }
.meta-grid .mi b { color: var(--text); font-weight: 600; }
.arlink { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 13.5px; }

/* ---------- guide ---------- */
.guide { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 30px; }
.guide ol { margin: 0; padding-left: 20px; }
.guide li { margin: 9px 0; color: #d3dae8; font-size: 15px; }
.guide b { color: var(--accent); }

footer { padding: 40px 22px 50px; text-align: center; color: var(--faint); font-size: 13px; }
footer p { margin: 4px 0; }

/* ---------- 右侧固定侧栏（首页与详情页共用） ---------- */
.lib-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 26px; align-items: start; }
.lib-main { min-width: 0; }
.lib-side { position: sticky; top: 60px; display: flex; flex-direction: column; gap: 16px; }
.side-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.side-title { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .4px; margin-bottom: 12px; }
.side-note { font-size: 12px; color: var(--faint); margin: 10px 0 0; line-height: 1.6; }
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item { display: flex; gap: 10px; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; transition: .15s; }
.rec-item:hover { border-color: var(--accent); text-decoration: none; }
.rec-rank { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 6px; background: rgba(109,141,255,.16); color: var(--accent); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rec-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rec-title { font-size: 13.5px; color: var(--text); font-weight: 600; line-height: 1.4; }
.rec-reason { font-size: 12px; color: var(--muted); }
.rec-empty { font-size: 13px; color: var(--faint); line-height: 1.7; padding: 6px 0; }
.rp-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.rp-bar { height: 8px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--border); overflow: hidden; }
.rp-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.ai-btn {
  width: 100%; margin-bottom: 10px; padding: 9px; border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: #fff;
  border: 1px solid transparent; background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.ai-btn:hover { opacity: .9; }
.ai-btn:disabled { opacity: .5; cursor: default; }
.rec-ai-note { font-size: 12px; color: #c084fc; margin: 2px 0 4px; }

@media (max-width: 1000px) {
  .lib-layout { grid-template-columns: 1fr; }
  .lib-side { position: static; }
}

@media (max-width: 640px) {
  .hero { padding-top: 48px; }
  .card-body { padding: 16px; }
  .narrative, .guide { padding: 20px; }
}
