@font-face {
  font-family: "TsangerJinKai02";
  src: url("https://cdn.jsdelivr.net/gh/AlfredoSequeworthy/TsangerJinKai02@main/TsangerJinKai02-W04.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "TsangerJinKai02";
  src: url("https://cdn.jsdelivr.net/gh/AlfredoSequeworthy/TsangerJinKai02@main/TsangerJinKai02-W05.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --parchment: #f5f4ed;
  --ivory: #faf9f5;
  --warm-sand: #e8e6dc;
  --brand: #1b365d;
  --brand-light: #2d5a8a;
  --brand-tint: #eef2f7;
  --near-black: #141413;
  --dark-warm: #3d3d3a;
  --olive: #504e49;
  --stone: #6b6a64;
  --border: #e8e6dc;
  --border-soft: #e5e3d8;
  --serif: "TsangerJinKai02", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "STSong", Georgia, serif;
  --mono: "JetBrains Mono", "SF Mono", Consolas, "TsangerJinKai02", "Source Han Serif SC", monospace;
  --ui: "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--parchment);
  color: var(--near-black);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.76;
  letter-spacing: .025em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-light); }
img, svg { max-width: 100%; }
button, input { font: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.skip-link { position: fixed; left: 12px; top: -80px; z-index: 100; padding: 8px 12px; background: var(--brand); color: var(--ivory); }
.skip-link:focus { top: 12px; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--parchment) 94%, transparent);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(12px);
}
.site-brand { display: flex; align-items: center; gap: 10px; color: var(--near-black); text-decoration: none; }
.site-brand img { width: 28px; height: 28px; }
.site-brand strong { font-weight: 500; }
.site-nav { display: flex; gap: 22px; align-items: center; font-family: var(--ui); font-size: 14px; }
.site-nav a { color: var(--olive); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--brand); }

.home { max-width: 1180px; margin: 0 auto; padding: 92px 56px 120px; }
.hero { min-height: 560px; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); gap: 72px; align-items: center; border-bottom: 1px solid var(--border); }
.eyebrow { margin: 0 0 18px; color: var(--brand); font: 500 12px/1.4 var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: 0 0 24px; font-size: clamp(54px, 7vw, 88px); line-height: 1.05; font-weight: 500; letter-spacing: 0; }
.hero .lede { margin: 0; max-width: 720px; color: var(--olive); font-size: 21px; line-height: 1.65; }
.hero-actions { display: flex; gap: 14px; margin-top: 34px; font-family: var(--ui); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 24px; border: 1px solid var(--brand); border-radius: 999px; text-decoration: none; }
.button.primary { color: var(--ivory); background: var(--brand); }
.button.secondary { color: var(--brand); background: transparent; }
.hero-map { padding: 28px; background: var(--ivory); border-left: 2px solid var(--brand); border-radius: 6px; }
.hero-map h2 { margin: 0 0 12px; font-size: 24px; font-weight: 500; }
.hero-map p { margin: 0; color: var(--olive); font-size: 15px; }
.hero-map ol { margin: 24px 0 0; padding-left: 26px; }
.hero-map li { padding: 8px 0; border-bottom: 1px solid var(--border-soft); }

.home-section { padding: 88px 0 0; }
.section-head { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 36px; margin-bottom: 36px; }
.section-no { color: var(--brand); font: 500 12px/1.5 var(--ui); letter-spacing: .12em; }
.section-head h2 { margin: 0 0 12px; font-size: 42px; line-height: 1.2; font-weight: 500; }
.section-head p { margin: 0; max-width: 760px; color: var(--olive); }
.system-figure { margin: 0; padding: 18px 0 0; }
.system-figure figcaption, .kami-figure figcaption { margin: 14px auto 0; max-width: 820px; color: var(--olive); font-size: 14px; line-height: 1.6; }

.part-list { border-top: 1px solid var(--border); }
.part { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 36px; padding: 36px 0; border-bottom: 1px solid var(--border); }
.part-index { color: var(--brand); font: 500 13px/1.4 var(--ui); }
.part h3 { margin: 0 0 10px; font-size: 28px; font-weight: 500; }
.part-intro { margin: 0 0 18px; color: var(--olive); }
.chapter-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.chapter-links a { display: grid; grid-template-columns: 38px 1fr; gap: 8px; padding: 11px 0; border-top: 1px solid var(--border-soft); color: var(--dark-warm); text-decoration: none; }
.chapter-links b { color: var(--brand); font: 500 12px/1.8 var(--ui); }

.catalog { max-width: 1180px; margin: 0 auto; padding: 76px 56px 120px; }
.catalog-hero { margin-bottom: 54px; }
.catalog-hero h1 { margin: 0 0 16px; font-size: 58px; line-height: 1.1; font-weight: 500; }
.catalog-hero p { max-width: 780px; margin: 0; color: var(--olive); font-size: 19px; }
.search { display: grid; grid-template-columns: 1fr auto; gap: 14px; margin: 30px 0 54px; }
.search input { min-height: 52px; padding: 0 16px; color: var(--near-black); background: var(--ivory); border: 1px solid var(--border); border-radius: 4px; outline: none; }
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.search-status { align-self: center; color: var(--stone); font: 400 13px/1.4 var(--ui); }
.catalog .part[hidden] { display: none; }
.chapter-links a[hidden] { display: none; }

.book-shell { max-width: 1240px; margin: 0 auto; padding: 52px 32px 112px; display: grid; grid-template-columns: 224px minmax(0, 760px); gap: 68px; justify-content: center; align-items: start; }
.book-sidebar { position: sticky; top: 92px; max-height: calc(100svh - 120px); overflow: auto; padding-right: 16px; scrollbar-width: thin; }
.sidebar-label { margin: 0 0 16px; color: var(--stone); font: 500 11px/1.4 var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.book-sidebar section { margin-bottom: 22px; }
.book-sidebar h2 { margin: 0 0 6px; color: var(--olive); font: 500 12px/1.5 var(--ui); }
.book-sidebar a { display: block; padding: 5px 8px 5px 12px; border-left: 2px solid transparent; color: var(--stone); font-size: 13px; line-height: 1.45; text-decoration: none; }
.book-sidebar a:hover { color: var(--dark-warm); }
.book-sidebar a[aria-current="page"] { color: var(--brand); border-left-color: var(--brand); }

.chapter { min-width: 0; }
.chapter-header { margin-bottom: 38px; padding-bottom: 34px; border-bottom: 1px solid var(--border); }
.chapter-meta { margin: 0 0 14px; color: var(--brand); font: 500 12px/1.4 var(--ui); letter-spacing: .1em; }
.chapter h1 { margin: 0 0 20px; font-size: 52px; line-height: 1.15; font-weight: 500; letter-spacing: 0; }
.chapter-summary { margin-top: 24px; padding: 22px 24px; background: var(--ivory); border-left: 2px solid var(--brand); border-radius: 4px; }
.chapter-summary > span { display: block; margin-bottom: 8px; color: var(--brand); font: 500 11px/1.4 var(--ui); letter-spacing: .12em; }
.chapter-claim { margin: 0; color: var(--dark-warm); font-size: 22px; line-height: 1.65; }
.chapter-stats { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 20px; color: var(--stone); font: 400 12px/1.5 var(--ui); }
.on-page { margin: 32px 0 44px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.on-page h2 { margin: 0 0 8px; color: var(--stone); font: 500 11px/1.4 var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.on-page ol { margin: 0; padding-left: 22px; columns: 2; column-gap: 34px; }
.on-page li { break-inside: avoid; font-size: 14px; color: var(--olive); }

.prose h2 { margin: 64px 0 18px; font-size: 34px; line-height: 1.25; font-weight: 500; scroll-margin-top: 92px; }
.prose h3 { margin: 44px 0 14px; font-size: 24px; line-height: 1.35; font-weight: 500; scroll-margin-top: 92px; }
.prose h4 { margin: 32px 0 12px; font-size: 19px; line-height: 1.4; font-weight: 500; }
.prose p { margin: 0 0 22px; }
.prose a { overflow-wrap: anywhere; word-break: break-word; }
.prose strong { font-weight: 500; color: var(--brand); }
.prose ul, .prose ol { margin: 0 0 26px; padding-left: 28px; }
.prose li { margin: 7px 0; }
.prose li::marker { color: var(--brand); }
.prose blockquote { margin: 32px 0; padding: 5px 0 5px 20px; border-left: 2px solid var(--brand); color: var(--olive); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { padding: 2px 6px; border-radius: 3px; color: var(--brand); background: var(--brand-tint); font: .84em/1.5 var(--mono); }
.prose pre { margin: 28px 0; padding: 18px 20px; overflow-x: auto; background: var(--ivory); border-radius: 4px; }
.prose pre code { padding: 0; color: var(--near-black); background: none; }
.prose table { width: 100%; margin: 30px 0; border-collapse: collapse; font-size: 15px; }
.table-scroll { width: 100%; overflow-x: auto; }
.prose th { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--dark-warm); text-align: left; font-weight: 500; }
.prose td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.equation { margin: 30px 0; padding: 24px 18px; overflow-x: auto; background: var(--ivory); border-radius: 4px; text-align: center; font-family: var(--mono); letter-spacing: 0; }
.source-list { margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--border); }
.source-list h2 { margin-top: 0; }

.kami-figure { margin: 42px 0 52px; }
.kami-figure svg { display: block; width: 100%; height: auto; background: var(--parchment); }
.figure-title { font-family: var(--ui); letter-spacing: .12em; }
.figure-node-title { font-family: var(--serif); font-weight: 500; }
.figure-node-note { font-family: var(--ui); }
.figure-caption-label { color: var(--brand); font-family: var(--ui); font-size: 12px; letter-spacing: .08em; }

.chapter-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 72px; padding-top: 22px; border-top: 1px solid var(--border); }
.chapter-pager a { color: var(--brand); text-decoration: none; }
.chapter-pager a:last-child { text-align: right; }
.chapter-pager small { display: block; margin-bottom: 4px; color: var(--stone); font: 500 10px/1.4 var(--ui); letter-spacing: .12em; text-transform: uppercase; }

.site-footer { max-width: 1180px; margin: 0 auto; padding: 34px 56px 56px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 30px; color: var(--stone); font-size: 13px; }
.site-footer p { margin: 0; }

@media (max-width: 880px) {
  body { font-size: 16px; line-height: 1.72; }
  .site-header { position: static; padding: 10px 24px; }
  .site-nav { gap: 14px; font-size: 13px; }
  .home, .catalog { padding: 58px 28px 88px; }
  .hero { min-height: auto; grid-template-columns: 1fr; gap: 48px; padding-bottom: 68px; }
  .hero h1 { font-size: 58px; }
  .section-head, .part { grid-template-columns: 1fr; gap: 8px; }
  .chapter-links { grid-template-columns: 1fr; }
  .book-shell { display: block; padding: 0 22px 80px; }
  .book-sidebar { position: static; max-height: none; display: flex; gap: 6px; overflow-x: auto; margin: 0 -22px 38px; padding: 12px 22px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
  .book-sidebar::-webkit-scrollbar { display: none; }
  .book-sidebar .sidebar-label, .book-sidebar h2 { display: none; }
  .book-sidebar section { display: contents; }
  .book-sidebar a { flex: 0 0 auto; padding: 8px 4px; border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .book-sidebar a[aria-current="page"] { border-bottom-color: var(--brand); }
  .chapter h1 { font-size: 42px; }
  .on-page { display: none; }
}

@media (max-width: 480px) {
  .site-brand span { display: none; }
  .home, .catalog { padding-left: 20px; padding-right: 20px; }
  .hero h1 { font-size: 48px; }
  .hero .lede { font-size: 18px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .section-head h2 { font-size: 34px; }
  .catalog-hero h1 { font-size: 44px; }
  .search { grid-template-columns: 1fr; }
  .chapter h1 { font-size: 36px; }
  .chapter-claim { font-size: 19px; }
  .prose h2 { font-size: 29px; }
  .prose h3 { font-size: 22px; }
  .prose table { display: block; overflow-x: auto; white-space: nowrap; }
  .chapter-pager { grid-template-columns: 1fr; }
  .chapter-pager a:last-child { text-align: left; }
  .site-footer { padding: 28px 20px 42px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
