/* ═══════════════════════════════════════════════════════════════════════════
   RYEWIRED DOCS — documentation site styles

   Layered on top of css/tokens.css, which is imported below. That import is
   deliberate and worth keeping: it means the brand palette
   (--rw-brown/--rw-red/--rw-blue) and the type stack
   (--font-ui/--font-mono) CANNOT drift out of sync with the app, because
   there is only one definition of them. Everything else here is the docs
   site's own and does not exist in the app.

   IMPORTANT: tokens.css is authored for the APP, whose shell is a fixed,
   non-scrolling canvas. It sets `html, body { overflow: hidden;
   user-select: none }` on a DARK surface palette. A documentation site
   needs the opposite of all three, so the base rules below deliberately
   override them rather than working around them.

   If a token in css/tokens.css is ever renamed or removed, this file needs
   the matching edit — the names used from it are: --rw-brown, --rw-red,
   --rw-blue, --warning, --success, --font-ui, --font-mono, --radius-sm,
   --radius, --radius-lg, --t-med.
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('../css/tokens.css');

/* ─────────────────────────────────────────────────────────────────────────
   Light surface palette
   The app is dark; the docs are light. These define the docs site's own
   SEMANTIC names rather than redefining the source palette, so
   --rw-brown/--rw-red/--rw-blue keep meaning the same colors they do in
   the app.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  --doc-surface:        #FCFBF9;
  --doc-surface-raised: #FFFFFF;
  --doc-surface-sunken: #F4F1ED;
  --doc-surface-accent: #F7F3EE;

  --doc-ink:            #241C16;
  --doc-ink-soft:       #4A3C33;
  --doc-ink-dim:        #6E5C50;
  --doc-ink-faint:      #766C63;

  --doc-rule:           #E4DDD5;
  --doc-rule-strong:    #CFC5BA;

  --doc-link:           var(--rw-blue);
  --doc-link-hover:     #1D3F73;
  --doc-link-visited:   #5B4A8A;
  --doc-link-visited-hover: #443368;
  /* A tint of the link color itself, so the hover highlight belongs to the
     link rather than introducing a new accent. */
  --doc-link-wash:      rgba(43, 87, 154, 0.10);

  /* Brand accent for the active nav marker and section rules. */
  --doc-accent:         var(--rw-brown);
  --doc-accent-soft:    rgba(92, 64, 51, 0.09);

  /* Callouts */
  --doc-note-bg:        rgba(43, 87, 154, 0.06);
  --doc-note-edge:      var(--rw-blue);
  --doc-warn-bg:        rgba(200, 120, 32, 0.08);
  --doc-warn-edge:      var(--warning);
  --doc-warn-text:      #8F5312;
  --doc-tip-bg:         rgba(42, 122, 74, 0.07);
  --doc-tip-edge:       var(--success);

  --doc-focus:          #1D5FD0;

  /* Layout metrics */
  --doc-sidebar-w:      264px;
  --doc-toc-w:          208px;
  --doc-header-h:       60px;
  --doc-measure:        68ch;   /* readable line length */

  /* Type */
  --doc-fs-body:        16px;
  --doc-lh-body:        1.68;
}

/* ─────────────────────────────────────────────────────────────────────────
   Base — overrides tokens.css's app-shell assumptions (see header note)
   ───────────────────────────────────────────────────────────────────────── */
html {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  /* So an #anchor target clears the sticky header instead of hiding under it. */
  scroll-padding-top: calc(var(--doc-header-h) + 16px);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  height: auto;
  min-height: 100%;
  overflow: visible;
  user-select: text;                 /* app disables selection; docs must allow it */
  background: var(--doc-surface);
  color: var(--doc-ink);
  font-family: var(--font-ui);
  font-size: var(--doc-fs-body);
  line-height: var(--doc-lh-body);
  font-weight: 400;
  text-rendering: optimizeLegibility;
}

/* One consistent focus ring everywhere, never removed — keyboard users
   need to see where they are. :focus-visible so a mouse click does not
   leave a ring behind. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--doc-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────
   Skip link — the first focusable thing on every page
   ───────────────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--doc-surface-raised);
  color: var(--doc-link);
  border: 2px solid var(--doc-link);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--t-med);
}
.skip-link:focus { top: 8px; }

/* ─────────────────────────────────────────────────────────────────────────
   Header
   ───────────────────────────────────────────────────────────────────────── */
.doc-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--doc-header-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--doc-surface-raised);
  border-bottom: 1px solid var(--doc-rule);
}

/* Brand: icon LEFT, name RIGHT, whole thing links to the docs home. */
.doc-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--doc-ink);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}
.doc-brand:hover { color: var(--doc-accent); }
.doc-brand img {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: block;
}
.doc-brand .brand-name { line-height: 1; }
.doc-brand .brand-docs {
  font-weight: 500;
  color: var(--doc-ink-faint);
  font-size: 15px;
  line-height: 1;
  padding-left: 9px;
  border-left: 1px solid var(--doc-rule-strong);
}

.doc-header-spacer { flex: 1 1 auto; }

.doc-header-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.doc-header-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  color: var(--doc-ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.doc-header-links a:hover {
  background: var(--doc-surface-sunken);
  color: var(--doc-ink);
}
/* Disabled app link in the public pre-launch build (scripts/public-site.js). */
.doc-header-links .soon-link {
  padding: 7px 12px;
  color: var(--doc-ink-soft);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: .6;
}

/* The support link keeps its coffee emoji — the only icon in the site's
   navigation, per direct request (categories/sections/concepts get none). */
.doc-support {
  color: var(--doc-accent) !important;
  font-weight: 600 !important;
}
.doc-support:hover { background: var(--doc-accent-soft) !important; }

/* Mobile nav toggle — hidden until the sidebar collapses. */
.nav-toggle {
  display: none;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  background: var(--doc-surface-sunken);
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius);
  color: var(--doc-ink);
  font-size: 14px;
  font-weight: 500;
}
.nav-toggle-bars {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: '';
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.nav-toggle-bars::before { top: -5px; }
.nav-toggle-bars::after  { top: 5px; }

/* ─────────────────────────────────────────────────────────────────────────
   Page shell — sidebar | content | on-this-page
   ───────────────────────────────────────────────────────────────────────── */
.doc-shell {
  display: grid;
  grid-template-columns: var(--doc-sidebar-w) minmax(0, 1fr) var(--doc-toc-w);
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
  /* So a short page still gets a full-height sidebar rule rather than one
     that stops partway down the viewport. */
  min-height: calc(100vh - var(--doc-header-h));
}

/* ── Sidebar navigation ── */
.doc-sidebar {
  position: sticky;
  top: var(--doc-header-h);
  max-height: calc(100vh - var(--doc-header-h));
  overflow-y: auto;
  padding: 28px 12px 48px 20px;
  border-right: 1px solid var(--doc-rule);
}
.doc-sidebar nav > ul { list-style: none; }
.doc-sidebar .nav-section { margin-bottom: 22px; }
.doc-sidebar .nav-section > h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--doc-ink-faint);
  padding: 0 10px 7px;
  margin: 0;
}
.doc-sidebar ul ul { list-style: none; }
.doc-sidebar a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--doc-ink-soft);
  text-decoration: none;
  font-size: 14.5px;
  line-height: 1.4;
  border-left: 2px solid transparent;
}
.doc-sidebar a:hover {
  background: var(--doc-surface-sunken);
  color: var(--doc-ink);
}
/* Current page: keyed off aria-current="page" so the styling hook and the
   accessibility signal are the same attribute, rather than a class that
   assistive tech cannot see. */
.doc-sidebar a[aria-current="page"] {
  background: var(--doc-accent-soft);
  color: var(--doc-accent);
  font-weight: 600;
  border-left-color: var(--doc-accent);
}

/* ── Main content column ── */
.doc-main {
  min-width: 0;
  padding: 34px 44px 80px;
}
.doc-article { max-width: var(--doc-measure); }

/* ── On-this-page ── */
.doc-toc {
  position: sticky;
  top: var(--doc-header-h);
  max-height: calc(100vh - var(--doc-header-h));
  overflow-y: auto;
  padding: 34px 20px 48px 4px;
  font-size: 13.5px;
}
.doc-toc h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--doc-ink-faint);
  margin-bottom: 10px;
}
.doc-toc ul { list-style: none; }
.doc-toc li { margin-bottom: 2px; }
.doc-toc a {
  display: block;
  padding: 4px 10px;
  border-left: 2px solid var(--doc-rule);
  color: var(--doc-ink-dim);
  text-decoration: none;
  line-height: 1.45;
}
.doc-toc a:hover {
  color: var(--doc-link);
  border-left-color: var(--doc-rule-strong);
}
.doc-toc a.is-active {
  color: var(--doc-accent);
  border-left-color: var(--doc-accent);
  font-weight: 600;
}
.doc-toc .toc-h3 { padding-left: 22px; font-size: 13px; }

/* ─────────────────────────────────────────────────────────────────────────
   Breadcrumb
   ───────────────────────────────────────────────────────────────────────── */
.doc-breadcrumb {
  margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--doc-ink-faint);
}
.doc-breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.doc-breadcrumb a { color: var(--doc-ink-dim); text-decoration: none; }
.doc-breadcrumb a:hover { color: var(--doc-link); text-decoration: underline; }
.doc-breadcrumb li + li::before {
  content: '/';
  margin-right: 6px;
  color: var(--doc-rule-strong);
}
.doc-breadcrumb [aria-current="page"] { color: var(--doc-ink-soft); }

/* ─────────────────────────────────────────────────────────────────────────
   Prose
   ───────────────────────────────────────────────────────────────────────── */
.doc-article h1 {
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: var(--doc-ink);
}
.doc-lede {
  font-size: 18.5px;
  line-height: 1.6;
  color: var(--doc-ink-dim);
  margin-bottom: 30px;
}
.doc-article h2 {
  font-size: 23px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 44px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--doc-rule);
  color: var(--doc-ink);
}
.doc-article h3 {
  font-size: 17.5px;
  font-weight: 650;
  margin: 30px 0 8px;
  color: var(--doc-ink);
}
.doc-article h4 {
  font-size: 15.5px;
  font-weight: 650;
  margin: 22px 0 6px;
  color: var(--doc-ink-soft);
}
.doc-article p { margin-bottom: 16px; }
.doc-article ul,
.doc-article ol { margin: 0 0 16px 24px; }
.doc-article li { margin-bottom: 7px; }
.doc-article li > ul,
.doc-article li > ol { margin-top: 7px; margin-bottom: 0; }

/* Inline links.

   Order matters here and is not stylistic: :visited and :hover carry equal
   specificity, so whichever is written last wins. With :visited last, a link
   the reader had already followed kept its visited color on hover and the
   hover appeared to do nothing at all. LVHA (:link, :visited, :hover,
   :active) is the order that makes every state reachable, so :hover and
   :focus-visible must stay BELOW :visited.

   The hover also changes weight of decoration rather than only nudging the
   hue: a small darkening of the same blue is close to invisible at body-text
   size, and it was the only feedback the link gave. */
.doc-article a {
  color: var(--doc-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  border-radius: 2px;
  transition: color var(--t-med), background-color var(--t-med),
              text-decoration-color var(--t-med);
}
.doc-article a:visited { color: var(--doc-link-visited); }

.doc-article a:hover,
.doc-article a:focus-visible {
  color: var(--doc-link-hover);
  text-decoration-thickness: 2px;
  background: var(--doc-link-wash);
  /* A hair of breathing room so the wash reads as a highlight on the word
     rather than a box jammed against the neighboring text. */
  box-shadow: 0 0 0 2px var(--doc-link-wash);
}

/* A visited link still gets the hover treatment; only its resting hue
   differs, so the two hover targets stay visually distinct. */
.doc-article a:visited:hover,
.doc-article a:visited:focus-visible { color: var(--doc-link-visited-hover); }

.doc-article strong { font-weight: 650; color: var(--doc-ink); }

.doc-article code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--doc-surface-sunken);
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--doc-ink);
  word-break: break-word;
}
.doc-article pre {
  background: var(--doc-surface-sunken);
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 18px;
  font-size: 13.5px;
  line-height: 1.55;
}
.doc-article pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.doc-article pre.has-copy { position: relative; padding-right: 76px; }
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  font: 600 12px/1 var(--font-ui);
  color: var(--doc-ink-soft);
  background: var(--doc-surface-raised);
  border: 1px solid var(--doc-rule-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  cursor: pointer;
}
.code-copy:hover { color: var(--doc-link); border-color: var(--doc-link); }
.code-copy:active { transform: translateY(1px); }
.code-copy:focus-visible { outline: 2px solid var(--doc-focus); outline-offset: 2px; }

/* Keyboard keys */
kbd {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--doc-surface-raised);
  border: 1px solid var(--doc-rule-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--doc-ink);
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────────────
   Tables
   ───────────────────────────────────────────────────────────────────────── */
.doc-table-wrap {
  overflow-x: auto;
  margin-bottom: 20px;
}
.doc-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
.doc-article caption {
  text-align: left;
  font-size: 13.5px;
  color: var(--doc-ink-dim);
  padding-bottom: 8px;
}
.doc-article th,
.doc-article td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--doc-rule);
  vertical-align: top;
}
.doc-article thead th {
  background: var(--doc-surface-sunken);
  font-weight: 650;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  color: var(--doc-ink-soft);
  border-bottom: 1px solid var(--doc-rule-strong);
}
.doc-article tbody tr:hover { background: var(--doc-surface-accent); }
.doc-article td code { white-space: nowrap; }

/* ─────────────────────────────────────────────────────────────────────────
   Callouts
   A semantic <aside> with a real visible label, not a color-only signal —
   color alone is invisible to a screen reader and to anyone who cannot
   distinguish the hues.
   ───────────────────────────────────────────────────────────────────────── */
.callout {
  border-left: 3px solid var(--doc-rule-strong);
  background: var(--doc-surface-sunken);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 0 0 20px;
}
.callout > p:last-child { margin-bottom: 0; }
.callout-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}
.callout-note { background: var(--doc-note-bg); border-left-color: var(--doc-note-edge); }
.callout-note .callout-label { color: var(--doc-note-edge); }
.callout-warn { background: var(--doc-warn-bg); border-left-color: var(--doc-warn-edge); }
.callout-warn .callout-label { color: var(--doc-warn-text); }
.callout-tip  { background: var(--doc-tip-bg);  border-left-color: var(--doc-tip-edge); }
.callout-tip .callout-label { color: var(--doc-tip-edge); }

/* ─────────────────────────────────────────────────────────────────────────
   Figures / screenshot placeholders
   A placeholder is a real <figure> with a real <figcaption>, so dropping a
   screenshot in later is only swapping the <img> src — the caption, the
   alt-text slot and the layout are already correct.
   ───────────────────────────────────────────────────────────────────────── */
.doc-figure { margin: 0 0 24px; }
.doc-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius);
  background: var(--doc-surface-sunken);
}
.doc-figure img.zoomable { cursor: zoom-in; }
.doc-figure img.zoomable:hover { border-color: var(--doc-rule-strong); }
.doc-figure img.zoomable:focus-visible { outline: 2px solid var(--doc-focus); outline-offset: 3px; }
.img-lightbox {
  margin: auto; /* tokens.css resets every margin to 0, which uncenters a modal dialog */
  max-width: min(96vw, 1600px);
  max-height: 94vh;
  padding: 16px;
  background: var(--doc-surface-raised);
  color: var(--doc-ink);
  border: 1px solid var(--doc-rule-strong);
  border-radius: var(--radius);
}
.img-lightbox::backdrop { background: rgba(20, 15, 12, 0.72); }
.img-lightbox img {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 90px);
  margin: 0 auto;
  border-radius: var(--radius-sm);
}
.img-lightbox-cap { margin: 10px 40px 0 0; font-size: 13.5px; color: var(--doc-ink-dim); }
.img-lightbox-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 32px;
  height: 32px;
  font-size: 22px;
  line-height: 1;
  color: var(--doc-ink-soft);
  background: var(--doc-surface-raised);
  border: 1px solid var(--doc-rule-strong);
  border-radius: 50%;
  cursor: pointer;
}
.img-lightbox-close:hover { color: var(--doc-link); border-color: var(--doc-link); }
.img-lightbox-close:focus-visible { outline: 2px solid var(--doc-focus); outline-offset: 2px; }
.doc-figure figcaption {
  font-size: 13.5px;
  color: var(--doc-ink-dim);
  padding-top: 8px;
  line-height: 1.5;
}

/* The placeholder body. Marked role="img" with an aria-label in the markup
   so it announces as one described image rather than as loose text. */
.figure-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 210px;
  padding: 28px 20px;
  text-align: center;
  background: repeating-linear-gradient(
    45deg,
    var(--doc-surface-sunken) 0 10px,
    var(--doc-surface-accent) 10px 20px
  );
  border: 2px dashed var(--doc-rule-strong);
  border-radius: var(--radius);
  color: var(--doc-ink-dim);
}
.figure-placeholder .fp-title {
  font-weight: 650;
  font-size: 14px;
  color: var(--doc-ink-soft);
  letter-spacing: 0.02em;
}
.figure-placeholder .fp-hint {
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--doc-ink-faint);
  max-width: 46ch;
}

/* ─────────────────────────────────────────────────────────────────────────
   Card grids (docs home and section landing pages)
   ───────────────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 14px;
  margin: 0 0 26px;
  list-style: none;
}
.card-grid > li { margin: 0; }
.doc-card {
  display: block;
  height: 100%;
  padding: 16px 18px;
  background: var(--doc-surface-raised);
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius-lg);
  text-decoration: none !important;
  color: inherit !important;
}
.doc-card:hover {
  border-color: var(--doc-rule-strong);
  background: var(--doc-surface-accent);
}
.doc-card .card-title {
  display: block;
  font-weight: 650;
  font-size: 15.5px;
  color: var(--doc-link);
  margin-bottom: 5px;
}
.doc-card:hover .card-title { text-decoration: underline; }
.doc-card .card-desc {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  color: var(--doc-ink-dim);
}

/* ─────────────────────────────────────────────────────────────────────────
   Prev / next pager
   ───────────────────────────────────────────────────────────────────────── */
.doc-pager {
  display: flex;
  gap: 12px;
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid var(--doc-rule);
}
.doc-pager a {
  flex: 1 1 0;
  padding: 12px 16px;
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius);
  text-decoration: none !important;
  color: inherit !important;
  background: var(--doc-surface-raised);
}
.doc-pager a:hover {
  border-color: var(--doc-rule-strong);
  background: var(--doc-surface-accent);
}
.doc-pager .pager-dir {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--doc-ink-faint);
  margin-bottom: 3px;
}
.doc-pager .pager-title {
  display: block;
  font-weight: 600;
  color: var(--doc-link);
  font-size: 15px;
}
.doc-pager .pager-next { text-align: right; }

/* ─────────────────────────────────────────────────────────────────────────
   Footer
   ───────────────────────────────────────────────────────────────────────── */
.doc-footer {
  border-top: 1px solid var(--doc-rule);
  background: var(--doc-surface-raised);
  padding: 26px 20px;
}
.doc-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: center;
  font-size: 14px;
  color: var(--doc-ink-dim);
}
.doc-footer a { color: var(--doc-link); text-decoration: none; }
.doc-footer a:hover { text-decoration: underline; }
.doc-footer .footer-spacer { flex: 1 1 auto; }

/* ─────────────────────────────────────────────────────────────────────────
   Component reference bits
   ───────────────────────────────────────────────────────────────────────── */
.part-list {
  list-style: none;
  margin-left: 0 !important;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.part-list li { margin: 0; }
.part-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 3px 9px;
  background: var(--doc-surface-sunken);
  border: 1px solid var(--doc-rule);
  border-radius: 999px;
  color: var(--doc-ink-soft);
}

/* ─────────────────────────────────────────────────────────────────────────
   Dark theme
   Applied by [data-theme="dark"] on <html>, set by the toggle in docs.js
   and persisted to localStorage. LIGHT IS THE DEFAULT: a reader with no
   stored choice and no JS gets the light palette above, which is why the
   dark values sit here as an override rather than the light ones sitting
   inside a prefers-color-scheme block.

   Only the SEMANTIC doc-* names are re-pointed. The brand palette
   (--rw-brown/--rw-red/--rw-blue, from tokens.css) is untouched, so the
   accent colors stay the app's own in both themes.
   ───────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --doc-surface:        #16110E;
  --doc-surface-raised: #1E1712;
  --doc-surface-sunken: #241C17;
  --doc-surface-accent: #2A211A;

  --doc-ink:            #F2EDE9;
  --doc-ink-soft:       #D3C6BC;
  --doc-ink-dim:        #A8998D;
  --doc-ink-faint:      #97877C;

  --doc-rule:           #372B23;
  --doc-rule-strong:    #4E3D31;

  /* The app's --rw-blue is too dark to read on a dark ground; these lift
     it to the same hue at a legible lightness rather than switching hue. */
  --doc-link:           #7BA7E8;
  --doc-link-hover:     #9DC0F2;
  --doc-link-visited:   #B6A3E0;
  --doc-link-visited-hover: #CFC2EE;
  --doc-link-wash:      rgba(123, 167, 232, 0.16);

  --doc-accent:         #C9A184;
  --doc-accent-soft:    rgba(201, 161, 132, 0.13);

  --doc-note-bg:        rgba(123, 167, 232, 0.10);
  --doc-note-edge:      #7BA7E8;
  --doc-warn-bg:        rgba(230, 160, 70, 0.11);
  --doc-warn-edge:      #E0A040;
  --doc-warn-text:      #E8B65E;
  --doc-tip-bg:         rgba(90, 190, 130, 0.10);
  --doc-tip-edge:       #5ABE82;

  --doc-focus:          #7BA7E8;

  color-scheme: dark;
}

/* The brand icon is a photographic PNG on a white-ish ground; a slight
   knock-down keeps it from glaring against the dark header. */
:root[data-theme="dark"] .doc-brand img { filter: brightness(0.92); }

/* ─────────────────────────────────────────────────────────────────────────
   Theme toggle
   ───────────────────────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--doc-rule);
  border-radius: var(--radius);
  color: var(--doc-ink-soft);
  flex: 0 0 auto;
}
.theme-toggle:hover {
  background: var(--doc-surface-sunken);
  color: var(--doc-ink);
  border-color: var(--doc-rule-strong);
}
.theme-toggle svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Show the icon for the theme the button will SWITCH TO, which is the
   convention readers expect from a single-button toggle. */
.theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }



/* ─────────────────────────────────────────────────────────────────────────
   Screen-reader-only utility
   Visually hidden but still announced and still focusable when it needs to
   be — never display:none, which removes it from the accessibility tree.
   ───────────────────────────────────────────────────────────────────────── */
.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;
}

/* ─────────────────────────────────────────────────────────────────────────
   Sidebar filter input
   ───────────────────────────────────────────────────────────────────────── */
.nav-filter { padding: 0 10px 14px; }
.nav-filter input {
  width: 100%;
  padding: 7px 10px;
  background: var(--doc-surface-raised);
  border: 1px solid var(--doc-rule-strong);
  border-radius: var(--radius);
  color: var(--doc-ink);
  font-family: var(--font-ui);
  font-size: 14px;
}
.nav-filter input::placeholder { color: var(--doc-ink-faint); }

/* ─────────────────────────────────────────────────────────────────────────
   Collapsible sidebar sections
   Native <details>/<summary>, so a section collapses with no JS at all, is
   keyboard operable, and is announced correctly for free. The generator
   marks the section containing the current page as [open].
   ───────────────────────────────────────────────────────────────────────── */
.doc-sidebar details { margin: 0; }

.doc-sidebar summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--doc-ink-faint);
  cursor: pointer;
  border-radius: var(--radius-sm);
  list-style: none;
  user-select: none;
}
.doc-sidebar summary::-webkit-details-marker { display: none; }

.doc-sidebar summary:hover {
  color: var(--doc-ink-soft);
  background: var(--doc-surface-sunken);
}

.doc-sidebar summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform var(--t-med);
  flex: 0 0 auto;
}
.doc-sidebar details[open] > summary::before { transform: rotate(90deg); }

.doc-sidebar details > ul { padding-bottom: 6px; }

/* ─────────────────────────────────────────────────────────────────────────
   Search results
   Replaces the nav list while a query is active, rather than sitting
   alongside it, so the sidebar never shows two competing lists.
   ───────────────────────────────────────────────────────────────────────── */
.search-results { padding: 4px 4px 8px; }

.search-list { list-style: none; margin: 0; }
.search-list li { margin: 0 0 2px; }

.search-list a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.search-list a:hover,
.search-list a:focus-visible {
  background: var(--doc-surface-sunken);
  border-left-color: var(--doc-accent);
}

.search-list .sr-title {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--doc-link);
  line-height: 1.35;
  margin-bottom: 2px;
}
.search-list .sr-snip {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--doc-ink-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-empty {
  padding: 10px;
  font-size: 13.5px;
  color: var(--doc-ink-dim);
}
.search-empty strong { color: var(--doc-ink); }

/* ─────────────────────────────────────────────────────────────────────────
   App icons inline in the prose
   The same Font Awesome glyphs the app itself uses, so a reader can match
   what the docs describe against what is on screen. Font Awesome is already
   vendored for the app (vendor/fontawesome/) and reused here rather than
   pulled from a CDN, keeping the site offline-capable.

   These are ALWAYS decorative: every one sits beside the same action named
   in words, so it carries no information of its own. The markup marks them
   aria-hidden, and this rule set never adds generated text a screen reader
   could pick up.
   ───────────────────────────────────────────────────────────────────────── */
.app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55em;
  height: 1.55em;
  margin-right: 0.42em;
  /* Center the box on the text's own middle rather than guessing a fixed
     offset. `vertical-align: middle` aligns to the parent's baseline plus
     half its x-height, so the icon tracks the text's real metrics at any
     font size instead of drifting the way a hardcoded em offset does. The
     -0.1em nudge accounts for the box being taller than the x-height it is
     centered against, which otherwise leaves the glyph sitting slightly low. */
  vertical-align: middle;
  position: relative;
  top: -0.11em;
  border-radius: var(--radius-sm);
  background: var(--doc-surface-sunken);
  border: 1px solid var(--doc-rule);
  color: var(--doc-ink-soft);
  font-size: 0.92em;
  flex: 0 0 auto;
}

/* In a table cell the icon leads the row, so a tighter gap reads better. */
.doc-article td .app-icon,
.doc-article th .app-icon { margin-right: 0.3em; }

/* Inside a heading, match the heading's own weight rather than the body's.
   Headings also run a tighter line-height than body text, so `middle`
   (which resolves against x-height) lands the box a fraction high; the
   slightly smaller nudge puts it back on the text's optical center. */
.doc-article h2 .app-icon,
.doc-article h3 .app-icon,
.doc-article h4 .app-icon {
  color: var(--doc-ink);
  top: -0.081em;
}

/* ─────────────────────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .doc-shell { grid-template-columns: var(--doc-sidebar-w) minmax(0, 1fr); }
  .doc-toc { display: none; }
  .doc-main { padding: 34px 36px 80px; }
}

@media (max-width: 860px) {
  .doc-shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .doc-header { gap: 12px; }
  .doc-brand .brand-docs { display: none; }

  .doc-sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--doc-rule);
    padding: 14px 16px 20px;
    background: var(--doc-surface-raised);
  }
  /* Collapsed by default on small screens; the toggle flips [hidden] and
     its own aria-expanded together, in docs.js. */
  .doc-sidebar[hidden] { display: none; }

  .doc-main { padding: 26px 20px 64px; }
  .doc-article h1 { font-size: 28px; }
  .doc-lede { font-size: 17px; }
  .doc-pager { flex-direction: column; }
  .doc-pager .pager-next { text-align: left; }
}

/* Narrow screens: the header runs out of room for full link text. Measured at
   375px the row overflowed to 527px, so the two text links collapse to short
   forms and the support link keeps only its coffee cup. The accessible name
   is preserved either way — the visible text is what shrinks, not the label a
   screen reader announces (see the .sr-only spans in the markup). */
.doc-header-links .link-short { display: none; }
@media (max-width: 700px) {
  .doc-header { padding: 0 12px; gap: 8px; }
  .doc-header-links a { padding: 7px 8px; }
  .doc-header-links .link-long { display: none; }
  .doc-header-links .link-short { display: inline; }
}
@media (max-width: 460px) {
  .doc-header-links .doc-support .support-text { display: none; }
  .nav-toggle span:not(.nav-toggle-bars) { display: none; }
  .nav-toggle { padding: 7px 10px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   Print
   ───────────────────────────────────────────────────────────────────────── */
@media print {
  .doc-header,
  .doc-sidebar,
  .doc-toc,
  .doc-pager,
  .skip-link,
  .nav-toggle { display: none !important; }

  .doc-shell { display: block; max-width: none; }
  .doc-main { padding: 0; }
  .doc-article { max-width: none; }

  body { background: #fff; color: #000; font-size: 11.5pt; }
  .doc-article a { color: #000; text-decoration: underline; }
  .doc-article a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #444;
  }
  .doc-figure,
  .callout,
  .doc-article table { break-inside: avoid; }
  .doc-article h2,
  .doc-article h3 { break-after: avoid; }
}

/* A menu rendered as a list, one item per row, each carrying the same icon
   the app's own menu shows. The icon is decorative (the item is named in
   words beside it), so the markup marks it aria-hidden. */
.doc-article .menu-list {
  list-style: none;
  padding-left: 0;
  margin: 0 0 16px 0;
}

.doc-article .menu-list li {
  margin-bottom: 7px;
  padding-left: 0;
}

.doc-article .menu-list .app-icon { align-self: center; }
