/* =====================================================
   TOMarketingTool API Docs — Main Stylesheet
   Design: Dark-first with light mode toggle, 
           QuickReply-style sidebar layout
   ===================================================== */

/* ===== CSS VARIABLES ===== */
:root {
  --bg-base: #0f1117;
  --bg-surface: #161b27;
  --bg-elevated: #1e2535;
  --bg-hover: #252d3d;
  --bg-active: #2a3347;

  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #58657a;
  --text-inverse: #0f1117;

  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,0.3);
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;

  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.15);
  --orange: #f59e0b;
  --orange-dim: rgba(245,158,11,0.15);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.15);
  --purple: #a855f7;
  --purple-dim: rgba(168,85,247,0.15);

  --header-h: 60px;
  --sidebar-w: 272px;
  --toc-w: 220px;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: 150ms cubic-bezier(0.4,0,0.2,1);
}

/* Light theme */
[data-theme="light"] {
  --bg-base: #f8f9fc;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f2f7;
  --bg-hover: #e8eaef;
  --bg-active: #dde0e9;

  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);

  --text-primary: #1a1f2e;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;

  --blue: #1d4ed8;
  --blue-dim: #eff6ff;

  --accent-glow: rgba(99,102,241,0.15);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; color: var(--text-primary); }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-light);
}

/* ===== HEADER ===== */
.site-header { user-select: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-inner {
  height: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Logo */
.header-left { display: flex; align-items: center; gap: 0.75rem; min-width: var(--sidebar-w); }

.mobile-menu-btn {
  display: flex;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.mobile-menu-btn svg { width: 20px; height: 20px; display: block; }
.mobile-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.logo-link { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; }

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.7rem; color: white;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(99,102,241,0.4);
}

.logo-text { display: flex; flex-direction: row; align-items: center; gap: 0.3rem; }
.logo-title, .logo-badge { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); line-height: 1.1; letter-spacing: normal; text-transform: none; }

/* Search box in header */
.header-center { flex: 1; display: flex; justify-content: center; }

.search-container { position: relative; width: min(480px, 100%); }
.search-box {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.875rem;
  transition: all var(--transition);
}
.search-box:focus-within { border-color: var(--accent); }
.search-input { flex: 1; background: transparent; border: none; color: var(--text-primary); font-size: 0.875rem; outline: none; }
.search-input::placeholder { color: var(--text-muted); }
.search-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-muted); }
.search-kbd {
  background: var(--bg-base); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: 2px 6px; font-size: 0.7rem;
  font-family: var(--font-mono); color: var(--text-muted); white-space: nowrap;
}

.search-dropdown {
  display: none; position: absolute; top: calc(100% + 0.5rem); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: 400px; overflow-y: auto; z-index: 100; padding: 0.5rem;
}
.search-dropdown.open { display: block; }
.search-result-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
  border-radius: var(--radius); text-decoration: none; color: inherit;
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 0.1rem; }

/* Header right */
.header-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

.theme-toggle { user-select: none;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 8px;
  display: flex; align-items: center;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none !important; }
[data-theme="light"] .theme-toggle .icon-sun { display: none !important; }
[data-theme="light"] .theme-toggle .icon-moon { display: block !important; }

.header-btn { display: none !important; align-items: center; gap: 0.375rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem; font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.header-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text-primary); }
.header-btn svg { width: 16px; height: 16px; }

.version-badge {
  font-size: 0.72rem; font-weight: 600;
  color: var(--accent-light);
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.25);
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  min-height: 100vh;
  padding-top: var(--header-h);
  max-width: 1680px;
  margin: 0 auto;
}

/* ===== SIDEBAR ===== */
.sidebar { user-select: none;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 1.25rem 0 2rem;
  background: var(--bg-surface);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0; }

.nav-section { padding: 0 0.75rem 0.5rem; }

.nav-section-title {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 1rem 0.5rem 0.4rem;
}

.nav-item {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.475rem 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.865rem; font-weight: 450;
  text-decoration: none;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--blue-dim);
  color: var(--blue);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--blue);
  border-radius: 0 4px 4px 0;
}

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

/* Nav sub-items */
.nav-sub {
  padding-left: 2.25rem;
  font-size: 0.83rem;
  font-weight: 400;
}

/* Nav groups */
.nav-group { }

.nav-group-toggle {
  display: flex; align-items: center; gap: 0.625rem;
  width: 100%; text-align: left;
  padding: 0.475rem 0.625rem;
  border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.865rem; font-weight: 450;
  font-family: var(--font-sans);
  transition: all var(--transition);
}
.nav-group-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.chevron {
  width: 14px; height: 14px;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform var(--transition);
}
.nav-group-toggle.open .chevron { transform: rotate(180deg); }

.nav-group-items { display: none; }
.nav-group-items.open { display: block; }

/* Method badges in nav */
.method-badge {
  font-size: 0.6rem; font-weight: 700;
  padding: 1px 5px; border-radius: 3px;
  letter-spacing: 0.04em; text-transform: uppercase;
  flex-shrink: 0;
}
.method-badge.get { background: var(--blue-dim); color: #60a5fa; }
.method-badge.post { background: var(--blue-dim); color: #4ade80; }
.method-badge.put { background: var(--orange-dim); color: #fbbf24; }
.method-badge.delete { background: var(--red-dim); color: #f87171; }
.method-badge.patch { background: var(--purple-dim); color: #c084fc; }

/* ===== MAIN CONTENT ===== */
.main-content {
  min-width: 0;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
}

.content-wrapper {
  padding: 2.5rem 3rem 4rem;
  max-width: none;
}

/* Typography elements within content */
.content-wrapper ul, .content-wrapper ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.content-wrapper ul {
  list-style-type: disc;
}
.content-wrapper ol {
  list-style-type: decimal;
}
.content-wrapper li {
  margin-bottom: 0.5rem;
}

/* ===== HERO ===== */
.hero-section {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  color: var(--accent-light);
  font-size: 0.78rem; font-weight: 500;
  padding: 5px 12px; border-radius: 20px;
  margin-bottom: 1.25rem;
}
.dot {
  width: 6px; height: 6px;
  background: var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero-title {
  font-size: 2.4rem; font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.gradient-text {
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 1.05rem; color: var(--text-secondary);
  max-width: none; line-height: 1.7;
  margin-bottom: 1.75rem;
}

.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600;
  text-decoration: none;
  transition: all 200ms cubic-bezier(0.4,0,0.2,1);
  cursor: pointer; border: none;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99,102,241,0.5);
  color: white;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex; align-items: center;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
}
.stat-item {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; gap: 2px;
}
.stat-number {
  font-size: 1.4rem; font-weight: 800;
  color: var(--text-primary);
  font-feature-settings: 'tnum';
}
.stat-label {
  font-size: 0.75rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}
.stat-divider {
  width: 1px; height: 40px;
  background: var(--border);
}

/* ===== BASE URL ===== */
.base-url-section { margin-bottom: 2rem; }
.section-label {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.inline-code {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.inline-code code {
  background: none; border: none; padding: 0;
  font-size: 0.9rem; color: var(--blue); font-weight: 500;
  flex: 1;
}

/* ===== SECTION TITLE ROW ===== */
.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-title-row h2 {
  font-size: 1.2rem; font-weight: 700;
}
.section-count {
  font-size: 0.78rem; color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 9px; border-radius: 20px;
}
.view-all-link {
  font-size: 0.8rem; color: var(--accent-light); font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
}
.view-all-link:hover { color: var(--accent); }

/* ===== MODULE CARDS GRID ===== */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.module-card {
  display: flex; align-items: flex-start; gap: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-decoration: none;
  transition: all 200ms cubic-bezier(0.4,0,0.2,1);
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: '';
  position: absolute;
  inset: 0; border-radius: inherit;
  background: linear-gradient(135deg, var(--accent, #6366f1), transparent 60%);
  opacity: 0;
  transition: opacity 200ms;
}
.module-card:hover {
  border-color: var(--accent, #6366f1);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.module-card:hover::before { opacity: 0.04; }

.module-card-icon {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.module-card-icon svg { width: 20px; height: 20px; }

.module-card-body { flex: 1; min-width: 0; }
.module-card-body h3 {
  font-size: 0.95rem; font-weight: 600;
  margin-bottom: 0.35rem; color: var(--text-primary);
}
.module-card-body p {
  font-size: 0.8rem; color: var(--text-secondary);
  line-height: 1.5; margin-bottom: 0.75rem;
}

.module-card-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.endpoint-count { display: none !important;
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 7px; border-radius: 4px;
}
.auth-badge {
  font-size: 0.7rem; font-weight: 500;
  color: #fbbf24;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.2);
  padding: 2px 7px; border-radius: 4px;
}
.auth-required {
  font-size: 0.7rem; font-weight: 500;
  color: #4ade80;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  padding: 2px 7px; border-radius: 4px;
}
.badge-internal {
  font-size: 0.7rem; font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px;
}

.module-card-arrow {
  width: 16px; height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 3px;
  transition: transform var(--transition), color var(--transition);
}
.module-card:hover .module-card-arrow {
  transform: translateX(3px);
  color: var(--accent-light);
}

/* ===== CALLOUTS ===== */
.callout {
  display: flex; gap: 0.75rem; align-items: flex-start;
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin: 1rem 0;
  font-size: 0.875rem; line-height: 1.6;
}
.callout svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.callout-info {
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  color: var(--text-secondary);
}
.callout-info svg { color: #60a5fa; }

.callout-warning {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  color: var(--text-secondary);
}
.callout-warning svg { color: #fbbf24; }

.callout-danger {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--text-secondary);
}
.callout-danger svg { color: #f87171; }

.callout-success {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  color: var(--text-secondary);
}
.callout-success svg { color: #4ade80; }

/* ===== CODE BLOCKS ===== */
.code-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1rem 0;
  overflow: hidden;
  position: relative;
}
[data-theme="light"] .code-block { background: #1e293b; }

.code-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.code-lang {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: #8b949e;
}

.copy-btn {
  background: none; border: none; cursor: pointer;
  color: #8b949e; padding: 4px;
  border-radius: 4px; display: flex;
  transition: all var(--transition);
}
.copy-btn:hover { color: #e6edf3; background: rgba(255,255,255,0.1); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.copied { color: #4ade80; }

.code-block pre {
  padding: 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.code-block code {
  background: none; border: none; padding: 0;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: #e6edf3;
  display: block;
  white-space: pre;
}

/* Syntax colors */
.code-block .key { color: #7ee787; }
.code-block .string { color: #a5d6ff; }
.code-block .number { color: #79c0ff; }
.code-block .comment { color: #8b949e; font-style: italic; }
.code-block .keyword { color: #ff7b72; }
.code-block .method { color: #d2a8ff; }

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1rem 0;
}

.api-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.86rem;
}
.api-table thead tr {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-strong);
}
.api-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}
.api-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.api-table tbody tr:last-child td { border-bottom: none; }
.api-table tbody tr:hover td { background: var(--bg-hover); }

/* Status badges */
.status-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
  white-space: nowrap;
}
.status-200 { background: var(--blue-dim); color: var(--blue); }
.status-201 { background: rgba(16,185,129,0.12); color: #34d399; }
.status-202 { background: rgba(20,184,166,0.12); color: #2dd4bf; }
.status-304 { background: var(--blue-dim); color: #60a5fa; }
.status-400 { background: var(--orange-dim); color: var(--orange); }
.status-401 { background: var(--red-dim); color: var(--red); }
.status-403 { background: var(--red-dim); color: #fb923c; }
.status-404 { background: var(--orange-dim); color: #fb923c; }
.status-500 { background: var(--red-dim); color: var(--red); }

/* Method badges (large) */
.method-pill {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem; font-weight: 700;
  padding: 3px 10px; border-radius: 5px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.method-pill.GET { background: var(--blue-dim); color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); }
.method-pill.POST { background: var(--blue-dim); color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.method-pill.PUT { background: var(--orange-dim); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.method-pill.DELETE { background: var(--red-dim); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }
.method-pill.PATCH { background: var(--purple-dim); color: #c084fc; border: 1px solid rgba(168,85,247,0.25); }

/* ===== ENDPOINT CARDS ===== */
.endpoint-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1.25rem 0;
  transition: border-color var(--transition);
}
.endpoint-card:hover { border-color: var(--border-strong); }

.endpoint-card-header {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 0.875rem 1.125rem;
  background: var(--bg-surface);
  cursor: pointer;
  user-select: none;
}
.endpoint-card-header:hover { background: var(--bg-hover); }

.endpoint-route {
  font-family: var(--font-mono);
  font-size: 0.87rem; font-weight: 500;
  color: var(--text-primary); flex: 1;
}

.endpoint-desc {
  font-size: 0.8rem; color: var(--text-muted);
  margin-left: auto;
}

.endpoint-card-body {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.125rem;
  display: none;
}
.endpoint-card-body.open { display: block; }

.auth-icon {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.72rem; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.auth-icon.required { background: rgba(245,158,11,0.1); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.auth-icon.open { background: rgba(34,197,94,0.1); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }

/* ===== TOC PANEL ===== */
.toc-panel { user-select: none;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-inner { padding: 0 0.5rem; }

.toc-title {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}

.toc-nav { display: flex; flex-direction: column; gap: 2px; }

.toc-link {
  display: block;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}
.toc-link:hover { color: var(--text-primary); border-left-color: var(--border-strong); }
.toc-link.active { background: var(--blue-dim); color: var(--blue); border-radius: 6px; border-left: none; font-weight: 500; padding: 4px 8px; }

/* Nested TOC */
.toc-link.sub {
  padding-left: 1rem;
  font-size: 0.78rem;
}

/* ===== SUB SECTION TITLE ===== */
.sub-section-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text-primary);
  margin: 2rem 0 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ===== PAGE SECTIONS (for module pages) ===== */
.page-header {
  display: flex; flex-direction: column; gap: 0.75rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.page-header-meta {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}
.page-title { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.page-desc { font-size: 1rem; color: var(--text-secondary); line-height: 1.7; max-width: none; }

.module-tag {
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ===== WHEN TO USE SECTION ===== */
.when-to-use {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.5rem 0;
}
.when-to-use h4 {
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.when-to-use ul { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; padding-left: 0; }
.when-to-use li {
  position: relative;
  padding-left: 1.25rem;
  font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5;
}
.when-to-use li::before {
  content: '—';
  color: var(--accent-light);
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
}

/* ===== ENDPOINTS SECTION ===== */
.endpoints-section { margin: 2rem 0; }

.section-heading {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-heading h2 {
  font-size: 1.15rem; font-weight: 700;
}
.section-anchor { color: var(--text-muted); font-size: 0.8rem; }

/* Quick endpoint table */
.endpoint-overview-table .api-table td:nth-child(1),
.endpoint-overview-table .api-table td:nth-child(2) { white-space: nowrap; }

/* ===== FLOW DIAGRAM ===== */
.flow-diagram {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
  margin: 1rem 0;
  color: #e6edf3;
}
[data-theme="light"] .flow-diagram { background: #1e293b; }

/* ===== PARAMETER TABLES ===== */
.param-table th:first-child { width: 160px; }
.param-required {
  font-size: 0.65rem; font-weight: 700;
  color: var(--red); background: var(--red-dim);
  padding: 1px 5px; border-radius: 3px;
  text-transform: uppercase;
}
.param-optional {
  font-size: 0.65rem; font-weight: 600;
  color: var(--text-muted); background: var(--bg-elevated);
  padding: 1px 5px; border-radius: 3px;
}
.param-type {
  font-family: var(--font-mono); font-size: 0.8rem;
  color: #a5d6ff;
}

/* ===== ENTITY CARD ===== */
.entity-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
}
.entity-card h4 {
  font-size: 0.95rem; font-weight: 700;
  margin-bottom: 0.875rem;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 0.5rem;
}
.entity-label {
  font-size: 0.7rem; font-weight: 600;
  background: rgba(99,102,241,0.1);
  color: var(--accent-light);
  padding: 2px 7px; border-radius: 4px;
}

/* ===== SEARCH MODAL ===== */
.search-modal {
  position: fixed; inset: 0; z-index: 999;
  display: none;
}
.search-modal.open { display: block; }

.search-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.search-modal-panel {
  position: absolute;
  top: 10vh; left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 2rem));
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.search-modal-input-wrap {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.search-modal-input-wrap svg { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.search-modal-input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 1rem; color: var(--text-primary);
  font-family: var(--font-sans);
}
.search-modal-input-wrap input::placeholder { color: var(--text-muted); }
.search-modal-input-wrap button {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.75rem;
  padding: 3px 8px; border-radius: 4px; cursor: pointer;
}

.search-modal-results {
  max-height: 400px; overflow-y: auto;
  padding: 0.5rem;
}

.search-result-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-title { font-size: 0.875rem; font-weight: 500; }
.search-result-path { font-size: 0.78rem; color: var(--text-muted); }
.search-result-module { font-size: 0.72rem; color: var(--text-muted); }

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: transparent;
  z-index: 49;
  
}

/* ===== PAGE FOOTER ===== */
.page-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.footer-inner > span:first-child { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.footer-inner {
  padding: 1.25rem 3rem;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8rem; color: var(--text-muted);
  flex-wrap: wrap; gap: 0.5rem;
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { color: var(--text-muted); transition: color var(--transition); }
.footer-links a:hover { color: var(--text-primary); }

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex; align-items: center; gap: 0.375rem;
  font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb-sep { color: var(--border-strong); }

/* ===== SCROLL PROGRESS ===== */
.scroll-progress {
  position: fixed; top: var(--header-h); left: 0; right: 0;
  height: 2px; background: var(--bg-elevated); z-index: 99;
}
.scroll-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  width: 0%;
  transition: width 100ms linear;
}

/* ===== ANCHOR LINKS ===== */
.anchor {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 0.5rem;
  opacity: 0;
  transition: opacity var(--transition);
  font-size: 0.85em;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 2rem 0;
}

/* ===== NEXT / PREV NAVIGATION ===== */
.doc-nav {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1rem; margin-top: 3rem;
  padding-top: 2rem; border-top: 1px solid var(--border);
}
.doc-nav-card {
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  text-decoration: none;
  transition: all var(--transition);
}
.doc-nav-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.doc-nav-label {
  font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin-bottom: 0.3rem;
}
.doc-nav-title {
  font-size: 0.9rem; font-weight: 600; color: var(--text-primary);
}
.doc-nav-next { text-align: right; }

/* ===== UTILITY CLASSES ===== */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ===== OVERRIDES ===== */
.layout.no-toc { grid-template-columns: var(--sidebar-w) 1fr; }
.layout.no-toc .content-wrapper { max-width: none; }

@media (min-width: 1201px) {
  body.sidebar-collapsed .sidebar { display: none; }
  body.sidebar-collapsed .layout { grid-template-columns: 1fr var(--toc-w); }
  body.sidebar-collapsed .layout.no-toc { grid-template-columns: 1fr; }
}
@media (min-width: 769px) and (max-width: 1200px) {
  body.sidebar-collapsed .sidebar { display: none; }
  body.sidebar-collapsed .layout { grid-template-columns: 1fr; }
  body.sidebar-collapsed .layout.no-toc { grid-template-columns: 1fr; }
}

/* ===== SCROLL OFFSETS ===== */
*[id] { scroll-margin-top: calc(var(--header-h) + 0.25rem); }

/* =====================================================
   RESPONSIVE BREAKPOINTS
   ===================================================== */

/* --- Tablet: hide TOC, keep sidebar --- */
@media (max-width: 1200px) {
  .toc-panel { display: none; }
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
  .layout.no-toc { grid-template-columns: var(--sidebar-w) 1fr; }
  .content-wrapper { max-width: 100%; padding: 2rem 2rem 3rem; }
}

/* --- Tablet small: narrower sidebar --- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .content-wrapper { padding: 1.75rem 1.5rem 3rem; }
  .footer-inner { padding: 1rem 1.5rem; }
  .page-title { font-size: 1.75rem; }
  .hero-title { font-size: 2rem; }
  .hero-desc { font-size: 0.95rem; }
}

/* --- Mobile: collapsible sidebar, stacked layout --- */
@media (max-width: 768px) {
  :root { --sidebar-w: 272px; --header-h: 110px; }

  .layout { grid-template-columns: 1fr; }
  .layout.no-toc { grid-template-columns: 1fr; }

  /* Sidebar: off-canvas drawer */
  .sidebar {
    position: fixed;
    left: 0; top: var(--header-h);
    height: calc(100vh - var(--header-h));
    transform: translateX(-100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    width: min(var(--sidebar-w), calc(100vw - 60px));
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .mobile-menu-btn { display: flex; }

  /* Header */
  .header-inner { padding: 0.5rem 0.75rem; gap: 0.5rem; flex-wrap: wrap; align-items: center; align-content: center; }
  .header-left { min-width: auto; gap: 0.5rem; flex: 1; }
  .header-center { display: flex; width: 100%; order: 3; margin-top: 0.25rem; }
  .search-container { width: 100%; max-width: none; }

  /* .version-badge { display: none; } removed so badge shows on mobile */
  .header-btn { display: none !important; }
  .logo-title, .logo-badge { font-size: 0.82rem; }
  .logo-icon { width: 30px; height: 30px; border-radius: 7px; }

  /* Content */
  .content-wrapper { padding: 1.25rem 1rem 2.5rem; }
  .main-content { min-height: auto; }

  /* Page header */
  .page-title { font-size: 1.5rem; }
  .page-desc { font-size: 0.9rem; }
  .page-header { margin-bottom: 1.75rem; padding-bottom: 1rem; }
  .breadcrumb { font-size: 0.75rem; margin-bottom: 0.5rem; }

  /* Hero */
  .hero-title { font-size: 1.6rem; }
  .hero-desc { font-size: 0.9rem; margin-bottom: 1.25rem; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .hero-section { margin-bottom: 1.75rem; padding-bottom: 1.75rem; }

  /* Stats bar */
  .stats-bar { flex-wrap: wrap; gap: 0.75rem; justify-content: center; padding: 0.875rem 1rem; }
  .stat-item { flex: 1 1 40%; text-align: center; min-width: 0; }
  .stat-number { font-size: 1.1rem; }
  .stat-divider { display: none; }

  /* Module cards grid */
  .modules-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .module-card { padding: 1rem; }
  .module-card-body p { font-size: 0.78rem; }

  /* Section headings */
  .section-heading { flex-wrap: wrap; gap: 0.5rem; }
  .section-heading h2 { font-size: 1rem; word-break: break-all; }
  .sub-section-title { font-size: 0.95rem; margin: 1.5rem 0 0.75rem; }
  .section-title-row { flex-wrap: wrap; gap: 0.5rem; }

  /* Tables */
  .table-wrapper { margin: 0.75rem 0; -webkit-overflow-scrolling: touch; }
  .api-table { font-size: 0.8rem; min-width: 520px; }
  .api-table th { padding: 0.5rem 0.75rem; font-size: 0.72rem; }
  .api-table td { padding: 0.5rem 0.75rem; }
  .api-table th:last-child, .api-table td:last-child { min-width: 220px; }
  .api-table code { font-size: 0.78rem; white-space: nowrap; }
  .param-table th:first-child { width: 120px; }

  /* Code blocks */
  .code-block { margin: 0.75rem 0; border-radius: var(--radius-sm); }
  .code-block-header { padding: 0.4rem 0.75rem; }
  .code-block pre { padding: 0.75rem; -webkit-overflow-scrolling: touch; }
  .code-block code { font-size: 0.78rem; }

  /* Endpoint cards */
  .endpoint-card-header { padding: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
  .endpoint-route { font-size: 0.8rem; word-break: break-all; }
  .endpoint-desc { margin-left: 0; font-size: 0.75rem; }
  .endpoint-card-body { padding: 1rem 0.75rem; }

  /* Endpoint detail */
  .endpoint-detail-header { flex-direction: column; gap: 0.5rem; }
  .endpoint-detail-route { font-size: 0.82rem; padding: 0.4rem 0.75rem; word-break: break-all; }

  /* Response tabs */
  .response-tabs { flex-wrap: wrap; gap: 4px; }
  .response-tab { font-size: 0.75rem; padding: 0.35rem 0.7rem; }

  /* Callouts */
  .callout { padding: 0.75rem; font-size: 0.82rem; }
  .callout svg { width: 16px; height: 16px; }

  /* Entity card */
  .entity-card { padding: 1rem; }

  /* Flow diagram */
  .flow-diagram { font-size: 0.76rem; padding: 1rem; -webkit-overflow-scrolling: touch; }

  /* When to use */
  .when-to-use { padding: 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .when-to-use ul { min-width: max-content; padding-right: 1rem; }
  .when-to-use li { font-size: 0.82rem; white-space: nowrap; }

  /* Doc nav */
  .doc-nav { grid-template-columns: 1fr; gap: 0.75rem; margin-top: 2rem; padding-top: 1.5rem; }
  .doc-nav-next { text-align: left; }
  .doc-nav-card { padding: 0.875rem 1rem; }
  .doc-nav-title { font-size: 0.85rem; }

  /* Footer */
  .footer-inner { flex-direction: column; gap: 0.75rem; text-align: center; padding: 1rem; }
  .footer-links { flex-wrap: wrap; justify-content: center; gap: 1rem; }

  /* Badges */
  .method-pill { font-size: 0.68rem; padding: 2px 8px; }
  .auth-badge, .auth-required, .badge-internal { font-size: 0.65rem; }
  .auth-icon { font-size: 0.68rem; }

  /* Inline code */
  .inline-code { padding: 0.5rem 0.75rem; }
  .inline-code code { font-size: 0.82rem; word-break: break-all; }

  .search-dropdown { border-radius: var(--radius); }
}

/* --- Small mobile --- */
@media (max-width: 480px) {
  :root { --header-h: 104px; }
  .header-inner { padding: 0 0.5rem; }
  .logo-title, .logo-badge { font-size: 0.78rem; }
  .logo-icon { width: 28px; height: 28px; border-radius: 6px; }
  .content-wrapper { padding: 1rem 0.75rem 2rem; }
  .page-title { font-size: 1.3rem; }
  .page-desc { font-size: 0.85rem; }
  .hero-title { font-size: 1.35rem; }
  .hero-desc { font-size: 0.85rem; }
  .modules-grid { gap: 0.5rem; }
  .module-card { padding: 0.875rem; gap: 0.75rem; }
  .module-card-icon { width: 36px; height: 36px; border-radius: 8px; }
  .module-card-icon svg { width: 17px; height: 17px; }
  .module-card-body h3 { font-size: 0.88rem; }
  .module-card-body p { font-size: 0.75rem; margin-bottom: 0.5rem; }
  .stats-bar { gap: 0.5rem; padding: 0.75rem; }
  .stat-item { flex: 1 1 45%; }
  .stat-number { font-size: 1rem; }
  .stat-label { font-size: 0.68rem; }
  .section-heading h2 { font-size: 0.9rem; }
  .sub-section-title { font-size: 0.88rem; }
  .api-table { min-width: 460px; font-size: 0.76rem; }
  .api-table th { padding: 0.4rem 0.5rem; font-size: 0.68rem; }
  .api-table td { padding: 0.4rem 0.5rem; }
  .code-block code { font-size: 0.74rem; }
  .code-block pre { padding: 0.625rem; }
  .doc-nav-card { padding: 0.75rem; }
  .doc-nav-label { font-size: 0.68rem; }
  .doc-nav-title { font-size: 0.8rem; }
  .footer-inner { font-size: 0.75rem; }
  .footer-links { gap: 0.75rem; }
  .footer-links a { font-size: 0.75rem; }
  .endpoint-card-header { padding: 0.625rem; }
  .endpoint-route { font-size: 0.76rem; }
}

/* --- Touch devices --- */
@media (hover: none) and (pointer: coarse) {
  .nav-item { padding: 0.6rem 0.625rem; min-height: 44px; }
  .toc-link { padding: 0.5rem; min-height: 40px; display: flex; align-items: center; }
  .copy-btn { padding: 8px; }
  .doc-nav-card { min-height: 56px; }
  .breadcrumb a { padding: 4px 0; }
  .footer-links a { padding: 4px 0; }
}

/* ===== PRINT ===== */
@media print {
  .site-header, .sidebar, .toc-panel, .scroll-progress { display: none !important; }
  .layout { display: block; }
  .main-content { padding: 0; min-height: auto; }
  .content-wrapper { padding: 0; }
  .doc-nav, .footer-inner { display: none; }
  .code-block { break-inside: avoid; }
  .table-wrapper { overflow: visible; }
}