:root {
  color-scheme: light;
  --ink: #1b2330;
  --muted: #5f6877;
  --line: #d9dee7;
  --surface: #ffffff;
  --soft: #f3f6fa;
  --brand: #2d5f8b;
  --brand-dark: #1d4166;
  --accent: #d48920;
  --code: #172033;
  --max: 980px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #f7f8fb;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-header,
.site-footer {
  background: var(--surface);
  border-color: var(--line);
}

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  padding: 22px 0;
  text-align: center;
}

.wrap {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 85px;
  padding: 18px 0;
}

.brand-logo {
  display: block;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  max-width: 430px;
  min-height: 49px;
}

.brand-logo:hover {
  text-decoration: none;
}

.brand-logo:hover .brand-title {
  color: var(--brand);
}

.brand-title {
  display: block;
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  color: var(--brand-dark);
  font-weight: 700;
  letter-spacing: 0;
}

.brand-subtitle {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-height: 32px;
}

.nav a {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-bottom: 2px solid transparent;
  color: var(--brand-dark);
  padding: 0 6px;
  font-size: 14px;
  font-weight: 700;
}

.nav a:hover {
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.breadcrumb-bar {
  background: #fbfcfe;
  border-bottom: 1px solid #e5e9f0;
  padding: 0;
}

.hero {
  background: linear-gradient(180deg, #ffffff 0%, #eef4fb 100%);
  border-bottom: 1px solid var(--line);
}

.hero-inner {
  padding: 22px 0 32px;
  display: grid;
  gap: 12px;
  max-width: var(--max);
  text-align: left;
}

.hero-inner > * {
  max-width: 780px;
}

.breadcrumbs {
  font-size: 13px;
  line-height: 1.2;
  color: var(--muted);
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
}

.breadcrumbs a,
.breadcrumbs [aria-current="page"] {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 2px;
}

.breadcrumbs li + li::before {
  content: "/";
  color: #7f8996;
  margin: 0 7px;
}

.breadcrumbs [aria-current="page"] {
  color: var(--brand-dark);
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.15;
  color: var(--brand-dark);
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

main {
  padding: 34px 0 48px;
}

.chapter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 30px;
  align-items: start;
}

.chapter {
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 0;
  padding: 34px 42px;
}

.chapter-nav {
  position: sticky;
  top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
  font-size: 14px;
}

.chapter-nav h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.chapter-nav ol {
  margin: 0;
  padding-left: 20px;
}

.chapter-nav li {
  margin: 5px 0;
}

.chapter-pagination {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.chapter-pagination a {
  display: grid;
  gap: 2px;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--brand-dark);
}

.chapter-pagination a[rel="next"] {
  text-align: right;
}

.chapter-pagination span {
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
h4 {
  color: var(--brand-dark);
  letter-spacing: 0;
  line-height: 1.25;
}

.chapter > h1:first-child {
  margin-top: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 24px;
  margin-top: 36px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

h3 {
  font-size: 20px;
  margin-top: 28px;
}

h4 {
  font-size: 18px;
  margin-top: 24px;
}

p,
ul,
ol,
table,
figure,
pre {
  margin-top: 0;
}

img {
  max-width: 100%;
  height: auto;
}

.diagram {
  width: min(100%, 720px);
}

.diagram-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.diagram-wide {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
}

figure,
.legacy-figure {
  margin: 24px 0;
  padding: 18px;
  background: var(--soft);
  border: 1px solid var(--line);
  text-align: center;
}

figcaption,
caption {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  padding-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
}

th,
td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
}

th {
  background: var(--soft);
  color: var(--brand-dark);
  text-align: left;
}

pre {
  background: var(--code);
  color: #eef4fb;
  overflow-x: auto;
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
}

code {
  font-family: Menlo, Consolas, "Liberation Mono", monospace;
}

.modern-note {
  border-left: 4px solid var(--accent);
  background: #fff8ed;
  padding: 14px 16px;
  margin: 24px 0;
}

.modern-note h2,
.modern-note h3 {
  margin-top: 0;
  border: 0;
  padding: 0;
}

.outline-list {
  display: grid;
  gap: 12px;
  padding-left: 20px;
}

.references li {
  margin-bottom: 10px;
}

@media (max-width: 820px) {
  .diagram-wide {
    min-width: 720px;
  }

  .masthead {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    min-height: 131px;
  }

  .brand-logo {
    max-width: 100%;
    width: 100%;
  }

  .breadcrumbs a,
  .breadcrumbs [aria-current="page"] {
    min-height: 44px;
    padding: 0 8px;
  }

  .breadcrumbs li + li::before {
    margin: 0 2px;
  }

  .hero h1 {
    font-size: 31px;
  }

  .chapter-layout {
    grid-template-columns: 1fr;
  }

  .chapter-nav {
    position: static;
  }

  .chapter {
    padding: 24px 16px;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  .chapter-pagination {
    grid-template-columns: 1fr;
  }

  .chapter-pagination a[rel="next"] {
    text-align: left;
  }
}

@media (max-width: 340px) {
  .nav { flex-wrap: wrap; gap: 6px; }
  .nav a { padding-inline: 5px; }
}
