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

:root {
  --bg:            #0e0e14;
  --bg-sidebar:    #0a0a10;
  --bg-hover:      #14141e;
  --bg-active:     #1a1a28;
  --border:        #1e1e2e;
  --text:          #d4d4e8;
  --text-muted:    #666688;
  --text-heading:  #eeeef8;
  --accent:        #5865f2;
  --accent-light:  #7c85f5;
  --accent-bg:     rgba(88, 101, 242, 0.12);
  --note-bg:       rgba(59, 130, 246, 0.08);
  --note-border:   #3b82f6;
  --tip-bg:        rgba(34, 197, 94, 0.08);
  --tip-border:    #22c55e;
  --warn-bg:       rgba(234, 179, 8, 0.08);
  --warn-border:   #eab308;
  --info-bg:       rgba(168, 85, 247, 0.08);
  --info-border:   #a855f7;

  --sidebar-width: 260px;
  --header-height: 56px;

  --radius-sm: 0.375rem;
  --radius:    0.5rem;
  --radius-lg: 0.75rem;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ───────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem 0 2rem;
}

.sidebar-logo {
  display: block;
  padding: 0 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  text-decoration: none;
}

.sidebar-logo .logo { height: 28px; width: auto; }

.sidebar-nav { flex: 1; padding: 0 0.75rem; }

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: color 0.15s;
}
.github-link:hover { color: var(--text); }

/* Sidebar nav groups */
.nav-group { margin-bottom: 1.75rem; }

.nav-group-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.625rem;
  margin-bottom: 0.375rem;
}

.nav-list { list-style: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  line-height: 1.5;
}
.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover svg, .nav-link.active svg { opacity: 1; }
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active {
  color: var(--accent-light);
  background: var(--accent-bg);
  font-weight: 500;
}

/* ─── Mobile header ────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}

.mobile-header .logo { height: 24px; }

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.overlay.visible { display: block; }

.no-scroll { overflow: hidden; }

/* ─── Main ─────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  padding: 3rem 2rem 4rem;
}

.content { max-width: 66%; margin: 0 auto; }

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Prose ────────────────────────────────────────────────────────── */
.prose { color: var(--text); }

.prose h2 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.01em;
}
.prose h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 2rem 0 0.75rem;
}
.prose h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 1.5rem 0 0.5rem;
}

.prose p { margin-bottom: 1.25rem; }

.prose a {
  color: var(--accent-light);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.prose a:hover { border-color: var(--accent-light); }

.prose strong { color: var(--text-heading); font-weight: 600; }

.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}
.prose li { margin-bottom: 0.375rem; }

.prose code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #1a1a28;
  color: #c4b5fd;
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  border: 1px solid #2a2a40;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.prose th {
  text-align: left;
  padding: 0.625rem 0.875rem;
  background: #13131c;
  color: var(--text-heading);
  font-weight: 600;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border);
}
.prose th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.prose th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
.prose td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.prose tr:last-child td { border-bottom: none; }
.prose tr:hover td { background: var(--bg-hover); }

/* ─── Code blocks (expressive-code override) ───────────────────────── */
.prose .expressive-code {
  margin: 1.5rem calc(-2rem);
  width: calc(100% + 4rem);
}

/* ─── Callout components ───────────────────────────────────────────── */
.callout {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 1.25rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}
.callout-icon {
  flex-shrink: 0;
  margin-top: 0.2em;
  align-self: flex-start;
}
.callout-content { flex: 1; min-width: 0; }
.callout-content > :last-child { margin-bottom: 0; }
.callout-content p { margin-bottom: 0.375rem; }
.callout-content p:last-child { margin-bottom: 0; }

.callout-note  { background: var(--note-bg); color: #93c5fd; }
.callout-note  .callout-icon { color: #60a5fa; }
.callout-tip   { background: var(--tip-bg);  color: #86efac; }
.callout-tip   .callout-icon { color: #4ade80; }
.callout-warn  { background: var(--warn-bg); color: #fde68a; }
.callout-warn  .callout-icon { color: #facc15; }
.callout-info  { background: var(--info-bg); color: #d8b4fe; }
.callout-info  .callout-icon { color: #c084fc; }

/* ─── Card components ──────────────────────────────────────────────── */
.card-grid { display: grid; gap: 1rem; margin: 1.25rem 0; }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.doc-card {
  display: block;
  background: #13131c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.doc-card:hover { border-color: var(--accent); background: #161620; }
.doc-card-title {
  display: block;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
}
.doc-card-desc { font-size: 0.875rem; color: var(--text-muted); }

/* ─── Steps ────────────────────────────────────────────────────────── */
.steps { counter-reset: steps; list-style: none; padding: 0; margin: 1.25rem 0; }
.step {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0 1rem;
  margin-bottom: 2rem;
  counter-increment: steps;
}
.step::before {
  content: counter(steps);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--accent-bg);
  color: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 50%;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.step-title {
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.625rem;
  font-size: 1rem;
  line-height: 2rem;
}
.step-content { grid-column: 2; }

/* ─── Response field ───────────────────────────────────────────────── */
.response-field {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  background: #13131c;
}
.response-field-header { display: flex; gap: 0.625rem; align-items: baseline; margin-bottom: 0.375rem; }
.response-field-name { font-family: var(--font-mono); font-size: 0.875rem; color: var(--accent-light); font-weight: 500; }
.response-field-type { font-size: 0.75rem; color: var(--text-muted); background: var(--bg); padding: 0.1em 0.4em; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.response-field-required { font-size: 0.7rem; color: #f87171; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.response-field-desc { font-size: 0.875rem; color: var(--text-muted); }
.response-field-desc p:last-child { margin-bottom: 0; }

/* ─── Accordion ────────────────────────────────────────────────────── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
  background: #13131c;
}
.accordion summary {
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-heading);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.accordion summary:hover { background: var(--bg-hover); }
.accordion summary::after { content: "+"; color: var(--text-muted); font-size: 1.25rem; line-height: 1; }
.accordion[open] summary::after { content: "−"; }
.accordion-body { padding: 0 1rem 1rem; }

/* ─── Page navigation ──────────────────────────────────────────────── */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  background: #13131c;
  transition: border-color 0.15s;
}
.page-nav-link:hover { border-color: var(--accent); }
.page-nav-next { text-align: right; }
.page-nav-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.page-nav-title { font-size: 0.9375rem; color: var(--text-heading); font-weight: 500; }

/* ─── TOC (right column, fixed to viewport edge) ───────────────────── */
.toc {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 220px;
  height: 100vh;
  overflow-y: auto;
  padding: 2.5rem 1.25rem 2.5rem 1rem;
  z-index: 50;
}

@media (min-width: 1280px) {
  .toc { display: block; }
  .main { padding-right: calc(220px + 2rem); }
}

.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-track { background: transparent; }
.toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.toc-inner {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.toc-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.toc-link {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  line-height: 1.4;
  transition: color 0.15s;
  border-left: 2px solid transparent;
  margin-left: -1.0625rem;
  padding-left: 0.875rem;
}
.toc-link:hover { color: var(--text); }
.toc-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
}
.toc-link-h3 {
  padding-left: 1.5rem;
  font-size: 0.75rem;
}

/* ─── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    top: 0;
  }
  .sidebar.open { transform: translateX(0); }
  .main {
    margin-left: 0;
    padding: 1.5rem 1rem 3rem;
  }
  .page-title { font-size: 1.625rem; }
  .card-grid.cols-2,
  .card-grid.cols-3,
  .card-grid.cols-4 { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
}
