:root {
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --text: #1a1d23;
  --text-muted: #5b6270;
  --border: #e1e4ea;
  --accent: #2554c7;
  --accent-contrast: #ffffff;
  --banner-bg: #fff4e5;
  --banner-border: #f0b429;
  --banner-text: #7a4a00;
  --link: #2554c7;
  --code-bg: #f0f1f4;
  --table-head-bg: #f0f2f6;
  --status-red: #b3261e;
  --status-amber: #8a5a00;
  --status-green: #1c6b3a;
  --max-width: 880px;
  --layout-width: 1120px;
  --sidebar-width: 220px;
  --font-body: 'Outfit', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-alt: #1b1e24;
    --text: #e7e9ee;
    --text-muted: #a3a9b7;
    --border: #2c303a;
    --accent: #7fa2ff;
    --accent-contrast: #0d1117;
    --banner-bg: #3a2d0f;
    --banner-border: #b3820f;
    --banner-text: #f2d089;
    --link: #7fa2ff;
    --code-bg: #20232b;
    --table-head-bg: #1f232b;
    --status-red: #ff8a80;
    --status-amber: #ffcc66;
    --status-green: #7fe3a3;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 10px; top: 10px; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 14px 20px;
  gap: 12px;
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.brand span { color: var(--accent); font-weight: 400; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

/* Persistent categorized sidebar (desktop) / collapsible menu panel (mobile) —
   one component, restyled per breakpoint below rather than duplicated. */
.layout {
  max-width: var(--layout-width);
  margin: 0 auto;
  padding: 32px 20px 60px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 20px;
}
.site-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 6px;
}
.site-nav a:hover { color: var(--text); background: var(--bg-alt); }
.site-nav a.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}
.site-nav > a:first-child { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.nav-group-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 1.2em 0 0.4em;
}
.nav-group-label:first-of-type { margin-top: 0.6em; }

.draft-banner {
  background: var(--banner-bg);
  border-bottom: 1px solid var(--banner-border);
  color: var(--banner-text);
  font-size: 0.9rem;
  padding: 10px 0;
}
.draft-banner a { color: inherit; text-decoration: underline; }

main { min-width: 0; }

h1 { font-size: 1.8rem; margin-top: 0; max-width: 38ch; }
h2 { font-size: 1.3rem; margin-top: 2.2em; border-top: 1px solid var(--border); padding-top: 1em; max-width: 38ch; scroll-margin-top: 16px; }
h3 { font-size: 1.05rem; margin-top: 1.6em; max-width: 38ch; }

/* Prose measure: policy text reads better capped well under the 880px container;
   tables, callouts, and the doc-grid stay full width since they aren't running text. */
main p, main > ul, main > ol {
  max-width: 70ch;
}

.doc-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5em;
  max-width: none;
}

.callout {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 1.4em 0;
  font-size: 0.95rem;
  max-width: none;
}
.callout.warn { border-left-color: var(--banner-border); }

.toc {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px 16px;
  margin: 1.4em 0 2em;
  max-width: none;
}
.toc-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.5em;
}
.toc ol {
  margin: 0;
  padding-left: 1.2em;
  columns: 2;
  column-gap: 24px;
}
.toc li { margin-bottom: 0.35em; font-size: 0.9rem; break-inside: avoid; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }
@media (max-width: 560px) {
  .toc ol { columns: 1; }
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0 1.6em;
  font-size: 0.92rem;
  overflow-x: auto;
  display: block;
  max-width: none;
}
th, td {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  vertical-align: top;
}
th { background: var(--table-head-bg); font-weight: 600; white-space: nowrap; }
td { min-width: 160px; }

code {
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

a { color: var(--link); }

ul, ol { padding-left: 1.4em; }
li { margin-bottom: 0.3em; }

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 1.4em 0;
}
.doc-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--bg-alt);
  text-decoration: none;
  color: var(--text);
  display: block;
}
.doc-card:hover { border-color: var(--accent); }
.doc-card h3 { margin: 0 0 6px; color: var(--accent); }
.doc-card p { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

.group-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 2em 0 0.6em;
}

.status-red { color: var(--status-red); font-weight: 600; }
.status-amber { color: var(--status-amber); font-weight: 600; }
.status-green { color: var(--status-green); font-weight: 600; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 32px 0 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 20px;
}
.footer-grid a { color: var(--text-muted); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); }
.fine-print {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 0.8rem;
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }

  .layout { display: block; padding: 24px 20px 60px; }

  .sidebar { position: static; }
  .site-nav {
    display: none;
    width: 100%;
    margin-bottom: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-alt);
  }
  .site-nav.open { display: flex; }
}
