:root {
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1b4f72;
  --bg: #ffffff;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 15px;
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 28px 0;
  overflow-y: auto;
}

.brand {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0 24px 20px;
  text-transform: uppercase;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.brand:hover { color: var(--accent, #6366f1); }

#nav { display: flex; flex-direction: column; }

#nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 24px;
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
#nav a:hover { color: var(--ink); }
#nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* ── Content ───────────────────────────────── */
.content {
  /* Center the 720px column within the empty space to the right of the
     sidebar, while never letting it slide under the fixed sidebar. */
  margin-left: max(
    var(--sidebar-w),
    calc(var(--sidebar-w) + (100% - var(--sidebar-w) - 720px) / 2)
  );
  margin-right: auto;
  max-width: 720px;
  padding: 56px 48px 96px;
}

/* All topics render in one scrollable document (crawler-friendly).
   scroll-margin keeps anchored sections clear of the viewport top. */
.page { display: block; scroll-margin-top: 24px; }
.page + .page { margin-top: 56px; }

.doc-title {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 24px;
}

h2 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

h3, .sub {
  font-size: 18px;
  font-weight: 600;
  margin: 30px 0 12px;
}

p { margin: 0 0 16px; }
.lead { font-size: 16px; color: var(--muted); }

/* Figures — flat, thin border, no rounding */
figure {
  margin: 24px 0;
  border: 1px solid var(--line);
}
figure img {
  display: block;
  width: 100%;
  cursor: zoom-in;
  background: #f9fafb;
}
figcaption {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* Lists */
.numbered, .plain { padding-left: 20px; margin: 0 0 16px; }
.numbered li, .plain li { margin: 6px 0; }
.plain { list-style: square; }

/* Glossary */
.glossary { margin: 8px 0 16px; }
.glossary dt {
  font-weight: 600;
  margin-top: 18px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.glossary dd { margin: 6px 0 0; color: var(--muted); }

/* Note — flat left rule, no fill */
.note {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 14px;
  color: var(--muted);
  font-size: 14px;
}
.note strong { color: var(--ink); }

/* Mobile menu button */
.menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 94vw;
  max-height: 90vh;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 820px) {
  .menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
    background: #fff;
  }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 64px 24px 72px; }
}
