/* Yaqeen docs styles. build.py copies this file to dist/assets/ with a content hash in the name.

   Tokens match the landing page (site/src/styles.css): paper, ink, navy, line, teal, night, one easing curve.
   Dark colours are the landing "night" colours. Write them once in the dark-vars block below: the build repeats the block for the
   browser setting and for the theme button, so the two cannot drift apart.

   Motion: 120 to 180 ms for feedback, 200 ms for the page fade. Everything is switched off by prefers-reduced-motion. */

:root {
  color-scheme: light dark;
  --paper: #f4f7f9;
  --surface: #fff;
  --ink: #0f2a40;
  --head: #123a5a;
  --muted: #4d6378;
  --line: #d5dee5;
  --accent: #0a7068;
  --chip: #e8eef2;
  --note-bg: #e6f3f1;
  --warn-bg: #fdf3dc;
  --warn: #8a5a00;
  --focus: #0a7068;
  --shadow: 0 16px 48px rgba(12, 34, 56, .18);
  --scrim: rgba(12, 34, 56, .45);
  --shade: rgba(15, 42, 64, .16);

  /* Code panel and syntax colours. Each colour is at least 4.5:1 on --code-bg (test_highlight.py checks it). */
  --code-bg: #eef3f6;
  --code-bar: #e2e9ee;
  --code-line: #cfd9e1;
  --code-ink: #0f2a40;
  --code-muted: #4d6378;
  --tk-kw: #a3265c;
  --tk-str: #0a6a63;
  --tk-num: #8f4e00;
  --tk-com: #55697b;
  --tk-pun: #3d5468;
  --tk-key: #1c569e;
  --tk-flag: #6b3aa0;
  --tk-var: #0b6584;
  --tk-fn: #5a3a9a;
  --tk-lit: #8f4e00;

  --i-sun: none;
  --i-moon: block;
  --radius: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --fast: 140ms;
  --hdr: 60px;
  --side: 264px;
  --col: 46rem;
  --prose: 37rem;
  --display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --paper: #0c2238;
  --surface: #11293f;
  --ink: #e6eef4;
  --head: #e6eef4;
  --muted: #a5b8c8;
  --line: #27445e;
  --accent: #19c4b8;
  --chip: #173650;
  --note-bg: #0f3238;
  --warn-bg: #33290f;
  --warn: #f0c15a;
  --focus: #19c4b8;
  --shadow: 0 16px 48px rgba(0, 0, 0, .5);
  --scrim: rgba(4, 12, 20, .6);
  --shade: rgba(0, 0, 0, .4);
  --code-bg: #081a2b;
  --code-bar: #0d2338;
  --code-line: #27445e;
  --code-ink: #e6eef4;
  --code-muted: #a5b8c8;
  --tk-kw: #ff93b5;
  --tk-str: #6fe0d3;
  --tk-num: #f2b968;
  --tk-com: #8fa8bb;
  --tk-pun: #b3c4d2;
  --tk-key: #90c4ff;
  --tk-flag: #c9aeff;
  --tk-var: #7fd6f2;
  --tk-fn: #c9aeff;
  --tk-lit: #f2b968;
  --i-sun: block;
  --i-moon: none;
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0c2238;
  --surface: #11293f;
  --ink: #e6eef4;
  --head: #e6eef4;
  --muted: #a5b8c8;
  --line: #27445e;
  --accent: #19c4b8;
  --chip: #173650;
  --note-bg: #0f3238;
  --warn-bg: #33290f;
  --warn: #f0c15a;
  --focus: #19c4b8;
  --shadow: 0 16px 48px rgba(0, 0, 0, .5);
  --scrim: rgba(4, 12, 20, .6);
  --shade: rgba(0, 0, 0, .4);
  --code-bg: #081a2b;
  --code-bar: #0d2338;
  --code-line: #27445e;
  --code-ink: #e6eef4;
  --code-muted: #a5b8c8;
  --tk-kw: #ff93b5;
  --tk-str: #6fe0d3;
  --tk-num: #f2b968;
  --tk-com: #8fa8bb;
  --tk-pun: #b3c4d2;
  --tk-key: #90c4ff;
  --tk-flag: #c9aeff;
  --tk-var: #7fd6f2;
  --tk-fn: #c9aeff;
  --tk-lit: #f2b968;
  --i-sun: block;
  --i-moon: none;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
[id] { scroll-margin-top: calc(var(--hdr) + 20px); }
body {
  margin: 0;
  font: 1.0625rem/1.65 var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body:has(.navtoggle:checked) { overflow: hidden; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  transition: text-decoration-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  padding: 8px 14px; color: var(--ink); background: var(--surface);
  border: 2px solid var(--accent); border-radius: var(--radius);
}
.skip:focus { top: 8px; }
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
/* Features that need the script stay out of the layout until the script is known to run (the head sets .js). */
html:not(.js) .needs-js { display: none; }

/* Header ----------------------------------------------------------------------------------------------------- */
.hdr {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: var(--hdr); padding: 0 24px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  font: 700 1.15rem/1 var(--display); letter-spacing: -.01em;
  color: var(--head); text-decoration: none;
}
.brand img { width: 28px; height: 28px; }
.brandbar { display: inline-flex; align-items: center; gap: 12px; flex: none; }
a.brand-docs { text-decoration: none; transition: color var(--fast) var(--ease); }
a.brand-docs:hover { color: var(--head); }
.brand-docs {
  padding-left: 12px; font: 500 .95rem/1 var(--body); letter-spacing: 0;
  color: var(--muted); border-left: 1px solid var(--line);
}
.search { flex: 1 1 auto; display: flex; justify-content: center; margin: 0; }
.search-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 440px; height: 40px; padding: 0 10px 0 12px;
  font: inherit; font-size: .95rem; text-align: left; cursor: pointer;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.search-btn:hover { border-color: var(--muted); }
.search-btn svg { flex: none; }
.search-btn kbd, .sfoot kbd {
  font: .78rem/1 var(--mono); padding: 3px 7px; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
}
.search-btn kbd { margin-left: auto; }
.hdr-end { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.search + .hdr-end { margin-left: 0; }
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; cursor: pointer;
  color: var(--muted); background: transparent; border: 0; border-radius: var(--radius);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.theme-btn:hover { background: var(--chip); color: var(--head); }
.theme-btn .i-sun { display: var(--i-sun); }
.theme-btn .i-moon { display: var(--i-moon); }
.back {
  padding: 8px 10px; font-size: .9rem; white-space: nowrap; text-decoration: none;
  color: var(--muted); border-radius: var(--radius);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.back::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; vertical-align: 1px;
  border: solid currentColor; border-width: 0 0 1.5px 1.5px; transform: rotate(45deg);
}
.back:hover { background: var(--chip); color: var(--head); }
.navtoggle, .navbtn, .side-back, .scrim { display: none; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; overflow: hidden; }
.progress i {
  display: block; height: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%;
}

/* Page list --------------------------------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.side {
  position: sticky; top: var(--hdr);
  height: calc(100vh - var(--hdr)); height: calc(100dvh - var(--hdr));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 48px; background: var(--paper); border-right: 1px solid var(--line);
}
.grp { margin: 0 0 6px; }
.grp > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; list-style: none; cursor: pointer;
  font: 600 .9375rem/1.3 var(--body); color: var(--head); border-radius: var(--radius);
  transition: background-color var(--fast) var(--ease);
}
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary:hover { background: var(--chip); }
.grp > summary::after {
  content: ""; flex: none; width: 6px; height: 6px;
  border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg);
  transition: transform var(--fast) var(--ease);
}
.grp[open] > summary::after { transform: rotate(45deg); }
.grp ul { list-style: none; margin: 2px 0 14px 16px; padding: 0; border-left: 1px solid var(--line); }
.grp li a {
  position: relative; display: block; padding: 6px 10px 6px 16px;
  font-size: .9375rem; line-height: 1.3; color: var(--ink); text-decoration: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.grp li a:hover { background: var(--chip); color: var(--head); }
.grp li a::before {
  content: ""; position: absolute; left: -1px; top: 4px; bottom: 4px; width: 2px; border-radius: 1px;
  background: var(--accent); transform: scaleY(0); transition: transform var(--fast) var(--ease);
}
.grp li a[aria-current] { background: var(--chip); color: var(--head); font-weight: 600; }
.grp li a[aria-current]::before { transform: scaleY(1); }
.side-back { margin: 0 0 8px; }

/* Page -------------------------------------------------------------------------------------------------------- */
main {
  display: grid; grid-template-columns: minmax(0, var(--col)); justify-content: center; align-content: start;
  column-gap: 56px; min-width: 0; padding: 44px 24px 112px;
}
main:focus { outline: 0; }
main > * { grid-column: 1; }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  main { animation: fade 200ms var(--ease) both; }
  main.enter { animation: fade 140ms var(--ease) both; }
}
.crumbs ol {
  display: flex; flex-wrap: wrap; margin: 0 0 14px; padding: 0; list-style: none;
  font-size: .875rem; color: var(--muted);
}
.kind { margin: 0 0 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.crumbs li + li::before { content: "/"; margin: 0 .5em; color: var(--line); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--head); text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--display); color: var(--head); font-weight: 600; letter-spacing: -.015em; }
h1 { margin: 0 0 .35em; font-size: clamp(1.9rem, 3vw, 2.4rem); line-height: 1.12; letter-spacing: -.02em; }
.lead { margin: 0 0 1.4em; font-size: 1.15rem; line-height: 1.5; color: var(--muted); }
h2 { margin: 2.4em 0 .7em; padding-top: 1.1em; font-size: 1.5rem; line-height: 1.2; border-top: 1px solid var(--line); }
h3 { margin: 2em 0 .5em; font-size: 1.2rem; line-height: 1.3; }
h4 { margin: 1.6em 0 .4em; font-size: 1.05rem; line-height: 1.35; }
.body > :first-child, .body > h2:first-child { margin-top: 0; }
.body > h2:first-child { padding-top: 0; border-top: 0; }
.anchor {
  margin-left: .4em; font-weight: 400; text-decoration: none; color: var(--muted); opacity: 0;
  transition: opacity var(--fast) var(--ease);
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; }
@media (hover: none) { .anchor { opacity: .5; } }
.body { overflow-wrap: break-word; }
.body p { margin: 0 0 1.1em; }
.body > :is(p, ul:not(.cards), ol, blockquote) { max-width: var(--prose); }
.callout { max-width: calc(var(--prose) + 34px); }
.body ul, .body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.body li { margin: .35em 0; }
.body li::marker { color: var(--muted); }
.body strong { font-weight: 600; color: var(--head); }
code {
  font: .88em var(--mono); padding: 2px 6px; color: var(--ink);
  background: var(--chip); border-radius: 4px;
}

/* Code blocks ------------------------------------------------------------------------------------------------- */
.code {
  margin: 1.4em 0; overflow: hidden;
  color: var(--code-ink); background: var(--code-bg);
  border: 1px solid var(--code-line); border-radius: 8px;
}
.code-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px;
  padding: 4px 6px 4px 14px; background: var(--code-bar); border-bottom: 1px solid var(--code-line);
}
.code-lang { font: .78rem/1.4 var(--mono); color: var(--code-muted); }
.copy {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  height: 30px; padding: 0 10px; font: 500 .8125rem/1 var(--body); cursor: pointer;
  color: var(--code-ink); background: transparent; border: 1px solid var(--code-line); border-radius: var(--radius);
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.copy:hover { background: color-mix(in srgb, var(--code-ink) 8%, transparent); border-color: var(--code-muted); }
.copy:active { background: color-mix(in srgb, var(--code-ink) 14%, transparent); }
.copy svg { flex: none; }
.copy .i-done, .copy[data-state="copied"] .i-copy { display: none; }
.copy[data-state="copied"] .i-done { display: block; }
.copy[data-state="copied"] { color: var(--tk-str); border-color: var(--tk-str); }
.copy[data-state="failed"] { color: var(--tk-kw); border-color: var(--tk-kw); }
.code pre {
  margin: 0; padding: 16px 18px; overflow: auto; tab-size: 2;
  font: .875rem/1.65 var(--mono); color: var(--code-ink);
}
.code pre code { padding: 0; font: inherit; color: inherit; background: none; border-radius: 0; }
.tk-kw { color: var(--tk-kw); }
.tk-str { color: var(--tk-str); }
.tk-num { color: var(--tk-num); }
.tk-com { color: var(--tk-com); }
.tk-pun { color: var(--tk-pun); }
.tk-key { color: var(--tk-key); }
.tk-flag { color: var(--tk-flag); }
.tk-var { color: var(--tk-var); }
.tk-fn { color: var(--tk-fn); }
.tk-lit { color: var(--tk-lit); }
/* Without the script the bar only shows when it has a language label. */
html:not(.js) .code-bar:not(:has(.code-lang)) { display: none; }

/* Tables, quotes, callouts ------------------------------------------------------------------------------------ */
.table-wrap {
  margin: 1.4em 0; overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  /* Shadows at the edges appear only while there is more to scroll to. */
  background:
    linear-gradient(to right, var(--surface) 24px, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 24px, transparent) right center / 40px 100% no-repeat local,
    linear-gradient(to right, var(--shade), transparent) left center / 14px 100% no-repeat scroll,
    linear-gradient(to left, var(--shade), transparent) right center / 14px 100% no-repeat scroll,
    var(--surface);
}
.table-wrap:focus-visible { outline-offset: 0; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; }
th { color: var(--head); font-weight: 600; background: var(--chip); white-space: nowrap; }
td + td, th + th { border-left: 1px solid var(--line); }
tbody tr + tr td { border-top: 1px solid var(--line); }
@media (hover: hover) {
  tbody tr { transition: background-color var(--fast) var(--ease); }
  tbody tr:hover { background: color-mix(in srgb, var(--chip) 45%, transparent); }
}
blockquote { margin: 1.4em 0; padding: .1em 1em; color: var(--muted); border-left: 3px solid var(--line); }
.callout {
  --edge: var(--accent); --tint: var(--note-bg);
  margin: 1.5em 0; padding: 4px 16px;
  background: var(--tint); border: 1px solid color-mix(in srgb, var(--edge) 28%, var(--line));
  border-left: 3px solid var(--edge); border-radius: var(--radius);
}
.callout p { margin: .75em 0; }
.callout-title { color: var(--edge); }
.callout-warning, .callout-caution { --edge: var(--warn); --tint: var(--warn-bg); }
hr { margin: 2.6em 0; border: 0; border-top: 1px solid var(--line); }
img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* On this page ------------------------------------------------------------------------------------------------ */
.toc {
  margin: 0 0 2em; padding: 6px 16px; font-size: .875rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.toc summary { padding: 8px 0; font-weight: 600; color: var(--head); cursor: pointer; }
.toc ul { list-style: none; margin: 0 0 8px; padding: 0; }
.toc a {
  position: relative; display: block; padding: 5px 0; color: var(--muted); text-decoration: none;
  transition: color var(--fast) var(--ease);
}
.toc a:hover { color: var(--head); }
.toc ul ul { padding-left: 14px; }
.toc a[aria-current] { color: var(--head); font-weight: 600; }

/* Previous and next -------------------------------------------------------------------------------------------- */
.pager { display: flex; gap: 16px; margin-top: 4em; padding-top: 1.6em; border-top: 1px solid var(--line); }
.pager a {
  display: block; flex: 1 1 0; max-width: calc(50% - 8px); padding: 12px 16px;
  font-weight: 600; line-height: 1.4; color: var(--head); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.pager a:hover { border-color: var(--accent); }
.pager .next { margin-left: auto; text-align: right; }
.pager small { display: block; font-weight: 400; color: var(--muted); }

/* Home page ---------------------------------------------------------------------------------------------------- */
.home { --col: 56rem; --prose: 44rem; }
.home h1 { font-size: clamp(2.2rem, 4.4vw, 3.2rem); }
.home .body > p:first-child { margin-bottom: 1.4em; font-size: 1.2rem; line-height: 1.5; color: var(--muted); }
.body .cards {
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin: 1.4em 0; padding: 0; list-style: none;
}
.body .cards li { display: flex; margin: 0; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 6px; width: 100%;
  padding: 20px 20px 48px; line-height: 1.5; color: var(--muted); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.card-title { font: 600 1.15rem/1.25 var(--display); letter-spacing: -.01em; color: var(--head); }
.card-desc { font-size: .95rem; }
.card::after {
  content: ""; position: absolute; left: 20px; bottom: 22px; width: 7px; height: 7px;
  border: solid var(--accent); border-width: 1.5px 1.5px 0 0; transform: rotate(45deg);
  transition: transform var(--fast) var(--ease);
}
.card:hover { border-color: var(--accent); }
.card:hover::after { transform: translateX(4px) rotate(45deg); }
.paths { display: grid; gap: 28px 32px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 1.4em 0 0; }
.path h3 { margin: 0 0 .3em; font-size: 1.1rem; }
.path h3 a { color: inherit; text-decoration: none; }
.path-intro { margin: 0 0 .6em; font-size: .9375rem; line-height: 1.5; color: var(--muted); }
.body .path ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.body .path li { margin: 0; }
.path li a {
  display: block; padding: 4px 0 4px 14px; font-size: .9375rem; line-height: 1.4; text-decoration: none;
  color: var(--ink); transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.path li a:hover { color: var(--accent); }

/* Diagrams ----------------------------------------------------------------------------------------------------- */
/* Written as a ```diagram block (see AUTHORING.md). Real text in boxes: it follows the theme and reflows on a phone. */
.dia { margin: 2em 0; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.dia ol, .dia ul { margin: 0; padding: 0; list-style: none; }
.dia figcaption { margin-top: 14px; font-size: .85rem; line-height: 1.5; color: var(--muted); }
.dia-box {
  position: relative; display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 12px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.dia-t { font-weight: 600; line-height: 1.3; color: var(--head); }
.dia-d { font-size: .85rem; line-height: 1.45; color: var(--muted); }
.dia-tag {
  align-self: flex-start; margin-top: 4px; padding: 1px 8px; font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  color: var(--accent); background: var(--note-bg); border-radius: 99px;
}
.dia-n {
  display: grid; place-items: center; width: 22px; height: 22px; margin-bottom: 4px; font-size: .75rem; font-weight: 700;
  color: var(--paper); background: var(--accent); border-radius: 50%;
}
.dia-hidden { background: transparent; border-style: dashed; }
.dia-hidden .dia-tag { color: var(--warn); background: var(--warn-bg); }
/* The arrows are drawn with borders, so a screen reader has nothing extra to read. */
.dia-box::after, .dia-lane + .dia-lane::before {
  content: ""; position: absolute; width: 7px; height: 7px; border: solid var(--accent); border-width: 1.5px 1.5px 0 0;
}
.dia-steps { display: grid; gap: 22px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.dia-steps .dia-box::after { top: calc(50% - 4px); right: -15px; transform: rotate(45deg); }
.dia-steps .dia-end::after, .dia-steps .dia-box:last-child::after { display: none; }
.dia-lanes { display: grid; gap: 34px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.dia-lane { position: relative; display: flex; flex-direction: column; gap: 8px; }
.dia-lane ul { display: flex; flex-direction: column; gap: 8px; }
.dia-lane .dia-box::after { display: none; }
.dia-lane + .dia-lane::before { top: 14px; left: -22px; transform: rotate(45deg); }
.dia-h { font: 600 .78rem/1.2 var(--body); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.dia-segs { display: flex; gap: 3px; }
.dia-seg {
  min-width: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px;
  background: var(--note-bg); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--radius);
}
.dia-seg:nth-child(2) { background: var(--chip); border-color: var(--line); }
.dia-seg:nth-child(3) { background: var(--paper); border-color: var(--line); }
@media (max-width: 760px) {
  .dia { padding: 14px; }
  .dia-steps, .dia-lanes { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .dia-steps .dia-box::after { top: auto; right: auto; bottom: -17px; left: calc(50% - 4px); transform: rotate(135deg); }
  .dia-steps .dia-end::after { display: block; }
  .dia-steps .dia-box:last-child::after { display: none; }
  .dia-lane + .dia-lane::before { top: -20px; left: calc(50% - 4px); transform: rotate(135deg); }
}
@media print { .dia { break-inside: avoid; } }

/* API reference ------------------------------------------------------------------------------------------------ */
.op { padding: .6em 0 .4em; border-top: 1px solid var(--line); }
.op h3 { margin: .4em 0 .3em; padding: 0; font: 600 1rem/1.4 var(--body); letter-spacing: 0; border: 0; }
.method {
  display: inline-block; min-width: 4.2em; margin-right: .6em; padding: 1px 6px;
  font: 700 .75rem/1.5 var(--body); text-align: center; color: #fff; background: #37566e; border-radius: 4px;
}
.method.get { background: #0a6a63; }
.method.post { background: #1e5fa8; }
.method.delete { background: #a32a2a; }
.method.put, .method.patch { background: #8a5a00; }
.op p { margin: .2em 0; }
.op .params { font-size: .9rem; color: var(--muted); }
section + section > h2 { margin-top: 2.2em; }

/* Search ------------------------------------------------------------------------------------------------------- */
.sdlg {
  flex-direction: column; width: min(640px, calc(100% - 32px));
  max-height: min(560px, calc(100vh - 16vh - 16px)); margin: 12vh auto auto; padding: 0; overflow: hidden;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.sdlg[open] { display: flex; }
.sdlg::backdrop { background: var(--scrim); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: no-preference) {
  .sdlg[open] { animation: pop 160ms var(--ease); }
  .sdlg[open]::backdrop { animation: fade 160ms var(--ease); }
}
.sbox { display: flex; align-items: center; gap: 10px; padding: 0 16px; color: var(--muted); border-bottom: 1px solid var(--line); }
.sbox input { flex: 1; min-width: 0; height: 56px; font: inherit; font-size: 1.05rem; color: var(--ink); background: transparent; border: 0; }
.sbox input:focus { outline: 0; }
.sbox input::-webkit-search-cancel-button { display: none; }
.sbox:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.sres { min-height: 72px; padding: 8px; overflow-y: auto; }
.sgh { padding: 10px 10px 4px; font-size: .8125rem; font-weight: 600; color: var(--muted); }
.sres a {
  display: block; padding: 8px 10px; line-height: 1.4; color: var(--head); text-decoration: none; border-radius: var(--radius);
}
.sres a[aria-selected="true"] { background: var(--chip); }
.sres a b { font-weight: 600; }
.sres small { display: block; margin-top: 2px; overflow: hidden; font-size: .85rem; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.sres mark { font-weight: 600; color: var(--accent); background: none; }
.sres a.sub { padding-left: 26px; }
.sres .crumb { display: block; margin-top: 1px; font-size: .78rem; color: var(--muted); }
.sdym { padding: 0; font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; cursor: pointer; text-decoration: underline; }
.smsg { margin: 0; padding: 18px 10px; font-size: .95rem; color: var(--muted); }
.sfoot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 10px 16px; font-size: .8125rem; color: var(--muted); border-top: 1px solid var(--line); }

/* Wide screens: the page list moves to a rail on the right ------------------------------------------------------ */
@media (min-width: 1280px) {
  main { grid-template-columns: minmax(0, var(--col)) 208px; }
  main > .toc {
    grid-column: 2; grid-row: 1 / span 99; position: sticky; top: calc(var(--hdr) + 32px); align-self: start;
    max-height: calc(100vh - var(--hdr) - 64px); overflow: auto; margin: 0; padding: 0 0 0 16px;
    background: none; border: 0; border-left: 1px solid var(--line); border-radius: 0;
  }
  .toc summary { pointer-events: none; list-style: none; padding: 0 0 8px; cursor: default; }
  .toc summary::-webkit-details-marker { display: none; }
  .toc a {
    margin-left: -17px; padding-left: 16px; border-left: 2px solid transparent;
    transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
  }
  .toc ul ul a { margin-left: -31px; padding-left: 30px; }
  .toc a[aria-current] { border-left-color: var(--accent); }
}

/* Phones and narrow windows: the page list becomes a drawer ------------------------------------------------------ */
@media (max-width: 899px) {
  :root { --side: min(320px, 86vw); }
  .hdr { gap: 8px; padding: 0 12px; }
  .brand-docs { display: none; }
  .navbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin-left: -4px; cursor: pointer; border-radius: var(--radius);
  }
  .bars, .bars::before, .bars::after {
    display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 1px;
    transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease);
  }
  .bars { position: relative; }
  .bars::before, .bars::after { content: ""; position: absolute; left: 0; }
  .bars::before { top: -6px; }
  .bars::after { top: 6px; }
  .navtoggle { display: block; position: fixed; left: 8px; top: 8px; z-index: 30; width: 44px; height: 44px; margin: 0; opacity: 0; cursor: pointer; }
  .navtoggle:focus-visible ~ .hdr .navbtn { outline: 3px solid var(--focus); outline-offset: -3px; }
  .navtoggle:checked ~ .hdr .bars { background: transparent; }
  .navtoggle:checked ~ .hdr .bars::before { transform: translateY(6px) rotate(45deg); }
  .navtoggle:checked ~ .hdr .bars::after { transform: translateY(-6px) rotate(-45deg); }
  .search { flex: 0 0 auto; margin-left: auto; }
  .search-btn { width: 44px; height: 44px; max-width: none; justify-content: center; padding: 0; background: transparent; border-color: transparent; }
  .search-label, .search-btn kbd { display: none; }
  .hdr-end { margin-left: 0; }
  .hdr-end .back { display: none; }
  .side-back { display: inline-block; }
  .shell { display: block; }
  .side {
    position: fixed; top: var(--hdr); bottom: 0; left: 0; z-index: 15; width: var(--side); height: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform 180ms var(--ease), visibility 0s linear 180ms;
  }
  .navtoggle:checked ~ .shell .side { transform: none; visibility: visible; transition-delay: 0s; }
  .scrim {
    display: block; position: fixed; inset: var(--hdr) 0 0 0; z-index: 14; background: var(--scrim);
    opacity: 0; visibility: hidden; transition: opacity 180ms var(--ease), visibility 0s linear 180ms;
  }
  .navtoggle:checked ~ .shell .scrim { opacity: 1; visibility: visible; transition-delay: 0s; }
  main { padding: 28px 16px 80px; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .pager .next { text-align: left; }
  .sdlg { width: calc(100% - 16px); margin-top: 8px; }
  h2 { margin-top: 2.2em; }
}

/* Page changes. The script swaps the text of the next page into <main> and leaves the header and page list alone, so
   nothing blinks. Only the text fades (old out, new in), through the View Transitions API where it exists. */
@media (prefers-reduced-motion: no-preference) {
  html.vt-run main { view-transition-name: page; }
  html.vt-run::view-transition-group(root),
  html.vt-run::view-transition-old(root),
  html.vt-run::view-transition-new(root) { animation: none; }
  html.vt-run::view-transition-old(page) { animation: fade-out 90ms ease-in both; }
  html.vt-run::view-transition-new(page) { animation: fade 160ms var(--ease) 70ms both; }
  @keyframes fade-out { to { opacity: 0; } }
  /* Sections of the page list open and close smoothly where the browser can animate the height. */
  :root { interpolate-size: allow-keywords; }
  .grp::details-content { block-size: 0; overflow: hidden; transition: block-size 180ms var(--ease), content-visibility 180ms allow-discrete; }
  .grp[open]::details-content { block-size: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  body { font-size: 11pt; color: #000; background: #fff; }
  .hdr, .side, .scrim, .navtoggle, .skip, .toc, .pager, .copy, .anchor, .crumbs, .sdlg, .progress { display: none !important; }
  .shell, main { display: block; padding: 0; animation: none; }
  a { color: #000; }
  .body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; }
  .code { background: #fff; border-color: #888; }
  .code-bar { background: none; border-color: #888; }
  .code pre { color: #000; white-space: pre-wrap; overflow: visible; }
  .code pre span { color: #000 !important; }
  .code-lang { color: #333; }
  h2 { border-top: 0; padding-top: 0; }
  pre, table, .callout { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
}

/* The YQN suggestion. It enters and leaves with opacity and a short rise, and the line change is a fade. */
.yqn-nudge {
  --nudge-ease: cubic-bezier(0.23, 1, 0.32, 1);
  position: fixed; right: 24px; bottom: 20px; z-index: 25; width: min(340px, calc(100vw - 32px));
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.24s var(--nudge-ease), transform 0.24s var(--nudge-ease);
}
.yqn-nudge[data-shown] { opacity: 1; transform: none; transition-duration: 0.32s; }
.yqn-nudge-card {
  display: flex; align-items: center; gap: 12px; min-height: 84px; padding: 12px 40px 12px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: 0 8px 24px rgb(14 35 56 / 14%); text-decoration: none;
  transition: transform 0.2s var(--nudge-ease);
}
.yqn-nudge-card:focus-visible, .yqn-nudge-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.yqn-nudge-face {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: url("/yqn-greeting.webp") -32px -8px / 104px auto no-repeat, var(--paper);
}
.yqn-nudge-text {
  display: flex; align-items: center; min-height: 3.75rem; font-size: 0.875rem; line-height: 1.25rem;
  text-wrap: pretty; opacity: 1; transition: opacity 0.24s var(--nudge-ease);
}
.yqn-nudge-text[data-fading] { opacity: 0; transition-duration: 0.16s; }
.yqn-nudge-close {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.yqn-nudge-close:hover { background: var(--paper); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .yqn-nudge-card:hover { transform: translateY(-2px); } }
@media (max-width: 480px) { .yqn-nudge-close { width: 44px; height: 44px; top: 0; right: 0; } }
@media (prefers-reduced-motion: reduce) {
  .yqn-nudge, .yqn-nudge[data-shown], .yqn-nudge-card:hover { transform: none; }
}
