:root {
  color-scheme: dark;
  --bg: #05070f;
  --bg-elev: #0b1120;
  --bg-elev-2: #121c33;
  --border: #1c2740;
  --border-strong: #2b3a66;
  --text: #e6ebff;
  --text-muted: #aab4d4;
  --text-dim: #7c88ab;
  --accent: #8aa0ff;
  --accent-bright: #a9baff;
  --accent-soft: rgba(138, 160, 255, 0.1);
  --prose: 44rem;
  --header-h: 3.75rem;
  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--bg);
  background-image: radial-gradient(1200px 700px at 70% -15%, #1a2542 0%, rgba(10, 15, 31, 0) 60%);
  background-repeat: no-repeat;
}

a {
  color: var(--accent);
  text-decoration-color: rgba(138, 160, 255, 0.4);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-bright);
  text-decoration-color: currentColor;
}

/* ---------- Site header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 7, 15, 0.82);
  backdrop-filter: blur(12px);
}

.wordmark {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

.wordmark:hover {
  color: var(--accent-bright);
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-dim);
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current='page'] {
  color: var(--accent);
}

/* ---------- Layout ---------- */

.wrap {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.doc-head {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  margin-bottom: 1.5rem;
}

.doc-head h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--text);
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-dim);
  list-style: none;
  padding: 0;
}

.doc-meta li + li {
  position: relative;
  padding-left: 1.25rem;
}

.doc-meta li + li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: var(--border-strong);
}

.entity {
  margin: 1.75rem 0 0;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.entity strong {
  color: var(--text-muted);
  font-weight: 600;
}

.doc-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  padding: 2.5rem 0 4rem;
}

/* ---------- Table of contents ---------- */

.toc {
  font-size: 0.875rem;
}

.toc summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-elev);
  list-style: none;
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc summary::after {
  content: '+';
  float: right;
  color: var(--text-dim);
  font-weight: 400;
}

.toc details[open] summary::after {
  content: '\2212';
}

.toc-title {
  display: none;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.75rem;
}

.toc ol {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0 0 0 0.25rem;
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-left: 2px solid var(--border);
  color: var(--text-dim);
  text-decoration: none;
}

.toc a:hover {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Prose ---------- */

.prose {
  max-width: var(--prose);
  min-width: 0;
}

.prose > section {
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
}

.prose h2 {
  font-size: 1.375rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 3.5rem 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.prose > section:first-of-type > h2 {
  margin-top: 0;
}

.prose h3 {
  font-size: 1.0625rem;
  line-height: 1.4;
  color: var(--text);
  margin: 2.25rem 0 0.75rem;
}

.prose h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent);
  margin: 1.75rem 0 0.5rem;
}

.prose p {
  margin: 0 0 1.125rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose li::marker {
  color: var(--border-strong);
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.lead {
  font-size: 1.0625rem;
  color: var(--text-muted);
}

.caps {
  font-variant-numeric: tabular-nums;
}

/* All-caps legal blocks: keep them readable rather than shouting in body size. */
.legalese {
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

/* ---------- Callouts ---------- */

.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-left-color: var(--accent);
  border-radius: 0.5rem;
  background: var(--accent-soft);
  font-size: 0.9375rem;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout .callout-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

/* ---------- Tables ---------- */

.table-wrap {
  margin: 1.5rem 0 2rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-elev);
}

table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

caption {
  text-align: left;
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

thead th {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  white-space: nowrap;
}

tbody th {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- Definition lists ---------- */

.defs {
  margin: 1.5rem 0;
}

.defs dt {
  font-weight: 600;
  color: var(--text);
  margin-top: 1.125rem;
}

.defs dd {
  margin: 0.25rem 0 0;
}

/* ---------- Contact block ---------- */

.contact-card {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-elev);
  font-size: 0.9375rem;
}

.contact-card dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.5rem 1.25rem;
  margin: 0;
}

.contact-card dt {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-top: 0.15rem;
}

.contact-card dd {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

.site-footer nav {
  display: flex;
  gap: 1.25rem;
  margin-left: auto;
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

.site-footer p {
  margin: 0;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: 0 0 0.5rem 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Desktop: sidebar TOC ---------- */

@media (min-width: 62rem) {
  .doc-body {
    grid-template-columns: minmax(0, 1fr) 16rem;
  }

  .prose {
    grid-column: 1;
    grid-row: 1;
  }

  .toc {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: calc(var(--header-h) + 2rem);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 4rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .toc-title {
    display: block;
  }

  .toc summary {
    display: none;
  }

  .toc ol {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ---------- Print ---------- */

@media print {
  :root {
    --text: #000;
    --text-muted: #1a1a1a;
    --text-dim: #444;
    --border: #ccc;
    --border-strong: #999;
    --accent: #000;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
    line-height: 1.5;
  }

  .site-header,
  .toc,
  .skip-link,
  .site-footer nav {
    display: none;
  }

  .doc-body {
    display: block;
    padding: 0;
  }

  .prose {
    max-width: none;
  }

  .prose h2 {
    page-break-after: avoid;
    margin-top: 1.5rem;
  }

  .prose h3,
  .prose h4 {
    page-break-after: avoid;
  }

  .table-wrap,
  .callout,
  .contact-card,
  tr {
    page-break-inside: avoid;
  }

  .table-wrap {
    overflow: visible;
    background: none;
  }

  table {
    min-width: 0;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}
