/* Documentation shell */

.docs.wrap { max-width: calc(1360px + 2 * var(--gutter)); }
.docs { display: grid; grid-template-columns: 248px minmax(0, 1fr) 208px; gap: clamp(24px, 3.4vw, 56px); align-items: start; }
.docs-side, .docs-toc { position: sticky; top: calc(var(--header-h) + 1px); max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
  padding: 28px 0 40px; scrollbar-width: thin; }
.docs-side { padding-right: 4px; }
.docs-main { min-width: 0; padding: 40px 0 24px; outline: none; }
.docs-bar { display: none; }

.search-trigger { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px 0 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-3); font-size: var(--text-sm); text-align: left;
  box-shadow: var(--shadow-1); transition: border-color var(--dur-fast), color var(--dur-fast); }
.search-trigger:hover { color: var(--text); border-color: var(--accent-ring); }
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger span { flex: 1; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2); font-family: var(--font-mono); font-size: 0.6875rem; }

.docs-nav { margin-top: 22px; }
.docs-nav h2 { margin: 22px 0 6px; padding: 0 12px; font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.docs-nav h2:first-child { margin-top: 0; }
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav a { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; padding: 0 12px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--text-sm); font-weight: 500; text-decoration: none;
  transition: color var(--dur-fast), background var(--dur-fast); }
.docs-nav a:hover { color: var(--text); background: var(--surface-2); }
.docs-nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.docs-nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--accent); }
.docs-nav a svg { width: 12px; height: 12px; color: var(--text-3); flex: none; }
@media (pointer: coarse) { .docs-nav a { min-height: 44px; } }

.docs-toc h2 { font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); font-weight: 600; margin-bottom: 10px; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.docs-toc a { display: block; margin-left: -1px; padding: 5px 0 5px 14px; border-left: 1px solid transparent; color: var(--text-3); font-size: var(--text-sm);
  line-height: 1.35; text-decoration: none; transition: color var(--dur-fast), border-color var(--dur-fast); }
.docs-toc a.sub { padding-left: 26px; font-size: var(--text-xs); }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ---------- Prose ---------- */
.prose { max-width: 800px; animation: rise var(--dur-med) var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.prose > * + * { margin-top: 18px; }
.prose .kicker { display: block; }
.prose h1 { margin-top: 10px; font-size: clamp(2rem, 4.4vw, 2.75rem); letter-spacing: -0.038em; line-height: 1.05; outline: none; }
.prose .lede { margin-top: 16px; font-size: var(--text-md); color: var(--text-2); max-width: 66ch; }
.prose h2 { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); font-size: var(--text-xl); letter-spacing: -0.028em; }
.prose h3 { margin-top: 36px; font-size: var(--text-md); }
.prose h2 .anchor, .prose h3 .anchor { margin-left: 8px; color: var(--text-3); text-decoration: none; opacity: 0; transition: opacity var(--dur-fast); font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus-visible { opacity: 1; }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); font-weight: 620; }
.prose a:not(.btn):not(.anchor):not(.card-link) { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 3px; }
.prose a:not(.btn):not(.anchor):not(.card-link):hover { text-decoration-color: currentColor; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 6px; }
.prose li::marker { color: var(--text-3); }
.prose .code, .prose .table-wrap { margin-top: 20px; }
.prose .code pre { max-height: 620px; }
.prose .callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid color-mix(in srgb, var(--info) 28%, transparent);
  background: var(--info-soft); }
.prose .callout.warn { border-color: color-mix(in srgb, var(--warn) 32%, transparent); background: var(--warn-soft); }
.prose .callout svg { width: 18px; height: 18px; flex: none; margin-top: 3px; color: var(--info); }
.prose .callout.warn svg { color: var(--warn); }
.prose .callout p { color: var(--text); font-size: var(--text-sm); }
.prose .callout p + p { margin-top: 6px; }
.prose .steps { list-style: none; padding: 0; counter-reset: step; }
.prose .steps > li { position: relative; padding-left: 44px; counter-increment: step; }
.prose .steps > li + li { margin-top: 16px; }
.prose .steps > li::before { content: counter(step); position: absolute; left: 0; top: -2px; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: var(--text-sm); font-weight: 650; font-variant-numeric: tabular-nums;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 20px; }
.card-link { display: block; padding: 16px 18px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); text-decoration: none;
  box-shadow: var(--shadow-1); transition: border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out); }
.card-link:hover { border-color: var(--accent-ring); transform: translateY(-2px); }
.card-link strong { display: block; color: var(--text); font-size: var(--text-base); }
.card-link span { display: block; margin-top: 4px; color: var(--text-3); font-size: var(--text-sm); line-height: 1.45; }
.endpoint { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface); font-family: var(--font-mono); font-size: var(--text-sm); overflow-wrap: anywhere; }
.method { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-family: var(--font-mono); font-size: 0.6875rem;
  font-weight: 700; letter-spacing: 0.04em; background: var(--info-soft); color: var(--info); }
.method.post { background: var(--ok-soft); color: var(--ok); }
.param-name { font-family: var(--font-mono); font-weight: 600; color: var(--text); white-space: nowrap; }
.param-req { display: block; margin-top: 3px; font-size: 0.6875rem; color: var(--warn); font-family: var(--font-sans); font-weight: 600; letter-spacing: 0.02em; }
.param-type { font-family: var(--font-mono); font-size: 0.78rem; color: var(--info); }
.param-type a { color: inherit !important; }
td.muted, .muted { color: var(--text-3); }
.dyn-state { padding: 18px; border-radius: var(--radius-md); border: 1px dashed var(--border-strong); color: var(--text-2); font-size: var(--text-sm); background: var(--surface); }
.dyn-state strong { display: block; margin-bottom: 4px; }
.source-note { margin-top: 8px !important; font-size: var(--text-xs); color: var(--text-3) !important; }

/* Benchmarks */
.bench-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin-top: 20px; border-radius: var(--radius-md); overflow: hidden;
  background: var(--border); border: 1px solid var(--border); }
.bench-tile { padding: 16px; background: var(--surface); }
.bench-tile dt { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.bench-tile dd { margin: 6px 0 0; font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text); }
.bench-tile dd small { font-size: var(--text-sm); font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-left: 3px; }
.chart { --s1: #27a88f; --s2: #8f7ff5; position: relative; margin-top: 20px; padding: 18px 18px 12px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); }
:root[data-theme="light"] .chart { --s1: #0a8f6c; --s2: #7a4fd6; }
.chart h4 { font-size: var(--text-sm); font-weight: 620; color: var(--text); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: var(--text-xs); color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; }
.chart svg { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--font-sans); }
.chart .axis-title { fill: var(--text-3); font-size: 11px; font-family: var(--font-sans); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--surface); stroke-width: 2; }
.chart .series-label { fill: var(--text-2); font-size: 11px; font-family: var(--font-sans); }
.chart .cross { stroke: var(--border-strong); stroke-width: 1; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-raised);
  box-shadow: var(--shadow-2); font-size: var(--text-xs); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-tip strong { display: block; color: var(--text); margin-bottom: 2px; }
.chart-tip span { display: flex; align-items: center; gap: 6px; }
.chart-tip i { width: 8px; height: 8px; border-radius: 50%; }

/* Changelog */
.release { position: relative; margin-top: 28px; padding: 22px 24px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-1); }
.release-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.release-head h2 { margin: 0; padding: 0; border: 0; font-size: var(--text-lg); }
.release-head time { color: var(--text-3); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.release ul { margin-top: 14px; }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 800px; margin-top: 64px; }
.pager a { display: flex; flex-direction: column; gap: 2px; min-height: 64px; padding: 14px 18px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface); text-decoration: none; transition: border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out); }
.pager a:hover { border-color: var(--accent-ring); transform: translateY(-2px); }
.pager a small { color: var(--text-3); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; }
.pager a span { font-weight: 620; }
.pager a.next { text-align: right; grid-column: 2; }

/* ---------- Dialogs: drawer and search ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(4, 6, 9, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.drawer { position: fixed; inset: 0 auto 0 0; width: min(330px, 88vw); max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0 12px calc(24px + var(--safe-b)) max(12px, var(--safe-l));
  border: 0; border-right: 1px solid var(--border-strong); background: var(--bg-raised); overflow-y: auto; box-shadow: var(--shadow-3); }
.drawer[open] { animation: slide-in var(--dur-med) var(--ease-out); }
@keyframes slide-in { from { transform: translateX(-100%); } }
.drawer-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; height: var(--header-h); padding-left: 12px;
  background: var(--bg-raised); border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.drawer .docs-nav { margin-top: 0; }

.search { width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - 48px)); margin: 10vh auto auto; padding: 0; border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong); background: var(--bg-raised); box-shadow: var(--shadow-3); overflow: hidden; }
.search[open] { display: flex; flex-direction: column; animation: rise var(--dur-fast) var(--ease-out); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--border); }
.search-box > svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.search-box input { flex: 1; min-width: 0; height: 54px; border: 0; background: transparent; outline: none; font-size: 1rem; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-esc { min-width: 44px; min-height: 32px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
  font-family: var(--font-mono); font-size: 0.6875rem; }
@media (pointer: coarse) { .search-esc { min-height: 44px; } }
.search-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.search-results:empty { display: none; }
.search-results li { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; scroll-margin: 8px; }
.search-results li[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-ring); }
.search-results .r-title { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-weight: 620; font-size: var(--text-sm); }
.search-results .r-title small { color: var(--text-3); font-weight: 500; font-size: var(--text-xs); }
.search-results .r-text { margin-top: 2px; color: var(--text-2); font-size: var(--text-xs); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results mark { background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--text); border-radius: 3px; padding: 0 1px; }
.search-hint { padding: 12px 16px; color: var(--text-3); font-size: var(--text-xs); border-top: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .docs { grid-template-columns: 232px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .docs { display: block; }
  .docs-side { display: none; }
  .docs-main { padding-top: 24px; }
  .docs-bar { position: sticky; top: var(--header-h); z-index: 60; display: flex; align-items: center; gap: 4px; height: 48px;
    padding: 0 max(8px, var(--safe-r)) 0 max(8px, var(--safe-l)); background: var(--glass); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border); }
  html { scroll-padding-top: calc(var(--header-h) + 64px); }
  .docs-bar-btn { display: inline-flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; padding: 0 8px; border: 0; background: transparent;
    font-size: var(--text-sm); font-weight: 600; text-align: left; }
  .docs-bar-btn svg { width: 18px; height: 18px; flex: none; color: var(--text-2); }
  .docs-bar-btn span[data-current-title] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .prose h2 { margin-top: 44px; }
  .search { margin-top: 12px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { grid-column: 1; }
  .prose h2 .anchor, .prose h3 .anchor { display: none; }
}
@media (prefers-reduced-motion: reduce) { .prose, .drawer[open], .search[open] { animation: none; } }

/* Generated tables become stacked cards on narrow screens (no sideways scrolling for parameter lists). */
@media (max-width: 700px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  table.stack tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.stack tr:last-child { border-bottom: 0; }
  table.data.stack td { padding: 3px 0; border: 0; text-align: left; min-width: 0 !important; white-space: normal; }
  table.stack td.num { text-align: left; }
  table.stack td:not(:first-child)::before { content: attr(data-label); display: inline-block; min-width: 96px; margin-right: 8px; font-size: 0.6875rem;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); font-family: var(--font-sans); font-weight: 600; }
  table.stack td:last-child:not(.num)::before { display: block; margin-top: 4px; }
  table.stack td.muted { display: none; }
  table.stack .param-req { display: inline; margin-left: 8px; }
}
.site-header .wrap, .site-footer .wrap { max-width: calc(1360px + 2 * var(--gutter)); }
