/* A2P2 whitepaper style · JD red documentation theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --topbar-h: 54px;
  --sidebar-w: 420px;
  --toc-w: 320px;
  --content-max: 1280px;
  --layout-max: 2020px;

  --jd-red: #C91C19;
  --jd-red-dark: #9F1718;
  --jd-red-soft: #FFF3F2;
  --jd-red-line: #F3C9C5;

  --title: #242424;
  --text: #3F3F46;
  --muted: #737373;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --subtle: #f7f9fc;
  --subtle-2: #FAFAFA;
  --border: #E5E5E5;
  --border-strong: #D4D4D4;

  --accent: var(--jd-red);
  --accent-dark: var(--jd-red-dark);
  --accent-light: var(--jd-red-soft);
  --danger: #C81E1E;
  --warning: #A16207;
  --success: #15803D;
  --ai: #7C3AED;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html { scroll-behavior: smooth; font-size: 16px; }
body {
  min-height: 100vh;
  padding-top: var(--topbar-h);
  display: flex;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid rgba(201, 28, 25, .26); outline-offset: 2px; }

/* Top navigation */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 300;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  background: var(--jd-red);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(16,42,99,0.08);
}
.topbar-inner {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, auto);
  align-items: center;
  gap: 24px;
}
.topbar-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-logo {
  width: 136px;
  height: 20px;
  flex: 0 0 136px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.topbar-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: left center;
}
.topbar-title {
  font-size: 18px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateY(2px);
}
.topbar-meta { justify-self: end; display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }
.topbar-action-btn {
  height: 32px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 6px;
  color: #FFFFFF;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.topbar-action-btn:hover {
  background: rgba(255, 255, 255, .12);
  transform: translateY(-1px);
}

/* JDT-inspired top navigation prototype */
.topbar-jdt {
  height: 92px;
  display: flex;
  align-items: stretch;
  color: var(--title);
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
}
.topbar-jdt-inner {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 96px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  gap: 46px;
}
.a2p2-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.a2p2-logo-mark {
  color: var(--jd-red);
  font-size: 36px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}
.a2p2-logo-text {
  display: grid;
  gap: 2px;
  color: var(--title);
  white-space: nowrap;
}
.a2p2-logo-title {
  font-size: 24px;
  font-weight: 750;
  line-height: 1.08;
}
.a2p2-logo-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
}
.topbar-jdt-nav {
  display: flex;
  align-items: center;
  gap: 38px;
}
.topbar-jdt-nav a {
  color: #3F3F46;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}
.topbar-jdt-nav a:hover,
.topbar-jdt-nav a.active { color: var(--jd-red); }
.topbar-jdt-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0;
}
.topbar-jdt-platform {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 30px;
  color: var(--jd-red);
  font-size: 16px;
  white-space: nowrap;
}
.topbar-jdt-platform::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}
.topbar-jdt-cta {
  min-width: 202px;
  padding: 0 28px;
  display: grid;
  align-content: center;
  gap: 7px;
  color: #FFFFFF;
  background: var(--jd-red);
}
.topbar-jdt-cta span {
  font-size: 16px;
  font-weight: 750;
  line-height: 1;
}
.topbar-jdt-cta strong {
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}
.topbar-jdt-preview-page {
  min-height: 100vh;
  padding: 0;
  display: block;
  background: #f7f9fc;
}
.topbar-jdt-preview-hero {
  min-height: 320px;
  display: grid;
  place-items: center;
  color: #FFFFFF;
  background: #252525;
}
.topbar-jdt-preview-copy {
  max-width: 760px;
  padding: 0 24px;
  text-align: center;
}
.topbar-jdt-preview-copy h1 {
  margin-bottom: 14px;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.22;
}
.topbar-jdt-preview-copy p {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  font-size: 16px;
  line-height: 1.7;
}

/* Layout */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: max(0px, calc((100vw - var(--layout-max)) / 2));
  z-index: 100;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 54px 22px 44px 106px;
  background: #FFFFFF;
}
#main {
  flex: 1;
  display: flex;
  justify-content: center;
  margin-left: var(--sidebar-w);
  margin-right: var(--toc-w);
}
.main-inner {
  width: 100%;
  max-width: var(--content-max);
  padding: 48px 42px 96px;
}
#toc {
  position: fixed;
  top: var(--topbar-h);
  right: max(0px, calc((100vw - var(--layout-max)) / 2));
  width: var(--toc-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 54px 62px 44px 0;
  background: #FFFFFF;
}

/* Sidebar */
#sidebar nav::before {
  content: "A2P2 · Agent Autonomous Payment\A Protocol";
  display: block;
  margin-bottom: 20px;
  color: #6B7280;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-line;
}
#sidebar nav ul { list-style: none; }
#sidebar nav li { margin: 0 0 12px; }
#sidebar nav a {
  display: block;
  color: #52525B;
  font-size: 14px;
  line-height: 1.52;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#sidebar nav a:hover { color: var(--jd-red); }
#sidebar nav a.active { color: var(--jd-red); font-weight: 650; }
.nav-num { color: inherit; font-weight: inherit; }

/* Right TOC */
.toc-card { padding: 0; border: 0; box-shadow: none; background: transparent; }
.toc-card .toc-title {
  margin-bottom: 20px;
  color: #6B7280;
  font-size: 13px;
  font-weight: 700;
}
.toc-card ul { list-style: none; }
.toc-card li { margin-bottom: 16px; }
.toc-card li:last-child { margin-bottom: 0; }
.toc-card a {
  display: block;
  color: #52525B;
  font-size: 13px;
  line-height: 1.52;
}
.toc-card a:hover,
.toc-card li.active a { color: var(--jd-red); }
.toc-card li.active a { font-weight: 550; }

/* Typography */
p { margin-bottom: 14px; color: var(--text); font-size: 16px; line-height: 1.72; }
strong { color: var(--title); font-weight: 700; }
h4,
h4.sub-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 10px;
  color: var(--title);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.35;
}
.section-badge {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-grid;
  place-items: center;
  color: var(--jd-red);
  background: var(--jd-red-soft);
  border: 1px solid var(--jd-red-line);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.chapter-header {
  margin-bottom: 32px;
  padding: 0 0 26px;
  border-bottom: 1px solid var(--border);
}
.chapter-title {
  margin-bottom: 14px;
  color: var(--title);
  font-size: 36px;
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.01em;
}
.chapter-number { color: var(--jd-red); font-weight: 700; margin-right: 10px; }
.chapter-rule {
  width: 64px;
  height: 3px;
  margin: 0 0 18px;
  background: var(--jd-red);
  border-radius: 999px;
}
.chapter-tagline {
  max-width: 100%;
  padding: 0;
  margin: 0;
  color: #5F6368;
  background: transparent;
  border: 0;
  font-size: 16px;
  line-height: 1.72;
}
.section { margin-bottom: 56px; scroll-margin-top: calc(var(--topbar-h) + 24px); }
h3.subsection-title {
  margin: 42px 0 18px;
  color: var(--title);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}
h3.subsection-title::after { display: none; }

/* Blocks */
.insight-box,
.scope-card,
.perspective-card,
.thing-card,
.decision-card,
.scenario-box,
.compare-block,
.level-card,
.token-feature,
.disclosure-level,
.note,
.push-flow,
.table-wrap,
.trust-card,
.abstract,
.lead-box,
.quote-box,
.threat-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.insight-box,
.compare-block,
.scenario-box,
.note,
.lead-box,
.quote-box {
  margin: 18px 0 24px;
  padding: 18px 20px;
}
.note { color: var(--text); font-size: 15px; line-height: 1.72; }
.note::before { display: none; }
.insight-box .insight-label,
.scope-card .scope-label,
.perspective-card .perspective-label,
.compare-block .compare-label,
.scenario-box .scenario-header {
  margin-bottom: 12px;
  color: var(--title);
  font-size: 16px;
  font-weight: 650;
}
.insight-box .insight-label::before,
.compare-block .compare-label::before { display: none; }
.insight-box p,
.compare-block p { margin-bottom: 8px; font-size: 16px; line-height: 1.72; }
.insight-box p:last-child,
.compare-block p:last-child { margin-bottom: 0; }

/* Grids and cards */
.scope-grid,
.perspective-grid,
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 24px; }
.three-things,
.decision-grid,
.trust-grid,
.token-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 24px; }
.scope-card,
.perspective-card,
.thing-card,
.decision-card,
.level-card,
.trust-card,
.token-feature,
.disclosure-level { padding: 18px; }
.scope-card:hover,
.perspective-card:hover,
.thing-card:hover,
.decision-card:hover,
.level-card:hover,
.token-feature:hover,
.trust-card:hover { transform: none; box-shadow: none; }
.scope-card ul,
.perspective-card ul,
.scenario-box .step-list,
.boundary-list { list-style: none; padding: 0; }
.scope-card li,
.perspective-card li,
.scenario-box .step-list li,
.boundary-list li {
  position: relative;
  padding: 4px 0 4px 18px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
.scope-card li::before,
.perspective-card li::before,
.scenario-box .step-list li::before,
.boundary-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 4px;
  color: var(--jd-red);
  font-weight: 700;
}
.scope-card.is li,
.scope-card.not li {
  padding-left: 28px;
}
.scope-card.is li::before,
.scope-card.not li::before {
  top: 4px;
  color: inherit;
  font-size: 15px;
  line-height: 1.6;
}
.scope-card.is li::before { content: "✓"; color: var(--danger); font-weight: 700; }
.scope-card.not li::before { content: "✕"; color: var(--danger); font-weight: 700; }
.thing-card .thing-num,
.thing-card .thing-title,
.decision-card .dc-label,
.trust-label,
.tf-label,
.dl-name {
  color: var(--title);
  font-weight: 650;
}
.thing-card p,
.decision-card p,
.trust-card p,
.tf-desc,
.dl-desc { margin: 0; font-size: 15px; line-height: 1.65; }
.trust-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.trust-icon { display: none; }
.trust-label { display: inline-block; border-left: 3px solid var(--jd-red); padding: 4px 10px; background: #fff; font-size: 18px; font-weight: 650; }

/* Bullet list items (蓝点列表) */
.bullet-p { margin-bottom: 4px; margin-left: 24px; }
.bullet-p.last { margin-bottom: 12px; }
.bullet-dot { color: var(--accent); font-size: 22px; line-height: 1; }

#main .main-inner > ul,
#main .main-inner .section ul {
  margin: 8px 0 28px 42px;
  padding-left: 18px;
}
#main .main-inner > ul li,
#main .main-inner .section ul li {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.78;
}
#main .main-inner > ul li::marker,
#main .main-inner .section ul li::marker {
  color: var(--jd-red);
  font-size: 0.78em;
}
#main .main-inner .section ul + .a2p2-table-title {
  margin-top: 20px;
}

/* h4 red-bar sub-heading (红线小标题) */
.red-bar { display: inline-block; border-left: 3px solid var(--jd-red); padding: 4px 10px; background: #fff; margin: 26px 0 10px; font-weight: 650; }

/* A2P2 Table Card (方案1) */
.a2p2-table-title { margin: 0 0 12px; display: flex; align-items: center; gap: 10px; color: #0f234a; font-size: 16px; font-weight: 700; }
.a2p2-table-title::before { content: ""; width: 5px; height: 18px; border-radius: 999px; background: var(--jd-red); display: inline-block; }
.a2p2-table-card { background: #fff; border: 1px solid #e7ecf3; border-radius: var(--radius); box-shadow: 0 10px 26px rgba(16,42,99,0.055); overflow: hidden; margin-bottom: 24px; }
.a2p2-table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: auto; background: #fff; }
.a2p2-table thead th { padding: 10px 14px; background: #fff; color: #0f234a; font-size: 15px; font-weight: 700; text-align: left; border-bottom: 1px solid #e7ecf3; white-space: nowrap; line-height: 1.82; }
.a2p2-table tbody td { padding: 10px 14px; vertical-align: top; color: #2b3445; font-size: 15px; line-height: 1.82; border-bottom: 1px solid #f3f6fa; background: #fff; }
.a2p2-table tbody td:first-child { color: #0f234a; font-weight: 600; white-space: nowrap; }
.a2p2-table tbody tr:last-child td { border-bottom: none; }
.a2p2-table tbody tr:hover td { background: #fbfcfe; }
.a2p2-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.a2p2-badge-final { color: #0f6b46; background: rgba(18,165,107,0.10); border: 1px solid rgba(18,165,107,0.20); }
.a2p2-badge-temp { color: #b54708; background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.24); }

/* Settlement Flow Cards */
.settlement-flow-card { margin: 22px 0 30px; padding: 12px 14px; border: 1px solid #e7ecf3; border-radius: var(--radius); background: #fff; box-shadow: 0 10px 28px rgba(16,42,99,0.045); }
.settlement-flow-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.flow-tag { display: inline-flex; align-items: center; height: 30px; padding: 0 13px; border-radius: 999px; background: #FFF3F2; color: #d71920; font-size: 14px; font-weight: 700; white-space: nowrap; }
.settlement-flow-head p { margin: 0; color: #667085; font-size: 14px; line-height: 1.6; }
.settlement-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.flow-step { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 10px; border: 1px solid #e5ebf4; border-radius: 999px; background: #fff; box-shadow: none; color: #0f234a; font-size: 12.5px; line-height: 1.35; white-space: nowrap; font-weight: 400; }
.flow-step span { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 20px; padding: 0 6px; border-radius: 999px; background: rgba(200, 30, 30, 0.08); color: var(--jd-red); font-size: 11px; font-weight: 700; }
.flow-step strong { font-weight: 400; }
.settlement-flow i { color: #8b98ad; font-style: normal; font-size: 18px; font-weight: 700; line-height: 1; }

/* Result Compare Cards */
.compare-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 18px 0 24px; }
.result-card { border: 1px solid #e7ecf3; border-radius: var(--radius); background: #fff; box-shadow: 0 10px 26px rgba(16,42,99,0.055); overflow: hidden; }
.result-card-head { padding: 14px 20px; border-bottom: 1px solid #eef2f7; background: #fbfcfe; display: flex; align-items: center; justify-content: space-between; }
.result-card-head h3 { margin: 0; color: #0f234a; font-size: 19px; font-weight: 700; }
.result-card-body { padding: 20px; display: grid; gap: 16px; }
.mini-block b { display: block; margin-bottom: 6px; color: var(--jd-red); font-size: 14px; font-weight: 700; }
.mini-block span { display: block; color: var(--text); font-size: 15px; line-height: 1.75; }
.result-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.result-badge-final { color: #0f6b46; background: rgba(18,165,107,0.10); border: 1px solid rgba(18,165,107,0.20); }
.result-badge-temp { color: #b54708; background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.24); }

/* Tables */
.table-wrap {
  margin: 22px 0 30px;
  overflow-x: auto;
}
.table-wrap table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 15px;
}
.table-wrap thead th {
  padding: 14px 16px;
  color: var(--title);
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 650;
  white-space: nowrap;
}
.table-wrap tbody tr { border-bottom: 1px solid var(--border); }
.table-wrap tbody tr:last-child { border-bottom: 0; }
.table-wrap tbody tr:hover { background: #FFF8F7; }
.table-wrap tbody td {
  padding: 9px 16px;
  color: var(--text);
  vertical-align: top;
  line-height: 1.62;
}
.table-wrap tbody td:first-child { color: var(--title); font-weight: 600; }
.highlight-row td { color: var(--title) !important; font-weight: 650 !important; background: #FFF8F7; }

/* Flow */
.anchor-chain {
  counter-reset: chain-step;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  margin: 18px 0 24px;
  color: #333333;
  background: #fff;
  border: 1px solid #e7ecf3;
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(16,42,99,0.045);
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 400;
}
.push-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  margin: 18px 0 24px;
  color: #333333;
  font-size: 14px;
  line-height: 1.52;
}
.anchor-chain .chain-arrow {
  display: inline-flex;
  align-items: center;
  color: #8b98ad;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.anchor-chain .chain-node {
  counter-increment: chain-step;
  min-height: 30px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #0f234a;
  background: #fff;
  border: 1px solid #e5ebf4;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
}
.anchor-chain .chain-node::before {
  content: counter(chain-step, decimal-leading-zero);
  flex: 0 0 auto;
  color: var(--jd-red);
  background: rgba(200, 30, 30, 0.08);
  border: 0;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 24px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.chain-arrow,
.flow-arrow,
.state-item .arrow-sym {
  color: #333333;
  font-weight: 600;
}
.flow-node {
  padding: 4px 9px;
  color: #333333;
  background: var(--subtle-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.52;
  white-space: nowrap;
}
.state-map { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.state-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--title);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

/* Level and tokens */
.level-card.highlight { border-color: var(--jd-red-line); }
.level-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.level-badge,
.level-type {
  display: inline-block;
  padding: 2px 8px;
  color: var(--jd-red);
  background: var(--jd-red-soft);
  border: 1px solid var(--jd-red-line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 650;
}
.level-type { margin-left: 6px; }
.level-name { color: var(--title); font-size: 15px; font-weight: 650; }
.level-meta { display: grid; gap: 4px; }
.level-meta-item { color: var(--text); font-size: 14px; line-height: 1.55; }
.token-feature .tf-label { margin-bottom: 6px; }
.disclosure-level { margin: 10px 0; }

pre {
  margin: 14px 0 20px;
  padding: 16px;
  overflow-x: auto;
  color: var(--title);
  background: var(--subtle);
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
}
footer {
  margin-top: 56px;
  padding-top: 18px;
  color: #9CA3AF;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  line-height: 1.35;
}
footer p {
  margin: 0 !important;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}
footer p + p {
  margin-top: 3px !important;
}

/* Cover helpers */
.cover { border-bottom: 1px solid var(--border); }
.cover h1 .gradient-title { color: var(--title) !important; background: none !important; -webkit-text-fill-color: currentColor !important; }
.cover .meta span::before { display: none !important; }

/* Scrollbars */
#sidebar::-webkit-scrollbar,
#toc::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
#sidebar::-webkit-scrollbar-thumb,
#toc::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb { background: #D8D8D8; border-radius: 999px; }


/* Decision result badges */
.decision-result { display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 13px; font-weight: 650; margin: 0 2px; }
.decision-result.allow { color: #1a5c2a; border: 1px solid rgba(26,92,42,.18); background: rgba(26,92,42,.06); }
.decision-result.deny  { color: #8b2e2e; border: 1px solid rgba(139,46,46,.18); background: rgba(139,46,46,.06); }
.decision-result.stepup { color: #7a5a10; border: 1px solid rgba(122,90,16,.18); background: rgba(122,90,16,.06); }

/* Scope card blue variant */
.scope-card.blue { border-color: var(--accent); }

/* Level type variants */
.level-type.manual { color: var(--text); background: var(--subtle); border-color: var(--border); }
.level-type.assist { color: #7a5a10; background: rgba(122,90,16,.06); border-color: rgba(122,90,16,.18); }
.level-type.auto   { color: #1a5c6a; background: rgba(26,92,106,.06); border-color: rgba(26,92,106,.18); }

/* Flow compare panel */
.compare-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 18px 0 24px;
}
.flow-block + .flow-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf0f4;
}
.flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.flow-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 800;
  color: var(--title);
}
.flow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--jd-red);
  box-shadow: 0 0 0 4px var(--jd-red-soft);
}
.flow-dot.blue {
  background: #245a99;
  box-shadow: 0 0 0 4px #e1edf9;
}
.agent-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
.flow-stage {
  position: relative;
  min-height: 142px;
  padding: 12px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(16,42,99,0.055);
}
.flow-stage.short { min-height: 108px; }
.flow-stage:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-52%);
  color: #9aa3af;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  z-index: 2;
}
.stage-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 850;
  color: #245a99;
  background: #e1edf9;
  border: 1px solid #bfd4ee;
}
.stage-title.red {
  color: var(--jd-red);
  background: var(--jd-red-soft);
  border-color: #f0c5c5;
}
.stage-title.green {
  color: #2f735d;
  background: #e0f1e9;
  border-color: #c2e2d3;
}
.stage-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flow-insight {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px solid #edf0f4;
  color: #394150;
  font-size: 14px;
  line-height: 1.62;
}
.flow-insight strong {
  color: var(--jd-red);
}

/* Protocol meta cards */
.protocol-meta {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 0;
}
.meta-card {
  position: relative;
  min-height: 76px;
  padding: 13px 16px 12px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  overflow: hidden;
}
.meta-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--jd-red);
  opacity: .82;
}
.meta-label {
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  font-weight: 750;
}
.meta-value {
  font-size: 15px;
  line-height: 1.25;
  color: var(--title);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.meta-value.is-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.meta-value.status {
  color: var(--jd-red);
  background: transparent;
  border: 0;
}

/* Chain card - A2P2 protocol chain visualization */
.chain-card {
  background: #f7f8fa;
  border: 1px solid #eff1f5;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16,42,99,0.055);
  padding: 20px;
  margin: 24px 0;
}
.chain-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.title-wrap { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.title-bar { width: 5px; height: 30px; margin-top: 2px; border-radius: 2px; background: #c91f1f; flex: 0 0 auto; }
.chain-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 850; letter-spacing: -0.02em; }
.chain-subtitle { margin: 7px 0 0; color: #687485; font-size: 14px; max-width: 760px; }
.chain-tag {
  flex: 0 0 auto; display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border-radius: 5px; background: #fff4f4; border: 1px solid #f0d1d1; color: #a91515;
  font-size: 12px; font-weight: 800; white-space: nowrap;
}
.chain-flow {
  position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-top: 8px;
}
.step-card {
  position: relative; z-index: 1; min-height: 167px; padding: 14px 13px;
  border: 1px solid #e4e7ec; border-radius: 7px; background: #ffffff;
  box-shadow: 0 6px 18px rgba(16,42,99,0.055); display: flex; flex-direction: column;
}
.step-kicker {
  display: inline-flex; align-items: center; justify-content: center; height: 20px; padding: 0 6px;
  border-radius: 5px; background: #f1f3f6; border: 1px solid #e1e6ed; color: #56616f;
  font-size: 11px; font-weight: 850; letter-spacing: .01em; align-self: flex-start; text-align: center;
}
.step-card.is-key { background: #ffffff; border-color: #e4e7ec; box-shadow: 0 6px 18px rgba(16,42,99,0.055); }
.step-card.is-key .step-kicker { color: #56616f; background: #f1f3f6; border-color: #e1e6ed; }
.step-title { margin: 10px 0 5px; font-size: 16px; line-height: 1.35; font-weight: 850; color: #1f2933; }
.step-desc { margin: 8px 0 0; color: #1f2933; font-size: 12.5px; line-height: 1.55; font-weight: 600; }
.layer-meta { margin-top: auto; display: grid; gap: 7px; padding-top: 12px; }
.layer-row { padding: 8px 9px; border-radius: 6px; border: 1px solid #edf0f4; background: #fafbfc; }
.layer-label { margin-bottom: 5px; color: #7a8493; font-size: 11px; font-weight: 850; line-height: 1; }
.layer-value { color: #2f3744; font-size: 12.5px; font-weight: 650; line-height: 1.45; }
.output-pills { display: flex; flex-wrap: wrap; flex-direction: column; gap: 3px; min-height: 29px; }
.output-pill {
  display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px;
  border-radius: 5px; background: #ffffff; border: 1px solid #dfe4eb; color: #334155;
  font-size: 11.5px; font-weight: 750; line-height: 1.25; white-space: nowrap;
}
.step-card.is-key .output-pill { background: #ffffff; border-color: #dfe4eb; color: #334155; }
.step-card.is-key .layer-row { background: #fafbfc; border-color: #edf0f4; }
.evidence-layer {
  position: relative; margin-top: 14px; padding: 10px 12px; border-radius: 7px;
  border: 1px solid #c9daee; background: #eef4fb;
}
.evidence-layer::before { content: ""; position: absolute; left: 4%; right: 4%; top: -7px; height: 1px; border-top: 1px dashed #cdd3dc; }
.evidence-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: #244b82; font-size: 14px; font-weight: 850; }
.evidence-dot { width: 7px; height: 7px; border-radius: 50%; background: #2f5f9f; box-shadow: 0 0 0 3px #dfeaf7; flex: 0 0 auto; }
.evidence-grid { display: flex; flex-wrap: nowrap; gap: 6px; }
.evidence-item {
  flex: 1; padding: 6px 8px; border-radius: 5px; border: 1px solid #c9daee; background: #ffffff;
  color: #244b82; font-size: 12px; font-weight: 750; display: flex; align-items: center;
  justify-content: center; text-align: center;
}
.evidence-caption { margin-top: 6px; color: #687485; font-size: 12px; line-height: 1.55; font-weight: 600; }
.governance-band {
  margin-top: 8px; display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  padding: 10px 12px; border-radius: 7px; border: 1px solid #efd6d6; background: #fff8f8;
}
.gov-title {
  display: flex; align-items: center; gap: 6px;
  color: #a91515; font-size: 14px; font-weight: 850; line-height: 1.35;
}
.gov-dot { width: 7px; height: 7px; border-radius: 50%; background: #c91f1f; box-shadow: 0 0 0 3px #fdeaea; flex: 0 0 auto; }
.gov-items { display: flex; flex-wrap: nowrap; gap: 6px; }
.gov-item {
  flex: 1; padding: 6px 8px; border-radius: 5px; border: 1px solid #eadede; background: #ffffff;
  color: #a91515; font-size: 12px; font-weight: 750; display: flex; align-items: center;
  justify-content: center; text-align: center;
}
.chain-note {
  margin-top: 14px; padding: 12px 14px; border-radius: 7px;
  border: 1px solid #e4e7ec; background: #fafbfc; color: #3f4652; font-size: 13.5px; line-height: 1.65;
}
.chain-note strong { color: #a91515; font-weight: 850; }

/* Lightbox */
.img-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75);
  cursor: zoom-out; opacity: 0; transition: opacity .2s;
}
.img-lightbox.show { opacity: 1; }
.img-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 4px; box-shadow: 0 8px 40px rgba(0,0,0,.4); }
.main-inner img { cursor: zoom-in; }

/* Risk Feedback (7.3.2) */
.risk-feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 24px;
}
.risk-feedback-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(16,42,99,0.055);
  padding: 15px 16px 16px;
}
.risk-feedback-card { border-top: 1px solid var(--border); }
.rf-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.rf-card-title-wrap { display: flex; align-items: center; gap: 9px; }
.rf-dir-icon {
  width: 28px; height: 28px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; flex: 0 0 auto;
}
.rf-dir-icon.up-icon { background: #f3f7fd; border: 1px solid #d6e3f3; color: #244b82; }
.rf-dir-icon.down-icon { background: var(--jd-red-soft); border: 1px solid var(--jd-red-line); color: var(--jd-red-dark); }
.rf-card-title { margin: 0; color: #202733; font-size: 17px; font-weight: 800; line-height: 1.35; }
.rf-card-tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px;
  border-radius: 4px; background: var(--subtle-2); border: 1px solid var(--border);
  color: #667085; font-size: 11.5px; font-weight: 750; white-space: nowrap;
}
.rf-signal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.rf-signal-item {
  position: relative; padding-left: 16px;
  color: #3f4652; font-size: 13.5px; line-height: 1.65; font-weight: 500;
}
.rf-signal-item::before {
  content: ""; position: absolute; left: 0; top: 10px;
  width: 4px; height: 4px; border-radius: 50%;
}
.rf-signal-item.up-dot::before { background: #2f5f9f; }
.rf-signal-item.down-dot::before { background: var(--jd-red); }
.rf-loop {
  margin: 14px 0 24px; padding: 13px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fafafa;
  display: grid; grid-template-columns: 140px 1fr;
  gap: 12px; align-items: stretch;
}
.rf-loop-label {
  display: flex; align-items: center; gap: 8px;
  padding-right: 12px; border-right: 1px solid var(--border);
  color: #202733; font-size: 14px; font-weight: 800; line-height: 1.35;
}
.rf-loop-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--jd-red); box-shadow: 0 0 0 4px #fdeaea; flex: 0 0 auto;
}
.rf-loop-text {
  display: flex; align-items: center; margin: 0;
  color: #3f4652; font-size: 13.5px; line-height: 1.7; font-weight: 550;
}
.rf-loop-text strong { color: var(--jd-red-dark); font-weight: 850; }

/* Mermaid diagram cards */
.mermaid-card {
  margin: 22px 0 30px;
  padding: 22px 24px 24px;
  border: 1px solid #e7ecf3;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(16,42,99,0.055);
  overflow: hidden;
}
.mermaid-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.mermaid-card-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--jd-red-soft);
  color: var(--jd-red);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.mermaid-card-head h3 {
  margin: 0;
  color: var(--title);
  font-size: 19px;
  font-weight: 700;
}
.mermaid-card .mermaid {
  padding: 18px;
  border: 1px solid #e3ebf5;
  border-radius: var(--radius);
  background: #fbfcfe;
  overflow-x: auto;
  font-size: 13px;
}

/* API reference cards */
.api-card {
  margin: 22px 0 30px;
  padding: 22px 24px 24px;
  border: 1px solid #e7ecf3;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(16,42,99,0.055);
  overflow: hidden;
}
.api-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.api-card-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--jd-red-soft);
  color: var(--jd-red);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.api-card-head h3 {
  margin: 0;
  color: var(--title);
  font-size: 19px;
  font-weight: 700;
}
.endpoint-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 10px 0 16px;
  border: 1px solid #dbe6f3;
  border-radius: var(--radius);
  background: #f8fbff;
  font-family: var(--font-mono);
}
.method-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--jd-red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.endpoint-path {
  color: var(--title);
  font-size: 14px;
  font-weight: 600;
}
.code-label {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  margin: 14px 0 0;
  border-radius: 6px 6px 0 0;
  background: #1e293b;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
pre.code-block {
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid #1e293b;
  border-radius: 0 6px 6px 6px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.62;
  overflow-x: auto;
  tab-size: 2;
}
.code-block .json-key { color: #93c5fd; }
.code-block .json-string { color: #86efac; }
.code-block .json-number { color: #fbbf24; }
.code-block .json-bool { color: #fca5a5; }

/* Principle grid for ch08 */
.principle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0 24px;
}
.principle-grid .scope-card strong {
  display: block;
  margin-bottom: 6px;
}
.principle-grid .scope-card span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ── Hamburger button ── */
.topbar-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.15);
  cursor: pointer;
  flex-shrink: 0;
}
.topbar-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .22s ease, opacity .22s ease;
}
.sidebar-open .topbar-hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.sidebar-open .topbar-hamburger span:nth-child(2) {
  opacity: 0;
}
.sidebar-open .topbar-hamburger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,.42);
}
.sidebar-overlay.show { display: block; }

/* ══════════════════════════════
   Responsive — 三档断点
   桌面: > 1024px  (默认，无 @media)
   平板: 601–1024px
   手机: ≤ 600px
   ══════════════════════════════ */

/* 平板 + 手机：隐藏固定侧栏和右侧 TOC，启用汉堡按钮 */
@media (max-width: 1024px) {
  #toc { display: none; }
  #main { margin-right: 0; }

  #sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 320px;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    overflow-y: auto;
    background: #fff;
    box-shadow: 2px 0 16px rgba(0,0,0,.12);
    padding: 40px 22px 44px 32px;
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
  }
  #main { margin-left: 0; }

  .topbar-hamburger { display: flex; }
  .topbar-meta { display: none; }
  .topbar-inner { grid-template-columns: 1fr auto; padding: 0 16px; gap: 12px; }
}

/* 平板专属微调 */
@media (min-width: 601px) and (max-width: 1024px) {
  .main-inner { padding: 36px 28px 80px; }
  .chapter-title { font-size: 30px; }
  h3.subsection-title { font-size: 22px; }
  .three-things,
  .decision-grid,
  .trust-grid,
  .token-features { grid-template-columns: repeat(2, 1fr); }
  .chain-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-flow { grid-template-columns: 1fr; }
  .flow-stage:not(:last-child)::after {
    content: "↓";
    right: 50%;
    top: auto;
    bottom: -25px;
    transform: translateX(50%);
  }
  .flow-stage { margin-bottom: 18px; }
  .gov-items { flex-wrap: wrap; }
  .evidence-grid { flex-wrap: wrap; }
  .chain-header { flex-direction: row; }
}

/* 手机 */
@media (max-width: 600px) {
  #sidebar { width: 280px; padding: 36px 18px 44px 24px; }

  body { display: block; }
  .topbar-inner { padding: 0 14px; }
  .topbar-title { font-size: 14px; }

  .main-inner { padding: 20px 16px 64px; }
  .chapter-title { font-size: 24px; }
  h3.subsection-title { font-size: 20px; }
  p { font-size: 15px; }

  .scope-grid,
  .perspective-grid,
  .level-grid,
  .three-things,
  .decision-grid,
  .trust-grid,
  .token-features,
  .compare-cards,
  .risk-feedback-grid { grid-template-columns: 1fr; }

  .chain-flow { grid-template-columns: 1fr; }
  .chain-header { flex-direction: column; }
  .agent-flow { grid-template-columns: 1fr; }
  .flow-stage:not(:last-child)::after {
    content: "↓";
    right: 50%;
    top: auto;
    bottom: -25px;
    transform: translateX(50%);
  }
  .flow-stage { margin-bottom: 18px; }
  .gov-title { border-right: 0; border-bottom: 1px solid #f0dddd; padding: 0 0 10px; }
  .gov-items { flex-wrap: wrap; }
  .evidence-grid { flex-wrap: wrap; }
  .rf-loop { grid-template-columns: 1fr; }
  .rf-loop-label { border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 10px; }

  .cover h1 { font-size: 24px !important; }
  .cover h1 .gradient-title { font-size: 28px !important; }
  .cover .meta { grid-template-columns: 1fr !important; }
  .overview-head { display: block; }
  .overview-note { display: block; margin-top: 4px; white-space: normal; }

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

/* 图片防溢出 */
.main-inner img { max-width: 100%; height: auto; }

@media print {
  .topbar,
  #sidebar,
  #toc { display: none !important; }
  body { display: block; padding-top: 0; color: #111; }
  #main { margin: 0; display: block; }
  .main-inner { max-width: none; padding: 0; }
}
