:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --paper: #ffffff;
  --paper-soft: #f8fafc;
  --ink: #101827;
  --muted: #5b677a;
  --faint: #dbe4ef;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #b45309;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -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;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.72;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 10;
  transform: translateY(-160%);
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  padding: 28px 22px;
  background: #0f172a;
  color: #dbeafe;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #14b8a6, #3b82f6);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 14px;
  line-height: 1.2;
}

.brand div > span {
  color: #93a4bd;
  font-size: 12px;
  margin-top: 3px;
}

.toc {
  display: grid;
  gap: 2px;
}

.toc a {
  text-decoration: none;
  color: #cbd5e1;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.35;
}

.toc a:hover,
.toc a:focus {
  color: #fff;
  background: rgba(148, 163, 184, 0.14);
  outline: none;
}

.sidebar-note {
  margin-top: 28px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.2);
}

.sidebar-note span {
  display: block;
  color: #99f6e4;
  font-size: 13px;
  font-weight: 750;
}

.sidebar-note p {
  color: #cbd5e1;
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.6;
}

.content {
  width: min(100%, 1120px);
  min-width: 0;
  padding: 36px 42px 72px;
}

.hero-section,
.doc-section {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 0.88fr);
  gap: 28px;
  align-items: center;
  padding: 34px;
  overflow: hidden;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.lead {
  color: var(--muted);
  font-size: 18px;
  margin: 22px 0 0;
  max-width: 720px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.hero-actions a {
  text-decoration: none;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 750;
}

.hero-actions a:first-child {
  background: var(--ink);
  color: #fff;
}

.hero-actions a:last-child {
  border: 1px solid var(--faint);
  color: var(--ink);
  background: var(--paper-soft);
}

.hero-media {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--faint);
  background: var(--paper-soft);
}

.hero-media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.doc-section {
  margin-top: 20px;
  padding: 34px;
  scroll-margin-top: 24px;
}

.question-section {
  margin-top: 28px;
}

.section-head {
  max-width: 920px;
}

.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(25px, 3.2vw, 38px);
  line-height: 1.18;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.32;
}

p {
  margin: 0 0 14px;
}

ol,
ul {
  padding-left: 1.35rem;
  margin: 0;
}

li + li {
  margin-top: 8px;
}

.term {
  font-weight: 760;
  color: #0f766e;
}

.route-map {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.route-map div,
.checklist-grid div,
.report-grid article,
.query-logic div,
.comparison-card,
.formula-card,
.speech-box,
.note-block,
.final-note {
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: var(--paper-soft);
}

.route-map div {
  padding: 16px;
  min-height: 142px;
}

.route-map span,
.query-logic span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ccfbf1;
  color: #0f766e;
  font-weight: 850;
  font-size: 13px;
  margin-bottom: 12px;
}

.route-map strong {
  display: block;
  font-size: 17px;
  margin-bottom: 6px;
}

.route-map p,
.checklist-grid p,
.report-grid p,
.query-logic p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.note-block,
.final-note {
  margin-top: 22px;
  padding: 18px;
  border-color: #99f6e4;
  background: #f0fdfa;
}

.note-block p,
.final-note p {
  margin: 6px 0 0;
}

.answer-grid,
.split-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.answer-grid > article,
.split-list > article {
  min-width: 0;
}

.formula-card {
  padding: 18px;
  display: grid;
  gap: 10px;
  align-content: center;
}

.formula-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

code {
  font-family: var(--mono);
}

.formula-card code {
  display: block;
  padding: 12px;
  border-radius: 7px;
  color: #0f172a;
  background: #e2e8f0;
  white-space: normal;
}

.diagram-card {
  margin: 26px 0 0;
  padding: 16px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: #fff;
  overflow-x: auto;
}

.diagram-card figcaption,
.funnel figcaption,
.pyramid figcaption,
.line-chart figcaption {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

.svg-card rect {
  fill: #fff;
  stroke: #cbd5e1;
  stroke-width: 2;
}

.svg-card text:nth-of-type(1) {
  fill: #0f172a;
  font-size: 24px;
  font-weight: 850;
}

.svg-card text:not(:nth-of-type(1)) {
  fill: #475569;
  font-size: 15px;
}

.field-table-wrap {
  overflow-x: auto;
  margin-top: 22px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #e8eef6;
  vertical-align: top;
}

th {
  color: #334155;
  background: #f8fafc;
  font-size: 14px;
}

td {
  color: #334155;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.speech-box {
  margin-top: 22px;
  padding: 18px;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.speech-box h3 {
  color: #1d4ed8;
}

.speech-box p {
  margin-bottom: 0;
}

.funnel {
  margin: 24px 0 0;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--faint);
  background: linear-gradient(180deg, #f8fafc, #fff);
}

.funnel-row {
  height: 42px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 820;
  border-radius: 6px;
  background: linear-gradient(90deg, #0f766e, #2563eb);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.13);
}

.w100 { width: 100%; }
.w88 { width: 88%; }
.w74 { width: 74%; }
.w58 { width: 58%; }
.w43 { width: 43%; }
.w30 { width: 30%; }
.w18 { width: 18%; min-width: 116px; }

.decision-tree {
  margin: 24px 0;
}

.tree-root {
  width: min(420px, 100%);
  margin: 0 auto 18px;
  padding: 16px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #0f172a, #334155);
  border-radius: var(--radius);
  font-weight: 850;
}

.tree-branches,
.checklist-grid,
.report-grid,
.query-logic {
  display: grid;
  gap: 14px;
}

.tree-branches {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tree-branches div {
  padding: 16px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: #fff;
  border-top: 4px solid var(--accent);
}

.tree-branches p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.checklist-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.checklist-grid div,
.report-grid article,
.query-logic div {
  padding: 16px;
}

.comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.comparison-card {
  padding: 18px;
  min-height: 164px;
}

.comparison-card span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 760;
}

.comparison-card strong {
  display: block;
  font-size: 30px;
  margin: 8px 0 12px;
}

.comparison-card.bad {
  border-color: #fecaca;
  background: #fff7f7;
}

.comparison-card.bad strong {
  color: var(--danger);
}

.comparison-card.good {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.comparison-card.good strong {
  color: var(--accent);
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.metric-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: #0f172a;
  background: #e2e8f0;
  font-size: 13px;
  font-weight: 720;
}

.report-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 22px;
}

.report-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pyramid {
  margin: 24px auto 0;
  max-width: 820px;
}

.pyramid-level {
  min-height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  border-radius: 6px;
  color: #fff;
  font-weight: 820;
  text-align: center;
  padding: 0 14px;
}

.level-1 { width: 42%; background: #0f766e; }
.level-2 { width: 55%; background: #0d9488; }
.level-3 { width: 68%; background: #2563eb; }
.level-4 { width: 82%; background: #3b82f6; }
.level-5 { width: 96%; background: #64748b; }

.query-logic {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 22px;
}

pre {
  margin: 24px 0 0;
  padding: 0;
  overflow-x: auto;
  max-width: 100%;
  border-radius: var(--radius);
  background: #0f172a;
  border: 1px solid #1e293b;
}

pre code {
  display: block;
  padding: 20px;
  color: #dbeafe;
  font-size: 13px;
  line-height: 1.62;
}

.pipeline {
  margin: 24px 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.pipeline div {
  min-height: 76px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-weight: 820;
}

.pipeline span {
  display: none;
}

.reconcile-matrix {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.4fr);
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 24px 0;
  background: #fff;
}

.reconcile-matrix > div {
  padding: 14px 16px;
  border-bottom: 1px solid #e8eef6;
}

.reconcile-matrix > div:nth-child(odd):not(.matrix-head) {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 800;
}

.reconcile-matrix > div:nth-child(even) {
  color: var(--muted);
}

.reconcile-matrix .matrix-head {
  grid-column: 1 / -1;
  background: #0f172a;
  color: #fff;
  font-weight: 850;
}

.line-chart {
  margin: 24px 0 0;
  padding: 14px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: #fff;
  overflow-x: auto;
}

.cheatsheet ol {
  margin-top: 8px;
  display: grid;
  gap: 10px;
  list-style-position: inside;
  padding-left: 0;
}

.cheatsheet li {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--faint);
  background: var(--paper-soft);
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .toc {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 22px;
  }

  .hero-section {
    grid-template-columns: 1fr;
  }

  .route-map,
  .tree-branches,
  .checklist-grid,
  .report-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .content {
    padding: 14px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .hero-section,
  .doc-section {
    padding: 20px;
  }

  .toc,
  .route-map,
  .answer-grid,
  .split-list,
  .comparison,
  .report-grid,
  .report-grid.compact,
  .query-logic,
  .checklist-grid,
  .tree-branches,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .hero-media img {
    aspect-ratio: 16 / 10;
  }

  .route-map div {
    min-height: auto;
  }

  .funnel {
    padding: 16px 10px;
  }

  .funnel-row {
    width: 100%;
  }

  .pyramid-level {
    width: 100%;
  }

  .reconcile-matrix {
    grid-template-columns: 1fr;
  }

  .reconcile-matrix > div:nth-child(odd):not(.matrix-head) {
    border-bottom: 0;
  }

  .field-table-wrap,
  .diagram-card,
  .line-chart,
  pre {
    max-width: 100%;
  }

  .field-table-wrap table {
    width: 760px;
  }

  .diagram-card svg,
  .line-chart svg {
    min-width: 680px;
  }
}
