:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-hover: #f0f2f5;
  --text: #1c1e21;
  --text-2: #4a4f57;
  --muted: #7a808a;
  --border: #e3e6ea;
  --primary: #1f8ae0;
  --primary-soft: #eaf4fd;
  --code-bg: #f3f5f8;
  --code-border: #e3e6ea;
  --req: #e5484d;
  --warn-bg: #fff8e6;
  --warn-border: #f0b429;
  --ok: #2fa84f;
  --stale: #e8a33d;
  --down: #e5484d;
  --t-str: #b5541c;
  --t-key: #1f6fb5;
  --t-num: #2f8a3c;
  --t-kw: #8e3fc4;
  --mark: #fff1a8;
  --shadow: 0 6px 28px rgba(15, 23, 42, .12);
  --head-h: 60px;
}

:root[data-theme="dark"] {
  --bg: #1b1b1d;
  --bg-soft: #242526;
  --bg-hover: #2c2d30;
  --text: #e6e7e9;
  --text-2: #c2c5ca;
  --muted: #8f949c;
  --border: #36383c;
  --primary: #4ea3f1;
  --primary-soft: #1f2d3b;
  --code-bg: #232427;
  --code-border: #36383c;
  --req: #ff6b6f;
  --warn-bg: #3a3020;
  --warn-border: #c99528;
  --t-str: #f0a36b;
  --t-key: #7fc0f5;
  --t-num: #8ad18e;
  --t-kw: #d29cf5;
  --mark: #5b5023;
  --shadow: 0 6px 28px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b1d;
    --bg-soft: #242526;
    --bg-hover: #2c2d30;
    --text: #e6e7e9;
    --text-2: #c2c5ca;
    --muted: #8f949c;
    --border: #36383c;
    --primary: #4ea3f1;
    --primary-soft: #1f2d3b;
    --code-bg: #232427;
    --code-border: #36383c;
    --req: #ff6b6f;
    --warn-bg: #3a3020;
    --warn-border: #c99528;
    --t-str: #f0a36b;
    --t-key: #7fc0f5;
    --t-num: #8ad18e;
    --t-kw: #d29cf5;
    --mark: #5b5023;
    --shadow: 0 6px 28px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

code {
  padding: 1px 5px;
  border: 1px solid var(--code-border);
  border-radius: 5px;
  background: var(--code-bg);
  font-size: 86%;
  word-break: break-word;
}

pre {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--code-bg);
  font-size: 12.5px;
  line-height: 1.6;
  overflow: auto;
}
pre code { padding: 0; border: 0; background: none; font-size: inherit; word-break: normal; }

.t-str { color: var(--t-str); }
.t-key { color: var(--t-key); }
.t-num { color: var(--t-num); }
.t-kw { color: var(--t-kw); }

.muted { color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* ---------- header ---------- */

.head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  height: var(--head-h);
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.head-nav { display: flex; gap: 22px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.head-nav a { color: var(--text); font-weight: 500; white-space: nowrap; }
.head-nav a:hover { color: var(--primary); text-decoration: none; }
.head-nav a.active { color: var(--primary); }

.head-tools { display: flex; align-items: center; gap: 18px; margin-left: auto; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 8px 0 12px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 1px solid transparent;
}
.search:focus-within { border-color: var(--primary); background: var(--bg); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--text-2); stroke-width: 2.2; flex: none; }
.search input { width: 150px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.kbd { display: flex; gap: 3px; }
kbd {
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
}

.support {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}
.support:hover { color: var(--primary); text-decoration: none; }
.support svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

.lang-switch {
  display: flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--bg-soft);
}
.lang-switch button {
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: 600 12px/1.2 inherit;
  font-family: inherit;
  cursor: pointer;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-btn { display: none; margin-right: -16px; }

.search-results {
  position: absolute;
  top: calc(var(--head-h) - 6px);
  right: 20px;
  width: min(480px, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.search-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.sel { background: var(--bg-hover); text-decoration: none; }
.search-results .r-body { min-width: 0; }
.search-results .r-title { font-weight: 500; }
.search-results .r-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .r-empty { padding: 12px 14px; color: var(--muted); }

/* ---------- layout ---------- */

.layout { display: flex; min-height: calc(100vh - var(--head-h)); }

.sidebar {
  position: sticky;
  top: var(--head-h);
  flex: 0 0 300px;
  height: calc(100vh - var(--head-h));
  overflow-y: auto;
  padding: 12px 10px 40px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: thin;
}

.main { flex: 1; min-width: 0; padding: 22px 32px 60px; }

.backdrop { display: none; }

/* ---------- sidebar menu ---------- */

.menu, .menu ul { list-style: none; margin: 0; padding: 0; }
.menu ul { padding-left: 14px; }
.menu li { margin: 1px 0; }

.menu-row { display: flex; align-items: center; }

.menu-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.menu-link.active { background: var(--primary-soft); color: var(--primary); }
.menu-link.parent-active { color: var(--primary); }
.menu-link .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu > li > .menu-row > .menu-link { font-weight: 500; }

.caret {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.caret:hover { background: var(--bg-hover); }
.caret svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s; }
.open > .menu-row .caret svg { transform: rotate(90deg); }

.mb {
  flex: none;
  min-width: 38px;
  padding: 0 5px;
  border-radius: 4px;
  color: #fff;
  font: 700 10px/16px ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
  text-transform: uppercase;
}

.GET { background: #2f80d6; }
.POST { background: #24a148; }
.PUT { background: #d9822b; }
.PATCH { background: #8e5bd1; }
.DELETE { background: #e5484d; }
.HEAD, .OPTIONS { background: #7a808a; }

.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--ok); }
.dot.stale { background: var(--stale); }
.dot.down { background: var(--down); }
.dot.off { background: var(--down); }
.st-off { color: var(--down); font-weight: 600; }

/* ---------- document ---------- */

.doc { max-width: 860px; }

.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 500px);
  gap: 32px;
  align-items: start;
}
.doc-side {
  position: sticky;
  top: calc(var(--head-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - var(--head-h) - 36px);
  overflow-y: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.crumbs li { display: flex; align-items: center; gap: 4px; }
.crumbs li + li::before {
  content: "";
  width: 6px;
  height: 6px;
  margin: 0 8px 0 4px;
  border-right: 1.5px solid var(--muted);
  border-top: 1.5px solid var(--muted);
  transform: rotate(45deg);
}
.crumbs a, .crumbs span { padding: 4px 8px; border-radius: 16px; color: var(--text); }
.crumbs a:hover { background: var(--bg-hover); text-decoration: none; }
.crumbs .cur { background: var(--primary-soft); color: var(--primary); }
.crumbs svg { display: block; width: 16px; height: 16px; fill: currentColor; }

h1 { margin: 0 0 12px; font-size: 32px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h2 { margin: 30px 0 12px; font-size: 24px; line-height: 1.3; font-weight: 700; }
h3 { margin: 24px 0 10px; font-size: 18px; font-weight: 600; }
p { margin: 0 0 12px; }
hr { margin: 22px 0; border: 0; border-top: 1px solid var(--border); }
.lead { color: var(--text-2); font-size: 16px; }

.endpoint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 12px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.endpoint .mb { font-size: 10.5px; line-height: 20px; min-width: 44px; }
.endpoint code { padding: 0; border: 0; background: none; font-size: 12.5px; overflow-wrap: anywhere; }

.notice.err { border-left-color: var(--down); background: color-mix(in srgb, var(--down) 10%, var(--bg)); }
.notice {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--warn-border);
  border-radius: 6px;
  background: var(--warn-bg);
}

.pill-btn {
  display: inline-block;
  margin: 0 8px 14px 0;
  padding: 7px 15px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: none;
  color: var(--primary);
  font: 700 13px/1.2 inherit;
  font-family: inherit;
  letter-spacing: .02em;
  text-transform: uppercase;
  cursor: pointer;
}
.pill-btn.active { background: var(--primary-soft); }

/* ---------- blocks with fields ---------- */

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }

.block { margin: 0 0 18px; }
.block > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.chev {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  transition: transform .15s;
}
details[open] > summary > .chev { transform: rotate(90deg); }

.req {
  color: var(--req);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.fields { margin-left: 6px; padding-left: 18px; border-left: 1px solid var(--border); }

.field { padding: 10px 0; }
.fhead {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}
.fname { white-space: nowrap; padding: 0; border: 0; background: none; font-size: 14px; font-weight: 600; color: var(--text); }
.ftype { min-width: 0; color: var(--muted); font-size: 13.5px; }
.ftype a { font-size: 12.5px; }
.fnull { color: var(--muted); font-size: 12px; font-style: italic; }
.fline { flex: 1; height: 1px; margin: 0 6px; background: var(--border); }
.fdesc, .fmeta { margin: 3px 0 0; color: var(--text); font-size: 14.5px; }
.fdesc p { margin: 0 0 4px; }
.fmeta b { font-weight: 600; }
.fmeta code { font-size: 12.5px; }

details.nested > summary { padding: 0; }
details.nested > summary .fhead::before {
  content: "";
  width: 6px;
  height: 6px;
  margin: 0 2px 0 -1px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s;
}
details.nested[open] > summary .fhead::before { transform: rotate(45deg); }
.nested-body { margin-top: 6px; }

.field-note { padding: 8px 0; color: var(--text-2); }

/* ---------- tabs ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.tab {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-2);
  font: 600 13px/1.4 inherit;
  font-family: inherit;
  cursor: pointer;
}
.tab:hover { border-color: var(--muted); }
.tab.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.tab.s2 { --tc: var(--ok); }
.tab.s4 { --tc: var(--stale); }
.tab.s5 { --tc: var(--down); }
.tab[class*=" s"]::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--tc); vertical-align: 1px; }
.tab-panel[hidden] { display: none; }

.example { margin-top: 10px; }
.example > summary { color: var(--primary); font-size: 14px; font-weight: 500; margin-bottom: 8px; }

/* ---------- right column cards ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.card-head:last-child { border-bottom: 0; }
.card-body { padding: 14px 16px; }
.card-head .link-btn {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.card-head .link-btn:hover { color: var(--primary); }

.langs { display: flex; gap: 6px; padding: 12px 12px 0; overflow-x: auto; scrollbar-width: thin; }
.lang {
  flex: none;
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font: 700 11.5px/1.2 inherit;
  font-family: inherit;
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
}
.lang:hover { background: var(--bg-hover); }
.lang.active { border-color: var(--req); color: var(--text); }

.code-wrap { position: relative; margin: 12px; }
.code-wrap pre { max-height: 340px; padding-left: 0; }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-2);
  font: 12px/1.5 inherit;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.code-wrap:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { color: var(--primary); }
@media (hover: none) { .copy-btn { opacity: 1; top: auto; bottom: 8px; } }

pre.numbered { counter-reset: ln; }
pre.numbered .line { display: block; padding-right: 14px; }
pre.numbered .line::before {
  counter-increment: ln;
  content: counter(ln);
  display: inline-block;
  width: 34px;
  margin-right: 12px;
  color: var(--muted);
  text-align: right;
  opacity: .7;
  user-select: none;
}

.rsec { border-bottom: 1px solid var(--border); }
.rsec:last-of-type { border-bottom: 0; }
.rsec > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
}
.rsec-body { padding: 0 16px 14px; }
.rsec-body label { display: block; margin: 8px 0 4px; font-size: 13px; font-weight: 600; }
.rsec-body label .mono { font-size: 12.5px; }
.rsec-body label .muted { font-weight: 400; }

.input, .textarea, .select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--text);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); background: var(--bg); }
.textarea { min-height: 220px; resize: vertical; tab-size: 2; }

.send-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 14px 16px 16px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font: 600 14px/1.3 inherit;
  font-family: inherit;
  cursor: pointer;
}
.send-btn:hover { filter: brightness(1.07); }
.send-btn:disabled { opacity: .6; cursor: progress; }

.resp { margin: 0 16px 16px; }
.resp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.status { font-weight: 700; }
.status.s2 { color: var(--ok); }
.status.s3 { color: var(--primary); }
.status.s4 { color: var(--stale); }
.status.s5, .status.s0 { color: var(--down); }
.resp pre { max-height: 360px; }

/* ---------- home / overview ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.svc-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.svc-card:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
.svc-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.svc-card p { margin: 0 0 10px; color: var(--text-2); font-size: 14px; }
.svc-card .clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.svc-card .meta { color: var(--muted); font-size: 13px; }

.op-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.op-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.op-row:last-child { border-bottom: 0; }
.op-row:hover { background: var(--bg-hover); text-decoration: none; }
.op-row code { padding: 0; border: 0; background: none; font-size: 13px; }
.op-row .s { margin-left: auto; color: var(--text-2); font-size: 14px; text-align: right; }

.used-in a { display: inline-block; margin: 0 10px 6px 0; }

/* ---------- pager ---------- */

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; }
.pager a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.pager a:hover { border-color: var(--primary); text-decoration: none; }
.pager .next { grid-column: 2; text-align: right; }
.pager small { display: block; color: var(--muted); font-size: 13px; }
.pager b { color: var(--primary); font-weight: 600; }

/* ---------- responsive ---------- */

@media (max-width: 1280px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-side { position: static; max-height: none; overflow: visible; }
}

@media (max-width: 996px) {
  .menu-btn { display: grid; }
  .head-nav { display: none; }
  .sidebar {
    position: fixed;
    top: var(--head-h);
    left: 0;
    bottom: 0;
    z-index: 25;
    width: min(300px, 85vw);
    height: auto;
    transform: translateX(-100%);
    transition: transform .2s;
  }
  .menu-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .menu-open .backdrop { display: block; position: fixed; inset: var(--head-h) 0 0; z-index: 24; background: rgba(0, 0, 0, .3); }
  .main { padding: 18px 16px 48px; }
}

@media (max-width: 640px) {
  .head { gap: 16px; padding: 0 12px; }
  .head-tools { gap: 6px; }
  .kbd { display: none; }
  .support span { display: none; }
  .search input { width: 90px; }
  h1 { font-size: 26px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .op-row { flex-wrap: wrap; }
  .op-row .s { flex-basis: 100%; margin-left: 0; text-align: left; }
}
