:root {
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --border: #e3e6ea;
  --text: #1b1f24;
  --text-muted: #5c6570;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --code-bg: #f1f3f6;
  --sidebar-bg: #ffffff;
  --sidebar-active: #eaf1ff;
  --get: #0f9d58;
  --post: #2563eb;
  --put: #d97706;
  --patch: #7c3aed;
  --delete: #dc2626;
  --shadow: 0 1px 3px rgba(20, 24, 30, 0.06), 0 1px 2px rgba(20, 24, 30, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-elevated: #161922;
    --border: #262b36;
    --text: #e6e9ef;
    --text-muted: #99a1ae;
    --accent: #5b9bff;
    --accent-soft: #16223d;
    --code-bg: #1b1f29;
    --sidebar-bg: #12151c;
    --sidebar-active: #16223d;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 16px 40px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7aa9ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--text-muted); }

#search-box {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 14px;
  font-family: inherit;
}
#search-box:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

nav#toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav#toc .toc-h2 > a {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 14px 8px 6px;
}
nav#toc .toc-h2:first-child > a { padding-top: 4px; }

nav#toc .toc-h3 a {
  display: block;
  padding: 6px 10px;
  margin: 1px 0;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
nav#toc .toc-h3 a:hover { background: var(--code-bg); text-decoration: none; }
nav#toc .toc-h3 a.active { background: var(--sidebar-active); color: var(--accent); font-weight: 600; }

.method-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 6px;
  color: white;
  vertical-align: middle;
}
.m-get { background: var(--get); }
.m-post { background: var(--post); }
.m-put { background: var(--put); }
.m-patch { background: var(--patch); }
.m-delete { background: var(--delete); }

/* Main content */
main {
  padding: 40px clamp(20px, 5vw, 72px);
  max-width: 880px;
  width: 100%;
}

#content h1 {
  font-size: 32px;
  margin: 0 0 6px;
  letter-spacing: -.02em;
}

#content h2 {
  font-size: 22px;
  margin: 48px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 20px;
}
#content h2:first-of-type { margin-top: 12px; }

#content h3 {
  font-size: 17px;
  margin: 36px 0 14px;
  scroll-margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

#content p { line-height: 1.65; color: var(--text); }
#content ul, #content ol { line-height: 1.7; padding-left: 22px; }
#content li { margin: 3px 0; }

#content code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.88em;
}

#content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.55;
}
#content pre code {
  background: none;
  padding: 0;
  font-size: 12.5px;
}

#content strong { font-weight: 600; }

#content h5 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 20px 0 8px;
}

/* Response status tabs */
.resp-tabs {
  margin: 14px 0 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.resp-tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  background: var(--code-bg);
}

.resp-tab {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 7px 7px 0 0;
  cursor: pointer;
  position: relative;
  top: 1px;
}
.resp-tab::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}
.resp-tab.status-2xx::before { background: var(--get); }
.resp-tab.status-3xx::before { background: var(--put); }
.resp-tab.status-4xx::before { background: var(--patch); }
.resp-tab.status-5xx::before { background: var(--delete); }

.resp-tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--bg-elevated);
}

.resp-panels { padding: 14px 16px; }
.resp-panel { display: none; }
.resp-panel.active { display: block; }
.resp-panel > *:first-child { margin-top: 0; }
.resp-panel > *:last-child { margin-bottom: 0; }
.resp-panel pre { margin: 8px 0; }

.top-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 30px;
}

#loading, #error {
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}
#error { color: var(--delete); display: none; white-space: pre-line; }

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 16px;
  display: none;
  align-items: center;
  justify-content: center;
}
.back-to-top.show { display: flex; }

.menu-toggle { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 20% 0 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
  }
  main { padding: 0 18px 40px; }
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 15;
  }
  .overlay.show { display: block; }
}
