:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --primary: #1e40af;
  --primary-soft: #dbeafe;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --get: #047857; --get-bg: #d1fae5;
  --post: #1d4ed8; --post-bg: #dbeafe;
  --put: #b45309; --put-bg: #fef3c7;
  --delete: #b91c1c; --delete-bg: #fee2e2;
  --patch: #6d28d9; --patch-bg: #ede9fe;
  --warn-bg: #fffbeb; --warn-border: #f59e0b;
  --info-bg: #eff6ff; --info-border: #3b82f6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #111a2e; --surface-2: #17223a; --border: #24324d;
    --text: #e2e8f0; --muted: #a3b2c9; --faint: #6b7a93; --primary: #93c5fd; --primary-soft: #1e3a8a55;
    --code-bg: #060b16; --code-text: #e2e8f0;
    --get: #6ee7b7; --get-bg: #064e3b80; --post: #93c5fd; --post-bg: #1e3a8a80; --put: #fcd34d; --put-bg: #78350f80;
    --delete: #fca5a5; --delete-bg: #7f1d1d80; --patch: #c4b5fd; --patch-bg: #4c1d9580;
    --warn-bg: #422006; --warn-border: #d97706; --info-bg: #0c1f3f; --info-border: #3b82f6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.65 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); }
code, pre, kbd { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ---------- topo */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px;
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: #0f172a; color: #e2e8f0; border-bottom: 1px solid #1e293b;
}
.topbar .brand { font-weight: 800; letter-spacing: .02em; font-size: 17px; color: #fff; text-decoration: none; }
.topbar .brand span { color: #60a5fa; font-weight: 600; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .base { font-size: 12.5px; color: #94a3b8; }
.topbar .base code { color: #e2e8f0; background: #1e293b; padding: 2px 8px; border-radius: 6px; }
.menu-toggle { display: none; background: none; border: 1px solid #334155; color: #e2e8f0; border-radius: 6px; padding: 4px 10px; font-size: 14px; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); max-width: 1400px; margin: 0 auto; }
.sidebar {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  padding: 22px 16px 40px; border-right: 1px solid var(--border);
}
.sidebar h4 { margin: 18px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.sidebar a {
  display: block; padding: 5px 10px; border-radius: 6px; color: var(--muted);
  text-decoration: none; font-size: 14px;
}
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.content { padding: 28px clamp(16px, 4vw, 56px) 80px; min-width: 0; }
.content section { max-width: 920px; margin-bottom: 56px; }
.content section.wide { max-width: none; }

h1 { font-size: 34px; line-height: 1.2; margin: 6px 0 12px; }
h2 { font-size: 25px; margin: 0 0 12px; padding-top: 8px; border-top: 1px solid var(--border); padding-top: 28px; }
section:first-child h1 + p { font-size: 17px; color: var(--muted); }
h3 { font-size: 18px; margin: 28px 0 8px; }
p, li { color: var(--text); }
.lead { font-size: 17px; color: var(--muted); }

/* ---------- blocos */
pre {
  background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 10px;
  overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 10px 0 18px; position: relative;
}
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; font-size: 11.5px; padding: 3px 9px; border-radius: 6px;
  border: 1px solid #334155; background: #1e293b; color: #cbd5e1; cursor: pointer;
}
.copy-btn:hover { background: #334155; }
.callout { border-left: 4px solid var(--info-border); background: var(--info-bg); padding: 12px 16px; border-radius: 8px; margin: 14px 0; }
.callout.warn { border-color: var(--warn-border); background: var(--warn-bg); }
.callout p { margin: 4px 0; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding: 2px 0 14px 44px; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center;
}
@media (prefers-color-scheme: dark) { .steps > li::before { color: #0b1220; } }

table.grid { width: 100%; border-collapse: collapse; margin: 10px 0 18px; font-size: 14px; }
table.grid th, table.grid td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
table.grid th { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ---------- abas de linguagem */
.tabs { margin: 10px 0 20px; }
.tabs .tab-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs .tab-buttons button {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 8px 8px 0 0;
  padding: 6px 12px; font-size: 13px; cursor: pointer; border-bottom: none;
}
.tabs .tab-buttons button.active { background: var(--code-bg); color: #fff; border-color: var(--code-bg); }
.tabs pre { margin-top: 0; border-top-left-radius: 0; }
.tabs .tab-panel[hidden] { display: none; }

/* ---------- referência */
.ref-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0 18px; position: sticky; top: 60px; background: var(--bg); padding: 10px 0; z-index: 5; }
.ref-tools input, .ref-tools select {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); min-width: 0;
}
.ref-tools input { flex: 1 1 280px; }
.ref-tools .count { color: var(--faint); font-size: 13px; }
.module-block > h3 { font-size: 21px; margin: 34px 0 6px; }
.screen-block { margin: 18px 0 8px; }
.screen-block h4 { margin: 0 0 8px; font-size: 16px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.screen-block h4 code { font-size: 12px; }
details.endpoint { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin: 6px 0; }
details.endpoint > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 12px; flex-wrap: wrap;
}
details.endpoint > summary::-webkit-details-marker { display: none; }
details.endpoint[open] > summary { border-bottom: 1px solid var(--border); }
.method { font: 700 11.5px/1 ui-monospace, monospace; padding: 5px 8px; border-radius: 6px; min-width: 62px; text-align: center; }
.method.GET { color: var(--get); background: var(--get-bg); }
.method.POST { color: var(--post); background: var(--post-bg); }
.method.PUT { color: var(--put); background: var(--put-bg); }
.method.DELETE { color: var(--delete); background: var(--delete-bg); }
.method.PATCH { color: var(--patch); background: var(--patch-bg); }
.endpoint .path { font-family: ui-monospace, monospace; font-size: 13.5px; word-break: break-all; }
.endpoint .summary-text { color: var(--muted); font-size: 13.5px; }
.endpoint .scope-tag { margin-left: auto; font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.endpoint .body { padding: 10px 16px 14px; }
.endpoint .body h5 { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.endpoint .body table.grid { font-size: 13px; }
.badge-req { font-size: 11px; color: var(--delete); font-weight: 600; }
.empty-state { color: var(--faint); padding: 20px 0; }

footer { color: var(--faint); font-size: 13px; padding: 30px 0; border-top: 1px solid var(--border); }

/* ---------- responsivo */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-block; }
  .topbar .base { display: none; }
  .sidebar {
    position: fixed; top: 60px; left: 0; width: 280px; z-index: 30; background: var(--surface);
    transform: translateX(-100%); transition: transform .2s; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: none; }
  h1 { font-size: 27px; }
  .endpoint .scope-tag { margin-left: 0; }
}
