/* Kiwify Labs documentation design system.
   Tokens first; components below. Product themes only override --accent / --accent-ink. */

:root {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eef1f4;
  --border: #d8dee4;
  --text: #1c2229;
  --muted: #566270;
  --accent: #1f7a4d;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--bg));
  --link: var(--accent);
  --focus: #1a66d6;
  --code-bg: #f3f5f7;
  --warn: #8a5a00;
  --warn-bg: #fff7e0;
  --danger: #a3262a;
  --danger-bg: #fdeceb;
  --info: #17509b;
  --info-bg: #eaf2fd;
  --ok: #17663d;
  --ok-bg: #e8f5ee;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06);
  --radius: 8px;
  --header-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

/* Theme: follows the OS unless the visitor picked one (html[data-theme], set by init.js from localStorage). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --surface: #161c23;
    --surface-2: #1d252e;
    --border: #2b343e;
    --text: #e6e9ed;
    --muted: #9aa6b2;
    --accent: #4cc38a;
    --accent-ink: #0f1419;
    --focus: #6aa6ff;
    --code-bg: #1a212a;
    --warn: #f0c05a;
    --warn-bg: #2a2210;
    --danger: #ff8e8e;
    --danger-bg: #2c1618;
    --info: #8ebcff;
    --info-bg: #14233a;
    --ok: #6fd6a0;
    --ok-bg: #12261c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #161c23;
  --surface-2: #1d252e;
  --border: #2b343e;
  --text: #e6e9ed;
  --muted: #9aa6b2;
  --accent: #4cc38a;
  --accent-ink: #0f1419;
  --focus: #6aa6ff;
  --code-bg: #1a212a;
  --warn: #f0c05a;
  --warn-bg: #2a2210;
  --danger: #ff8e8e;
  --danger-bg: #2c1618;
  --info: #8ebcff;
  --info-bg: #14233a;
  --ok: #6fd6a0;
  --ok-bg: #12261c;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 72px); }
body { margin: 0; font: 16px/1.6 var(--font); color: var(--text); background: var(--bg); }
img, svg, picture { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
code, kbd, pre { font-family: var(--mono); font-size: .875em; }
:not(pre) > code { background: var(--code-bg); border: 1px solid var(--border); padding: .1em .35em; border-radius: 4px; word-break: break-word; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 46rem; }
.container { width: min(100% - 32px, 72rem); margin-inline: auto; }
.container-wide { width: min(100% - 32px, 90rem); margin-inline: auto; }

.skip-link { position: absolute; left: 8px; top: -60px; background: var(--bg); color: var(--text); border: 2px solid var(--focus); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip-link:focus { top: 8px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; font: inherit; font-weight: 600; font-size: .9rem; padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; text-decoration: none; min-height: 36px; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid transparent; background: transparent; color: var(--text); border-radius: 6px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .45rem .65rem; min-height: 36px; }
input::placeholder { color: var(--muted); }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
.badge-accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); color: var(--text); }
.badge-muted { color: var(--muted); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
.bar { display: flex; align-items: center; gap: 14px; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 500; white-space: nowrap; }
.brand-logo { display: block; height: 40px; width: auto; }
.brand picture { display: inline-flex; }
.brand-docs { font-weight: 700; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); line-height: 1.4; }
.footer-brand img { height: 32px; width: auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.brand-logo, .footer-brand img) { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .55)); } }
:root[data-theme="dark"] :is(.brand-logo, .footer-brand img) { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .55)); }

/* Theme toggle: moon in light mode, sun in dark mode; hidden until JS enables it */
.theme-toggle[hidden] { display: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
.nav-toggle[hidden] { display: none; }
.js .nav-toggle { display: none; }
.primary-nav { margin-right: auto; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: .4rem .7rem; border-radius: 6px; font-weight: 600; font-size: .9rem; user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: .7; }
.menu > summary:hover { background: var(--surface-2); }
.menu[open] > summary { background: var(--surface-2); }
.menu > ul { position: absolute; left: 0; top: calc(100% + 6px); min-width: 15rem; margin: 0; padding: 6px; list-style: none; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .14); z-index: 50; }
.menu > ul a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: .5rem .65rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.menu > ul a:hover, .menu > ul a[aria-current="true"] { background: var(--surface-2); }
.menu-empty { padding: .5rem .65rem; color: var(--muted); }
.version-meta { display: inline-flex; gap: 4px; }
.version-label { color: var(--muted); font-weight: 500; }

.search { position: relative; display: flex; align-items: center; gap: 8px; }
.search-field { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input[type="search"] { width: min(24vw, 20rem); min-width: 11rem; padding-left: 32px; }
.search .scope { max-width: 9rem; }
.btn-search { display: none; }
.no-js .btn-search { display: inline-flex; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 22rem; list-style: none; margin: 0; padding: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .16); z-index: 60; max-height: 70vh; overflow: auto; }
.suggest[hidden] { display: none; }
.suggest li a { display: block; padding: .5rem .65rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.suggest li a small { display: block; color: var(--muted); }
.suggest li[aria-selected="true"] a, .suggest li a:hover { background: var(--accent-soft); }
.suggest .suggest-empty { padding: .5rem .65rem; color: var(--muted); }

.product-bar { border-top: 1px solid var(--border); background: var(--surface); }
.product-bar-inner { display: flex; align-items: center; gap: 18px; min-height: 48px; flex-wrap: wrap; }
.product-id { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.product-links { display: flex; gap: 14px; list-style: none; margin: 0 0 0 auto; padding: 0; font-size: .9rem; }
.product-links a { color: var(--muted); text-decoration: none; }
.product-links a:hover { color: var(--text); text-decoration: underline; }

/* Logos: intrinsic aspect ratio is always preserved (height-bound, width auto). */
.logo img { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; }
.logo-header { display: inline-flex; height: 26px; max-width: 200px; }
.logo-card { display: inline-flex; height: 44px; max-width: 220px; }
.logo-hero { display: inline-flex; height: 72px; max-width: 360px; }
.logo-hero img { height: 72px; }
.product-hero-logo { flex: none; }
.logo-card img { height: 44px; }
.logo-header img { height: 26px; }
.logo-fallback { display: inline-flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 8px; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); font-weight: 800; }
.logo-header.logo-fallback { width: 26px; font-size: .85rem; }
.logo-card.logo-fallback { width: 44px; font-size: 1.2rem; }
.logo-hero.logo-fallback { width: 72px; font-size: 2rem; }

/* Home */
.home { padding: 40px 0 56px; }
.home-intro h1 { font-size: 2.25rem; }
.section-heading { font-size: 1.1rem; margin: 2rem 0 .8rem; color: var(--text); }
.product-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 16px; }
.product-card-link { display: flex; flex-direction: column; gap: 14px; height: 100%; padding: 20px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, background .15s; }
.product-card-link:hover { border-color: var(--accent); background: var(--surface); }
.product-card-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card-name { font-size: 1.15rem; font-weight: 700; }
.product-card-tagline { color: var(--accent); font-weight: 600; font-size: .9rem; }
.product-card-desc { color: var(--muted); font-size: .95rem; }
.product-card-cta { margin-top: auto; padding-top: 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent); }
.empty-state { border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px; background: var(--surface); }
.empty-state h2, .empty-state h3 { margin-top: 0; }

/* Documentation layout */
.doc-layout { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 0 40px; width: min(100% - 32px, 90rem); margin-inline: auto; align-items: start; }
.doc-layout.has-toc { grid-template-columns: 17rem minmax(0, 1fr) 14.5rem; }
.sidebar { position: sticky; top: calc(var(--header-h) + 49px); max-height: calc(100vh - var(--header-h) - 49px); overflow-y: auto; padding: 24px 12px 32px 0; border-right: 1px solid var(--border); font-size: .92rem; }
.sidebar-title { font-weight: 700; margin: 0 0 10px; }
.sidebar-title a { color: var(--text); text-decoration: none; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list .nav-list { margin-left: 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-link { display: block; padding: .28rem .5rem; border-radius: 6px; color: var(--muted); text-decoration: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"], .sidebar-title a[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-section > details > summary { cursor: pointer; list-style: none; padding: .35rem .5rem; font-weight: 600; border-radius: 6px; display: flex; align-items: center; gap: 6px; }
.nav-section > details > summary::-webkit-details-marker { display: none; }
.nav-section > details > summary::before { content: ""; width: 6px; height: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .12s; flex: none; }
.nav-section > details[open] > summary::before { transform: rotate(45deg); }
.nav-section > details > summary:hover { background: var(--surface-2); }

.doc-main { min-width: 0; padding: 24px 0 64px; max-width: 50rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 18px; padding: 0; font-size: .875rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin: 0 8px; color: var(--border); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); text-decoration: underline; }
.doc-header { margin-bottom: 20px; }
.kicker { margin: 0 0 8px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: .875rem; margin: 0; }
.product-hero { display: flex; gap: 24px; align-items: center; padding-bottom: 20px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.product-hero h1 { margin-bottom: .25em; }
.toc { position: sticky; top: calc(var(--header-h) + 49px + 24px); max-height: calc(100vh - 160px); overflow: auto; font-size: .85rem; padding: 0 0 24px 0; }
.toc-title { font-weight: 700; margin: 24px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: .2rem .8rem; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--text); border-left-color: var(--accent); font-weight: 600; }
.toc-l3 a { padding-left: 1.6rem; }

/* Prose */
.prose { overflow-wrap: anywhere; }
.prose h2 { padding-top: .4em; border-top: 1px solid var(--border); margin-top: 2em; }
.prose h2:first-child { border-top: 0; margin-top: 0; }
.prose .anchor { margin-left: .4em; text-decoration: none; opacity: 0; font-weight: 400; color: var(--muted); }
.prose :is(h2, h3, h4, h5):hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose li > p { margin: .25em 0; }
.prose blockquote { margin: 1em 0; padding: .1em 1em; border-left: 3px solid var(--border); color: var(--muted); }
.prose img { height: auto; border-radius: 6px; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.figure { margin: 1.2em 0; }
.figure figcaption { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.table-wrap { overflow-x: auto; margin: 1em 0; border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap th { white-space: nowrap; }
/* `.prose` allows breaks anywhere, which lets auto-layout squeeze columns until single words split in two.
   In tables, break only when a word cannot fit at all, so each column stays at least as wide as its longest word
   (the wrapper scrolls sideways if the whole table needs more room). */
.table-wrap th, .table-wrap td { overflow-wrap: break-word; }
.table-wrap code { word-break: normal; overflow-wrap: break-word; }
.table-wrap th:first-child, .table-wrap td:first-child { padding-right: 1.25rem; }
.table-wrap thead th { background: var(--surface); font-weight: 600; }
.table-wrap tr:last-child td { border-bottom: 0; }

.code-block { margin: 1em 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.code-lang { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.copy-btn { font: inherit; font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); cursor: pointer; }
.copy-btn:hover { background: var(--surface-2); }
.no-js .copy-btn { display: none; }
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; line-height: 1.5; tab-size: 2; }
.code-block pre:focus-visible { outline-offset: -3px; }
.code-tabs { position: relative; margin: 1em 0; }
.code-tabs > .code-block { margin: 0; }
/* the dropdown sits in the code header, where the language name would be */
.code-tabs-bar { position: absolute; top: 0; left: 0; z-index: 1; height: 37px; display: flex; align-items: center; padding-left: 10px; }
.code-tabs-label { display: inline-flex; align-items: center; margin: 0; }
.code-tabs-label { font-size: 0; } /* visually hides the "Language" text; screen readers still get it as the select label */
.code-tabs-select { font: inherit; font-size: .78rem; font-weight: 600; line-height: 1.2; padding: .2rem .15rem; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; text-transform: uppercase; letter-spacing: .06em; }
.code-tabs-select:hover { color: var(--text); }
.code-tabs-select option { text-transform: none; letter-spacing: 0; background: var(--bg); color: var(--text); }
.code-tabs-select:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 2px; }
.code-tabs .code-lang { visibility: hidden; } /* keeps the header height; the dropdown replaces it */
.no-js .code-tabs-bar { display: none; }
.no-js .code-tabs .code-lang { visibility: visible; }
.no-js .code-tabs > .code-block { margin: 0 0 1em; }
.hljs-comment, .hljs-quote { color: #5b6b79; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: #a31d6a; }
.hljs-string, .hljs-attr, .hljs-regexp, .hljs-addition { color: #0b6b3a; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #1a56b5; }
.hljs-title, .hljs-section, .hljs-name, .hljs-type, .hljs-class { color: #8a4b00; }
.hljs-variable, .hljs-template-variable, .hljs-attribute { color: #7a3fa0; }
.hljs-deletion { color: var(--danger); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.hljs-comment, .hljs-quote) { color: #8b9aa8; }
  :root:not([data-theme="light"]) :is(.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in) { color: #ff9ac7; }
  :root:not([data-theme="light"]) :is(.hljs-string, .hljs-attr, .hljs-regexp, .hljs-addition) { color: #7fe0a8; }
  :root:not([data-theme="light"]) :is(.hljs-number, .hljs-symbol, .hljs-bullet) { color: #8ebcff; }
  :root:not([data-theme="light"]) :is(.hljs-title, .hljs-section, .hljs-name, .hljs-type, .hljs-class) { color: #ffc980; }
  :root:not([data-theme="light"]) :is(.hljs-variable, .hljs-template-variable, .hljs-attribute) { color: #d4aaff; }
}
:root[data-theme="dark"] :is(.hljs-comment, .hljs-quote) { color: #8b9aa8; }
:root[data-theme="dark"] :is(.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in) { color: #ff9ac7; }
:root[data-theme="dark"] :is(.hljs-string, .hljs-attr, .hljs-regexp, .hljs-addition) { color: #7fe0a8; }
:root[data-theme="dark"] :is(.hljs-number, .hljs-symbol, .hljs-bullet) { color: #8ebcff; }
:root[data-theme="dark"] :is(.hljs-title, .hljs-section, .hljs-name, .hljs-type, .hljs-class) { color: #ffc980; }
:root[data-theme="dark"] :is(.hljs-variable, .hljs-template-variable, .hljs-attribute) { color: #d4aaff; }

.admonition { margin: 1.2em 0; padding: .8rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); }
.admonition > :last-child { margin-bottom: 0; }
.admonition-title { font-weight: 700; margin: 0 0 .3em; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.admonition-note, .admonition-tip { border-left-color: var(--info); background: var(--info-bg); }
.admonition-note .admonition-title { color: var(--info); }
.admonition-tip { border-left-color: var(--ok); background: var(--ok-bg); }
.admonition-tip .admonition-title { color: var(--ok); }
.admonition-warning, .admonition-important { border-left-color: var(--warn); background: var(--warn-bg); }
.admonition-warning .admonition-title, .admonition-important .admonition-title { color: var(--warn); }
.admonition-caution { border-left-color: var(--danger); background: var(--danger-bg); }
.admonition-caution .admonition-title { color: var(--danger); }

.callout { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: 1.2em 0; background: var(--surface); }
.callout-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 .4em; color: var(--muted); }
.callout ul { margin: 0; padding-left: 1.2em; }
.callout-expected { border-left: 4px solid var(--ok); }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 1.5em 0 0; }
.tags a { display: inline-block; font-size: .8rem; padding: .1rem .6rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); text-decoration: none; }
.tags a:hover { color: var(--text); background: var(--surface-2); }

.card-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 12px; }
.card-list-stacked { grid-template-columns: 1fr; }
.card { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; background: var(--bg); }
.card:hover { border-color: var(--accent); background: var(--surface); }
.card-kicker { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.card-title { font-weight: 700; }
.card-text { color: var(--muted); font-size: .92rem; }
.browse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 24px; }
.browse-section h3 { margin: 0 0 .4em; font-size: 1rem; }
.browse-section ul { list-style: none; margin: 0 0 .5em; padding: 0; }
.browse-section li { padding: .15rem 0; }
.browse-section .more { font-size: .85rem; font-weight: 600; }

.feedback { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.feedback-title { font-size: 1rem; margin: 0 0 .6rem; }
.feedback-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 2rem; }
.pager-link { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.pager-link:hover { border-color: var(--accent); background: var(--surface); }
.pager-next { text-align: right; grid-column: 2; }
.pager-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pager-title { font-weight: 700; color: var(--accent); }

/* Search page */
.search-page { padding: 32px 0 64px; }
.search-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 12px 0 24px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1 1 18rem; }
.field label { font-size: .78rem; font-weight: 600; color: var(--muted); }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-width: 52rem; }
.result { padding: 14px 0; border-bottom: 1px solid var(--border); }
.result-title { font-size: 1.1rem; margin: 0 0 4px; }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .82rem; margin: 0 0 6px; }
.result-excerpt { margin: 0 0 4px; color: var(--text); }
.result-url { margin: 0; font-size: .78rem; color: var(--muted); word-break: break-all; }
mark { background: color-mix(in srgb, #f5c542 45%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.tips { margin: 0 0 1em; padding-left: 1.2em; }
.facets { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.chip { display: inline-block; padding: .1rem .6rem; border: 1px solid var(--border); border-radius: 999px; font-size: .82rem; text-decoration: none; }
.pagination { display: flex; gap: 14px; align-items: center; margin-top: 20px; }

.error-page { padding: 64px 0; max-width: 42rem; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--accent); margin: 0; line-height: 1; }
.debug { background: var(--code-bg); border: 1px solid var(--border); padding: 12px; overflow: auto; font-size: .8rem; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: center; padding: 20px 0; font-size: .875rem; color: var(--muted); }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.footer-copy { margin: 0; }
.site-footer ul { list-style: none; display: flex; gap: 16px; margin: 0; padding: 0; }
.site-footer nav { margin-left: auto; }
.site-footer a { color: var(--muted); }

/* Responsive */
@media (max-width: 1180px) {
  .doc-layout.has-toc { grid-template-columns: 16rem minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 880px) {
  .js .nav-toggle { display: inline-flex; }
  .search input[type="search"] { width: 100%; min-width: 0; }
  .search { flex: 1; min-width: 0; }
  .search-field { flex: 1; min-width: 0; }
  .bar { gap: 8px; }
  .search .scope { display: none; }
  .primary-nav { margin-right: 0; }
  .doc-layout, .doc-layout.has-toc { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); position: static; max-height: none; padding: 12px 0; }
  .js .sidebar { position: fixed; z-index: 45; inset: calc(var(--header-h) + 49px) 0 0 0; max-height: none; background: var(--bg); padding: 16px; transform: translateX(-100%); visibility: hidden; transition: transform .18s ease, visibility 0s .18s; overflow-y: auto; }
  .js .sidebar.open { transform: none; visibility: visible; transition: transform .18s ease; }
  .product-hero { flex-direction: column; align-items: flex-start; }
  .suggest { min-width: 0; }
  .product-links { margin-left: 0; }
}
@media (max-width: 520px) {
  h1 { font-size: 1.6rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; text-align: left; }
  .menu > ul { min-width: 12rem; }
}
/* Desktop app shell: header and footer stay in view and only the page body scrolls.
   Small screens and short windows keep the normal page scroll. */
@media screen and (min-width: 881px) and (min-height: 560px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
  .site-header { position: relative; flex: none; }
  .page-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; container-type: size; scroll-padding-top: 16px; }
  .site-footer { flex: none; margin-top: 0; }
  .footer-inner { padding: 10px 0; }
  .sidebar { top: 0; max-height: 100cqh; }
  .toc { top: 24px; max-height: calc(100cqh - 48px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .sidebar, .toc, .feedback, .pager, .site-footer, .copy-btn { display: none !important; }
  .doc-layout { display: block; }
}
