:root {
  --ink: #161513;
  --muted: #5e5850;
  --faint: #8a8378;
  --line: #e6e0d4;
  --line-strong: #cfc6b6;
  --bg: #f4f0e8;
  --paper: #fffcf7;
  --nav: #1c1a17;
  --nav-text: #efeae0;
  --accent: #9a3412;
  --ok: #17663a;
  --warn: #9a5b08;
  --bad: #b42318;
  --info: #1d4e89;
  --chip: #efe8db;
  --max: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

a { color: var(--accent); }
a:hover { color: var(--ink); }

.site-header {
  background: var(--nav);
  color: var(--nav-text);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #2c2924;
}

.site-header .inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 56px;
}

.site-header a,
.site-header a:hover,
.site-header .brand,
.site-header .brand:hover,
.site-header .brand strong {
  color: var(--nav-text);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-decoration: none;
  color: var(--nav-text);
  flex-shrink: 0;
}

.brand:hover,
.brand:hover strong {
  color: #fff;
  text-decoration: none;
}

.brand:hover span {
  color: #efeae0;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: inherit;
}

.brand span {
  font-size: 11px;
  color: #b8b0a3;
  letter-spacing: 0.04em;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 2px;
}

.site-header nav a {
  color: #c9c2b6;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 4px;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: #fff;
  background: #2d2a25;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  color: var(--nav-text);
  border: 1px solid #4a453c;
  padding: 8px 12px;
  font-size: 13px;
  min-height: 44px;
  min-width: 44px;
}

img, svg, video {
  max-width: 100%;
  height: auto;
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px 24px 80px;
  min-width: 0;
}

.kicker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
  margin: 0 0 8px;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
  font-weight: 650;
}

h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 40px 0 12px;
  padding-top: 8px;
}

h3 {
  font-size: 16px;
  margin: 24px 0 8px;
}

.lede {
  font-size: 18px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 46rem;
  margin: 0 0 20px;
}

.meta {
  font-size: 13px;
  color: var(--faint);
  margin: 0 0 32px;
}

p { margin: 0 0 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0 32px;
}

.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 18px;
}

.stat b {
  display: block;
  font-size: 26px;
  letter-spacing: -0.03em;
  font-weight: 650;
}

.stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.stat.warn b, .stat.poor b { color: var(--warn); }
.stat.bad b { color: var(--bad); }
.stat.ok b { color: var(--ok); }
.stat.info b { color: var(--info); }

.callout {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  margin: 20px 0 28px;
}

.callout.warn { border-left-color: var(--warn); }
.callout.bad { border-left-color: var(--bad); }
.callout.info { border-left-color: var(--info); }

.callout strong { display: block; margin-bottom: 4px; }

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0 28px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 18px;
}

.card h3 { margin-top: 0; }

.toc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 36px;
}

.toc a {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}

.toc a:hover { border-color: var(--line-strong); }

.toc a b {
  display: block;
  font-size: 15px;
}

.toc a span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 14px;
  margin: 12px 0 28px;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  background: #f8f4ec;
}

td code, p code, li code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--chip);
  padding: 1px 5px;
}

.score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.score.good { color: var(--ok); }
.score.ok { color: var(--info); }
.score.poor { color: var(--warn); }
.score.bad { color: var(--bad); }

.pill, .pri {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 3px;
  color: #fff;
  margin-right: 6px;
}

.P0 { background: var(--bad); }
.P1 { background: var(--warn); }
.P2 { background: var(--info); }
.P3 { background: #57534e; }

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 12px 0 28px;
}

.steps li {
  position: relative;
  padding: 0 0 20px 48px;
  border-left: 1px solid var(--line-strong);
  margin-left: 14px;
}

.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }

.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -14px;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--nav);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.steps strong { display: block; margin-bottom: 2px; }

.flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 28px;
}

.flow div {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px 14px;
}

.flow b { display: block; }
.flow span { font-size: 13px; color: var(--muted); }

.diagram {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0 28px;
}

.diagram svg { display: block; max-width: 100%; height: auto; }

.caption {
  font-size: 12px;
  color: var(--faint);
  margin: -20px 0 28px;
}

ul.plain { margin: 8px 0 20px; padding-left: 18px; }
ul.plain li { margin: 5px 0; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 12px 0 28px;
}

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 24px 48px;
  font-size: 12px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.site-footer .copy {
  display: inline;
  margin: 0 0 0 auto;
  flex-shrink: 0;
}

.pager {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 48px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.pager a {
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
}

.pager a span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

@media (max-width: 960px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .flow { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  div.toc, .cards, .two-col { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  .lede { font-size: 16px; max-width: none; }
  .nav-toggle { display: block; }
  .site-header .inner { flex-wrap: wrap; padding: 8px 16px; gap: 8px 16px; }
  .site-header nav {
    display: none;
    width: 100%;
    flex-direction: column;
  }
  .site-header nav.open { display: flex; }
  .site-header nav a { padding: 12px 10px; }
  main { padding: 24px 16px 56px; }
  .site-footer {
    white-space: normal;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 16px;
    padding: 16px 16px 40px;
  }
  .site-footer .copy { margin-left: auto; }
  th, td { padding: 8px 10px; }
}

.subnav {
  background: #2a2722;
  border-bottom: 1px solid #3a3630;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 24px;
  justify-content: center;
  position: sticky;
  top: 56px;
  z-index: 18;
}

.shots.session,
.shots.usage {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.shots.primary {
  grid-template-columns: minmax(160px, 280px) minmax(200px, 1fr) minmax(240px, 1.2fr);
}

.shots.extra,
.shots.compare {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.shots-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 0 0;
}

details {
  margin: 8px 0 16px;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.subnav a {
  color: #c9c2b6;
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
}

.subnav a:hover,
.subnav a[aria-current="page"] {
  color: #fff;
  background: #3d3933;
}

.gallery main { padding-top: 28px; }

.gallery section.page,
.gallery .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 20px 22px;
  margin: 0 0 28px;
}

.gallery section.page h2,
.gallery .panel h2 {
  margin-top: 0;
}

.path, .job { color: var(--muted); font-size: 14px; }

.shots {
  display: grid;
  gap: 12px;
  margin: 12px 0 16px;
  grid-template-columns: minmax(220px, 360px) 1fr;
}

.gallery .shots { grid-template-columns: var(--cols, minmax(220px, 360px) 1fr); }

figure {
  margin: 0;
  background: #111;
  border: 1px solid #2a2a2a;
  overflow: hidden;
}

figure img { display: block; width: 100%; height: auto; }

figcaption {
  font-size: 12px;
  color: #c8c8c8;
  padding: 7px 10px;
}

.sticky {
  position: sticky;
  top: 104px;
  z-index: 15;
  background: var(--bg);
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 24px;
}

.global {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.global span { font-size: 13px; color: var(--muted); margin-right: 4px; }

.global button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.global button[aria-pressed="true"] {
  background: var(--nav);
  color: #fff;
  border-color: var(--nav);
}

.tab-radio { position: absolute; opacity: 0; pointer-events: none; }

.tab-bar {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  width: max-content;
  max-width: 100%;
  margin: 0 0 14px;
}

.tab-label {
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.tab-label:last-child { border-right: 0; }

.tab-panel { display: none; }

.gaps { margin-top: 12px; }
.gaps + .gaps { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

.fix { margin-top: 12px; }
.fix h4 { display: inline; font-size: 15px; }
.fix p { margin: 6px 0 0; }

nav.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 28px;
}

nav.toc a {
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 4px 9px;
  border-radius: 999px;
}

@media (max-width: 900px) {
  .shots, .gallery .shots { grid-template-columns: 1fr !important; }
  .subnav { padding: 8px 16px; }
}

.schema-explorer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 20px;
  align-items: start;
  margin: 12px 0 28px;
  min-width: 0;
}

.schema-explorer .diagram {
  margin: 0;
  min-width: 0;
}

.schema-node { cursor: pointer; }
.schema-node rect {
  transition: fill 0.12s ease, stroke 0.12s ease, stroke-width 0.12s ease;
  stroke-width: 1.75;
}
.schema-node:hover rect,
.schema-node:focus rect,
.schema-node.is-active rect {
  fill: #f8efe6;
  stroke: var(--accent);
  stroke-width: 2.5;
}
.schema-node:focus { outline: none; }

.schema-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}

.schema-list button {
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.schema-list button:hover,
.schema-list button.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.schema-explorer .diagram svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(70vh, 560px);
  object-fit: contain;
}

.schema-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 16px 20px;
  min-width: 0;
  max-height: calc(100vh - 140px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: sticky;
  top: 120px;
}

.schema-panel h3 { margin: 0 0 4px; }
.schema-panel h4 {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

.schema-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.schema-close {
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--chip);
  padding: 4px 8px;
  cursor: pointer;
}

.schema-panel .table-wrap {
  overflow: visible;
  min-width: 0;
}
.schema-panel table {
  display: table;
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
  margin: 0 0 8px;
  overflow: visible;
}
.schema-panel th,
.schema-panel td {
  padding: 6px 8px;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.schema-panel td code {
  word-break: break-all;
}
.schema-panel .col-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.key-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--chip);
  margin: 0;
}

.key-chip.pk { background: #1c1a17; color: #fff; }
.key-chip.fk { background: #efe0d4; color: var(--accent); }
.key-chip.uq { background: #e4ece6; color: var(--ok); }

.proc {
  border-top: 1px solid var(--line);
  padding: 10px 0 4px;
}

.proc .status { font-size: 12px; font-weight: 700; }
.proc .status.ok { color: var(--ok); }
.proc .status.bad { color: var(--bad); }
.proc .status.warn { color: var(--warn); }

.meta-line { font-size: 12px; color: var(--faint); margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }

.method {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 3px;
  color: #fff;
  min-width: 52px;
  text-align: center;
}

.method.GET { background: #17663a; }
.method.POST { background: #1d4e89; }
.method.PUT { background: #9a5b08; }
.method.PATCH { background: #5b2d8e; }
.method.DELETE { background: #b42318; }

.api-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 18px;
  margin: 0 0 16px;
}

.api-card h3 {
  margin: 8px 0 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 650;
}

.api-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}

.sample-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sample-grid h4 {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

pre.sample {
  margin: 0;
  padding: 10px 12px;
  background: #1c1a17;
  color: #efeae0;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1100px) {
  .schema-panel table,
  .schema-panel thead,
  .schema-panel tbody,
  .schema-panel tr,
  .schema-panel th,
  .schema-panel td { display: block; width: 100%; }
  .schema-panel thead { display: none; }
  .schema-panel tr {
    border-top: 1px solid var(--line);
    padding: 8px 0 10px;
  }
  .schema-panel td {
    padding: 2px 0;
  }
  .schema-panel td:first-child { font-weight: 650; }
}

@media (max-width: 900px) {
  .schema-explorer { grid-template-columns: 1fr; }
  .schema-explorer .diagram svg {
    height: auto;
    max-height: min(42vh, 280px);
  }
  .schema-panel {
    position: static;
    top: auto;
    width: 100%;
    min-width: 0;
    max-height: none;
    overflow: visible;
    order: 2;
  }
  .swagger { grid-template-columns: 1fr; }
  .swagger-tags {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .swagger-tags a { border-left: 0; border: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .sample-grid { grid-template-columns: 1fr; }
}

.swagger {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin: 8px 0 28px;
  min-width: 0;
}

.swagger-tags {
  position: sticky;
  top: 104px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}

.swagger-tags a {
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.swagger-tags a:hover,
.swagger-tags a.is-active {
  background: var(--chip);
  border-left-color: var(--accent);
  color: var(--ink);
}

.swagger-ops .swagger-tag > h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

.swagger-tag + .swagger-tag { margin-top: 28px; }

.op {
  border: 1px solid var(--line);
  border-radius: 4px;
  margin: 0 0 8px;
  overflow: hidden;
  background: var(--paper);
}

.op.GET { background: #f2f7f4; border-color: #c5d9cc; }
.op.POST { background: #f3f6fa; border-color: #c5d0de; }
.op.PUT { background: #faf6f0; border-color: #e2d2b8; }
.op.PATCH { background: #f6f3f9; border-color: #d4c6e2; }
.op.DELETE { background: #faf3f2; border-color: #e2c4c1; }

.op > summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
}

.op > summary::-webkit-details-marker { display: none; }

.op .path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.op .op-sum {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46%;
}

.op-body {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.op-body .api-meta { margin-top: 0; }

@media (max-width: 900px) {
  .swagger { grid-template-columns: 1fr; }
  .swagger-tags {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .swagger-tags a { border-left: 0; border: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .sample-grid { grid-template-columns: 1fr; }
  .op .op-sum {
    margin-left: 0;
    max-width: 100%;
    white-space: normal;
    flex-basis: 100%;
    overflow: visible;
    text-overflow: unset;
  }
  .gallery section.page,
  .gallery .panel { padding: 16px; }
  .tab-bar { width: 100%; }
  .tab-label { flex: 1; text-align: center; padding: 10px 8px; }
  .sticky { top: 96px; }
}

@media (max-width: 520px) {
  .stats, .flow { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .stat b { font-size: 22px; }
}

@media print {
  .site-header { position: static; }
  .nav-toggle, .pager { display: none; }
  body { background: #fff; }
  a { color: inherit; text-decoration: none; }
  .site-header nav a[aria-current="page"] { background: transparent; color: #fff; }
  .subnav { position: static; }
  .sticky { position: static; }
  .schema-panel { position: static; max-height: none; overflow: visible; }
  .op { break-inside: avoid; }
}
