:root {
  --bg: #0d1117;
  --sidebar-bg: #0a0d12;
  --content-bg: #0d1117;
  --panel: #161b22;
  --border: #232a33;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --faint: #6e7681;
  --accent: #58a6ff;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --code-bg: #1b2129;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }

/* Off-screen note for LLM/AI readers: present in the DOM/source but invisible to
   sighted users and skipped by screen readers (aria-hidden on the element). */
.llm-note {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

/* --- Layout --------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  align-items: start;
}

/* --- Sidebar (sticky, scrolls with the page) ------------------------------ */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 22px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  padding: 4px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand:hover { text-decoration: none; }
.brand .mark { color: var(--accent); }
.brand em { font-style: normal; font-size: .72rem; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-group {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--faint);
  padding: 16px 10px 6px;
  font-weight: 600;
}

.nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: .92rem;
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active {
  color: var(--text);
  background: rgba(88, 166, 255, .10);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav a.external { color: var(--accent); }

.sidebar-foot {
  padding: 12px 0 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-foot a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: .86rem;
}
.sidebar-foot a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.sidebar-foot .ext { color: var(--faint); font-size: .8rem; margin-left: 10px; }

/* --- Content -------------------------------------------------------------- */

.content {
  min-width: 0;
  padding: 0 48px 120px;
}

.content-inner { max-width: 820px; margin: 0 auto; }

.page-head {
  padding: 56px 0 28px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { font-size: 2rem; margin: 0 0 8px; letter-spacing: -.01em; }
.page-head .lede { margin: 0; color: var(--muted); font-size: 1.05rem; }

section { padding-top: 40px; scroll-margin-top: 24px; }
section > h2 {
  font-size: 1.45rem;
  margin: 0 0 6px;
  letter-spacing: -.01em;
}
section > h2::before {
  content: "#";
  color: var(--faint);
  margin-right: 10px;
  font-weight: 400;
}
section h3 { font-size: 1.08rem; margin: 26px 0 8px; }

p { margin: 12px 0; }
ul { margin: 12px 0; padding-left: 22px; }
li { margin: 4px 0; }

code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .88em;
  color: #c9d4e3;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.55;
}
pre code { background: none; padding: 0; color: #d7e0ea; }

/* --- Code blocks with copy button ----------------------------------------- */

.code-block { position: relative; }
.code-block pre { margin: 18px 0; }
/* Keep the first line of code from sliding under the button. */
.code-block pre code { display: block; padding-right: 80px; }

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--muted);
  background: rgba(13, 17, 23, .72);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .15s ease, transform .15s ease, color .15s ease,
    border-color .15s ease, background .15s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.copy-btn svg { width: 14px; height: 14px; flex: none; }
.copy-btn .copy-label { white-space: nowrap; }

.code-block:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; transform: translateY(0); }
.copy-btn:hover { color: var(--text); border-color: var(--accent); background: var(--panel); }
.copy-btn:active { transform: scale(.96); }
.copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
  background: rgba(63, 185, 80, .12);
  opacity: 1;
  transform: translateY(0);
}
@media (hover: none) { .copy-btn { opacity: 1; transform: none; } }  /* always visible on touch */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: .92rem;
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: rgba(255,255,255,.015); }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.method { font-weight: 700; font-family: "SFMono-Regular", Consolas, monospace; font-size: .82rem; }
.method.get { color: var(--green); }
.method.post { color: var(--accent); }
.method.patch { color: var(--amber); }
.method.delete { color: var(--red); }

.callout {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 18px 0;
  font-size: .94rem;
}
.callout.warn { border-left-color: var(--amber); }
.callout p { margin: 0; }

/* --- Mobile --------------------------------------------------------------- */

.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 30;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.backdrop { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed;
    z-index: 25;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0,0,0,.5);
  }
  .content { padding: 0 22px 100px; }
  .page-head { padding-top: 72px; }
}
