:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --sidebar-bg: #F4F5F6;
  --border: #E4E7E9;
  --text: #171C1D;
  --text-muted: #636E72;
  --text-faint: #8896A0;
  --accent: #2563EB;
  --accent-soft: #E8EFFE;
  --topbar-h: 56px;
  --sidebar-w: 280px;
  --content-max: 760px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

/* Topbar -------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.topbar__title { font-weight: 600; font-size: 15px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}
.icon-button:hover { background: var(--sidebar-bg); }
.hamburger, .hamburger::before, .hamburger::after {
  display: block;
  width: 18px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  position: relative;
}
.hamburger::before, .hamburger::after { content: ""; position: absolute; left: 0; }
.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

/* Layout -------------------------------------------------------------- */
.layout { display: flex; padding-top: var(--topbar-h); }

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 12px 40px;
  transition: transform 0.2s ease;
}
.sidebar__title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 4px 12px 16px;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left 0.2s ease;
}
.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 48px 32px 96px;
}

/* Desktop collapse ---------------------------------------------------- */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

/* Nav ----------------------------------------------------------------- */
.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: block;
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.3;
}
.nav-item:hover { background: #E9EBED; color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.nav-section { margin-top: 14px; }

/* Section / sub-section headers are colored "chips" so the menu hierarchy
   reads at a glance: section (blue, largest) > sub-section (purple, mid) >
   note links (plain text, smallest). */
.nav-section__header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 8px;
  padding: 6px 12px;
  margin-bottom: 4px;
}
.nav-section__caret { font-size: 11px; transition: transform 0.15s ease; }
.nav-section.is-collapsed .nav-section__caret { transform: rotate(-90deg); }
.nav-section.is-collapsed .nav-section__body { display: none; }
.nav-section__body { margin-top: 2px; }

/* Section chip — blue, largest. */
.nav-section--category > .nav-section__header {
  font-size: 18px;
  color: #1D4ED8;
  background: #DBE6FE;
}
.nav-section--category > .nav-section__header:hover { background: #C7D8FD; }

/* Sub-section chip — purple, between section and note. Indented under parent. */
.nav-section--subcategory { margin-top: 8px; margin-left: 12px; }
.nav-section--subcategory > .nav-section__header {
  font-size: 16px;
  color: #6D28D9;
  background: #EDE6FC;
}
.nav-section--subcategory > .nav-section__header:hover { background: #E2D6FA; }

/* Note content (rendered markdown) ------------------------------------ */
.note { font-size: 16px; line-height: 1.7; color: var(--text); }
.note > *:first-child { margin-top: 0; }
.note h1 { font-size: 30px; font-weight: 700; margin: 0 0 20px; letter-spacing: -0.01em; }
.note h2 { font-size: 22px; font-weight: 600; margin: 40px 0 12px; }
.note h3 { font-size: 18px; font-weight: 600; margin: 28px 0 8px; }
.note p { margin: 0 0 16px; }
.note ul, .note ol { margin: 0 0 16px; padding-left: 24px; }
.note li { margin: 4px 0; }
.note a { color: var(--accent); text-decoration: none; }
.note a:hover { text-decoration: underline; }
/* Cap diagrams/screenshots so they don't dominate the page; scales down to
   fit within the box while preserving aspect ratio. */
.note img {
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  border-radius: 8px;
  margin: 8px 0 20px;
}
.note code {
  background: #ECEEF0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 0.88em;
}
.note pre {
  background: #1E2528;
  color: #E6E9EB;
  padding: 16px 18px;
  border-radius: 8px;
  overflow-x: auto;
}
.note pre code { background: none; padding: 0; color: inherit; }
.note blockquote {
  margin: 0 0 16px;
  padding: 4px 18px;
  border-left: 3px solid var(--border);
  background: var(--sidebar-bg);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
}
.note blockquote p:last-child { margin-bottom: 0; }

/* Callouts (see js/callouts.js). The Data callout = blue, used everywhere to
   flag where a field's authoritative value lives. */
.note .callout {
  border: 1px solid #BFD3FD;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--text);
}
.note .callout__label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.note .callout--data { /* blue is the data / source-of-truth color */ }
.note table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14px; }
.note th, .note td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.note th { background: var(--sidebar-bg); font-weight: 600; }
.note hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.note-message {
  max-width: var(--content-max);
  color: var(--text-muted);
}
.note-message h1 { color: var(--text); font-size: 24px; }

/* Mobile -------------------------------------------------------------- */
@media (max-width: 720px) {
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); z-index: 15; box-shadow: 2px 0 16px rgba(0,0,0,0.08); }
  .sidebar.is-open { transform: translateX(0); }
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  .content { padding: 32px 20px 80px; }
}
