/* === dev: API reference === */
/* Loaded by api_docs.html, in the dashboard and on the public page. Tokens and buttons come from app.css. */

.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.verb.put { background: #f0e6ff; color: #5b34a8; }
.verb.mini { min-width: 38px; margin-right: 8px; padding: 1px 0; font-size: 9.5px; letter-spacing: .02em; vertical-align: 1px; }

html { scroll-behavior: smooth; }

/* ---------------------------------------------------------------- Frames */
/* Inside the dashboard the page is as wide as the window allows. */
.page:has(> .ref-embed), .page:has(> .flash + .ref-embed) { max-width: none; padding: 0; }
.ref-embed { container: ref / inline-size; --ref-top: 68px; padding: 8px 32px 96px; }
.ref-standalone { container: ref / inline-size; --ref-top: 76px; max-width: 1640px; margin: 0 auto; padding: 8px 32px 120px; }

.ref-page { background: var(--bg); }
.ref-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 32px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.ref-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.ref-brand img { display: block; border-radius: 7px; }
.ref-brand b { font-weight: 650; letter-spacing: -0.01em; }
.ref-brand span { padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: 13.5px; }
.ref-toplink { padding: 0 8px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.ref-toplink:hover { color: var(--ink); text-decoration: underline; }
.ref-top .top-fill { flex: 1; }

.ref { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 0 44px; align-items: start; }
.ref-toc { display: none; }
@container ref (min-width: 1360px) {
  .ref { grid-template-columns: 236px minmax(0, 1fr) 172px; gap: 0 40px; }
  .ref-toc { display: block; }
}

/* ---------------------------------------------------------------- Navigation */
.ref-nav { position: sticky; top: var(--ref-top); align-self: start; max-height: calc(100vh - var(--ref-top) - 12px); overflow-y: auto; padding: 4px 0 16px; scrollbar-width: thin; }
.ref-menu > summary { display: none; list-style: none; }
.ref-menu > summary::-webkit-details-marker { display: none; }
.ref-search { padding-bottom: 12px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.ref-input { position: relative; display: block; }
.ref-input .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.ref-input input { height: 36px; padding: 0 34px 0 34px; font-size: 13.5px; border-radius: 8px; background: var(--tint); }
.ref-input input::-webkit-search-cancel-button { display: none; }
.ref-input kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.ref-input input:focus + kbd { display: none; }
.ref-count { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.ref-tree ul { list-style: none; margin: 0; padding: 0; }
.ref-tree > ul > li { margin-bottom: 2px; }
.ref-gh { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; font-weight: 600; text-decoration: none; color: var(--ink); }
.ref-gh:hover { background: var(--hover); }
.ref-n { font: 500 11px var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.ref-grp > ul { margin: 2px 0 8px 10px; padding-left: 8px; border-left: 1px solid var(--line); }
.ref.js .ref-grp:not(.on) > ul { display: none; }
.ref-grp.on > .ref-gh { background: var(--brand-soft); color: var(--green-ink); }
.ref-grp li > a { display: block; padding: 4px 8px; border-radius: 5px; font-size: 13px; line-height: 1.35; color: var(--muted); text-decoration: none; }
.ref-grp li > a:hover { color: var(--ink); background: var(--hover); }
.ref-grp li.cur > a { color: var(--ink); font-weight: 600; background: var(--tint); }
.ref-grp li.gone, .ref-grp.gone { display: none; }
.ref-side { padding: 14px 4px 0; }
.ref-side .btn { width: 100%; }

.ref-toc { position: sticky; top: var(--ref-top); align-self: start; max-height: calc(100vh - var(--ref-top) - 12px); overflow-y: auto; padding-top: 4px; }
.toc-title { font: 500 11px var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.ref-toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.ref-toc li a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; font-size: 12.5px; line-height: 1.4; color: var(--muted); text-decoration: none; }
.ref-toc li a:hover { color: var(--ink); }
.ref-toc li.cur a { color: var(--ink); font-weight: 600; border-left-color: var(--brand-edge); }

/* ---------------------------------------------------------------- Introduction and guides */
.ref-main { min-width: 0; }
.ref-group { padding-top: 8px; }
.ref-group + .ref-group { margin-top: 56px; }
.ref-hero { padding: 24px 0 8px; max-width: 70ch; }
.ref-hero h1 { font-size: 32px; letter-spacing: -0.03em; }
.ref-hero .lead { margin-top: 12px; font-size: 17px; line-height: 1.55; color: var(--ink-2); }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.ref-group-head { padding: 12px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.ref-group-head h2 { font-size: 24px; letter-spacing: -0.022em; margin-bottom: 8px; }
.guide { padding: 36px 0 8px; scroll-margin-top: var(--ref-top); }
.guide + .guide { border-top: 1px solid var(--line); margin-top: 32px; }
.guide > h2 { font-size: 20px; letter-spacing: -0.018em; margin-bottom: 12px; }
.ref .prose { gap: 12px; font-size: 14.5px; line-height: 1.65; max-width: 74ch; }
.ref .prose p, .ref .prose li { color: var(--ink-2); }
.ref .prose ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.ref .prose a, .ref .errs a, .ref .params a, .ref .resp-desc a { text-decoration-color: var(--line-strong); }
.ref .prose strong { color: var(--ink); font-weight: 600; }
.ref .prose code, .ref .param-desc code, .ref .errs code { font-size: 12.5px; }
.guide .codebox, .guide pre.cb-pane.static, .guide .events, .guide .roles, .guide .matrix, .guide .errs { max-width: 820px; margin-top: 16px; }
.kv { display: flex; align-items: center; gap: 10px; max-width: 720px; padding: 8px 8px 8px 14px; background: var(--tint); border: 1px solid var(--line); border-radius: 8px; }
.kv code { flex: 1; min-width: 0; background: none; padding: 0; font-size: 13.5px; }
.cb-copy { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; }
.cb-copy:hover { background: var(--hover); color: var(--ink); }
.cb-copy .i { width: 13px; height: 13px; }
.cb-copy.done { color: var(--green-ink); border-color: #86b81a; }

.roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.role { padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.role h3 { font-size: 15px; }
.role-sum { margin: 4px 0 10px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.role ul { margin: 0 0 8px; padding-left: 16px; display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.role ul.can li::marker { color: var(--green-ink); }
.role ul.cannot li::marker { color: var(--bad-ink); }
.role-n { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font: 500 11.5px var(--mono); color: var(--muted); }
.matrix { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.matrix table { margin: 0; font-size: 13px; }
.matrix th, .matrix td { padding: 10px 14px; }
.matrix td:nth-child(n+3), .matrix th:nth-child(n+3) { text-align: center; }
.matrix .yes { color: var(--green-ink); } .matrix .no { color: var(--faint); }

/* ---------------------------------------------------------------- Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 5px; font: 500 12px var(--mono); background: var(--idle-bg); color: var(--idle-ink); white-space: nowrap; }
.chip.perm { text-transform: lowercase; }
.chip.perm-view { background: var(--idle-bg); color: var(--idle-ink); }
.chip.perm-deploy { background: #e6efff; color: #1d4aa8; }
.chip.perm-secrets { background: var(--busy-bg); color: var(--busy-ink); }
.chip.perm-workspace { background: var(--ink); color: var(--brand); }
.chip.status.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.status.bad { background: var(--bad-bg); color: var(--bad-ink); }
.chip.status.warn { background: var(--busy-bg); color: var(--busy-ink); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: #6aa300; } .dot.bad { background: #c93a28; }

/* ---------------------------------------------------------------- One endpoint */
.op { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 44%); gap: 8px 44px; padding: 44px 0 40px; border-top: 1px solid var(--line); scroll-margin-top: var(--ref-top); }
.ref-group-head + .op { border-top: 0; }
.op-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.op-head .verb { min-width: 52px; }
.op-path { background: none; padding: 0; font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.op-link { margin-left: 2px; color: var(--faint); text-decoration: none; font-weight: 500; opacity: 0; transition: opacity .12s; }
.op:hover .op-link, .op-link:focus-visible { opacity: 1; }
.op-link:hover { color: var(--ink); }
.op-title { margin: 10px 0 6px; font-size: 22px; letter-spacing: -0.02em; line-height: 1.25; }
.op-perm { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.op-needs { margin-top: 12px; padding: 9px 12px; border-radius: 8px; background: var(--busy-bg); color: var(--ink-2); font-size: 13px; }
.op-needs p { display: inline; }
.op-doc h4 { margin: 28px 0 8px; font: 500 11px var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.h4-note { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 12.5px; color: var(--faint); margin-left: 6px; }
.op-doc .prose { max-width: none; }

.params { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.param { padding: 11px 0; border-bottom: 1px solid var(--line); }
.param-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pn { background: none; padding: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
.pt { font: 400 12px var(--mono); color: var(--muted); }
.pt a { color: var(--muted); text-decoration-color: var(--line-strong); }
.preq { font: 500 11px var(--mono); color: var(--bad-ink); }
.param-desc { margin-top: 4px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.param-desc p { margin: 0; }
.pmeta { margin-top: 4px !important; font-size: 12.5px; color: var(--muted); }
.param.d1 { margin-left: 18px; padding-left: 14px; border-left: 2px solid var(--line); border-bottom-color: transparent; padding-top: 7px; padding-bottom: 7px; }
.param.d2 { margin-left: 36px; padding-left: 14px; border-left: 2px solid var(--line); border-bottom-color: transparent; padding-top: 7px; padding-bottom: 7px; }
.resp-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.resp-desc { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.resp-desc p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.errs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.errs li { display: grid; grid-template-columns: 44px 148px minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.errs li code { background: none; padding: 0; color: var(--ink); font-weight: 600; }
.errs.wide li { grid-template-columns: 52px 170px minmax(0, 1fr); }
.errs .chip { justify-content: center; padding: 0; }
.errs p { display: inline; }

/* ---------------------------------------------------------------- Code */
.op-code-in { position: sticky; top: var(--ref-top); display: grid; gap: 12px; align-self: start; max-height: calc(100vh - var(--ref-top) - 12px); overflow: auto; }
.op-req { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint); min-width: 0; }
.op-req code { background: none; padding: 0; font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codebox { background: #0d0f0c; border-radius: 10px; overflow: hidden; min-width: 0; }
.cb-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 0 4px; background: #151813; border-bottom: 1px solid #23271f; }
.cb-tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
.cb-tabs::-webkit-scrollbar { display: none; }
.cb-tab { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border: 0; border-bottom: 2px solid transparent; background: none; color: #8d9484; font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.cb-tab:hover { color: #dfe6cf; }
.cb-tab.on { color: #fff; border-bottom-color: var(--brand); }
.cb-tab:focus-visible, .cb-var:focus-visible, .cb-copy:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.codebox .cb-copy { background: #1d211a; border-color: #2d3228; color: #c9d1bb; }
.codebox .cb-copy:hover { background: #262b21; color: #fff; }
.codebox .cb-copy.done { color: var(--brand); border-color: #5b7a10; }
.cb-variants { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px 0; }
.cb-var { height: 24px; padding: 0 10px; border: 1px solid #2d3228; border-radius: 12px; background: none; color: #9aa291; font: inherit; font-size: 12px; cursor: pointer; }
.cb-var:hover { color: #fff; border-color: #4a5240; }
.cb-var.on { background: #232a1a; border-color: #5b7a10; color: var(--brand); }
.cb-pane { margin: 0; padding: 14px 16px 16px; color: #dfe6cf; font: 400 12.5px/1.65 var(--mono); white-space: pre; overflow-x: auto; tab-size: 4; -moz-tab-size: 4; scrollbar-width: thin; }
.cb-pane:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 0; }
pre.cb-pane.static { background: #0d0f0c; border-radius: 10px; }
.tk-k { color: #c0a2ff; } .tk-s { color: #b1e225; } .tk-n { color: #f5b971; } .tk-c { color: #7a8270; font-style: italic; }
.tk-p { color: #8d9484; } .tk-v { color: #8fb4ff; } .tk-f { color: #f0f2e6; } .tk-b { color: #f08fb0; } .tk-o { color: #8d9484; }
.codebox.resp .cb-tab { height: 32px; }

.try-bar { display: flex; align-items: center; gap: 12px; }
.try-hint { font-size: 12.5px; color: var(--muted); }
.try { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 30px -22px rgba(10, 10, 10, .4); }
.try-warn { font-size: 12.5px; color: var(--muted); }
.try-grid { display: grid; gap: 10px; }
.try label { font-size: 12.5px; }
.try input, .try textarea { font-size: 13px; font-family: var(--mono); }
.try input { height: 32px; }
.try textarea { min-height: 120px; font-size: 12px; }
.try-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.try-actions .btn.confirm { background: #c93a28; border-color: #c93a28; color: #fff; }
.try-out { display: grid; gap: 8px; }
.try-out .meta { display: flex; align-items: center; gap: 10px; font: 12px var(--mono); color: var(--muted); }
.try-out pre.cb-pane { background: #0d0f0c; border-radius: 8px; max-height: 340px; overflow: auto; }
.try-err { font-size: 13px; color: var(--bad-ink); }

/* ---------------------------------------------------------------- Webhooks, objects, changelog */
.events { display: grid; gap: 6px; }
.event { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.event > summary, .object > summary { display: flex; align-items: baseline; gap: 12px; padding: 10px 14px; cursor: pointer; list-style: none; font-size: 13.5px; }
.event > summary::-webkit-details-marker, .object > summary::-webkit-details-marker { display: none; }
.event > summary::before, .object > summary::before { content: ""; flex: none; width: 6px; height: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); align-self: center; transition: transform .12s; }
.event[open] > summary::before, .object[open] > summary::before { transform: rotate(45deg); }
.event > summary span, .object > summary span { color: var(--muted); font-size: 13px; }
.event > summary code { background: none; padding: 0; font-weight: 600; color: var(--ink); }
.event pre.cb-pane.static { border-radius: 0 0 8px 8px; margin: 0; }
.objects { display: grid; gap: 6px; max-width: 900px; margin-top: 16px; }
.object { border: 1px solid var(--line); border-radius: 8px; scroll-margin-top: var(--ref-top); }
.object > summary code { background: none; padding: 0; font-weight: 650; color: var(--ink); }
.object .params { margin: 0 14px 10px; }
.change { max-width: 74ch; padding: 20px 0; border-bottom: 1px solid var(--line); }
.change h3 { font-size: 16px; }
.change time { display: block; margin: 2px 0 10px; font: 500 12px var(--mono); color: var(--muted); }
.change ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.ref-none { margin-top: 40px; padding: 28px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); text-align: center; }
.op.gone, .guide.gone, .ref-group.gone, .ref-group-head.gone, .change.gone, .object.gone, .ref-hero.gone { display: none; }
.ref.searching .ref-grp > ul { display: block; }
.ref-group.searching > .ref-group-head { margin-bottom: 0; }

/* ---------------------------------------------------------------- Narrower than a desktop */
@container ref (max-width: 1180px) {
  .op { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .op-code-in { position: static; max-height: none; margin-top: 12px; }
}
@container ref (max-width: 880px) {
  .ref { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ref-nav { position: static; max-height: none; overflow: visible; padding: 0 0 16px; }
  .ref-menu { border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
  .ref-menu > summary { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 14px; font-weight: 600; cursor: pointer; }
  .ref-menu > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
  .ref-menu[open] > summary::after { transform: rotate(-135deg); }
  .ref-menu > :not(summary) { margin: 0 12px; }
  .ref-menu > .ref-side { margin-bottom: 14px; }
  .ref-menu[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
  .ref-tree { max-height: 52vh; overflow: auto; }
  .ref-search { position: static; }
  .ref-input input { height: 44px; }
  .roles { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .ref-embed { padding: 8px 16px 80px; }
  .ref-standalone { padding: 8px 16px 96px; }
  .ref-top { padding: 0 16px; }
  .ref-brand span { display: none; }
  .ref-hero h1 { font-size: 26px; }
  .ref-hero .lead { font-size: 15.5px; }
  .op { padding: 32px 0 28px; }
  .op-title { font-size: 19px; }
  .op-link { opacity: 1; }
  .errs li, .errs.wide li { grid-template-columns: 44px minmax(0, 1fr); }
  .errs li > span:last-child { grid-column: 1 / -1; }
  .cb-pane { padding: 12px 14px 14px; font-size: 12px; }
  .cb-tab { height: 44px; }
  .cb-copy, .kv .cb-copy { height: 36px; }
  .try-hint { display: none; }
  .try-actions .btn { height: 44px; }
  .hero-actions .btn { height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .op-link, .event > summary::before, .object > summary::before { transition: none; } html { scroll-behavior: auto; } }

/* Text that follows code, or other text, in a guide. */
.guide .prose + .prose, .guide .codebox + .prose, .guide pre.cb-pane.static + .prose, .guide .matrix + .prose { margin-top: 14px; }

/* === fullwidth === */
/* In the dashboard, a guide (Authentication, Webhook signatures, ...) puts its code next to the text
   it belongs to, on the same two columns as .op so the code lines up all the way down the page.
   Tables, role cards and event lists stay below the text at their own width. */
@container ref (min-width: 1181px) {
  .ref-embed .guide { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 44%); gap: 0 44px; align-items: start; }
  .ref-embed .guide > h2, .ref-embed .guide > :not(.prose):not(.codebox):not(pre.cb-pane) { grid-column: 1 / -1; }
  .ref-embed .guide > .prose { grid-column: 1; }
  .ref-embed .guide > .codebox, .ref-embed .guide > pre.cb-pane.static { grid-column: 2; max-width: none; margin-top: 0; }
}
