/* ==========================================================================
   Kaimei AI — documentation layout
   Builds on css/site.css (tokens, header, footer, code panels, tables).
   ========================================================================== */

:root {
  --docs-side-w: 272px;
  --docs-top: 84px;          /* fixed site header + breathing room */
  --docs-max: 1480px;
  /* light: each colour clears 4.5:1 as text on the page and behind white badge text */
  --m-get: #1f5fd1;
  --m-post: #08754d;
  --m-put: #9a5200;
  --m-patch: #7036d6;
  --m-delete: #b81e65;
}
/* the site's tertiary grey sits right at 4.5:1; the docs use small text in it, so give it margin */
html:not([data-theme="dark"]) body.docs { --ink-3: #62677a; }
html[data-theme="dark"] {
  --m-get: #7fb0ff;
  --m-post: #3dd68c;
  --m-put: #ffc857;
  --m-patch: #c3a7ff;
  --m-delete: #ff6bb5;
}

html { scroll-padding-top: 92px; }
[id] { scroll-margin-top: 92px; }
body.docs { overflow-x: clip; }
/* more opaque than the marketing pages: dark code panels scroll under it all the time */
body.docs .site-header { background: color-mix(in srgb, var(--bg) 96%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); border-bottom-color: var(--line); }

/* page-level glow behind the hero and the top of the sidebar; sized to the viewport so it never widens the page */
.docs-glow { position: absolute; top: 0; left: 0; right: 0; height: 760px; overflow: hidden; z-index: -1; pointer-events: none; }
.docs-glow .aurora { opacity: calc(var(--aurora-opacity) * 0.5); }
.docs-glow::after { content: ""; position: absolute; inset: auto 0 0 0; height: 240px; background: linear-gradient(to bottom, transparent, var(--bg)); }
body.docs .site-header::after { opacity: 1; }

/* ---------- Shell ---------- */
.docs-shell {
  display: grid; grid-template-columns: var(--docs-side-w) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 72px);
  max-width: var(--docs-max); margin: 0 auto;
  padding: var(--docs-top) clamp(16px, 3vw, 40px) 0;
}
.docs-side {
  position: sticky; top: 72px; height: calc(100vh - 72px); overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 48px 0; font-size: 14px; scrollbar-width: thin;
}
.docs-side::-webkit-scrollbar { width: 6px; }
.docs-side::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.docs-main { min-width: 0; padding-bottom: 96px; }

/* ---------- Sidebar ---------- */
.docs-search { position: relative; margin: 0 0 18px; }
.docs-search input {
  width: 100%; height: 38px; padding: 0 64px 0 36px; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 10px; transition: border-color 0.2s, box-shadow 0.2s;
}
.docs-search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--accent-soft); }
.docs-search input::placeholder { color: var(--ink-4); }
.docs-search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.docs-search kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 6px; background: var(--bg-sunken);
}
.side-empty { display: none; padding: 10px 12px; color: var(--ink-3); font-size: 13px; }
.docs-side.is-filtering .side-empty.is-visible { display: block; }
.side-group { margin-bottom: 20px; }
.side-group > h5 {
  margin: 0 0 8px 12px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.side-group ul { display: grid; gap: 1px; }
.side-group li.is-hidden, .side-group.is-hidden { display: none; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 5px 12px; border-radius: 8px;
  color: var(--ink-2); line-height: 1.3; transition: background 0.15s, color 0.15s;
}
.side-link:hover { color: var(--ink); background: var(--bg-sunken); }
.side-link.is-active { color: var(--ink); background: var(--accent-soft); font-weight: 500; }
.side-link.is-active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--grad-v); }
.side-sub { margin: 2px 0 8px 12px; padding-left: 10px; border-left: 1px solid var(--line); }
.side-sub .side-link { min-height: 28px; padding: 3px 10px; font-size: 13px; color: var(--ink-3); }
.side-sub .side-link:hover, .side-sub .side-link.is-active { color: var(--ink); }
.side-sub .side-link.is-active { background: transparent; font-weight: 500; }
.side-sub .side-link.is-active::before { left: -11px; }
/* one page per entry; the current page shows its sections and endpoints underneath */
.side-sub[hidden] { display: none !important; }
.side-link.is-page[aria-current="page"] { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.side-link.is-page[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--grad-v); }
.side-sub .side-link.is-child { padding-left: 22px; }
.docs-side.is-filtering .side-sub { margin-bottom: 6px; }
.mdot { flex: none; width: 34px; font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-align: left; }
.mdot.get { color: var(--m-get); } .mdot.post { color: var(--m-post); } .mdot.put { color: var(--m-put); } .mdot.patch { color: var(--m-patch); } .mdot.delete { color: var(--m-delete); }
.side-foot { margin: 12px 0 0; padding: 14px 12px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: 13px; }
.side-foot a { color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.side-foot a:hover { color: var(--ink); }
.side-foot a svg { width: 12px; height: 12px; }

/* ---------- Mobile top bar + drawer ---------- */
.docs-topbar { display: none; }
.docs-backdrop { display: none; }
@media (max-width: 1023px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); padding-top: 60px; }
  .docs-topbar {
    position: sticky; top: 60px; z-index: 40; display: flex; align-items: center; gap: 12px; height: 48px; margin: 0 calc(-1 * clamp(16px, 3vw, 40px));
    padding: 0 clamp(16px, 3vw, 40px); background: var(--header-bg); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
    font-size: 13.5px; color: var(--ink-2);
  }
  .docs-topbar button { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); color: var(--ink); font-size: 13px; font-weight: 500; background: var(--bg-elev); }
  .docs-topbar button svg { width: 15px; height: 15px; }
  .docs-topbar .crumb { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .docs-side {
    position: fixed; inset: 60px auto 0 0; z-index: 60; width: min(320px, 86vw); height: auto; padding: 16px 16px 40px;
    background: var(--bg); border-right: 1px solid var(--line); box-shadow: var(--shadow-lg);
    transform: translateX(-104%); transition: transform 0.3s var(--ease); visibility: hidden;
  }
  .docs-side.is-open { transform: none; visibility: visible; }
  .docs-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(9, 10, 15, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  .docs-backdrop.is-open { display: block; opacity: 1; pointer-events: auto; }
  .docs-search kbd { display: none; }
  .docs-search input { padding-right: 12px; }
}

/* ---------- Hero ---------- */
.docs-hero { position: relative; padding: 28px 0 44px; }
.docs-hero .h1 { font-size: clamp(2.2rem, 4.4vw, 3.6rem); letter-spacing: -0.035em; line-height: 1.02; max-width: 820px; }
.docs-hero .lead { margin-top: 20px; max-width: 700px; font-size: clamp(1.05rem, 1.3vw, 1.2rem); }
.docs-hero .cta-row { margin-top: 28px; }
.docs-facts { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 8px; }
.docs-facts .chip a { color: inherit; }
.docs-facts .chip a:hover { color: var(--accent); }
.docs-cards { margin-top: 36px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1280px) { .docs-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.docs-card { display: flex; flex-direction: column; gap: 8px; padding: 20px 20px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg-elev); transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s; }
.docs-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.docs-card .k { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-sunken); border: 1px solid var(--line); color: var(--ink); margin-bottom: 6px; }
.docs-card .k svg { width: 17px; height: 17px; }
.docs-card b { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.docs-card span { font-size: 13.5px; color: var(--ink-3); line-height: 1.45; }
@media (max-width: 760px) { .docs-cards { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Sections and prose ---------- */
.doc-part { padding: 48px 0 8px; margin-top: 24px; border-top: 1px solid var(--line); }
.doc-part > .eyebrow { margin-bottom: 14px; }
.doc-part > .h2 { font-size: clamp(1.75rem, 3vw, 2.4rem); }
.doc-part > .lead { margin-top: 14px; max-width: 760px; font-size: 1.08rem; }
.doc-section { padding: 40px 0 8px; }
.doc-section > h2, .doc-section > h3 { position: relative; scroll-margin-top: 92px; }
.doc-section > h2 { font-size: clamp(1.45rem, 2.2vw, 1.9rem); font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.doc-section > h3 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
/* small uppercase labels are real headings (h2 or h3 by position) styled alike */
.kicker { margin: 26px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); line-height: 1.4; }
.prose { max-width: 760px; }
.prose p, .prose li { color: var(--ink-2); font-size: 15.5px; line-height: 1.65; }
/* long paths and identifiers in inline code wrap instead of pushing past a phone's edge */
.prose p, .prose li, .param-desc, .ep-desc, .returns, .callout, .kv span, .mini span { overflow-wrap: break-word; }
.prose li code, .prose p code, .param-desc code, .ep-desc code, .callout code { overflow-wrap: anywhere; }
.prose p + p, .prose p + ul, .prose ul + p, .prose p + ol, .prose ol + p, .prose .callout + p, .prose p + .callout { margin-top: 14px; }
.prose > p:first-child, .prose > ul:first-child { margin-top: 14px; }
.prose ul, .prose ol { padding-left: 1.2em; margin-top: 10px; display: grid; gap: 6px; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li::marker { color: var(--ink-4); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.prose a:hover { text-decoration-color: var(--accent); }
.prose code, .params code, .table code, .callout code, .ep-desc code, .obj-attrs code, .docs-card code {
  font-family: var(--font-mono); font-size: 0.86em; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--ink);
}
.prose strong, .params strong { color: var(--ink); font-weight: 600; }
.prose .table-wrap { margin-top: 18px; }
.prose .table-wrap + p { margin-top: 18px; }
.prose .code-panel, .prose pre.code-block { margin-top: 18px; }
.anchor { position: absolute; left: -1.1em; top: 0; opacity: 0; color: var(--ink-4); text-decoration: none; font-weight: 400; transition: opacity 0.15s; padding-right: 0.3em; }
h2:hover > .anchor, h3:hover > .anchor, .ep-title:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); }
@media (max-width: 1023px) { .anchor { display: none; } }

/* two-column grid for prose + code */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; margin-top: 18px; }
.two > * { min-width: 0; }   /* a long inline code path must wrap, not widen the column */
.two > .prose { max-width: none; }
.two > .code-col { position: sticky; top: var(--docs-top); display: grid; gap: 14px; }
@media (max-width: 1179px) { .two { grid-template-columns: minmax(0, 1fr); } .two > .code-col { position: static; } }

/* tables */
.docs-main .table-wrap { margin-top: 14px; }
.docs-main table.table { font-size: 14px; }
.docs-main .table th, .docs-main .table td { padding: 11px 14px; }
.docs-main .table td:first-child { white-space: nowrap; }
.docs-main .table tr:hover td { background: color-mix(in srgb, var(--bg-sunken) 55%, transparent); }
.table .mono { font-size: 12.5px; }

/* callouts */
.callout { position: relative; margin-top: 16px; padding: 14px 16px 14px 18px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--line); font-size: 14.5px; color: var(--ink-2); line-height: 1.55; overflow: hidden; }
.callout::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad-v); }
.callout.warn::before { background: linear-gradient(180deg, #ffb347, #ff6bb5); }
.callout.tip::before { background: linear-gradient(180deg, #3dd68c, #3ec8ff); }
.callout b { color: var(--ink); font-weight: 600; }
.callout p + p { margin-top: 8px; }

/* ---------- Endpoint blocks ---------- */
.ep { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; align-items: start; padding: 44px 0 36px; border-top: 1px solid var(--line); }
.ep:first-of-type { border-top: 0; }
.ep-main { min-width: 0; }
.ep-code { position: sticky; top: var(--docs-top); min-width: 0; display: grid; gap: 14px; }
.ep-title { position: relative; margin: 0; font-size: 1.28rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.ep-route { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.ep-path { font-family: var(--font-mono); font-size: 13.5px; color: var(--ink); background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; word-break: break-all; }
.ep-path .var { color: var(--accent); }
html:not([data-theme="dark"]) .ep-path .var, html:not([data-theme="dark"]) .docs-main .tag.grad { color: #3346d8; }
.ep-auth { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.ep-auth::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: var(--ink-4); }
.ep-auth.user::before { background: var(--m-patch); }
.ep-auth.public::before { background: var(--m-post); }
.ep-desc { margin-top: 14px; color: var(--ink-2); font-size: 15px; line-height: 1.6; }
.ep-desc p + p { margin-top: 10px; }
.ep-main .kicker { margin: 26px 0 6px; }
.ep-main .returns { margin-top: 6px; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.ep-main .returns code { font-size: 0.86em; }
.method {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em;
  color: #fff; background: var(--ink);
}
.method.get { background: var(--m-get); } .method.post { background: var(--m-post); } .method.put { background: var(--m-put); } .method.patch { background: var(--m-patch); } .method.delete { background: var(--m-delete); }
html[data-theme="dark"] .method { color: #0b0c10; }

/* parameters */
.params { display: grid; }
.param { padding: 12px 0; border-top: 1px solid var(--line); }
.param:first-child { border-top: 0; }
.param-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 10px; }
.param-head .name { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; color: var(--ink); }
.param-head .type { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.param-head .req { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--m-delete); }
.param-head .opt { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.param-head .default { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-left: auto; }
.param-head .default b { font-weight: 500; color: var(--ink-2); }
.param-desc { margin-top: 5px; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.param-desc p + p { margin-top: 6px; }
.param-desc ul { margin-top: 6px; padding-left: 1.1em; list-style: disc; display: grid; gap: 3px; }
.param .params { margin: 10px 0 0 14px; padding-left: 14px; border-left: 1px solid var(--line); }
.param .params .param { padding: 9px 0; }

/* object attribute lists share the param styles */
.obj-attrs .param-head .name { font-weight: 500; }

/* code panels inside docs */
.docs-main .code-panel { box-shadow: var(--shadow-md); }
.docs-main .code-panel pre { padding: 18px 20px 20px; font-size: 12.75px; line-height: 1.6; max-height: 640px; overflow: auto; }
.docs-main .code-panel pre::-webkit-scrollbar { width: 8px; height: 8px; }
.docs-main .code-panel pre::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 99px; }
.docs-main .code-tab { height: 36px; padding: 0 12px; font-size: 12px; }
.tab-list { display: flex; align-items: center; gap: 2px; min-width: 0; }
/* code and tables scroll sideways, so they take keyboard focus; show it */
.code-panel pre:focus-visible { outline: 2px solid #8aa4ff; outline-offset: -3px; border-radius: 0 0 16px 16px; }
.table-wrap:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.docs-main .code-tabs .copy { height: 28px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.02); font-family: var(--font-mono); font-size: 12px; color: #8b91a5; }
/* status and label truncate (label first) so the copy button always stays inside the panel */
.panel-head .status { position: relative; display: block; flex: 0 1 auto; min-width: 0; padding-left: 13px; color: #d7dbe8; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .status::before { content: ""; position: absolute; left: 0; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 99px; background: #3dd68c; }
.panel-head .status.err::before { background: #ff6b8a; }
.panel-head .status.neutral::before { background: #8aa4ff; }
.panel-head .label { flex: 0 1000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .copy { flex: none; margin-left: auto; height: 28px; padding: 0 10px; border-radius: 8px; font-family: var(--font-mono); font-size: 12px; color: #a3a9bd; border: 1px solid rgba(255, 255, 255, 0.1); display: inline-flex; align-items: center; gap: 6px; transition: all 0.2s; }
.panel-head .copy:hover { color: #fff; border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.04); }
.panel-head .copy svg { width: 13px; height: 13px; }
.tk-key { color: #ffcb6b; }
.tk-bool { color: #f78c6c; }
.tk-flag { color: #89ddff; }
.tk-url { color: #9ce0a6; }
.tk-cmd { color: #82aaff; }
.tk-var { color: #c792ea; }
.tk-ell { color: #8790a8; }
/* comments in docs code: the site's #6b7389 is 4.0:1 on the code background */
.docs-main .tk-cm { color: #8790a8; }
.tk-method { color: #c792ea; font-weight: 600; }
.tk-hdr { color: #ffcb6b; }

@media (max-width: 1179px) {
  .ep { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .ep-code { position: static; }
}

/* ---------- Grids of small items ---------- */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 16px; }
.kv { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev); }
.kv b { display: block; font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--ink); }
.kv span { display: block; margin-top: 4px; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.id-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 14px; }
.id-grid .chip { height: 34px; justify-content: space-between; }
.id-grid .chip b { color: var(--accent); }

/* steps */
.doc-steps { counter-reset: step; display: grid; gap: 0; margin-top: 20px; }
.doc-step { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; padding: 0 0 30px; }
.doc-step::before { counter-increment: step; content: counter(step); width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: #fff; background: var(--ink); }
html[data-theme="dark"] .doc-step::before { color: #0b0c10; }
.doc-step::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 6px; width: 1px; background: var(--line-strong); }
.doc-step:last-child::after { display: none; }
.doc-step-body { min-width: 0; }
.doc-step .step-title { margin: 4px 0 6px; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.doc-step .prose { margin-top: 0; }
.doc-step .prose > p:first-child { margin-top: 0; }
.doc-step .code-panel, .doc-step .table-wrap { margin-top: 14px; }

/* method / insight cards */
.minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.mini { padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-elev); }
.mini .tag { margin-bottom: 10px; }
.mini b { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.mini span { display: block; margin-top: 4px; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.mini code { font-size: 12px; }

/* guides grid (notebooks) */
.docs-main .grid-3 { margin-top: 20px; }
.docs-main .guide h2, .docs-main .guide h3 { font-size: 1.05rem; margin: 0; }
.docs-main .guide p { font-size: 14.5px; }

/* figure */
.doc-figure { margin: 28px 0 0; max-width: 760px; }
.doc-figure img { width: 100%; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow-md); background: #fff; }
.doc-figure figcaption { margin-top: 10px; font-size: 13px; color: var(--ink-3); }

/* footer band inside docs */
.docs-main .cta-band { margin-top: 56px; padding: clamp(40px, 6vw, 72px) clamp(24px, 5vw, 64px); }
.docs-main .cta-band .h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }

/* no reveal delays in docs: content shows at once */
.docs-main .reveal { opacity: 1; transform: none; }

@media (max-width: 640px) {
  .docs-hero { padding-top: 16px; }
  .ep { padding: 32px 0 26px; }
  .docs-main .code-panel pre { font-size: 12px; padding: 14px 14px 16px; }
}

/* ---------- One page per topic ---------- */
.page-head { padding: 30px 0 6px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; }
.crumbs a { color: var(--ink-3); transition: color 0.15s; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--ink-4); }
.page-title { font-size: clamp(2rem, 3.6vw, 2.9rem); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; text-wrap: balance; }
.page-head .lead { margin-top: 14px; max-width: 760px; font-size: clamp(1.05rem, 1.3vw, 1.18rem); color: var(--ink-2); }
.page-head + .doc-section { padding-top: 22px; }
.page-head + .doc-section.is-lead { padding-top: 18px; }
.page-head + .doc-section.is-lead > .prose > p:first-child, .page-head + .doc-section.is-lead > .two:first-child { margin-top: 0; }
.doc-section.is-lead + .ep { border-top: 1px solid var(--line); margin-top: 28px; }

/* overview pages: a card per page in the group */
.index-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 8px; }
.index-card { display: flex; flex-direction: column; gap: 8px; padding: 20px 22px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg-elev); transition: border-color 0.25s, box-shadow 0.25s; }
.index-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.index-title { font-size: 1.08rem; font-weight: 600; letter-spacing: -0.015em; color: var(--ink); }
.index-title:hover { color: var(--accent); }
.index-card p { color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.index-card .more { margin-top: auto; padding-top: 4px; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--accent); }
.index-card .more svg { width: 14px; height: 14px; }
.index-card:has(.index-title:hover) .more svg { transform: translateX(2px); }
.ep-list { display: grid; gap: 2px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.ep-list a { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; color: var(--ink-2); }
.ep-list a:hover { color: var(--ink); }
.ep-list .mdot { width: 46px; }
.index-card:not(:has(.ep-list)) { cursor: pointer; position: relative; }
.index-card:not(:has(.ep-list)) .index-title::after { content: ""; position: absolute; inset: 0; }
@media (max-width: 760px) { .index-grid { grid-template-columns: minmax(0, 1fr); } }

/* docs home: browse by group */
.browse-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.browse-card { padding: 20px 22px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg-elev); }
.browse-card h3 { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }
.browse-card ul { display: grid; gap: 2px; }
.browse-card a { display: block; padding: 4px 0; font-size: 14.5px; color: var(--ink-2); transition: color 0.15s; }
.browse-card a:hover { color: var(--accent); }
@media (max-width: 1100px) { .browse-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .browse-grid { grid-template-columns: minmax(0, 1fr); } }

/* previous / next */
.pager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.pager-link { display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-elev); transition: border-color 0.2s, transform 0.25s var(--ease), box-shadow 0.25s; min-width: 0; }
.pager-link:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pager-link span { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.pager-link span svg { width: 13px; height: 13px; }
.pager-link b { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-link.next { text-align: right; align-items: flex-end; grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: minmax(0, 1fr); } .pager-link.next { grid-column: 1; } .pager > span:empty { display: none; } }
.docs-main .cta-band { margin-top: 48px; }

@media print {
  .site-header, .mobile-nav, .docs-side, .docs-topbar, .site-footer, .cta-band, .copy, .pager { display: none !important; }
  .docs-shell { display: block; padding-top: 0; }
  .ep, .two { grid-template-columns: minmax(0, 1fr); }
  .ep-code, .code-col { position: static; }
  .code-pane { display: block !important; }
}

/* footer column titles are h2 on docs pages (they follow the page's h2s); same look as the site's h4 */
.site-footer .footer-col h2.footer-title { font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 16px; }

/* ---------- Risk and compliance pages ---------- */
/* tables whose first column holds sentences, not identifiers */
.docs-main .table.wrap td:first-child { white-space: normal; min-width: 150px; }
.docs-main .table.wrap td { line-height: 1.5; }
.docs-main .table.wrap td b { color: var(--ink); font-weight: 600; }

/* an explanation, drawn the way the dashboard draws it */
.xcard { position: relative; margin: 22px 0 0; max-width: 880px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg-elev); box-shadow: var(--shadow-md); overflow: hidden; }
.xcard-head { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.xcard-head > div { position: relative; padding: 16px 44px 16px 20px; border-right: 1px solid var(--line); min-width: 0; }
.xcard-head > div:last-child { border-right: 0; }
.xlabel { display: block; margin-bottom: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.xcard-head b { display: block; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.xcard-head .xword { font-size: 1.6rem; }
.xcard-head small { display: block; margin-top: 4px; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.xcard-body { position: relative; padding: 16px 20px 4px; }
.xcard .demo-legend { margin: 0 0 12px; }
.xcard .attr-row { grid-template-columns: minmax(150px, 240px) minmax(0, 1fr) 76px; font-family: var(--font-sans); font-size: 13.5px; }
.xcard .attr-name span { color: var(--ink-3); }
.xcard-sum { margin: 14px -20px 0; padding: 12px 20px; border-top: 1px dashed var(--line-strong); font-size: 14px; color: var(--ink-2); }
.xcard-cf { position: relative; padding: 14px 44px 16px 20px; border-top: 1px solid var(--line); background: var(--bg-sunken); font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.xmark { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 99px; background: var(--grad); color: #0b0c10; font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; }
.xcard .xmark { position: absolute; top: 14px; right: 14px; }
.prose .xnotes { list-style: none; padding: 0; margin-top: 22px; display: grid; gap: 16px; }
.xnotes li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; }
.xnotes li .xmark { margin-top: 2px; }
@media (max-width: 760px) {
  .xcard-head { grid-template-columns: minmax(0, 1fr); }
  .xcard-head > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .xcard-head > div:last-child { border-bottom: 0; }
  .xcard .attr-row { grid-template-columns: minmax(96px, 140px) minmax(0, 1fr) 64px; font-size: 12px; gap: 8px; }
}
