/* ---------------------------------------------------------------------------
   Stitchwork documentation — standalone stylesheet.

   No build step, no external fonts, no CDN. Everything here is self-contained
   so the docs folder can be dropped on any static host (or opened from disk).

   Palette follows the marketing site: warm paper, ink, a single brown accent.
   Dark mode mirrors it rather than inverting to blue-grey, so the two sites
   still read as one brand at night.
--------------------------------------------------------------------------- */

:root {
  --paper:        #f7f4ee;
  --paper-warm:   #efe9dd;
  --paper-sunk:   #e9e2d4;
  --surface:      #fffdf9;
  --ink:          #1c1b18;
  --ink-soft:     #4a4843;
  --ink-faint:    #6f6b61;
  --rule:         #ddd6c6;
  --rule-soft:    #e8e1d2;
  --accent:       #7a4a2b;
  --accent-ink:   #4a2c19;
  --accent-wash:  #f1e6db;

  --ok:           #2f6b45;
  --ok-wash:      #e4efe7;
  --warn:         #8a5a12;
  --warn-wash:    #f6ecd9;
  --danger:       #8c3227;
  --danger-wash:  #f6e3e0;

  --code-bg:      #221f1b;
  --code-ink:     #ece5d8;
  --code-dim:     #9b9384;
  --code-str:     #c9b784;
  --code-key:     #d9a679;

  /* The marketing site's thread colour. It belongs to the logo, not to the
     docs UI — everything else here still runs on --accent. */
  --thread:       #b8410e;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'URW Palladio L', Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --sidebar-w: 268px;
  --toc-w: 208px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 27, 24, .05), 0 8px 24px rgba(28, 27, 24, .06);
}

:root[data-theme="dark"] {
  --paper:        #161513;
  --paper-warm:   #1e1c19;
  --paper-sunk:   #100f0d;
  --surface:      #1c1a17;
  --ink:          #ece7dc;
  --ink-soft:     #b8b1a3;
  --ink-faint:    #8e877a;
  --rule:         #322e28;
  --rule-soft:    #262320;
  --accent:       #c99263;
  --accent-ink:   #e0b088;
  --accent-wash:  #2a221b;
  /* The thread lifted off the true brand hue — #b8410e on near-black is only
     3.4:1, which is thin even for a graphic. */
  --thread:       #e0612a;

  --ok:           #7fbd97;
  --ok-wash:      #1c2620;
  --warn:         #d8ac63;
  --warn-wash:    #2a2318;
  --danger:       #e0897c;
  --danger-wash:  #2c1e1c;

  --code-bg:      #0f0e0c;
  --code-ink:     #ded7c9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #161513;
    --paper-warm:   #1e1c19;
    --paper-sunk:   #100f0d;
    --surface:      #1c1a17;
    --ink:          #ece7dc;
    --ink-soft:     #b8b1a3;
    --ink-faint:    #8e877a;
    --rule:         #322e28;
    --rule-soft:    #262320;
    --accent:       #c99263;
    --accent-ink:   #e0b088;
    --accent-wash:  #2a221b;
    --thread:       #e0612a;
    --ok:           #7fbd97;
    --ok-wash:      #1c2620;
    --warn:         #d8ac63;
    --warn-wash:    #2a2318;
    --danger:       #e0897c;
    --danger-wash:  #2c1e1c;
    --code-bg:      #0f0e0c;
    --code-ink:     #ded7c9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

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

header.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
@supports not (backdrop-filter: blur(1px)) {
  header.topbar { background: var(--paper); }
}

/* The logo mark, lifted straight off the marketing site. The two paths carry
   no colour of their own: the ink stitch inherits the surrounding text colour
   so it flips with the theme, and the thread stitch stays the brand's. */
.logo-mark { width: 22px; height: 22px; flex: none; }
.logo-mark .lm-ink { stroke: currentColor; }
.logo-mark .lm-thread { stroke: var(--thread); }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--accent-ink); }
.brand .wordmark {
  font-family: var(--serif);
  font-size: 20px; letter-spacing: -.01em; line-height: 1;
}
.brand .kicker {
  font-family: var(--sans);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 9px; border-left: 1px solid var(--rule);
}

.topbar .spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

button.icon-btn, a.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; min-width: 34px; padding: 0 10px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink-soft);
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
button.icon-btn:hover, a.icon-btn:hover {
  background: var(--paper-warm); color: var(--ink); border-color: var(--ink-faint);
  text-decoration: none;
}
button.icon-btn svg, a.icon-btn svg { width: 15px; height: 15px; display: block; }

/* The route back to the marketing site. Docs opened from a search result are
   often someone's first contact with Stitchwork, and there was no way home.
   It takes .icon-btn's colour and border — the three controls on the right of
   the bar are one quiet group. */
.to-site svg { margin-left: -2px; }

.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px 0 11px;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink-faint);
  font: inherit; font-size: 14px;
  cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--ink-faint); }
.search-trigger .label { flex: 1; }
.search-trigger kbd { margin-left: auto; }

kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 2px 5px; border-radius: 4px;
  background: var(--paper-sunk); border: 1px solid var(--rule);
  color: var(--ink-faint);
}

/* Drawer trigger — desktop hides it. Typed selector so it beats
   `button.icon-btn`'s own display. */
button.nav-toggle { display: none; }

/* --- layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
}

/* --- sidebar ------------------------------------------------------------ */

.sidebar {
  grid-column: 1;
  position: sticky; top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 20px 60px 24px;
  border-right: 1px solid var(--rule);
}
.sidebar nav > .nav-group { margin-bottom: 26px; }
.sidebar .nav-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 9px 10px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li + li { margin-top: 1px; }
.sidebar a {
  display: block;
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.45;
  border-left: 2px solid transparent;
}
.sidebar a:hover { background: var(--paper-warm); color: var(--ink); text-decoration: none; }
.sidebar a[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-weight: 500;
}
.sidebar .sub { margin: 2px 0 6px 10px; padding-left: 10px; border-left: 1px solid var(--rule-soft); }
.sidebar .sub a { font-size: 13.5px; padding: 3px 9px; color: var(--ink-faint); }

/* --- content ------------------------------------------------------------ */

main {
  grid-column: 2;
  min-width: 0;
  padding: 44px 52px 96px;
}

.eyebrow {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

main h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(32px, 4vw, 42px);
  line-height: 1.12; letter-spacing: -.015em;
  margin: 0 0 14px;
}
main .lede {
  font-size: 19px; line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 40px;
  max-width: 62ch;
}

main h2 {
  font-family: var(--serif); font-weight: 400;
  font-size: 27px; line-height: 1.2; letter-spacing: -.01em;
  margin: 56px 0 14px;
  padding-top: 4px;
}
main h2:first-of-type { margin-top: 4px; }
main h3 {
  font-family: var(--sans); font-weight: 600;
  font-size: 17.5px; line-height: 1.35;
  margin: 34px 0 10px;
}
main h4 {
  font-family: var(--sans); font-weight: 600;
  font-size: 15px; letter-spacing: .01em;
  color: var(--ink-soft);
  margin: 24px 0 8px;
}

main p { margin: 0 0 16px; max-width: 72ch; }
main ul, main ol { margin: 0 0 16px; padding-left: 22px; max-width: 72ch; }
main li { margin-bottom: 6px; }
main li > ul, main li > ol { margin-top: 6px; margin-bottom: 4px; }

main hr {
  border: 0; border-top: 1px solid var(--rule);
  margin: 44px 0;
}

.anchor {
  float: left; margin-left: -22px; width: 22px;
  color: var(--rule); opacity: 0;
  font-weight: 400; text-decoration: none;
  transition: opacity .12s ease;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
.anchor:hover { color: var(--accent); text-decoration: none; }

strong { font-weight: 600; }

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

code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--paper-sunk);
  border: 1px solid var(--rule-soft);
  border-radius: 5px;
  padding: .1em .38em;
  /* Break only when the token genuinely doesn't fit — a long JSON snippet in
     prose must not push the page sideways on a phone. */
  overflow-wrap: break-word;
  word-break: break-word;
}
a code { color: inherit; }

pre {
  position: relative;
  margin: 0 0 20px;
  padding: 16px 18px;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.62;
  -webkit-overflow-scrolling: touch;
}
pre code {
  background: none; border: 0; padding: 0;
  font-size: inherit; color: inherit;
  white-space: pre;
}
pre .cm { color: var(--code-dim); }
pre .st { color: var(--code-str); }
pre .kw { color: var(--code-key); }

.copy-btn {
  position: absolute; top: 8px; right: 8px;
  height: 26px; padding: 0 9px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 6px;
  color: #cfc7b8;
  font: inherit; font-size: 11.5px; letter-spacing: .02em;
  cursor: pointer; opacity: 0;
  transition: opacity .12s ease, background .12s ease;
}
pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.copy-btn.done { color: #9ed5b2; }

.code-label {
  display: block;
  font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 7px;
}

/* --- callouts ----------------------------------------------------------- */

.callout {
  margin: 0 0 22px;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-wash);
  font-size: 15.5px;
  max-width: 72ch;
}
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title {
  display: block;
  font-weight: 600; font-size: 13px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}
.callout.warn { border-color: var(--warn); background: var(--warn-wash); }
.callout.warn .callout-title { color: var(--warn); }
.callout.danger { border-color: var(--danger); background: var(--danger-wash); }
.callout.danger .callout-title { color: var(--danger); }
.callout.ok { border-color: var(--ok); background: var(--ok-wash); }
.callout.ok .callout-title { color: var(--ok); }

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

.table-wrap {
  overflow-x: auto;
  margin: 0 0 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td {
  text-align: left; vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule-soft);
}
thead th {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--paper-warm);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--paper-warm); }
td code, th code { white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }

/* --- endpoint blocks ---------------------------------------------------- */

.endpoint {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0 0 18px;
  overflow: hidden;
}
.endpoint > .ep-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--rule);
}
.endpoint > .ep-body { padding: 14px 16px 2px; }
.endpoint > .ep-body > :last-child { margin-bottom: 14px; }
.ep-path {
  font-family: var(--mono); font-size: 14px;
  color: var(--ink);
  word-break: break-all;
}
.ep-note {
  width: 100%;
  font-size: 14px; color: var(--ink-soft);
  margin: 0;
}

.method {
  display: inline-block;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: .06em;
  padding: 3px 7px; border-radius: 5px;
  color: #fff; background: var(--ink-faint);
  text-transform: uppercase;
}
.method.get    { background: #2f6b45; }
.method.post   { background: #7a4a2b; }
.method.put    { background: #8a5a12; }
.method.patch  { background: #8a5a12; }
.method.delete { background: #8c3227; }

.pill {
  display: inline-block;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .05em;
  padding: 3px 8px; border-radius: 99px;
  border: 1px solid var(--rule);
  background: var(--paper-sunk);
  color: var(--ink-faint);
  white-space: nowrap;
}
.pill.auth-session { border-color: #9ab3a4; color: var(--ok); background: var(--ok-wash); }
.pill.auth-public  { border-color: #c9a98e; color: var(--accent); background: var(--accent-wash); }
.pill.auth-secret  { border-color: #c99; color: var(--danger); background: var(--danger-wash); }
.pill.auth-none    { border-color: var(--rule); }
.pill.owner        { border-color: #d3b98d; color: var(--warn); background: var(--warn-wash); }

/* --- cards -------------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 0 0 30px;
}
.card {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
a.card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 6px;
  font-size: 16px; font-weight: 600;
  color: var(--ink);
}
.card p { margin: 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.5; }
.card .card-kicker {
  display: block;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px;
}

/* --- steps -------------------------------------------------------------- */

ol.steps { list-style: none; margin: 0 0 28px; padding: 0; counter-reset: step; max-width: 74ch; }
ol.steps > li {
  position: relative;
  counter-increment: step;
  padding: 0 0 26px 46px;
  margin: 0;
  border-left: 1px solid var(--rule);
  margin-left: 15px;
}
ol.steps > li:last-child { border-left-color: transparent; padding-bottom: 4px; }
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: -15px; top: -2px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--paper); border: 1px solid var(--rule);
  font-size: 13px; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
ol.steps > li > h3 { margin: 2px 0 8px; }
ol.steps > li > :last-child { margin-bottom: 0; }

/* --- diagram ------------------------------------------------------------ */

.flow {
  margin: 0 0 26px;
  padding: 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
}
.flow pre {
  margin: 0; padding: 0;
  background: none; color: var(--ink-soft);
  font-size: 13px; line-height: 1.5;
}
.flow figcaption {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
  font-size: 14px; color: var(--ink-faint);
}

/* --- definition list ---------------------------------------------------- */

dl.defs { margin: 0 0 24px; max-width: 72ch; }
dl.defs dt {
  font-family: var(--mono); font-size: 14px;
  color: var(--ink); font-weight: 600;
  margin-top: 16px;
}
dl.defs dt:first-child { margin-top: 0; }
dl.defs dd { margin: 4px 0 0; color: var(--ink-soft); font-size: 15px; }

/* --- on-this-page ------------------------------------------------------- */

.toc {
  grid-column: 3;
  position: sticky; top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 46px 24px 60px 4px;
  font-size: 13.5px;
}
.toc .toc-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 10px;
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a {
  display: block;
  padding: 4px 0 4px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-faint);
  line-height: 1.4;
}
.toc li a:hover { color: var(--ink); text-decoration: none; }
.toc li a.active { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 500; }
.toc li.lvl-3 a { padding-left: 24px; font-size: 13px; }

/* --- pager -------------------------------------------------------------- */

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 56px; padding-top: 28px;
  border-top: 1px solid var(--rule);
}
.pager a {
  display: block; padding: 14px 18px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .14s ease;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir {
  display: block; font-size: 11.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 3px;
}
.pager .ttl { font-size: 16px; color: var(--accent-ink); font-weight: 500; }
.pager .next { grid-column: 2; text-align: right; }
.pager .prev { grid-column: 1; }

/* Page footer. It carries the mark and the way back out to the rest of
   Stitchwork — the sidebar only ever points further into the docs. */
footer.docs-foot {
  margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 13.5px; color: var(--ink-faint);
  display: flex; flex-wrap: wrap; gap: 20px 36px;
  align-items: start; justify-content: space-between;
}
.docs-foot .df-brand { display: flex; flex-direction: column; gap: 6px; }
.docs-foot .df-mark { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.docs-foot .df-mark:hover { color: var(--accent-ink); text-decoration: none; }
.docs-foot .df-mark .logo-mark { width: 19px; height: 19px; }
.docs-foot .df-word { font-family: var(--serif); font-size: 17px; letter-spacing: -.01em; line-height: 1; }
.docs-foot .df-meta { font-size: 12.5px; }
.docs-foot .df-links { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; }
.docs-foot .df-links a { color: var(--ink-soft); padding-block: 3px; }
.docs-foot .df-links a:hover { color: var(--accent-ink); }

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

.search-modal[hidden] { display: none; }
.search-modal {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: start center;
  padding: 12vh 20px 20px;
  background: color-mix(in srgb, var(--paper-sunk) 72%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.search-panel {
  width: min(640px, 100%);
  max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(28, 27, 24, .22);
  overflow: hidden;
}
.search-panel input {
  border: 0; border-bottom: 1px solid var(--rule);
  background: transparent; color: var(--ink);
  font: inherit; font-size: 17px;
  padding: 16px 18px;
  outline: none;
}
.search-panel input::placeholder { color: var(--ink-faint); }
.search-results { overflow-y: auto; padding: 6px; }
.search-results a {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--ink);
}
.search-results a:hover, .search-results a.sel { background: var(--accent-wash); text-decoration: none; }
.search-results .r-title,
.search-results .r-crumb,
.search-results .r-blurb { display: block; }
.search-results .r-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.search-results .r-crumb {
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 1px;
}
.search-results .r-blurb {
  font-size: 13px; color: var(--ink-soft);
  margin-top: 2px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-empty { padding: 26px 18px; color: var(--ink-faint); font-size: 14.5px; text-align: center; }
.search-foot {
  border-top: 1px solid var(--rule);
  padding: 8px 14px;
  font-size: 12px; color: var(--ink-faint);
  display: flex; gap: 14px;
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  main { grid-column: 2; padding: 40px 36px 90px; }
}

@media (max-width: 860px) {
  :root { --header-h: 56px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  button.nav-toggle { display: inline-flex; }
  .search-trigger { min-width: 0; }
  .search-trigger .label, .search-trigger kbd { display: none; }
  .to-site .label { display: none; }
  .brand .kicker { display: none; }

  .sidebar {
    position: fixed; top: var(--header-h); left: 0; z-index: 45;
    width: min(310px, 84vw); height: calc(100dvh - var(--header-h));
    background: var(--paper);
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: 6px 0 30px rgba(28, 27, 24, .12);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ''; position: fixed; inset: var(--header-h) 0 0 0; z-index: 44;
    background: rgba(28, 27, 24, .32);
  }
  main { grid-column: 1; padding: 30px 20px 80px; }
  main .lede { font-size: 17.5px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next, .pager .prev { grid-column: 1; text-align: left; }
  .anchor { display: none; }
}

/* At the smallest phone widths the topbar runs out of room for five controls
   — they need about 345px and stop fitting below that. The site link is the
   one to drop: it is the only one the page footer also carries.
   Typed selector so it beats `a.icon-btn`'s own display. */
@media (max-width: 360px) {
  a.to-site { display: none; }
}

@media print {
  header.topbar, .sidebar, .toc, .pager, .copy-btn, .search-modal { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  pre { border: 1px solid #ccc; background: #f6f6f6; color: #111; }
  a { color: #111; }
}
