:root {
  --navy-950: #102a43;
  --navy-800: #1d4667;
  --teal-700: #087f8c;
  --teal-600: #1199a6;
  --teal-100: #dff3f3;
  --amber-600: #c87513;
  --amber-100: #fff1d2;
  --red-700: #a63f3f;
  --red-100: #fde9e7;
  --blue-100: #e9f1fb;
  --green-100: #e4f3eb;
  --ink: #24313d;
  --muted: #627180;
  --line: #d8e0e7;
  --line-dark: #bdc9d4;
  --paper: #fffefb;
  --canvas: #edf2f5;
  --sans: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --shadow: 0 18px 45px rgba(16, 42, 67, .09);
}

* { box-sizing: border-box; }

html {
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.88;
  scroll-behavior: smooth;
}

body { margin: 0; }

a { color: var(--teal-700); text-underline-offset: 3px; }
a:hover { color: var(--navy-800); }

.skip-link {
  position: fixed;
  z-index: 200;
  top: 8px;
  left: -999px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--navy-950);
  color: #fff;
  font-family: var(--sans);
}

.skip-link:focus { left: 8px; }

.reading-progress {
  position: fixed;
  z-index: 100;
  inset: 0 auto auto 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal-600), #e8a33a);
}

.topbar {
  position: sticky;
  z-index: 60;
  top: 0;
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px clamp(14px, 3vw, 36px);
  border-bottom: 1px solid rgba(189, 201, 212, .8);
  background: rgba(255, 254, 251, .96);
  box-shadow: 0 3px 18px rgba(16, 42, 67, .04);
  backdrop-filter: blur(12px);
  font-family: var(--sans);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--navy-950);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 10px 4px 10px 4px;
  background: var(--navy-950);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.brand-copy { min-width: 0; line-height: 1.3; }
.brand-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy span { display: block; color: var(--muted); font-size: .74rem; letter-spacing: .08em; }

.top-actions { display: flex; align-items: center; gap: 8px; }

.button,
.icon-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #fff;
  color: var(--navy-800);
  font: 600 .84rem/1.3 var(--sans);
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.icon-button:hover { border-color: var(--teal-600); color: var(--teal-700); }
.button.primary { border-color: var(--teal-700); background: var(--teal-700); color: #fff; }
.icon-button { display: none; width: 38px; padding: 0; font-size: 1.15rem; }

.reader-shell {
  display: grid;
  max-width: 1640px;
  min-height: calc(100vh - 62px);
  margin: 0 auto;
  grid-template-columns: 272px minmax(0, 920px) 236px;
  justify-content: center;
  align-items: start;
  gap: 28px;
  padding: 28px clamp(18px, 3vw, 42px) 80px;
}

.book-sidebar,
.chapter-toc {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  scrollbar-width: thin;
  font-family: var(--sans);
}

.book-sidebar {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .78);
}

.sidebar-label,
.toc-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.book-sidebar h2 {
  margin: 0 0 4px;
  color: var(--navy-950);
  font-size: .96rem;
  line-height: 1.45;
}

.edition-label { margin: 0 0 14px; color: var(--teal-700); font-size: .78rem; }

.chapter-list,
.chapter-toc ol { margin: 0; padding: 0; list-style: none; }
.chapter-list { display: grid; gap: 3px; }

.chapter-list a {
  display: grid;
  grid-template-columns: 29px 1fr;
  align-items: start;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 7px;
  color: #425466;
  font-size: .77rem;
  line-height: 1.42;
  text-decoration: none;
}

.chapter-list a:hover { background: var(--teal-100); color: var(--navy-950); }
.chapter-list a.active { background: var(--navy-950); color: #fff; }
.chapter-list .num { color: var(--teal-700); font-weight: 800; }
.chapter-list a.active .num { color: #72d9df; }

.sidebar-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sidebar-tools .button { padding-inline: 7px; font-size: .76rem; }
.sidebar-tools .sidebar-version { grid-column: 1 / -1; }

.paper {
  min-width: 0;
  padding: clamp(34px, 5vw, 66px) clamp(28px, 7vw, 86px) 68px;
  border: 1px solid #e4e2db;
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.chapter-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 15px;
  color: var(--teal-700);
  font: 800 .75rem/1.4 var(--sans);
  letter-spacing: .14em;
}

.chapter-kicker::after { width: 64px; height: 1px; background: var(--teal-600); content: ""; }

.chapter-content > h1:first-child {
  margin: 0 0 30px;
  padding-bottom: 24px;
  border-bottom: 3px double var(--line-dark);
  color: var(--navy-950);
  font-family: var(--sans);
  font-size: clamp(1.9rem, 4vw, 2.65rem);
  line-height: 1.32;
  letter-spacing: -.025em;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: -13px 0 30px;
  padding: 14px 16px;
  border: 1px solid #cbd9df;
  border-radius: 9px;
  background: #f4f8fa;
  color: var(--muted);
  font: .82rem/1.55 var(--sans);
}

.document-actions .button { flex: 0 0 auto; }
.document-actions span { flex: 1 1 260px; }

.chapter-content h2 {
  position: relative;
  margin: 2.9em 0 1em;
  padding: 10px 14px 10px 19px;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, var(--blue-100), rgba(233, 241, 251, .14));
  color: var(--navy-950);
  font-family: var(--sans);
  font-size: 1.35rem;
  line-height: 1.45;
}

.chapter-content h2::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: 4px;
  background: var(--teal-700);
  content: "";
}

.chapter-content h3 {
  margin: 2.2em 0 .78em;
  color: var(--navy-800);
  font-family: var(--sans);
  font-size: 1.08rem;
  line-height: 1.5;
}

.chapter-content p {
  margin: 0 0 1.05em;
  text-align: justify;
  text-justify: inter-ideograph;
}

.chapter-content strong { color: #162f46; }
.chapter-content ul,
.chapter-content ol { margin: .65em 0 1.2em; padding-left: 1.7em; }
.chapter-content li { margin: .32em 0; }

.chapter-content blockquote {
  margin: 1.5em 0;
  padding: 17px 20px;
  border: 1px solid #c9dedf;
  border-left: 5px solid var(--teal-700);
  border-radius: 4px 9px 9px 4px;
  background: #f3fbfb;
  color: #294958;
}

.chapter-content blockquote p:last-child { margin-bottom: 0; }

.chapter-content code {
  padding: .08em .34em;
  border-radius: 4px;
  background: #edf1f4;
  color: #9b3f2d;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .86em;
}

.code-frame { position: relative; margin: 1.5em 0; }
.chapter-content pre {
  overflow: auto;
  margin: 0;
  padding: 20px;
  border: 1px solid #203c54;
  border-radius: 8px;
  background: #132b3e;
  color: #e8f2f6;
  font-size: .82rem;
  line-height: 1.65;
  tab-size: 2;
}

.chapter-content pre code { padding: 0; background: none; color: inherit; }
.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border: 1px solid #527089;
  border-radius: 5px;
  background: #1d405a;
  color: #dbe8ee;
  font: .7rem var(--sans);
  cursor: pointer;
}

.table-wrap { overflow-x: auto; margin: 1.45em 0; border: 1px solid var(--line); border-radius: 8px; }
.chapter-content table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: .83rem; line-height: 1.55; }
.chapter-content th,
.chapter-content td { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.chapter-content th { background: var(--navy-950); color: #fff; font-weight: 700; }
.chapter-content tr:nth-child(even) td { background: #f7f9fa; }
.chapter-content tr:last-child td { border-bottom: 0; }
.chapter-content th:last-child,
.chapter-content td:last-child { border-right: 0; }

.learning-box {
  margin: 1.55em 0;
  padding: 15px 18px;
  border: 1px solid #e6cf9c;
  border-radius: 9px;
  background: var(--amber-100);
  font-family: var(--sans);
  font-size: .92rem;
}

.learning-box.think { border-color: #c6d8ed; background: var(--blue-100); }
.learning-box.do { border-color: #b9dbcb; background: var(--green-100); }
.learning-box.warning { border-color: #e3b6b1; background: var(--red-100); }
.learning-box strong:first-child { font-family: var(--sans); }

.chapter-opener-figure {
  margin: 1.35em auto 2.2em;
  padding: 10px;
  border: 1px solid #d6d0c4;
  border-radius: 8px;
  background: #faf7ef;
  box-shadow: 0 12px 28px rgba(16, 42, 67, .08);
}

.chapter-opener-figure button,
.knowledge-figure button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(16, 42, 67, .06);
  cursor: zoom-in;
}

.chapter-opener-figure img,
.knowledge-figure img { display: block; width: 100%; height: auto; border-radius: 9px; }
.chapter-opener-figure figcaption,
.knowledge-figure figcaption { margin-top: 9px; color: #536473; font: .82rem/1.55 var(--sans); text-align: center; }

.knowledge-figure { margin: 2em auto; }

.figure-dialog {
  width: min(1280px, calc(100vw - 34px));
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(5, 20, 33, .35);
}
.figure-dialog::backdrop { background: rgba(8, 25, 39, .72); }
.figure-dialog img { display: block; width: 100%; height: auto; }
.dialog-close { position: absolute; top: 10px; right: 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; width: 38px; height: 38px; cursor: pointer; font-size: 1.15rem; }

.chapter-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 54px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
}

.chapter-footer a { max-width: 48%; text-decoration: none; }
.chapter-footer small { display: block; color: var(--muted); }

.chapter-toc { padding: 8px 0 12px; }
.chapter-toc ol { display: grid; gap: 4px; border-left: 1px solid var(--line-dark); }
.chapter-toc a { display: block; padding: 5px 10px 5px 13px; color: #647483; font: .76rem/1.45 var(--sans); text-decoration: none; }
.chapter-toc a:hover,
.chapter-toc a.active { margin-left: -1px; border-left: 2px solid var(--teal-700); color: var(--navy-950); }

.catalog {
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 12%, rgba(17, 153, 166, .14), transparent 34%),
    linear-gradient(145deg, #f8faf9 0, #e9f0f3 70%);
}

.catalog-main { max-width: 1220px; margin: 0 auto; padding: 54px 24px 88px; }
.book-hero {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  overflow: hidden;
  border-radius: 18px;
  background: var(--navy-950);
  color: #fff;
  box-shadow: 0 28px 65px rgba(16, 42, 67, .2);
}

.hero-copy { padding: clamp(34px, 6vw, 70px); }
.hero-overline { margin: 0 0 18px; color: #74d7dc; font: 800 .75rem/1.4 var(--sans); letter-spacing: .17em; }
.book-hero h1 { max-width: 720px; margin: 0 0 18px; font: 800 clamp(2.25rem, 5vw, 4.4rem)/1.17 var(--sans); letter-spacing: -.04em; }
.book-hero .lead { max-width: 690px; margin: 0 0 26px; color: #d9e7ed; font-size: 1.05rem; line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-actions .button { min-height: 42px; }
.hero-actions .button.secondary { border-color: #5c778d; background: transparent; color: #fff; }

.hero-visual { position: relative; min-height: 390px; background: linear-gradient(160deg, #0d7781, #143a58); }
.hero-orbit { position: absolute; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; }
.hero-orbit.one { width: 290px; height: 290px; top: 45px; left: 48px; }
.hero-orbit.two { width: 210px; height: 210px; top: 86px; left: 88px; }
.hero-core { position: absolute; top: 142px; left: 145px; display: grid; width: 96px; height: 96px; place-items: center; border-radius: 22px 7px 22px 7px; background: var(--amber-100); color: var(--navy-950); font: 900 1.35rem var(--sans); box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.hero-chip { position: absolute; padding: 8px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; background: rgba(16,42,67,.58); color: #fff; font: .75rem var(--sans); }
.hero-chip.c1 { top: 64px; left: 42px; }.hero-chip.c2 { top: 80px; right: 30px; }.hero-chip.c3 { bottom: 74px; left: 32px; }.hero-chip.c4 { right: 38px; bottom: 62px; }

.catalog-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 28px 0 48px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.catalog-stats div { padding: 18px; background: rgba(255,255,255,.88); text-align: center; }
.catalog-stats strong { display: block; color: var(--navy-950); font: 800 1.45rem var(--sans); }
.catalog-stats span { color: var(--muted); font: .76rem var(--sans); }

.catalog-section h2 { margin: 0 0 6px; color: var(--navy-950); font: 800 1.65rem var(--sans); }
.section-intro { margin: 0 0 24px; color: var(--muted); font-family: var(--sans); }
.part { margin-top: 35px; }
.part-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; font-family: var(--sans); }
.part-title span { color: var(--teal-700); font-size: .72rem; font-weight: 800; letter-spacing: .13em; }
.part-title h3 { margin: 0; color: var(--navy-800); font-size: 1.06rem; }
.chapter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chapter-card { display: grid; grid-template-columns: 54px 1fr; gap: 14px; min-height: 132px; padding: 18px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.9); color: inherit; text-decoration: none; transition: transform .15s, box-shadow .15s; }
.chapter-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(16,42,67,.1); }
.chapter-number { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 13px 5px 13px 5px; background: var(--teal-100); color: var(--teal-700); font: 900 1rem var(--sans); }
.chapter-card h4 { margin: 1px 0 8px; color: var(--navy-950); font: 750 1rem/1.48 var(--sans); }
.chapter-card p { display: -webkit-box; overflow: hidden; margin: 0; color: var(--muted); font: .78rem/1.55 var(--sans); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.catalog-note { margin-top: 46px; padding: 20px 24px; border: 1px solid #cbd9df; border-radius: 10px; background: rgba(255,255,255,.72); color: #4b6070; font: .84rem/1.7 var(--sans); }
.catalog-note a { color: var(--teal-700); font-weight: 700; }

@media (max-width: 1280px) {
  .reader-shell { grid-template-columns: 250px minmax(0, 900px); }
  .chapter-toc { display: none; }
}

@media (max-width: 860px) {
  html { font-size: 16px; }
  .topbar { min-height: 56px; }
  .icon-button { display: inline-flex; }
  .top-actions .hide-mobile { display: none; }
  .reader-shell { display: block; padding: 14px 10px 54px; }
  .book-sidebar { position: fixed; z-index: 80; inset: 56px auto 0 0; width: min(340px, 88vw); max-height: none; border-radius: 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 15px 0 45px rgba(16,42,67,.22); }
  body.nav-open .book-sidebar { transform: translateX(0); }
  body.nav-open::after { position: fixed; z-index: 70; inset: 56px 0 0; background: rgba(10,30,45,.48); content: ""; }
  .paper { padding: 32px clamp(20px, 6vw, 42px) 50px; }
  .chapter-content h2 { margin-top: 2.4em; font-size: 1.22rem; }
  .book-hero { grid-template-columns: 1fr; }
  .hero-visual { display: none; }
  .catalog-main { padding: 22px 12px 60px; }
  .catalog-stats { grid-template-columns: repeat(2, 1fr); }
  .chapter-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .brand-copy span { display: none; }
  .paper { padding-inline: 18px; border-radius: 0; }
  .chapter-content > h1:first-child { font-size: 1.72rem; }
  .chapter-content p { text-align: left; }
  .chapter-footer { flex-direction: column; }
  .chapter-footer a { max-width: none; }
  .catalog-stats div { padding: 13px 7px; }
  .chapter-card { grid-template-columns: 44px 1fr; padding: 14px; }
  .chapter-number { width: 44px; height: 44px; }
}

@media print {
  @page { size: A4; margin: 18mm 17mm 20mm; }
  html, body { background: #fff; font-size: 10.5pt; }
  .topbar, .book-sidebar, .chapter-toc, .chapter-footer, .reading-progress, .copy-code, .figure-dialog { display: none !important; }
  .reader-shell { display: block; max-width: none; padding: 0; }
  .paper { padding: 0; border: 0; box-shadow: none; }
  .chapter-content h1 { break-before: page; }
  .chapter-content > h1:first-child { break-before: auto; }
  .chapter-content h2, .chapter-content h3 { break-after: avoid; }
  .chapter-opener-figure, .knowledge-figure, table, blockquote, pre { break-inside: avoid; }
  .chapter-opener-figure { padding: 0; border: 0; box-shadow: none; }
  .chapter-opener-figure button, .knowledge-figure button { border: 0; box-shadow: none; }
  a { color: inherit; text-decoration: none; }
}
