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

:root {
  --bg-primary: #F4F8F6;
  --bg-secondary: #ffffff;
  --bg-code: #f6f8fa;
  --border-subtle: #e2e8e5;
  --border-medium: #d0d8d5;
  --text-primary: #06100C;
  --text-secondary: #0A2A1F;
  --text-muted: #4A362A;
  --text-faint: #6b7280;
  --accent-primary: #0E4A33;
  --accent-secondary: #4FA36A;
  --accent-blue: #1A8890;
  --accent-amber: #E2B84A;
  --accent-red: #C86A3E;
  --sidebar-width: 280px;
  --header-height: 60px;
  --radius: 8px;
  --radius-sm: 4px;
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: #1a1d1c;
  --bg-secondary: #0d0f0e;
  --bg-code: #1e2322;
  --border-subtle: #2a2f2d;
  --border-medium: #3a403d;
  --text-primary: #e8ece9;
  --text-secondary: #c5ccc8;
  --text-muted: #9ca39f;
  --text-faint: #6b7270;
  --accent-primary: #4FA36A;
  --accent-secondary: #6dbf84;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  line-height: 1.7;
  font-size: 15px;
  overflow-x: hidden;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: var(--text-primary);
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  color: #fff;
}

.logo-text {
  font-size: 16px;
}

.logo-divider {
  color: var(--border-medium);
  font-weight: 300;
}

.logo-docs {
  color: var(--text-faint);
  font-weight: 400;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}

.header-links a {
  color: var(--text-muted);
  transition: color 0.2s;
}

.header-links a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.github-link:hover {
  border-color: var(--accent-primary);
  background: rgba(14, 74, 51, 0.05);
}

/* Dark mode toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }

[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }

[data-theme="dark"] .github-link:hover,
[data-theme="dark"] .theme-toggle:hover {
  background: rgba(79, 163, 106, 0.1);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  color: var(--text-muted);
}

@media (max-width: 1024px) {
  .menu-toggle {
    display: flex;
  }
  .header-links {
    display: none;
  }
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-primary);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
  transition: transform 0.3s ease;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

/* Sidebar mobile header */
.sidebar-mobile-header {
  display: none;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

@media (max-width: 1024px) {
  .sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
}

.sidebar-mobile-header .theme-toggle {
  width: 40px;
  height: 40px;
}

.sidebar-mobile-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.sidebar-mobile-close:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 8px 24px;
  margin-top: 16px;
}

.sidebar-section:first-child .sidebar-section-title {
  margin-top: 0;
}

.sidebar-link {
  display: block;
  padding: 6px 24px;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(14, 74, 51, 0.05);
  text-decoration: none;
}

.sidebar-link.active {
  color: var(--accent-primary);
  background: rgba(14, 74, 51, 0.08);
  border-left-color: var(--accent-primary);
  font-weight: 500;
}

.sidebar-link.nested {
  padding-left: 40px;
  font-size: 13px;
}

/* Main content */
.main {
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
  overflow-x: hidden;
}

@media (max-width: 1024px) {
  .main {
    margin-left: 0;
  }
}

.content {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 40px 120px;
}

@media (max-width: 768px) {
  .content {
    padding: 32px 20px 80px;
  }

  .feature-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Overlay for mobile */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.overlay.open {
  display: block;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: 'DM Serif Display', serif;
  color: var(--text-primary);
  font-weight: 400;
  line-height: 1.3;
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.5rem;
  margin-top: 56px;
  margin-bottom: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

h2:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

h3 {
  font-size: 1.25rem;
  margin-top: 40px;
  margin-bottom: 12px;
}

h4 {
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 16px;
}

.lead {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

ul, ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

li {
  margin-bottom: 8px;
}

/* Code blocks */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 100%;
}

code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875em;
  word-break: break-word;
}

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

/* Syntax highlighting */
.token-comment { color: #6b7280; }
.token-keyword { color: #0E4A33; font-weight: 500; }
.token-string { color: #1A8890; }
.token-number { color: #C86A3E; }
.token-property { color: #4FA36A; }
.token-operator { color: #4A362A; }

/* Dark mode syntax highlighting */
[data-theme="dark"] .token-comment { color: #8b9298; }
[data-theme="dark"] .token-keyword { color: #7dd3a0; }
[data-theme="dark"] .token-string { color: #5ec4cc; }
[data-theme="dark"] .token-number { color: #e8a070; }
[data-theme="dark"] .token-property { color: #a8e6b8; }
[data-theme="dark"] .token-operator { color: #c9b8a8; }

/* Tables */
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  table {
    display: table;
    overflow-x: visible;
    max-width: none;
  }
}

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

th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-code);
}

tr:hover td {
  background: rgba(14, 74, 51, 0.02);
}

/* Callouts */
.callout {
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  border-left: 3px solid;
}

.callout-info {
  background: rgba(26, 136, 144, 0.08);
  border-color: var(--accent-blue);
}

.callout-warning {
  background: rgba(226, 184, 74, 0.1);
  border-color: var(--accent-amber);
}

.callout-tip {
  background: rgba(79, 163, 106, 0.1);
  border-color: var(--accent-secondary);
}

.callout-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-size: 14px;
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-green {
  background: rgba(79, 163, 106, 0.15);
  color: #2d7a4a;
}

.badge-amber {
  background: rgba(226, 184, 74, 0.2);
  color: #9a7b1f;
}

.badge-red {
  background: rgba(200, 106, 62, 0.15);
  color: #a84f2a;
}

.badge-blue {
  background: rgba(26, 136, 144, 0.15);
  color: #136970;
}

/* Section anchors */
.anchor {
  color: var(--text-faint);
  opacity: 0;
  margin-left: 8px;
  transition: opacity 0.2s;
}

h2:hover .anchor,
h3:hover .anchor {
  opacity: 1;
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.feature-grid-2col {
  grid-template-columns: repeat(2, 1fr);
}

.feature-card {
  padding: 20px;
  background: var(--bg-code);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.feature-card h4 {
  margin-top: 0;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 14px;
  margin-bottom: 0;
  color: var(--text-faint);
}

/* Platform scores */
.platform-score {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-code);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.platform-score-bar {
  flex: 1;
  height: 8px;
  background: var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}

.platform-score-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 4px;
}

.platform-score-label {
  min-width: 140px;
  font-weight: 500;
  color: var(--text-secondary);
}

.platform-score-label .platform-score-subtitle {
  display: block;
  font-size: 0.75em;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.platform-score-label a {
  color: inherit;
  text-decoration: none;
}

.platform-score-label a:hover {
  text-decoration: underline;
}

.platform-score-value {
  min-width: 50px;
  text-align: right;
  font-weight: 600;
  color: var(--accent-primary);
}

/* Info box */
.info-box {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 14px;
}

.info-box ul {
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 4px;
}

/* Mermaid diagram wrapper */
.mermaid-wrap {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px 16px;
  margin-bottom: 24px;
  overflow-x: auto;
  text-align: center;
  -webkit-overflow-scrolling: touch;
}

.mermaid-wrap pre.mermaid,
.mermaid-wrap > svg,
.mermaid-wrap > [id] > svg {
  margin: 0;
  background: transparent;
  min-width: min-content;
  display: inline-block;
  touch-action: pan-x pan-y;
}

/* Expand button */
.mermaid-expand-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  z-index: 2;
}

.mermaid-wrap:hover .mermaid-expand-btn {
  opacity: 1;
}

@media (max-width: 768px) {
  .mermaid-expand-btn {
    opacity: 0.7;
  }
}

.mermaid-expand-btn:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.mermaid-expand-btn svg {
  width: 16px;
  height: 16px;
}

/* Fullscreen overlay */
.mermaid-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.2s;
}

.mermaid-overlay.open {
  opacity: 1;
}

.mermaid-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.mermaid-overlay-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mermaid-overlay-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
}

.mermaid-overlay-controls button:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.mermaid-overlay-controls .zoom-label {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  user-select: none;
}

.mermaid-overlay-controls svg {
  width: 16px;
  height: 16px;
}

.mermaid-overlay-close {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

.mermaid-overlay-close:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.mermaid-overlay-close svg {
  width: 14px;
  height: 14px;
}

.mermaid-overlay-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: grab;
  touch-action: none;
}

.mermaid-overlay-body:active {
  cursor: grabbing;
}

.mermaid-overlay-body .zoom-container {
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.mermaid-overlay-body .zoom-container.dragging {
  transition: none;
}

.mermaid-overlay-body svg {
  max-width: none;
  max-height: none;
}

/* Severity badges */
.severity-critical {
  background: rgba(200, 60, 60, 0.15);
  color: #c83c3c;
}

.severity-high {
  background: rgba(200, 106, 62, 0.15);
  color: #a84f2a;
}

.severity-medium {
  background: rgba(226, 184, 74, 0.15);
  color: #9a7a1a;
}

.code-block {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* Multi-page sidebar section titles as links */
a.sidebar-section-title {
  display: block;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px 6px;
  text-decoration: none;
}

a.sidebar-section-title:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

a.sidebar-section-title.active {
  color: var(--accent-primary);
}

/* Prev / Next page navigation */
.docs-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.docs-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: border-color 0.2s, background 0.2s;
  text-decoration: none;
  min-width: 0;
}

.docs-nav-link:hover {
  border-color: var(--accent-primary);
  background: rgba(14, 74, 51, 0.04);
  text-decoration: none;
}

[data-theme="dark"] .docs-nav-link:hover {
  background: rgba(79, 163, 106, 0.08);
}

.docs-nav-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docs-nav-arrow {
  font-size: 20px;
  color: var(--text-faint);
  flex-shrink: 0;
  transition: color 0.2s;
}

.docs-nav-link:hover .docs-nav-arrow {
  color: var(--accent-primary);
}

.docs-nav-next {
  margin-left: auto;
}

.docs-nav-next .docs-nav-label {
  align-items: flex-end;
}

.docs-nav-dir {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.docs-nav-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}
