:root {
  --bg: #07090f;
  --bg-elev: #0e1320;
  --bg-card: #121829;
  --bg-code: #060911;
  --border: rgba(148, 163, 184, 0.16);
  --border-gold: rgba(245, 158, 11, 0.42);
  --border-cyan: rgba(56, 189, 248, 0.42);
  --text: #eef2ff;
  --text-soft: #cbd5e1;
  --muted: #8b9bb4;
  --gold: #f59e0b;
  --gold-bright: #fbbf24;
  --cyan: #38bdf8;
  --emerald: #34d399;
  --rose: #fb7185;
  --violet: #a78bfa;
  --reader-size: 17px;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-code: #0f172a;
  --border: rgba(15, 23, 42, 0.11);
  --border-gold: rgba(217, 119, 6, 0.4);
  --border-cyan: rgba(2, 132, 199, 0.35);
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --gold: #d97706;
  --gold-bright: #b45309;
  --cyan: #0284c7;
  --emerald: #059669;
  --rose: #e11d48;
  --violet: #7c3aed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Progress Bar */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--cyan), var(--emerald));
  z-index: 100;
  transition: width 0.08s linear;
}

/* Sticky Top Promo + Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7, 9, 15, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.92);
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
}
.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--cyan));
  color: #050811;
  font-weight: 900;
  font-size: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.3);
}
.brand-text strong {
  display: block;
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.brand-text span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s;
}
.nav-tab:hover { background: var(--bg-card); color: var(--text); }
.nav-tab.active {
  background: rgba(245, 158, 11, 0.14);
  border-color: var(--border-gold);
  color: var(--gold-bright);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctrl-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-soft);
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.ctrl-btn:hover { border-color: var(--border-cyan); color: var(--text); }

.cta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  color: #041016 !important;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none !important;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.28);
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.cta-pill:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(56, 189, 248, 0.42); }
.cta-pill.gold {
  background: linear-gradient(135deg, var(--gold), #f97316);
  color: #090c14 !important;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.3);
}
.cta-pill.ghost {
  background: transparent;
  border: 1px solid var(--border-cyan);
  color: var(--cyan) !important;
  box-shadow: none;
}

/* Hero Banner */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse 70% 60% at 20% 10%, rgba(245, 158, 11, 0.14), transparent 65%),
    radial-gradient(ellipse 65% 60% at 85% 20%, rgba(56, 189, 248, 0.14), transparent 65%),
    var(--bg);
}
.hero-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 52px 20px 44px;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-gold);
  background: rgba(245, 158, 11, 0.1);
  color: var(--gold-bright);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(32px, 5.2vw, 56px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.hero h1 .hl-gold {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero h1 .hl-cyan {
  background: linear-gradient(135deg, #38bdf8, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  max-width: 820px;
  font-size: 16.5px;
  color: var(--text-soft);
  margin-bottom: 26px;
}
.hero-ctas {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 12px;
}
.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 16px;
}
.stat-box .num {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold-bright);
  line-height: 1.25;
}
.stat-box .num.cyan { color: var(--cyan); }
.stat-box .num.rose { color: var(--rose); }
.stat-box .num.emerald { color: var(--emerald); }
.stat-box .lbl { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* Main Container */
.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}
.section-pane { display: none; }
.section-pane.active { display: block; }

/* Reader Layout (Novel) */
.reader-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.toc-sidebar {
  position: sticky;
  top: 76px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.toc-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toc-list { display: flex; flex-direction: column; gap: 5px; }
.toc-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.14s;
}
.toc-item:hover { background: rgba(148, 163, 184, 0.08); color: var(--text); }
.toc-item.active {
  background: rgba(245, 158, 11, 0.14);
  border-color: var(--border-gold);
  color: var(--text);
}
.toc-item .ch-num { display: block; font-size: 11px; color: var(--gold); font-weight: 700; }
.toc-item .ch-name { display: block; font-size: 13px; font-weight: 650; line-height: 1.35; margin-top: 2px; }

.toc-promo {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(155deg, rgba(56, 189, 248, 0.14), rgba(52, 211, 153, 0.08));
  border: 1px solid var(--border-cyan);
  font-size: 12.5px;
}
.toc-promo strong { display: block; color: var(--text); font-size: 13.5px; margin-bottom: 5px; }
.toc-promo p { color: var(--text-soft); margin-bottom: 10px; line-height: 1.55; }

/* Article Card */
.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 40px;
}
.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.13);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.tag.gold { background: rgba(245, 158, 11, 0.13); color: var(--gold-bright); border-color: rgba(245, 158, 11, 0.3); }
.tag.emerald { background: rgba(52, 211, 153, 0.13); color: var(--emerald); border-color: rgba(52, 211, 153, 0.3); }
.tag.rose { background: rgba(251, 113, 133, 0.13); color: var(--rose); border-color: rgba(251, 113, 133, 0.3); }

.article-card h2.ch-heading {
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 10px;
}
.ch-subtitle {
  font-size: 15px;
  color: var(--muted);
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}

.prose {
  font-size: var(--reader-size);
  color: var(--text-soft);
}
.prose p { margin-bottom: 18px; text-align: justify; }
.prose h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 30px 0 14px;
  padding-left: 12px;
  border-left: 4px solid var(--gold);
}
.prose h4 {
  font-size: 16.5px;
  font-weight: 750;
  color: var(--cyan);
  margin: 22px 0 10px;
}
.prose strong { color: var(--text); }
.prose ul, .prose ol { margin: 12px 0 18px 22px; }
.prose li { margin-bottom: 8px; }

.callout {
  margin: 24px 0;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--border-cyan);
  background: rgba(56, 189, 248, 0.07);
}
.callout.gold { border-color: var(--border-gold); background: rgba(245, 158, 11, 0.08); }
.callout.rose { border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.08); }
.callout.emerald { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.callout-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-box {
  margin: 20px 0;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg-code);
  overflow: hidden;
}
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.copy-btn {
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
}
.code-box pre {
  padding: 15px 16px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
}
code.inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: rgba(148, 163, 184, 0.14);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--gold-bright);
}

.formula-box {
  margin: 18px 0;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--bg-code);
  border: 1px solid var(--border-gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: #fde68a;
  text-align: center;
  overflow-x: auto;
}

/* Chapter Footer AI CTA + Prev/Next */
.chapter-ai-box {
  margin-top: 32px;
  padding: 22px 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(52, 211, 153, 0.08));
  border: 1px solid var(--border-cyan);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chapter-ai-box h4 { color: var(--text); font-size: 16px; margin: 0; }
.chapter-ai-prompt {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  font-size: 13px;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chapter-ai-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.chapter-nav {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ch-nav-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.ch-nav-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-bright); }
.ch-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 18px 0;
  border-radius: 13px;
  border: 1px solid var(--border);
}
table.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}
table.info-table th, table.info-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.info-table th {
  background: rgba(245, 158, 11, 0.1);
  color: var(--text);
  font-weight: 750;
}
table.info-table tr:last-child td { border-bottom: none; }

/* Evidence Grid */
.evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin: 20px 0;
}
.evidence-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.evidence-card img {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  object-position: top;
  display: block;
  border-bottom: 1px solid var(--border);
}
.evidence-cap {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
}

/* Timeline */
.timeline {
  position: relative;
  margin: 22px 0;
  padding-left: 24px;
  border-left: 2px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.tl-item { position: relative; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -31px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}
.tl-date { font-size: 12.5px; font-weight: 800; color: var(--gold-bright); }
.tl-title { font-size: 16px; font-weight: 800; color: var(--text); margin: 2px 0 4px; }
.tl-desc { font-size: 14px; color: var(--text-soft); }

/* Labs */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}
.lab-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lab-card.full { grid-column: 1 / -1; }
.lab-card h3 { font-size: 19px; font-weight: 850; color: var(--text); }
.lab-desc { font-size: 13.5px; color: var(--muted); }
.slider-row { display: flex; flex-direction: column; gap: 6px; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--cyan); }
.lab-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.metric-pill {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.metric-pill .k { font-size: 11.5px; color: #94a3b8; }
.metric-pill .v { font-size: 18px; font-weight: 850; margin-top: 3px; font-family: ui-monospace, Menlo, monospace; }
.metric-pill .v.danger { color: var(--rose); }
.metric-pill .v.safe { color: var(--emerald); }
.metric-pill .v.cyan { color: var(--cyan); }

.lab-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-code);
  color: #e2e8f0;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
}
.checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 10px;
}
.chk-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-soft);
}
.chk-item input { margin-top: 4px; accent-color: var(--emerald); width: 16px; height: 16px; flex-shrink: 0; }
.chk-item.checked { border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.08); color: var(--text); }

/* Bottom Mega Funnel to cLnAi.io */
.mega-funnel {
  margin-top: 46px;
  border-radius: 22px;
  padding: 36px 32px;
  background:
    radial-gradient(circle at 15% 20%, rgba(56, 189, 248, 0.22), transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(52, 211, 153, 0.18), transparent 50%),
    var(--bg-card);
  border: 1px solid var(--border-cyan);
  text-align: center;
}
.mega-funnel h2 { font-size: clamp(22px, 3.2vw, 32px); font-weight: 900; margin-bottom: 12px; }
.mega-funnel p { max-width: 760px; margin: 0 auto 22px; color: var(--text-soft); font-size: 15.5px; }
.funnel-features {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.funnel-btns { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 20px 44px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.site-footer p { margin-bottom: 6px; }

/* Mobile */
@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; }
  .toc-sidebar { position: static; max-height: none; }
  .article-card { padding: 22px 18px; }
  .header-inner { padding: 10px 14px; }
  .nav-tab { padding: 6px 10px; font-size: 12.5px; }
  .hero-inner { padding: 34px 16px 30px; }
  .mega-funnel { padding: 26px 18px; }
}
