/* API reference: group pages (subgroups, filter, usual flow) and one page per operation (what to send on the left,
 * a working request and a sample response on the right). Only tokens of docs.css, so the dark theme follows.
 * Regions are bands with hairlines, the way docs.css draws its tables: no nested frames. */

.api-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A path breaks only before a slash: each segment keeps together. */
.seg { white-space: nowrap; }
.param { color: var(--info-foreground); }

.article > :is(.flow-strip, .ops-head, .ops-status, .op-groups, .ops-empty, .op-page) { grid-column: breakout; }

/* ---------- Group page: the usual flow ----------
 * One column until every step gets about 15rem, the width its longest path segment needs. A strip of four steps goes
 * two by two in between. */
.article > .flow-strip {
  list-style: none; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.flow-strip > li {
  margin: 0; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 6px 10px; align-content: start;
  padding: 12px 14px 13px 0; min-width: 0;
}
.flow-strip > li + li { border-top: 1px solid var(--border); }
@container article (min-width: 31rem) {
  .flow-strip.steps-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-strip.steps-4 > li:nth-child(2n) { border-left: 1px solid var(--border); padding-left: 14px; }
  .flow-strip.steps-4 > li:nth-child(2) { border-top: 0; }
}
@container article (min-width: 47rem) {
  .flow-strip.steps-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flow-strip.steps-3 > li + li { border-top: 0; border-left: 1px solid var(--border); padding-left: 14px; }
}
@container article (min-width: 78rem) {
  .flow-strip.steps-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .flow-strip.steps-5 > li + li { border-top: 0; border-left: 1px solid var(--border); padding-left: 14px; }
}
.flow-strip .n {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--number-bg); color: var(--on-number); font: 700 var(--text-xs)/1 var(--font-sans);
}
.flow-strip b { font-weight: 600; font-size: var(--text-sm); line-height: 24px; }
.flow-call { grid-column: 2; display: block; border-radius: 6px; margin: -2px -4px; padding: 2px 4px; color: var(--muted-foreground); }
.flow-call + .flow-call { margin-top: 2px; }
.call { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; align-items: start; font: var(--text-xs)/1.45 var(--font-mono); }
.call .method { min-width: 52px; height: 20px; font-size: var(--text-xs); }
.call-path { padding-top: 1px; }
@media (hover: hover) and (pointer: fine) {
  .flow-call:hover { background: var(--muted); color: var(--foreground); text-decoration: none; }
}

/* ---------- Group page: operations in subgroups, with a filter ---------- */
.ops-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.article > .ops-head { --flow-space: 2.75rem; }
.ops-head h2 { margin: 0; }
.ops-filter { margin-left: auto; width: min(320px, 100%); }
.ops-filter .field { height: 40px; font-size: var(--text-sm); }
.ops-filter .field::placeholder { color: var(--muted-foreground); }
.ops-status { margin: 0; font-size: var(--text-xs); color: var(--muted-foreground); }
.article > .ops-status { --flow-space: 0.375rem; text-align: right; }
.article > .op-groups { --flow-space: 0.75rem; }
.op-groups { columns: 2; column-gap: 40px; }
.op-groups.single { columns: 1; }
.op-group { break-inside: avoid; margin: 0 0 22px; }
.op-group[hidden], .op-group li[hidden] { display: none; }
.op-group h3 {
  display: flex; align-items: baseline; gap: 8px; margin: 0 0 4px; padding: 0 8px 6px;
  border-bottom: var(--line) solid var(--rule); font: 900 var(--text-sm)/1.4 var(--font-sans); letter-spacing: .04em; text-transform: uppercase;
}
.op-group h3 .count { font: 500 var(--text-xs)/1 var(--font-mono); color: var(--muted-foreground); }
.op-group ul { list-style: none; margin: 0; padding: 0; }
.op-group li { margin: 0; }
.op-row {
  display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 1px 10px; align-items: baseline;
  padding: 6px 8px 7px; border-radius: 8px; color: var(--foreground);
}
.op-row .method { min-width: 58px; height: 20px; font-size: var(--text-xs); align-self: start; margin-top: 1px; }
.op-row .sum { font-size: var(--text-sm); line-height: 1.4; }
.op-row .path { grid-column: 2; font: var(--text-xs)/1.45 var(--font-mono); color: var(--muted-foreground); }
.tag-usual {
  margin-left: 6px; padding: 1px 7px; border-radius: 6px; font-size: var(--text-xs); font-weight: 500; white-space: nowrap;
  color: var(--info-foreground); background: color-mix(in srgb, var(--info) var(--tone-tint), var(--card));
}
.op-row:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  .op-row:hover { background: var(--muted); text-decoration: none; }
  .op-row:hover .sum { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
}
.ops-empty { margin: 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--muted-foreground); font-size: var(--text-sm); }
.ops-search {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--info-foreground); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
@container article (max-width: 40rem) {
  .op-groups { columns: 1; }
  .ops-filter { margin-left: 0; width: 100%; }
  .article > .ops-status { text-align: left; }
}
/* A phone zooms into a field whose text is smaller than 16px. */
@media (max-width: 600px) { .ops-filter .field { font-size: var(--text-base); } }

/* ---------- Operation page ----------
 * The markup goes description → example → fields, the order of a narrow screen and of the keyboard. A wide screen puts
 * the example in a sticky column on the right. */
.op-page { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 0 44px; align-items: start; }
.op-top { grid-column: 1; grid-row: 1; min-width: 0; }
.op-main { grid-column: 1; grid-row: 2; min-width: 0; }
.op-aside {
  grid-column: 2; grid-row: 1 / span 2;
  position: sticky; top: calc(var(--header) + 20px); display: flex; flex-direction: column; gap: 14px; min-width: 0;
  max-height: calc(100svh - var(--header) - 40px); overflow-y: auto; scrollbar-width: thin;
}
.op-top > *, .op-main > * { margin-block: 0; }
.op-top > * + * { margin-block-start: 0.875rem; }
.op-main > * + * { margin-block-start: 0.875rem; }
.op-main > h2 {
  margin-block-start: 2.25rem; font-size: var(--text-xl);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; scroll-margin-top: calc(var(--header) + 16px);
}
.op-main > h2:first-child { margin-block-start: 1.75rem; }
.op-main > h2 small { font: var(--text-xs) var(--font-mono); font-weight: 400; color: var(--muted-foreground); letter-spacing: 0; }
.op-main > h2 small .ref-link { font-size: var(--text-xs); }
.op-main > h2 + * { margin-block-start: 0.75rem; }
.op-main > .fields + .fields { margin-block-start: 1.5rem; }
.op-top .op-line { flex-wrap: nowrap; align-items: flex-start; }
.op-top .op-line .method { margin-top: 0; }
.op-top .op-line .path { min-width: 0; padding-top: 1px; }
.op-page .op-desc { max-width: none; }
.body-desc p { margin: 0; color: var(--muted-foreground); font-size: var(--text-sm); }
.op-page .op-desc > :is(ul, ol) { padding-left: 1.25rem; }
.op-page .op-desc > * + * { margin-top: 10px; }

.op-aside .codeblock { margin: 0; }
/* Code keeps its lines: a long line scrolls inside the block instead of breaking in the middle of a word. */
.op-aside .codeblock pre { font-size: var(--text-xs); padding: 12px 16px 14px; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.op-aside .codeblock pre.hl { max-height: min(56svh, 560px); overflow: auto; }
/* The code block is ink in both themes: its labels take fixed light colors, not the tokens of the page. */
.op-aside .code-head .lang { text-transform: none; letter-spacing: 0; font: 500 var(--text-sm)/1 var(--font-text); color: #f6f3ed; }
.op-aside .code-head .lang small { margin-left: 6px; font: var(--text-xs) var(--font-mono); color: #f6f3ed99; }
.op-aside .code-head { min-height: 40px; }
.sample-empty .code-head { border-bottom: 0; }
.sample-text { margin: -4px 0 0; padding: 0 16px 14px; font-size: var(--text-sm); line-height: 1.5; color: #f6f3edb8; }
.sample-text code { background: #f6f3ed24 !important; color: #f6f3ed !important; }
.code-note { margin: -6px 2px 0; font-size: var(--text-sm); color: var(--muted-foreground); line-height: 1.45; }

/* Fields: a band with a head row and a hairline between rows, required ones first. */
.fields { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.fields-head {
  display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0;
  border-bottom: 1px solid var(--border); font-size: var(--text-sm); font-weight: 500; color: var(--muted-foreground);
}
.fields-head .count { margin-left: auto; font: 500 var(--text-xs)/1 var(--font-mono); color: var(--muted-foreground); }
.fields > .prop, .opt-group > .prop { padding: 11px 0 12px; }
.fields > .prop:last-child, .opt-group:last-child > .prop:last-child { border-bottom: 0; }
.fields .pname { font-size: var(--text-sm); }
.fields .ptype { font-size: var(--text-xs); }
.fields .pdesc { margin-top: 4px; font-size: var(--text-sm); line-height: 1.5; }
.fields .pdesc p { margin: 0; }
.fields .pdesc p + p { margin-top: 6px; }
.fields .pmeta { font-size: var(--text-sm); }
.fields .enum code { font-size: var(--text-xs) !important; }
.pin { font: var(--text-xs)/1.4 var(--font-mono); color: var(--muted-foreground); }
.fields .prop-top { align-items: baseline; }
.req, .op-page .preq {
  margin-left: auto; padding: 2px 7px; border-radius: 6px; font: 500 var(--text-xs)/1.3 var(--font-text); white-space: nowrap;
  text-transform: none; letter-spacing: 0;
  color: var(--destructive-foreground); background: color-mix(in srgb, var(--destructive) var(--tone-wash), var(--card));
}
.op-page .prop .prop .preq { margin-left: 0; }
.field-note { color: var(--warning-foreground); }

/* Nested fields open under their parent, indented, with the same hairlines: no frame inside a frame. */
:is(.op-page, .model) .prop details .schema, :is(.op-page, .resp-fields) .schema {
  border: 0; border-radius: 0; overflow: visible; margin: 6px 0 0; padding-left: 14px;
}
:is(.op-page, .model) .prop details .schema > .prop:last-child { border-bottom: 0; }
:is(.op-page, .model) .prop details .schema > .prop { padding-inline: 0; }
:is(.op-page, .model) .prop details .schema > .prop:first-of-type { border-top: 1px solid var(--border); }
.op-page .schema-head { background: none; padding-inline: 0; }
.enum code { overflow-wrap: normal; word-break: normal; }
.enum-more { margin-top: 6px; }
.enum-more > summary { cursor: pointer; width: fit-content; font-size: var(--text-sm); color: var(--info-foreground); }

.opt-group + .opt-group { border-top: 1px solid var(--border); }
.opt-group > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0; cursor: pointer;
  font-size: var(--text-sm); font-weight: 500;
}
.opt-group > summary::-webkit-details-marker { display: none; }
.opt-group > summary .names {
  min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: var(--text-xs) var(--font-mono); font-weight: 400; color: var(--muted-foreground);
}
.opt-group > summary .count { flex: none; font: 500 var(--text-xs)/1 var(--font-mono); color: var(--muted-foreground); }
.opt-group > summary svg { flex: none; width: 14px; height: 14px; color: var(--muted-foreground); transition: rotate var(--dur-fast) var(--ease-out); }
.opt-group[open] > summary svg { rotate: 90deg; }
.opt-group[open] > summary { border-bottom: 1px solid var(--border); }
.opt-group[open] > summary .names { visibility: hidden; }
.opt-group > summary:focus-visible { outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .opt-group > summary:hover { color: var(--foreground); text-decoration: underline; text-underline-offset: 3px; } }
@media (prefers-reduced-motion: reduce) { .opt-group > summary svg { transition: none; } }

/* Responses: one row per code, common errors in one line. */
.resp-list { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.resp-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 2px 12px; padding: 11px 0; font-size: var(--text-sm); line-height: 1.5; }
.resp-row + .resp-row { border-top: 1px solid var(--border); }
.resp-row .code { line-height: 21px; }
.resp-row > div { min-width: 0; }
.resp-row p, .resp-row ul { margin: 0; }
.resp-row ul { padding-left: 1.1rem; }
.resp-row > div > * + * { margin-top: 6px; }
.resp-row.common { grid-template-columns: minmax(0, 1fr); color: var(--muted-foreground); }
.resp-row.common .code { margin: 0 2px; }
.resp-fields > summary { cursor: pointer; font-size: var(--text-sm); color: var(--info-foreground); width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.resp-fields > summary .ref-link { font-size: var(--text-xs); }
.op-main > h2 small .ref-link { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--link-line); }
.resp-fields .schema { margin-top: 8px; }

/* The neighbours in the usual flow: cards like the pager of the page. */
.op-next { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.op-main > .op-next { margin-block-start: 2.25rem; }
.op-next a {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-xl); color: var(--foreground); font-size: var(--text-sm); font-weight: 500; min-width: 0;
}
.op-next a .dir { font-size: var(--text-xs); font-weight: 400; color: var(--muted-foreground); }
.op-next a .call { color: var(--muted-foreground); font-weight: 400; }
.op-next a.next { grid-column: 2; text-align: right; align-items: flex-end; }
.op-next a.next .call { justify-content: end; }
@media (hover: hover) and (pointer: fine) { .op-next a:hover { background: var(--muted); text-decoration: none; } }
@media (max-width: 560px) { .op-next { grid-template-columns: minmax(0, 1fr); } .op-next a.next { grid-column: 1; } }

@media (max-width: 1340px) { .op-aside .codeblock pre { padding-inline: 12px; } }
/* Narrower: one column in the order of the markup, the example right after the description. */
@media (max-width: 1240px) {
  .op-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .op-top, .op-main, .op-aside { grid-column: 1; grid-row: auto; }
  .op-aside { position: static; margin-top: 1.5rem; max-height: none; overflow: visible; }
}
/* Phones: the sample response takes less of the screen before the fields. */
@media (max-width: 600px) { .op-aside .codeblock pre.hl { max-height: 40svh; } }

/* Phones and touch screens: every link and toggle of the reference is at least 40 px tall. Links inside running
 * sentences stay as they are. */
@media (max-width: 600px), (pointer: coarse) {
  .flow-call { padding-block: 10px; margin-block: -6px; }
  .op-row { min-height: 44px; }
  .op-page .badges .badge { min-height: 40px; }
  .op-page .ptype .ref-link, .op-page h2 .ref-link, .op-page .schema-head .ref-link, .model .ptype .ref-link,
  .model .schema-head .ref-link,
  .resp-fields > summary .ref-link {
    display: inline-flex; align-items: center; min-height: 40px;
  }
  .op-page .prop details > summary, .model .prop details > summary, .resp-fields > summary, .enum-more > summary {
    display: flex; align-items: center; min-height: 40px; width: fit-content; max-width: 100%; overflow-wrap: anywhere;
  }
  .op-page .prop-top, .model .prop-top { align-items: center; }
  .ops-search { min-height: 40px; }
}

/* ---------- Line length ----------
 * Prose keeps the measure of docs.css (--measure, about 76 characters of 16px text) and descriptions of fields and
 * codes the same number of characters at 14px. Tables, code and lists of operations keep the full width. */
.op-page .op-desc > *, .op-top > .op-note, .api-notes > *,
.article:has(> .table-wrap.api-perms) > :is(p, ul, ol, .callout) { max-width: var(--measure); }
.op-page :is(.pdesc, .pmeta, .body-desc, .resp-row > div > :is(p, ul, ol), .resp-row.common > p), .op-page .field-note, .code-note,
.model :is(.pdesc, .pmeta) { max-width: calc(var(--measure) * 0.84); }

/* The models filter sticks under the top bar on a solid band, so no text shows above it. */
.article > .model-filter.field-wrap { top: var(--header); padding-block: 10px 8px; box-shadow: 0 -6px 0 var(--card); }

/* Models: each model is a band of field rows under its name, without a frame and without repeating the name. */
.model > .schema { border: 0; border-radius: 0; overflow: visible; border-top: 1px solid var(--border); }
.model > .schema > .schema-head:not(:has(+ .prop > .ptype:only-child)) { display: none; }
.model > .schema > .prop { padding-inline: 0; }
.model > .schema > .prop:last-child { border-bottom: 0; }

/* The example column: the response block gives up height first, so the column rarely needs a scroll of its own, and
 * the wheel over it scrolls the page. */
.op-aside > .codeblock { display: flex; flex-direction: column; flex: 0 0 auto; min-height: 0; }
.op-aside > .codeblock:has(pre.hl) { flex: 0 1 auto; }
.op-aside > .codeblock pre.hl { max-height: none; min-height: 7.5rem; flex: 0 1 auto; }
.op-aside > .code-note { flex: none; }
/* The permissions matrix: every table keeps the same three columns and fits the column of the page. */
.api-perms table { table-layout: fixed; }
.api-perms td code { white-space: normal; overflow-wrap: anywhere; }
