:root {
  --bg: #0f1419;
  --bg-elev: #151b24;
  --fg: #e8edf4;
  --muted: #9aa6b8;
  --line: #273142;
  --code-bg: #0b0f14;
  --code-border: #2a3548;
  --accent: #8eb4ff;
  --accent-soft: #1a2740;
  --side-bg: #121820;
  --side-w: 248px;
  --ex-w: min(440px, 38vw);
  --method: #a8b4ff;
  --method-get: #5ecf9a;
  --method-post: #8eb4ff;
  --method-patch: #e0b35c;
  --method-delete: #e07a7a;
  --warn-bg: #2a2210;
  --warn-line: #8a6d1f;
  --th-bg: #1a2230;
  --ok: #5ecf9a;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15.5px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  align-items: stretch;
}

/* ——— Sidebar ——— */
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
  padding: 18px 0 32px;
  display: flex;
  flex-direction: column;
}
.side-brand {
  padding: 0 18px;
  font-size: .95rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: .01em;
}
.side-sub {
  padding: 2px 18px 14px;
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
}
.side nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 10px;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-group > span {
  display: block;
  padding: 4px 8px 6px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-group a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: #c5cedc;
  text-decoration: none;
  font-size: .88rem;
  line-height: 1.35;
}
.nav-group a:hover {
  background: var(--accent-soft);
  color: var(--fg);
}
.nav-group a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.nav-group a .m {
  color: var(--method);
  font-weight: 600;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .82em;
  margin-right: 4px;
}
.nav-group a code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: .9em;
}
.side-meta {
  margin-top: auto;
  padding: 16px 18px 0;
  border-top: 1px solid var(--line);
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-meta a { color: var(--accent); text-decoration: none; }
.side-meta a:hover { text-decoration: underline; }

/* ——— Content column ——— */
.content {
  min-width: 0;
  background: var(--bg);
  padding: 36px 28px 96px;
}
.content > .intro,
.content > .block {
  max-width: 720px;
}
h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -.02em;
}
h2 {
  font-size: 1.28rem;
  margin: 44px 0 12px;
  padding-top: 8px;
  scroll-margin-top: 20px;
}
h2::before {
  content: "";
  display: block;
  height: 1px;
  background: var(--line);
  margin: 0 0 28px;
}
.content > .intro + h2,
.content > .intro + .block h2,
h2.no-rule::before { display: none; }
h2.no-rule { margin-top: 28px; }
h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
  scroll-margin-top: 20px;
}
a { color: var(--accent); }
p, li { overflow-wrap: anywhere; }
.lead {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 1.02rem;
  max-width: 62ch;
}
code {
  background: var(--accent-soft);
  color: #d7e4ff;
  padding: 1px 6px;
  border-radius: 4px;
  font: .88em ui-monospace, Menlo, Consolas, monospace;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0;
  font: .84rem/1.55 ui-monospace, Menlo, Consolas, monospace;
  color: #d7dee9;
}
pre code {
  background: none;
  color: inherit;
  padding: 0;
  font: inherit;
}
.block pre { margin: 12px 0; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 12px 0;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: .92rem;
}
th, td {
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
th {
  background: var(--th-bg);
  color: var(--muted);
  font-weight: 600;
  font-size: .82rem;
}
.note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 14px 0;
}

/* ——— Endpoint row: prose | examples ——— */
.ep {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--ex-w);
  gap: 28px;
  align-items: start;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 16px;
}
.ep:last-of-type { border-bottom: none; }
.ep-main { min-width: 0; max-width: 640px; }
.ep-main > p:first-of-type,
.ep-main > ul { margin-top: 10px; }
.ep-ex {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Full URL bar */
.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.endpoint .method {
  flex: 0 0 auto;
  font: 700 .75rem/1 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .04em;
  padding: 5px 8px;
  border-radius: 5px;
  color: #0b0f14;
}
.endpoint .method.get { background: var(--method-get); }
.endpoint .method.post { background: var(--method-post); }
.endpoint .method.patch { background: var(--method-patch); }
.endpoint .method.delete { background: var(--method-delete); }
.endpoint-url {
  flex: 1 1 12rem;
  min-width: 0;
  background: none;
  color: var(--fg);
  padding: 0;
  font: .82rem/1.4 ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
  user-select: all;
}
.btn-copy {
  flex: 0 0 auto;
  margin-left: auto;
  appearance: none;
  border: 1px solid var(--code-border);
  background: var(--accent-soft);
  color: #b9d0ff;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.btn-copy svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
  flex: 0 0 auto;
}
.btn-copy .ico-check { display: none; }
.btn-copy:hover { border-color: var(--accent); color: #c9dbff; }
.btn-copy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn-copy.is-copied {
  color: var(--ok);
  border-color: var(--ok);
}
.btn-copy.is-copied .ico-copy { display: none; }
.btn-copy.is-copied .ico-check { display: block; }

/* Example cards in right column */
.ex-card {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  overflow: hidden;
}
.ex-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--code-border);
  background: #10161f;
}
.ex-hd span {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ex-hd .status-ok { color: var(--ok); }
.ex-hd .btn-copy {
  width: 28px;
  height: 28px;
  background: transparent;
}
.ex-hd .btn-copy svg {
  width: 14px;
  height: 14px;
}
.ex-card pre {
  border: none;
  border-radius: 0;
  background: transparent;
  max-height: 420px;
  overflow: auto;
}

.section-head {
  max-width: 720px;
  margin-top: 12px;
}
.qp-title {
  margin: 16px 0 8px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ——— Responsive ——— */
@media (max-width: 1100px) {
  .ep {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .ep-ex { position: static; }
  :root { --ex-w: 1fr; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side {
    position: relative;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
  }
  .side nav { gap: 10px; }
  .side-meta {
    margin-top: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px 14px;
  }
  .content { padding: 22px 16px 64px; }
  .endpoint { padding: 8px 10px; }
  .btn-copy { margin-left: 0; }
}

@media print {
  :root {
    --bg: #fff;
    --fg: #111;
    --muted: #444;
    --line: #ccc;
    --code-bg: #f4f4f4;
    --side-bg: #fff;
  }
  .side { display: none; }
  .layout { display: block; }
  .ep { display: block; }
  .ep-ex { position: static; margin-top: 12px; }
  .btn-copy { display: none; }
  pre { white-space: pre-wrap; word-break: break-word; page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
}
