*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f9fafb;
  color: #111827;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.topbar-icon { display: block; flex-shrink: 0; }
.topbar-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}
.topbar-sub {
  font-size: 13px;
  color: #9ca3af;
  border-left: 1px solid #e5e7eb;
  padding-left: 14px;
}

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - 52px);
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 20px 0;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
}
.sidebar-section { margin-bottom: 2px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 18px 4px;
}
.sidebar-link {
  display: block;
  padding: 5px 18px;
  font-size: 13px;
  color: #4b5563;
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.4;
}
.sidebar-link:hover { color: #c0522a; background: #fef3ee; }
.sidebar-link.active {
  color: #c0522a;
  border-left-color: #c0522a;
  background: #fef3ee;
  font-weight: 500;
}
.sidebar-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 6px 12px;
}

/* ── Content ────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 36px 48px 72px;
  max-width: 820px;
  min-width: 0;
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.breadcrumb a { color: #c0522a; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Typography ─────────────────────────────────────────── */
h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 30px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
  margin-bottom: 10px;
}
h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  color: #111827;
  margin: 36px 0 10px;
}
h3 {
  font-size: 15px;
  font-weight: 600;
  color: #374151;
  margin: 24px 0 8px;
}
p {
  color: #374151;
  margin-bottom: 14px;
}
p.lead {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 28px;
}
a { color: #c0522a; }
a:hover { text-decoration: underline; }
ul, ol {
  color: #374151;
  padding-left: 22px;
  margin-bottom: 14px;
}
li { margin-bottom: 4px; }
li > ul, li > ol { margin-top: 4px; margin-bottom: 0; }

code {
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  color: #c0522a;
}
pre {
  background: #1e1b18;
  color: #e5e0d8;
  padding: 16px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  line-height: 1.6;
  margin-bottom: 16px;
  overflow-x: auto;
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ── Callout ────────────────────────────────────────────── */
.callout {
  background: #fef3ee;
  border: 1px solid #fdd6be;
  border-left: 3px solid #c0522a;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 16px;
}
.callout p { margin: 0; font-size: 13.5px; color: #7c3a20; }
.callout p + p { margin-top: 6px; }

/* ── Prev/Next nav ──────────────────────────────────────── */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 52px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}
.page-nav a {
  font-size: 13px;
  font-weight: 500;
  color: #c0522a;
  text-decoration: none;
}
.page-nav a:hover { text-decoration: underline; }

/* ── Section index cards ────────────────────────────────── */
.section-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 24px;
}
.section-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 18px;
  text-decoration: none;
  background: #fff;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.section-card:hover {
  border-color: #c0522a;
  box-shadow: 0 2px 8px rgba(192, 82, 42, 0.1);
  text-decoration: none;
}
.section-card h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}
.section-card p {
  margin: 0;
  font-size: 12.5px;
  color: #6b7280;
}

/* ── Tables ─────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13.5px;
}
th {
  text-align: left;
  padding: 8px 12px;
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  color: #374151;
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}
tr:last-child td { border-bottom: none; }

/* ── Mobile nav toggle (checkbox hack, no JS) ──────────── */
.nav-toggle-input { display: none; }
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 6px;
    color: #374151;
    cursor: pointer;
    border-radius: 4px;
  }
  .nav-toggle:hover { background: #f3f4f6; }

  .topbar-sub { display: none; }

  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    z-index: 20;
    width: 260px;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: 16px;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .nav-toggle-input:checked ~ .topbar .nav-toggle {
    color: #c0522a;
  }

  .nav-toggle-input:checked ~ .layout .sidebar {
    transform: translateX(0);
  }

  .nav-toggle-input:checked ~ .layout .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .content {
    padding: 24px 20px 48px;
  }

  h1 { font-size: 24px; }

  .page-nav { flex-direction: column; gap: 12px; }

  .section-cards {
    grid-template-columns: 1fr;
  }

  pre { font-size: 12px; padding: 12px 14px; }

  table { font-size: 12.5px; }
  th, td { padding: 6px 8px; }
}

/* ── Dark mode ─────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  body {
    background: #18181b;
    color: #d4d4d8;
  }

  /* ── Topbar ── */
  .topbar {
    background: #27272a;
    border-bottom-color: #3f3f46;
  }
  .topbar-name { color: #fafafa; }
  .topbar-sub {
    color: #a1a1aa;
    border-left-color: #3f3f46;
  }

  /* ── Sidebar ── */
  .sidebar {
    background: #27272a;
    border-right-color: #3f3f46;
  }
  .sidebar-section-label { color: #a1a1aa; }
  .sidebar-link { color: #a1a1aa; }
  .sidebar-link:hover {
    color: #c0522a;
    background: rgba(192, 82, 42, 0.1);
  }
  .sidebar-link.active {
    color: #c0522a;
    background: rgba(192, 82, 42, 0.1);
  }
  .sidebar-divider { background: #3f3f46; }

  /* ── Typography ── */
  h1, h2 { color: #fafafa; }
  h3 { color: #d4d4d8; }
  p { color: #d4d4d8; }
  p.lead { color: #a1a1aa; }
  ul, ol { color: #d4d4d8; }

  /* ── Links ── */
  a { color: #c0522a; }

  /* ── Code ── */
  code {
    background: #27272a;
    color: #d4835a;
  }
  pre {
    background: #2e2b28;
  }

  /* ── Breadcrumb ── */
  .breadcrumb { color: #a1a1aa; }

  /* ── Callout ── */
  .callout {
    background: #27272a;
    border-color: #3f3f46;
    border-left-color: #c0522a;
  }
  .callout p { color: #d4d4d8; }

  /* ── Page nav ── */
  .page-nav { border-top-color: #3f3f46; }

  /* ── Section cards ── */
  .section-card {
    background: #27272a;
    border-color: #3f3f46;
  }
  .section-card:hover {
    border-color: #c0522a;
    box-shadow: 0 2px 8px rgba(192, 82, 42, 0.15);
  }
  .section-card h3 { color: #fafafa; }
  .section-card p { color: #a1a1aa; }

  /* ── Tables ── */
  th {
    background: #27272a;
    border-bottom-color: #3f3f46;
    color: #d4d4d8;
  }
  td {
    border-bottom-color: #3f3f46;
    color: #d4d4d8;
  }

  /* ── Mobile ── */
  .nav-toggle { color: #d4d4d8; }
  .nav-toggle:hover { background: #3f3f46; }
  .nav-backdrop { background: rgba(0, 0, 0, 0.5); }
}
