:root {
  --bg: #070b16;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.11);
  --text: #edf2fb;
  --muted: #9aa7bf;
  --accent: #5eead4;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  width: 720px;
  height: 720px;
  top: -300px;
  right: -260px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  filter: blur(120px);
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }

.container { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }

.chapter-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 22, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.chapter-header .container { display: flex; align-items: center; justify-content: space-between; gap: 20px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.back-link:hover { color: var(--text); border-color: var(--accent); }

.header-brand { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.header-brand b { color: var(--accent); letter-spacing: 0.1em; font-size: 12px; }

.chapter-main { padding: 64px 0 96px; }

.chapter-intro {
  position: relative;
  padding: 38px;
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.018));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.chapter-intro::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  top: -140px;
  right: -110px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.1;
  filter: blur(26px);
}
.chapter-badge {
  display: inline-block;
  padding: 5px 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.chapter-intro h1 {
  margin: 18px 0 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}
.chapter-intro p { max-width: 760px; margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.chapter-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chapter-tags span {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.chapter-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.chapter-index a {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.chapter-index a:hover { color: var(--text); border-color: var(--accent); }
.chapter-index a.current {
  color: #07131b;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 44px 0 18px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.viz-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.viz-grid .wide { grid-column: 1 / -1; }

.viz-card {
  margin: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.viz-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-3px); }
.viz-card figcaption { margin-bottom: 14px; }
.viz-card h2 { margin: 0; font-size: 17px; }
.viz-card p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }

.chart {
  width: 100%;
  min-height: 220px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(6, 10, 20, 0.5);
  padding: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.chart svg { display: block; width: 100%; height: auto; max-height: 400px; }
.chart.is-rendered svg { animation: chartIn 0.7s ease both; }
@keyframes chartIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.note {
  margin: 18px 0 0;
  padding: 14px 18px;
  border-left: 2px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.note code { color: var(--accent); font-family: Consolas, Monaco, monospace; font-size: 12px; }

.chapter-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; margin-top: 46px; }
.chapter-nav a {
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.chapter-nav a:hover { background: var(--surface-strong); border-color: var(--accent); }
.chapter-nav .next { border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }

.site-footer { border-top: 1px solid var(--border); padding: 32px 0; color: var(--muted); font-size: 12px; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }

@media (max-width: 880px) {
  .viz-grid { grid-template-columns: 1fr; }
  .viz-grid .wide { grid-column: auto; }
  .chapter-intro { padding: 28px; }
}

@media (max-width: 560px) {
  .container { width: calc(100% - 32px); }
  .header-brand { display: none; }
  .chapter-main { padding: 42px 0 72px; }
  .viz-card { padding: 16px; }
  .chart { padding: 4px; min-height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
