/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --content-max: 680px;
  --code-panel-w: 420px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 24px;
  --fs-2xl: 30px;
  /* Light theme */
  --bg: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-code: #1e1e2e;
  --bg-code-response: #1a1a2e;
  --bg-inline-code: #f3f4f6;
  --bg-card: #f8f9fa;
  --bg-hover: #f3f4f6;
  --bg-badge: #f0f0f0;
  --border: #e5e7eb;
  --border-light: #f0f0f0;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-code: #e2e8f0;
  --accent: #ff5400;
  --accent-light: #fff3ed;
  --link: #2563eb;
  --method-get: #22c55e;
  --method-post: #3b82f6;
  --method-put: #a855f7;
  --method-patch: #f59e0b;
  --method-delete: #ef4444;
  --method-get-bg: #f0fdf4;
  --method-post-bg: #eff6ff;
  --method-put-bg: #faf5ff;
  --method-patch-bg: #fffbeb;
  --method-delete-bg: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-sidebar: #15171e;
  --bg-code: #1a1c25;
  --bg-code-response: #1a1c25;
  --bg-inline-code: #262833;
  --bg-card: #1a1c25;
  --bg-hover: #1e2029;
  --bg-badge: #262833;
  --border: #2a2d3a;
  --border-light: #22242e;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-code: #e2e8f0;
  --accent: #ff6b1a;
  --accent-light: #2a1a0e;
  --link: #60a5fa;
  --method-get-bg: #0a1f0e;
  --method-post-bg: #0a1529;
  --method-put-bg: #1a0a29;
  --method-patch-bg: #1f1a0a;
  --method-delete-bg: #1f0a0a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.3);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

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

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sidebar-logo svg { width: 28px; height: 28px; flex-shrink: 0; }
.sidebar-logo span {
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.5px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box .search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box .search-kbd {
  position: absolute;
  right: 8px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--bg-badge);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section { margin-bottom: 2px; }

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background .1s;
}
.nav-section-header:hover { background: var(--bg-hover); }
.nav-section-header .chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform .15s;
  flex-shrink: 0;
}
.nav-section.collapsed .chevron { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 4px 24px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .1s;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { color: var(--text); background: var(--bg-hover); font-weight: 500; }

.method-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.method-badge.get { color: var(--method-get); background: var(--method-get-bg); }
.method-badge.post { color: var(--method-post); background: var(--method-post-bg); }
.method-badge.put { color: var(--method-put); background: var(--method-put-bg); }
.method-badge.patch { color: var(--method-patch); background: var(--method-patch-bg); }
.method-badge.delete { color: var(--method-delete); background: var(--method-delete-bg); }

.sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  transition: all .15s;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.theme-toggle svg { width: 14px; height: 14px; }

.sidebar-version {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ===== Main Content ===== */
.main {
  overflow-y: auto;
  scroll-behavior: smooth;
}
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== Endpoint Section ===== */
.endpoint-section {
  border-bottom: 1px solid var(--border);
}

.endpoint-inner {
  display: grid;
  grid-template-columns: 1fr var(--code-panel-w);
  min-height: auto;
}

.endpoint-content {
  padding: 40px 48px;
  max-width: calc(var(--content-max) + 96px);
}

.endpoint-code {
  background: var(--bg-code);
  padding: 24px;
  min-height: 200px;
  position: relative;
}

/* Intro section has no code panel */
.intro-section .endpoint-inner {
  grid-template-columns: 1fr;
}
.intro-section .endpoint-content {
  max-width: 900px;
}

/* ===== Typography ===== */
.section-tag {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.7;
}

.endpoint-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.endpoint-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.7;
}
.endpoint-desc code {
  background: var(--bg-inline-code);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: 16px;
}
.auth-badge svg { width: 12px; height: 12px; }

/* ===== Method + Path ===== */
.method-path {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  background: var(--bg-card);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.method-path .method {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.method-path .path {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text);
}

/* ===== Parameters & Body ===== */
.params-heading {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  margin-top: 24px;
}

.param-table {
  width: 100%;
  border-collapse: collapse;
}
.param-table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.param-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.param-table tr:last-child td { border-bottom: none; }

.param-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}
.param-required {
  color: var(--method-delete);
  font-size: var(--fs-xs);
  font-weight: 600;
  margin-left: 4px;
}
.param-type {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.param-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}
.param-enum {
  margin-top: 4px;
}
.param-enum code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--bg-inline-code);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  color: var(--text);
}
.param-default {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ===== Responses ===== */
.responses-section { margin-top: 28px; }

.response-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.response-item:last-child { border-bottom: none; }

.status-code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  min-width: 36px;
}
.status-code.s2xx { color: var(--method-get); }
.status-code.s4xx { color: var(--method-patch); }
.status-code.s5xx { color: var(--method-delete); }

.response-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ===== Code Panel ===== */
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.code-method-path {
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-method-path .method {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
}
.code-method-path .path {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-code);
}

.lang-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.lang-tab {
  padding: 6px 12px;
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  color: rgba(255,255,255,.5);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
.lang-tab:hover { color: rgba(255,255,255,.8); }
.lang-tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.code-block {
  background: rgba(0,0,0,.2);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  position: relative;
}
.code-block pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-code);
  white-space: pre;
}

.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  color: rgba(255,255,255,.5);
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  transition: all .15s;
  opacity: 0;
}
.code-block:hover .code-copy { opacity: 1; }
.code-copy:hover { background: rgba(255,255,255,.2); color: #fff; }

/* Response tabs in code panel */
.response-tabs {
  display: flex;
  gap: 0;
  margin-top: 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.response-tab {
  padding: 6px 10px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: rgba(255,255,255,.5);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}
.response-tab:hover { color: rgba(255,255,255,.8); }
.response-tab.active { color: #fff; border-bottom-color: var(--accent); }

.response-block {
  margin-top: 12px;
}

/* ===== Syntax Highlighting ===== */
.tok-keyword { color: #c678dd; }
.tok-string { color: #98c379; }
.tok-number { color: #d19a66; }
.tok-boolean { color: #56b6c2; }
.tok-null { color: #56b6c2; }
.tok-property { color: #e06c75; }
.tok-comment { color: #5c6370; font-style: italic; }
.tok-url { color: #61afef; }
.tok-flag { color: #abb2bf; }

/* ===== Intro Content ===== */
.intro-content h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 10px;
}
.intro-content h2:first-child { margin-top: 0; }
.intro-content p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.7;
}
.intro-content code {
  background: var(--bg-inline-code);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.intro-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 10px 0 16px;
  overflow-x: auto;
}
.intro-content pre code {
  background: none;
  padding: 0;
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.intro-content strong { color: var(--text); font-weight: 600; }
.intro-content ol, .intro-content ul {
  margin: 8px 0 16px 24px;
  color: var(--text-secondary);
}
.intro-content li { margin-bottom: 6px; line-height: 1.6; }
.intro-content table {
  width: auto;
  border-collapse: collapse;
  margin: 10px 0 16px;
}
.intro-content table th,
.intro-content table td {
  padding: 8px 16px;
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.intro-content table th {
  background: var(--bg-card);
  font-weight: 600;
  text-align: left;
  color: var(--text);
}
.intro-content table td { color: var(--text-secondary); }
.intro-content table code {
  font-size: var(--fs-xs);
}

/* ===== Tag Description Section ===== */
.tag-section {
  border-bottom: 1px solid var(--border);
}
.tag-section .endpoint-inner {
  grid-template-columns: 1fr var(--code-panel-w);
}
.tag-section .endpoint-content {
  padding: 40px 48px;
}
.tag-section .endpoint-code {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 40px;
}

.operations-list {
  background: rgba(0,0,0,.2);
  border-radius: var(--radius-md);
  padding: 16px;
}
.operations-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}
.operation-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  text-decoration: none;
  transition: opacity .15s;
}
.operation-link:hover { opacity: .8; text-decoration: none; }
.operation-link .method {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  min-width: 48px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 3px;
}
.operation-link .path {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: rgba(255,255,255,.8);
}

/* ===== Body Fields ===== */
.body-fields { margin-top: 8px; }

.field-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.field-row:last-child { border-bottom: none; }

.field-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.field-constraints {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.field-constraint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--bg-badge);
  padding: 0 5px;
  border-radius: 3px;
}

/* ===== Scrollbar ===== */
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  :root { --code-panel-w: 340px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 280px;
    z-index: 100;
    transition: left .25s;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { left: 0; }
  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .mobile-overlay.show { display: block; }
  .mobile-header {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .mobile-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
  }
  .endpoint-inner { grid-template-columns: 1fr; }
  .endpoint-code { border-radius: 0; }
  .tag-section .endpoint-inner { grid-template-columns: 1fr; }
}

.mobile-header { display: none; }

/* ===== Search Results ===== */
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-md);
}
.search-results.visible { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: background .1s;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item .result-name { color: var(--text); }
