:root {
  --ink: #172235;
  --muted: #5f7085;
  --line: #dce5ec;
  --paper: #ffffff;
  --wash: #f3f7f9;
  --navy: #14263c;
  --teal: #17877c;
  --blue: #2f68d8;
  --amber: #d7892f;
  --red: #c94b4b;
  --shadow: 0 16px 44px rgba(30, 54, 76, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font: 15px/1.75 Arial, "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input { font: inherit; }
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  color: #fff;
  background: rgba(20, 38, 60, 0.97);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand { font-size: 17px; font-weight: 700; white-space: nowrap; }
.brand small { margin-left: 10px; color: #a9c5d6; font-size: 12px; font-weight: 400; }
.search { position: relative; width: min(440px, 42vw); margin-left: auto; }
.search input {
  width: 100%; height: 36px; padding: 0 38px 0 13px;
  color: #fff; background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.2); border-radius: 6px; outline: 0;
}
.search input:focus { border-color: #68c7bd; box-shadow: 0 0 0 3px rgba(104,199,189,.16); }
.search span { position: absolute; right: 12px; top: 5px; color: #bed0dc; }
.print-btn, .home-link { height: 36px; display: inline-flex; align-items: center; padding: 0 13px; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.28); border-radius: 6px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.home-link:hover { border-color: #68c7bd; background: rgba(104,199,189,.12); }

.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); max-width: 1500px; margin: 0 auto; }
.sidebar {
  position: sticky; top: 62px; height: calc(100vh - 62px); overflow: auto;
  padding: 28px 20px 32px 28px; background: #eef4f6; border-right: 1px solid var(--line);
}
.sidebar strong { display: block; margin: 0 8px 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.sidebar a { display: block; padding: 8px 10px; color: #40546a; text-decoration: none; border-left: 2px solid transparent; }
.sidebar a:hover, .sidebar a.active { color: var(--teal); background: #fff; border-left-color: var(--teal); }
.sidebar .meta { margin: 22px 8px 0; padding-top: 16px; color: #758597; font-size: 12px; border-top: 1px solid var(--line); }

main { min-width: 0; background: var(--paper); }
.hero {
  min-height: 360px; padding: 74px clamp(28px, 7vw, 100px) 52px;
  color: #fff; background: linear-gradient(115deg, #14263c 0%, #183d55 58%, #176e69 100%);
}
.eyebrow { color: #7ed8cc; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.hero h1 { max-width: 820px; margin: 12px 0 16px; font-size: 46px; line-height: 1.16; letter-spacing: 0; }
.hero p { max-width: 760px; margin: 0; color: #d4e4ec; font-size: 18px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 38px; }
.hero-stats b { display: block; font-size: 27px; line-height: 1.1; }
.hero-stats span { color: #afcbd6; font-size: 12px; }

.content { width: min(1120px, calc(100% - 56px)); margin: 0 auto; padding: 46px 0 84px; }
.chapter { scroll-margin-top: 82px; padding: 26px 0 50px; border-bottom: 1px solid var(--line); }
.chapter:last-child { border-bottom: 0; }
.chapter-head { display: grid; grid-template-columns: 50px 1fr; gap: 16px; align-items: start; margin-bottom: 24px; }
.chapter-no { display: grid; place-items: center; width: 44px; height: 44px; color: #fff; background: var(--teal); border-radius: 4px; font-weight: 700; }
h2 { margin: 0; font-size: 29px; line-height: 1.25; }
.chapter-head p { margin: 7px 0 0; color: var(--muted); }
.module { position: relative; padding-left: 18px; border-left: 5px solid var(--teal); }
.module .chapter-no { background: var(--teal); }
.module-figure { border-left-color: #2f68d8; }
.module-figure .chapter-no { background: #2f68d8; }
.module-relative { border-left-color: #d8624d; }
.module-relative .chapter-no { background: #d8624d; }
.module-absolute { border-left-color: #d78a2f; }
.module-absolute .chapter-no { background: #d78a2f; }
.workflow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 20px 0 28px; border: 1px solid var(--line); }
.workflow span { position: relative; padding: 11px 9px; color: #41556a; background: #f7fafb; border-right: 1px solid var(--line); text-align: center; font-size: 13px; font-weight: 700; }
.workflow span:last-child { border-right: 0; }
.module-wb .workflow span { border-top: 3px solid var(--teal); }
.module-figure .workflow span { border-top: 3px solid #2f68d8; }
.module-relative .workflow span { border-top: 3px solid #d8624d; }
.module-absolute .workflow span { border-top: 3px solid #d78a2f; }
h3 { margin: 30px 0 9px; font-size: 19px; }
p { margin: 10px 0; }
code, kbd { padding: 2px 5px; color: #244663; background: #edf3f6; border: 1px solid #d9e4ea; border-radius: 3px; font-family: Consolas, monospace; }

.quick-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin: 24px 0; background: var(--line); border: 1px solid var(--line); }
.quick-grid div { min-height: 104px; padding: 17px; background: #fff; }
.quick-grid b { display: block; margin-bottom: 4px; font-size: 17px; }
.quick-grid span { color: var(--muted); font-size: 13px; }

.callout { margin: 22px 0; padding: 16px 18px; color: #284e52; background: #edf8f6; border-left: 3px solid var(--teal); }
.callout.warning { color: #694617; background: #fff6e8; border-left-color: var(--amber); }
.callout.danger { color: #6e3030; background: #fff0f0; border-left-color: var(--red); }

.steps { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin: 18px 0 26px; padding: 0; list-style: none; counter-reset: steps; }
.steps li { position: relative; min-height: 86px; padding: 15px 16px 15px 52px; background: #f7fafb; border: 1px solid var(--line); }
.steps li::before { counter-increment: steps; content: counter(steps); position: absolute; left: 15px; top: 16px; display: grid; place-items: center; width: 25px; height: 25px; color: #fff; background: var(--blue); border-radius: 50%; font-weight: 700; }
.steps b { display: block; margin-bottom: 2px; }

.shot { margin: 24px 0 34px; }
.shot-media { position: relative; overflow: hidden; background: #dfe7ec; border: 1px solid #cdd9e1; box-shadow: var(--shadow); }
.shot img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.shot figcaption { padding: 13px 16px; color: #4f6276; background: #f7fafb; border: 1px solid var(--line); border-top: 0; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; margin: 13px 0 0; padding: 0; list-style: none; }
.legend li { display: grid; grid-template-columns: 25px 1fr; gap: 8px; align-items: start; }
.legend b { display: grid; place-items: center; width: 23px; height: 23px; color: #fff; background: #ec514c; border-radius: 50%; font-size: 12px; }

.data { width: 100%; margin: 18px 0 26px; border-collapse: collapse; }
.data th, .data td { padding: 10px 12px; text-align: left; border: 1px solid var(--line); }
.data th { background: #edf3f6; }
.data td { vertical-align: top; }
.formula { overflow-x: auto; margin: 18px 0; padding: 17px; color: #d7f2ef; background: var(--navy); font: 15px/1.7 Consolas, monospace; }

.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0; border: 1px solid var(--line); }
.metric-row div { padding: 14px; border-right: 1px solid var(--line); }
.metric-row div:last-child { border-right: 0; }
.metric-row b { display: block; font-size: 21px; }
.metric-row span { color: var(--muted); font-size: 12px; }

.checklist { padding-left: 22px; }
.checklist li { margin: 8px 0; }
.checklist li::marker { color: var(--teal); }

.lightbox { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 24px; background: rgba(8,16,26,.92); }
.lightbox.open { display: grid; }
.lightbox img { max-width: 96vw; max-height: 90vh; object-fit: contain; }
.lightbox button { position: absolute; top: 16px; right: 18px; width: 40px; height: 40px; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; cursor: pointer; }
.search-empty { display: none; padding: 50px 0; color: var(--muted); text-align: center; }
.footer { padding: 28px; color: #9eb4c2; background: var(--navy); text-align: center; }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 218px minmax(0, 1fr); }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .content { width: min(100% - 34px, 980px); }
}
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 58px; flex-wrap: wrap; gap: 9px; padding: 10px 14px; }
  .brand small, .print-btn { display: none; }
  .search { order: 2; width: 100%; }
  .layout { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 20; display: flex; gap: 2px; width: 100%; height: auto; padding: 7px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar strong, .sidebar .meta { display: none; }
  .sidebar a { flex: 0 0 auto; padding: 7px 9px; border-left: 0; border-bottom: 2px solid transparent; font-size: 12px; }
  .sidebar a.active { border-bottom-color: var(--teal); }
  .hero { min-height: 320px; padding: 52px 22px 36px; }
  .hero h1 { font-size: 34px; }
  .hero p { font-size: 16px; }
  .content { width: calc(100% - 28px); padding-top: 20px; }
  .chapter { padding: 24px 0 36px; }
  .chapter-head { grid-template-columns: 40px 1fr; gap: 11px; }
  .chapter-no { width: 36px; height: 36px; }
  h2 { font-size: 23px; }
  .quick-grid, .steps, .legend, .twocol { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr 1fr; }
  .metric-row div:nth-child(2) { border-right: 0; }
  .metric-row div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .module { padding-left: 10px; border-left-width: 3px; }
  .workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow span { border-bottom: 1px solid var(--line); }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .sidebar, .lightbox, .print-btn { display: none !important; }
  .layout { display: block; max-width: none; }
  .hero { min-height: auto; color: #172235; background: #fff; border-bottom: 2px solid #172235; }
  .hero p, .hero-stats span { color: #526477; }
  .content { width: 100%; padding: 20px 0; }
  .chapter { break-before: page; }
  .shot-media { box-shadow: none; break-inside: avoid; }
  .shot img { cursor: default; }
}
