:root {
  --bg: #ffffff;
  --surface: #fbfbfd;
  --surface-alt: #f4f4f7;
  --border: #e5e5eb;
  --border-strong: #d4d4db;
  --text: #0f172a;
  --text-dim: #52525b;
  --text-mute: #71717a;
  --accent: #045377;
  --accent-dark: #033d59;
  --accent-gold: #f2b705;
  --topbar-bg: #045377;
  --code-bg: #0f172a;
  --code-text: #f8fafc;
  --code-inline-bg: #eef0f5;
  --code-inline-text: #1f2937;
  --sidebar-w: 280px;
  --toc-w: 240px;
  --topbar-h: 60px;
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--accent); color: white; padding: 8px 12px; border-radius: 6px; z-index: 9999;
}
.skip-link:focus { left: 12px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 24px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--accent-dark);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--accent-gold); text-decoration: none;
  font-size: 16px; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-gold);
  color: var(--accent-dark); font-weight: 800; font-size: 14px;
}
.brand-text small {
  color: rgba(255,255,255,.65); font-weight: 500; font-size: 12px; margin-left: 4px;
}
.topnav {
  margin-left: auto; display: flex; gap: 4px;
}
.topnav a {
  padding: 6px 12px; border-radius: 6px; color: rgba(255,255,255,.8); font-weight: 500;
}
.topnav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topnav a.active { background: rgba(255,255,255,.16); color: #fff; }
.menu-toggle {
  display: none; border: 1px solid rgba(255,255,255,.25); background: transparent;
  color: #fff;
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 16px;
}

/* Search */
.search { position: relative; flex: 1; max-width: 420px; }
.search input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1px solid rgba(255,255,255,.2); border-radius: 8px;
  background: rgba(255,255,255,.12) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 10px center;
  font-size: 14px; color: #fff;
}
.search input::placeholder { color: rgba(255,255,255,.65); }
.search input:focus {
  outline: none; border-color: var(--accent-gold);
  background-color: rgba(255,255,255,.18);
  box-shadow: 0 0 0 3px rgba(242,183,5,.25);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: white; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 50;
}
.search-results a {
  display: block; padding: 10px 14px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a.focused {
  background: var(--surface-alt); text-decoration: none;
}
.search-results .cat {
  font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .08em;
}
.search-results .snippet { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.search-results mark { background: #fde68a; color: inherit; padding: 0 2px; border-radius: 2px; }
.search-results .empty { padding: 14px; color: var(--text-mute); font-size: 14px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
}
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 24px 16px 40px 24px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.nav-group { margin-bottom: 20px; }
.nav-heading {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute); padding: 0 8px 6px;
}
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 0; }
.sidebar li a {
  display: block; padding: 6px 10px; border-radius: 6px;
  color: var(--text-dim); font-size: 14px;
  line-height: 1.3;
}
.sidebar li a:hover {
  background: var(--surface-alt); color: var(--text); text-decoration: none;
}
.sidebar li a.active {
  background: rgba(4,83,119,.08); color: var(--accent); font-weight: 600;
  border-left: 3px solid var(--accent); padding-left: 7px;
}

/* Content */
.content {
  padding: 32px 44px 80px;
  min-width: 0;
}
.breadcrumb {
  font-size: 13px; color: var(--text-mute); margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-mute); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 4px; }

.article h1 {
  font-size: 34px; line-height: 1.2; margin: 0 0 8px;
  letter-spacing: -.02em; color: var(--text);
}
.article h2 {
  font-size: 22px; margin: 40px 0 12px; letter-spacing: -.01em;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.article h3 {
  font-size: 17px; margin: 28px 0 10px; font-weight: 700; color: var(--text);
}
.article h4 {
  font-size: 14px; margin: 18px 0 8px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute);
}
.article h5 {
  font-size: 12px; margin: 14px 0 6px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-mute);
}
.nested-section {
  margin-left: 16px;
  padding-left: 18px;
  border-left: 3px solid var(--border-strong);
  margin-bottom: 4px;
}
.article p { margin: 0 0 14px; color: var(--text); }
.article .lead {
  font-size: 17px; color: var(--text-dim);
}
.article ul {
  padding-left: 22px; margin: 0 0 16px;
}
.article li { margin: 4px 0; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 20px; }
.article table.fields {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.article table.fields thead th {
  background: var(--surface-alt); text-align: left;
  padding: 10px 12px; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute);
  border-bottom: 1px solid var(--border);
}
.article table.fields td {
  padding: 10px 12px; vertical-align: top;
  border-top: 1px solid var(--border);
}
.article table.fields td:first-child {
  white-space: nowrap; width: 1%;
}

/* Code */
.article code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 1px 5px;
  background: var(--code-inline-bg);
  color: var(--code-inline-text);
  border-radius: 4px;
}
.article pre code {
  padding: 0; background: transparent; color: inherit; font-size: 13px;
}
.code-wrap {
  position: relative; margin: 0 0 20px;
}
.article pre {
  background: var(--code-bg); color: var(--code-text);
  padding: 16px 18px; border-radius: var(--radius);
  overflow-x: auto; margin: 0;
  font-size: 13px; line-height: 1.55;
  font-family: var(--font-mono);
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.08);
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,.14);
  padding: 4px 10px; font-size: 12px; font-weight: 600;
  border-radius: 6px; cursor: pointer;
  transition: background .15s, color .15s;
  font-family: var(--font-sans);
}
.copy-btn:hover { background: rgba(255,255,255,.18); color: white; }
.copy-btn.copied { background: #16a34a; color: white; border-color: #16a34a; }

/* Collapsible sample payloads (from PDF sticky-notes) */
details.sample {
  margin: 12px 0 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
details.sample > summary {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  background: var(--surface-alt);
  border-bottom: 1px solid transparent;
  transition: background .15s;
}
details.sample > summary::-webkit-details-marker { display: none; }
details.sample > summary::before {
  content: "▸";
  color: var(--text-mute);
  display: inline-block;
  width: 12px;
  transition: transform .15s;
}
details.sample[open] > summary::before { transform: rotate(90deg); }
details.sample[open] > summary { border-bottom-color: var(--border); }
details.sample > summary:hover { background: #eef0f5; }
details.sample .sample-label {
  font-weight: 600; color: var(--text); font-size: 14px;
}
details.sample .sample-kind {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mute); font-weight: 600;
  padding: 2px 8px; background: white; border: 1px solid var(--border);
  border-radius: 999px;
}
details.sample .sample-page {
  margin-left: auto;
  font-size: 11px; color: var(--text-mute); font-family: var(--font-mono);
}
details.sample .code-wrap { margin: 0; }
details.sample .code-wrap pre { border-radius: 0; }

/* Stage sections on legacy pages */
.stage {
  margin-top: 40px;
  padding-top: 4px;
}
.stage > h2 {
  font-size: 22px;
  margin-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.stage > p { color: var(--text-dim); max-width: 72ch; }

/* Endpoint summary card at the top of legacy pages */
.endpoint-card {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 20px 0 28px;
}
.endpoint-card .endpoint-method {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent);
}
.endpoint-card .endpoint-code {
  font-family: var(--font-mono); font-size: 16px;
  font-weight: 600; color: var(--text);
}
.endpoint-card .endpoint-meta {
  margin-left: auto;
  font-size: 12px; color: var(--text-mute);
}

/* HTTP method badge (REST endpoints) */
.method {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px;
  color: white; background: var(--accent);
}
.method.get { background: #1971c2; }
.method.post { background: #2f9e44; }
.method.put { background: #e8590c; }
.method.patch { background: #ae3ec9; }
.method.delete { background: #e03131; }

.muted { color: var(--text-mute); font-size: 13px; }

/* TOC */
.toc {
  position: sticky; top: var(--topbar-h);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 32px 20px;
  font-size: 13px;
  border-left: 1px solid var(--border);
}
.toc-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute); font-weight: 700; margin-bottom: 10px;
}
#toc-links a {
  display: block; padding: 4px 0; color: var(--text-mute);
}
#toc-links a:hover { color: var(--accent); text-decoration: none; }
#toc-links a.active { color: var(--accent); font-weight: 600; }
#toc-links .lvl-3 { padding-left: 12px; font-size: 12px; }
#toc-links:empty::before {
  content: "No sub-sections."; color: var(--text-mute); font-style: italic;
}

/* Pager */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px;
}
.pager a {
  display: flex; flex-direction: column; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); background: var(--surface);
  transition: border-color .15s, transform .15s;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.pager a span { font-size: 12px; color: var(--text-mute); }
.pager a strong { font-size: 14px; font-weight: 600; }
.pager .next { text-align: right; grid-column: 2; }
.pager .prev { grid-column: 1; }

/* Home */
.home { max-width: 1100px; margin: 0 auto; padding: 48px 24px 80px; }
.hero {
  padding: 56px 48px;
  background: linear-gradient(135deg, #e6f0f2 0%, #f3f7f4 55%, #fdf6e3 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 48px;
}
.hero-inner { max-width: 820px; }
.eyebrow {
  display: inline-block;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
  padding: 4px 10px; background: white; border-radius: 999px; border: 1px solid var(--border);
}
.hero h1 {
  font-size: 44px; line-height: 1.1; margin: 18px 0 14px;
  letter-spacing: -.03em;
}
.hero p { font-size: 18px; color: var(--text-dim); margin: 0 0 24px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-mute); text-decoration: none; }

.endpoint-chip {
  display: inline-flex; align-items: center; gap: 10px;
  background: white; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px 6px 6px; font-family: var(--font-mono); font-size: 13px;
  color: var(--text-dim);
}
.endpoint-chip .method {
  background: var(--accent); color: white; font-family: var(--font-sans);
  font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; letter-spacing: .05em;
}

.section-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 20px; margin-bottom: 48px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px 24px;
}
.card h2 {
  font-size: 15px; margin: 0 0 12px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}
.card ul { list-style: none; margin: 0; padding: 0; }
.card li { border-bottom: 1px dashed var(--border); }
.card li:last-child { border-bottom: none; }
.card li a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; color: var(--text); font-weight: 500;
}
.card li a .arrow { color: var(--text-mute); transition: transform .15s; }
.card li a:hover { color: var(--accent); text-decoration: none; }
.card li a:hover .arrow { transform: translateX(4px); color: var(--accent); }

.quicklinks { margin-top: 48px; }
.quicklinks h2 {
  font-size: 20px; margin-bottom: 18px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.concepts {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px;
}
.concept {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
}
.concept h3 { font-size: 14px; margin: 0 0 6px; }
.concept p { font-size: 13px; color: var(--text-dim); margin: 0; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  background: var(--surface);
  font-size: 13px; color: var(--text-mute);
}
.footer-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

/* Responsive */
@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 82%;
    max-width: 320px; transform: translateX(-100%); transition: transform .2s;
    border-right: 1px solid var(--border); z-index: 30;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,.15); }
  .menu-toggle { display: inline-block; }
  .topnav { display: none; }
  .content { padding: 20px 20px 60px; }
  .hero { padding: 36px 24px; }
  .hero h1 { font-size: 30px; }
  .section-grid, .concepts { grid-template-columns: 1fr; }
  .search { max-width: 100%; }
}
@media (max-width: 600px) {
  .brand-text small { display: none; }
}
