:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-muted: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-subtle: #57606a;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --accent-subtle: #ddf4ff;
  --code-bg: #f6f8fa;
  --sidebar-w: 296px;
  --toc-w: 220px;
  --header-h: 56px;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(27, 31, 36, 0.04);
  --success: #1a7f37;
  --warning: #9a6700;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-subtle: #161b22;
  --bg-muted: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-subtle: #7d8590;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-subtle: rgba(56, 139, 253, 0.15);
  --code-bg: #161b22;
  --shadow: 0 1px 0 rgba(27, 31, 36, 0.4);
  --success: #3fb950;
  --warning: #d29922;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

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

/* Top bar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.site-header .brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex: 1;
}

.header-nav a {
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}
.header-nav a:hover,
.header-nav a.active {
  color: var(--text);
  background: var(--bg-muted);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
}
.btn-icon:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn-outline:hover {
  background: var(--bg-muted);
  text-decoration: none;
}

.menu-toggle {
  display: none;
}

/* Layout */
.docs-shell {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  flex-shrink: 0;
  padding: 20px 16px 40px;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
}

.sidebar-group {
  margin-bottom: 20px;
}

.sidebar-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  padding: 0 8px;
  margin-bottom: 6px;
}

.sidebar-nav a {
  display: block;
  padding: 5px 8px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: var(--bg-muted);
  text-decoration: none;
}
.sidebar-nav a.active {
  color: var(--text);
  font-weight: 600;
  background: var(--accent-subtle);
}

.sidebar-nav .sub a {
  padding-left: 20px;
  font-size: 13px;
}

.content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
}

.doc-main {
  flex: 1;
  min-width: 0;
  max-width: 900px;
  padding: 32px 40px 80px;
}

.doc-toc {
  position: sticky;
  top: var(--header-h);
  width: var(--toc-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  flex-shrink: 0;
  padding: 32px 16px 40px 0;
}

.doc-toc-inner {
  border-left: 2px solid var(--border);
  padding-left: 16px;
}

.doc-toc-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 10px;
}

.doc-toc a {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 0;
  text-decoration: none;
  line-height: 1.4;
}
.doc-toc a:hover,
.doc-toc a.active {
  color: var(--accent);
}

.doc-toc .sub {
  padding-left: 12px;
}

/* Typography */
.doc-main h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.doc-main h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.doc-main h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 32px 0 12px;
}

.doc-main h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 24px 0 8px;
}

.lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.7;
}

.doc-main p {
  margin: 0 0 16px;
}

.doc-main ul,
.doc-main ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.doc-main li {
  margin-bottom: 6px;
}

.callout {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  margin: 20px 0;
  font-size: 14px;
}
.callout.info {
  border-color: rgba(9, 105, 218, 0.4);
  background: var(--accent-subtle);
}
.callout.warn {
  border-color: rgba(154, 103, 0, 0.35);
  background: rgba(210, 153, 34, 0.1);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 6px;
}
.badge.post { border-color: #1a7f37; color: var(--success); }
.badge.get { border-color: #0969da; color: var(--accent); }
.badge.delete { border-color: #cf222e; color: #cf222e; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: none;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--code-bg);
  border: 1px solid var(--border);
}

pre {
  position: relative;
  margin: 16px 0 24px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}

pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: inherit;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}
.copy-btn:hover {
  color: var(--text);
  background: var(--bg-muted);
}

.endpoint-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 24px 0;
  overflow: hidden;
}

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.endpoint-body {
  padding: 16px 18px 20px;
}

.method {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.method.post { background: rgba(26, 127, 55, 0.15); color: var(--success); }
.method.get { background: var(--accent-subtle); color: var(--accent); }
.method.delete { background: rgba(207, 34, 46, 0.12); color: #cf222e; }

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 28px 0 8px;
}

.hero-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hero-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  text-decoration: none;
}
.hero-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text);
}
.hero-card span {
  font-size: 13px;
  color: var(--text-muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 40px;
  background: var(--bg-subtle);
  font-size: 14px;
  color: var(--text-muted);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto 24px;
}

.footer-grid h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}

.footer-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-grid li {
  margin-bottom: 6px;
}

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.legal-section h3 {
  margin-top: 28px;
}

@media (max-width: 1100px) {
  .doc-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .menu-toggle {
    display: inline-flex;
  }

  .header-nav {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 80;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .doc-main {
    padding: 24px 20px 60px;
  }
}
