:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-code: #f6f7f9;
  --fg: #16181d;
  --fg-muted: #5b6270;
  --fg-faint: #858c99;
  --border: #e3e6ea;
  --accent: #0b7a6f;
  --accent-soft: #e7f5f2;
  --accent-fg: #ffffff;
  --ok: #17683c;
  --warn: #8a5a00;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --wrap: 1260px;
  --sidebar: 240px;
  --toc: 200px;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f1115;
    --bg-soft: #171a20;
    --bg-code: #14171d;
    --fg: #e6e9ef;
    --fg-muted: #a2aab8;
    --fg-faint: #79818f;
    --border: #262b34;
    --accent: #4fd8c4;
    --accent-soft: #0f2421;
    --accent-fg: #16181d;
    --ok: #6fd39b;
    --warn: #e7b45c;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #171a20;
  --bg-code: #14171d;
  --fg: #e6e9ef;
  --fg-muted: #a2aab8;
  --fg-faint: #79818f;
  --border: #262b34;
  --accent: #4fd8c4;
  --accent-soft: #0f2421;
  --accent-fg: #16181d;
  --ok: #6fd39b;
  --warn: #e7b45c;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-fg); padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

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

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.bar {
  max-width: var(--wrap); margin: 0 auto; padding: .55rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 650; letter-spacing: -.01em; color: var(--fg); text-decoration: none; font-size: 1.02rem;
}
.brand .mark { color: var(--accent); }
.nav { margin-left: auto; display: flex; gap: 1.1rem; flex-wrap: wrap; }
.nav a { color: var(--fg-muted); text-decoration: none; font-size: .93rem; font-weight: 500; }
.nav a:hover, .nav a[aria-current] { color: var(--fg); }
.theme {
  background: none; border: 1px solid var(--border); color: var(--fg-muted);
  border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
}
.theme:hover { color: var(--fg); border-color: var(--fg-faint); }

/* ---------- landing ---------- */

.hero {
  color: #f6fcf6; background: #103c37;
  background-image: linear-gradient(110deg, #103c37 25%, #17534a);
  padding: clamp(3rem, 8vw, 7rem) 0;
}
.hero .wrap { display: grid; gap: 3rem; align-items: center; }
@media (min-width: 950px) { .hero .wrap { grid-template-columns: 1.1fr 1fr; gap: 5rem; } }
.eyebrow, .frame figcaption { font: 600 .84rem/1.4 var(--mono); letter-spacing: .06em; }
.hero .eyebrow { color: #b9f5d9; margin: 0 0 1.3rem; }
.hero h1 { font-size: clamp(3.7rem, 7vw, 6rem); line-height: .98; letter-spacing: -.055em; margin: 0; }
.hero .lede { max-width: 33rem; color: #d4e6de; margin: 1.5rem 0 2rem; }
.hero .btn-primary { background: #d5f782; color: #183328; }
.hero .btn-ghost { color: #f6fcf6; border-color: #82a99b; }
.frame { margin: 0; padding: clamp(1rem, 3vw, 2rem); background: #0b2825; border: 1px solid #59867a; border-radius: 12px; }
.frame figcaption { color: #cde7dc; }
.frame figcaption span { color: #80a298; padding: 0 .4rem; }
.octets { display: grid; grid-template-columns: repeat(6, 1fr); gap: .32rem; margin: 1.8rem 0 1rem; }
.octets b { text-align: center; padding: .45em 0; background: #20433d; border-bottom: 2px solid #80bcad; font: 500 clamp(1.1rem, 2.5vw, 2rem)/1.4 var(--mono); }
.octets b:first-child { color: #d5f782; border-color: currentColor; }
.frame dl { margin: 0 0 1.25rem; }
.frame dl div { display: grid; grid-template-columns: 11ch 1fr; align-items: baseline; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid #31524a; }
.frame dt { font: .9rem var(--mono); color: #b6dfc9; }
.frame dd { margin: 0; font-size: .92rem; }
.frame a { color: #d5f782; font-size: .92rem; }
.cta { display: flex; gap: .7rem; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: var(--radius); font-weight: 600; font-size: .95rem;
  text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { border-color: var(--border); color: var(--fg); }
.btn-ghost:hover { border-color: var(--fg-faint); }

.handbook { padding-block: clamp(2.5rem, 5vw, 5rem); }
.handbook h1, .section-title h2 { line-height: 1.1; letter-spacing: -.04em; margin: 0; }
.handbook h1 { font-size: clamp(2.2rem, 5vw, 4rem); }
.section-title { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.section-title h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; margin-top: 2rem; }
.guide { display: block; background: var(--bg-soft); padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.guide-group { margin-top: 2.5rem; }
.guide-group h2 { margin-bottom: 0; }
.guide-group .guides { margin-top: .8rem; }
.guide:hover, .guide:focus-visible { border-color: var(--accent); }
.guide strong { display: block; color: var(--fg); margin-bottom: .6rem; }
.guide strong::after { content: "↗"; float: right; color: var(--accent); }
.guide span, .page-lede { color: var(--fg-muted); }
/* ---------- docs layout ---------- */

/* One column on a phone, sidebar + article on a laptop, and a third rail for the on-page
   contents where there is room for it without squeezing the reading measure. */
.docs { display: grid; gap: 2.5rem; align-items: start; padding-block: 2rem 4rem; }
@media (min-width: 950px) {
  .docs { grid-template-columns: var(--sidebar) minmax(0, 1fr); gap: 3rem; }
}
@media (min-width: 1180px) {
  .docs { grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc); }
}

.sidebar { position: sticky; top: 4.25rem; font-size: .93rem; }
.sidebar h2 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-faint); margin: 0 0 .6rem; font-weight: 650;
}
.sidebar ol { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block; padding: .3rem .6rem; border-radius: 7px; color: var(--fg-muted);
  text-decoration: none; border-left: 2px solid transparent;
}
.sidebar a:hover { color: var(--fg); background: var(--bg-soft); }
.sidebar a[aria-current="page"] {
  color: var(--accent); font-weight: 600; background: var(--accent-soft); border-left-color: var(--accent);
}

article { min-width: 0; max-width: 46rem; }

/* ---------- breadcrumb ---------- */

.breadcrumb {
  display: flex; flex-wrap: wrap; gap: .45rem; align-items: center;
  font-size: .84rem; color: var(--fg-faint); margin: 0 0 1rem;
}
.breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--fg-faint); }

/* ---------- on-page contents ---------- */

/* The right rail exists only where there is a column for it. Below that it would be a
   screenful of duplicated links above the article it describes, and the page already has
   a section navigation, anchored headings and find-in-page. */
.toc { display: none; font-size: .86rem; }
@media (min-width: 1180px) {
  .toc { display: block; position: sticky; top: 4.25rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
}
.toc h2 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-faint); margin: 0 0 .5rem; font-weight: 650;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block; padding: .22rem 0 .22rem .7rem; color: var(--fg-muted);
  text-decoration: none; border-left: 2px solid var(--border);
}
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }
article h1 { font-size: 2rem; letter-spacing: -.03em; margin: 0 0 .35rem; line-height: 1.15; }
article .page-lede { color: var(--fg-muted); font-size: 1.05rem; margin: 0 0 2.25rem; }
article h2 {
  font-size: 1.35rem; letter-spacing: -.02em; margin: 2.75rem 0 .75rem;
  padding-top: .75rem; border-top: 1px solid var(--border);
}
article h3 { font-size: 1.05rem; margin: 1.85rem 0 .5rem; }
article p, article li { overflow-wrap: break-word; }
article ul, article ol { padding-left: 1.35rem; }
article li { margin: .3rem 0; }
article img { max-width: 100%; height: auto; }

h2 a.zola-anchor, h3 a.zola-anchor {
  color: var(--fg-faint); text-decoration: none; margin-left: .4rem; opacity: 0; font-weight: 400;
}
h2:hover a.zola-anchor, h3:hover a.zola-anchor { opacity: 1; }

blockquote {
  margin: 1.5rem 0; padding: .9rem 1.1rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
blockquote p { margin: 0; }
blockquote p + p { margin-top: .6rem; }

/* ---------- code ---------- */

code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 5px; padding: .1em .35em;
}
pre {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; overflow-x: auto; font-size: .88rem; line-height: 1.6; margin: 1.25rem 0;
}
pre code { background: none; border: 0; padding: 0; font-size: 1em; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; margin: 1.25rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 650; color: var(--fg); white-space: nowrap; }
tbody tr:hover { background: var(--bg-soft); }

/* ---------- utility ---------- */

.muted { color: var(--fg-muted); }
.pill {
  display: inline-block; font-family: var(--mono); font-size: .78rem;
  border: 1px solid var(--border); border-radius: 999px; padding: .1rem .55rem; color: var(--fg-muted);
}
.next {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 3.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); font-size: .93rem;
}

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0; background: var(--bg-soft); }
.site-footer p { margin: 0 0 .6rem; font-size: .9rem; }
.site-footer .muted { font-size: .82rem; max-width: 52rem; }
.site-footer nav { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-top: 1rem; font-size: .9rem; }

/* ---------- search ---------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.search { position: relative; }
.search input {
  width: 12rem; max-width: 34vw;
  padding: .35rem .65rem; font: inherit; font-size: .88rem;
  color: var(--fg); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 8px;
}
.search input::placeholder { color: var(--fg-faint); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

#results {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 30;
  width: min(30rem, 88vw); max-height: 70vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / .18);
}
#results a {
  display: block; padding: .7rem .9rem; text-decoration: none; color: var(--fg);
  border-bottom: 1px solid var(--border);
}
#results a:last-child { border-bottom: 0; }
#results a:hover { background: var(--bg-soft); }
#results strong { display: block; font-size: .93rem; color: var(--accent); }
#results span { display: block; font-size: .82rem; color: var(--fg-muted); margin-top: .15rem; }
#results .no-hits { margin: 0; padding: .8rem .9rem; font-size: .88rem; color: var(--fg-muted); }

@media (max-width: 720px) {
  .search input { width: 7.5rem; }
  .nav { gap: .8rem; font-size: .88rem; }
}

.coverage table { width: max-content; }
.coverage th, .coverage td { max-width: 24rem; vertical-align: top; }
.coverage td code { white-space: normal; overflow-wrap: anywhere; }
.coverage td:first-child code { white-space: nowrap; }
#coverage-controls:not([hidden]) {
  display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1rem;
}
#coverage-controls label { font-weight: 500; }
#coverage-query {
  font: inherit; background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .4rem .6rem; max-width: 100%;
}
#coverage-count { font-size: .9rem; color: var(--fg-muted); }
.coverage td:first-child, .coverage th:first-child {
  position: sticky; left: 0; background: var(--bg); border-right: 1px solid var(--border);
}


@media (max-width: 949px) {
  .sidebar { display: none; }
  .docs { grid-template-columns: minmax(0, 1fr); }
  article { width: 100%; margin-inline: auto; }
}
@media (max-width: 520px) {
  .bar { gap: .65rem; padding-inline: .8rem; }
  .search { min-width: 0; }
  .search input, .search input:focus { width: min(24vw, 7rem); }
  .theme { flex: none; }
}
article > table { display: block; overflow-x: auto; }
@media (max-width: 600px) {
  #results { position: fixed; inset: 3.2rem .75rem auto; width: auto; }
}
