:root {
  /* Core Tones - Dark (Zinc based for a modern, sleek look) */
  --bg: #09090b;
  --bg-rgb: 9, 9, 11;
  --surface: #18181b;
  --surface-hover: #27272a;
  
  /* Text */
  --ink: #fafafa;
  --muted: #a1a1aa;
  
  /* Borders */
  --line: #27272a;
  --line-hover: #3f3f46;
  
  /* Accents - Cyan / Blue gradient vibe */
  --accent: #0ea5e9;
  --accent-hover: #38bdf8;
  --accent-soft: rgba(14, 165, 233, 0.15);
  
  /* Tags */
  --tag-bg: #1e293b;
  --tag-text: #38bdf8;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 24px -6px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.2);

  /* Layout */
  --max-w: 1600px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

body.light-mode {
  --bg: #f8fafc;
  --bg-rgb: 248, 250, 252;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-hover: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --tag-bg: #dbeafe;
  --tag-text: #1e40af;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 12px 24px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Typography base */
h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 1rem 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal {
  opacity: 0;
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Navbar */
.top-nav, .page-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(var(--bg-rgb), 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.nav-container, .page-nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-nav {
  /* Used in index.html hero, let's normalize it to be similar */
  margin: 0;
  padding: 1rem 2rem;
  max-width: none;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.75rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: linear-gradient(to right, var(--ink), var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.menu {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  align-items: center;
}

.menu a {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s ease;
}

.menu a:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.menu a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--line-hover);
  transform: rotate(15deg);
}

/* Main Layout wrappers */
main, .hero-wrapper {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem;
}

/* Hero Section */
.hero {
  padding: 6rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

.hero-content {
  max-width: 800px;
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

.hero-copy {
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(14, 165, 233, 0.4);
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--line-hover);
}

/* Stat Ribbon */
.stat-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 4rem;
  width: 100%;
  max-width: var(--max-w);
}

.stat-ribbon article {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  text-align: left;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.stat-ribbon article:hover {
  transform: translateY(-4px);
  border-color: var(--line-hover);
  box-shadow: var(--shadow);
}

.stat-ribbon .label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.5rem;
}

.stat-ribbon .value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 3rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow);
}

.panel-head {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.5rem;
}

.panel-head h2 {
  font-size: 2rem;
  margin: 0;
}

/* Results section specifics */
.results-wrap {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  align-items: start;
}

.score-cards {
  display: grid;
  gap: 1rem;
}

.score-card {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.score-title {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

.score-values {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
}

.chart-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.chart-card h3 {
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.caption {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

/* Docs Layout */
.docs-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 3rem;
}

.docs-sidebar {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 1rem;
}

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

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 1rem;
  font-weight: 700;
}

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-list a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--muted);
  transition: all 0.2s ease;
}

.sidebar-list a:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.sidebar-list a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.docs-main {
  min-height: 60vh;
  min-width: 0;
}

.docs-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.docs-content h1 { 
  font-size: 2.25rem; 
  border-bottom: 1px solid var(--line); 
  padding-bottom: 1rem; 
  margin-bottom: 2.5rem; 
}

.docs-content h2 { 
  font-size: 1.75rem; 
  margin-top: 3rem; 
  margin-bottom: 1.25rem; 
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.docs-content h2::before {
  content: '';
  display: block;
  width: 6px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 4px;
}

.docs-content h3 { 
  font-size: 1.35rem; 
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.docs-content h3::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.1em;
  background: var(--accent-soft);
  border-radius: 3px;
}

.docs-content p { margin-bottom: 1.5rem; }
.docs-content ul, .docs-content ol { margin-bottom: 1.5rem; padding-left: 1.5rem; }
.docs-content li { margin-bottom: 0.5rem; }

.docs-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--surface-hover);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--accent);
}

.docs-content pre {
  background: var(--surface-hover);
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.docs-content pre code {
  background: transparent;
  padding: 0;
  color: var(--ink);
  font-size: 0.9em;
}

.docs-content blockquote {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
}

.docs-content tr {
  transition: background 0.2s ease;
}

.docs-content tbody tr:nth-child(even) {
  background: var(--surface-hover);
}

.docs-content tbody tr:hover {
  background: var(--accent-soft);
}

.docs-content th, .docs-content td {
  padding: 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
}

.docs-content th {
  background: var(--surface-hover);
  font-weight: 600;
}

/* Visuals Layout */
.visuals-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.5rem 1.25rem;
  border-radius: 99px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
  gap: 1rem;
}

.visual-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.visual-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.img-wrapper {
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
  position: relative;
}

.img-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(14, 165, 233, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}

.visual-card:hover .img-wrapper::after {
  background: rgba(14, 165, 233, 0.15);
}

.visual-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.visual-card:hover img {
  transform: scale(1.05);
}

.visual-card figcaption {
  margin-top: 1.25rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  transition: color 0.3s ease;
}

.visual-card:hover figcaption {
  color: var(--accent);
}

/* Image Viewer Modal */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(var(--bg-rgb), 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-viewer.open {
  display: flex;
  opacity: 1;
}

.image-viewer-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.image-viewer.open .image-viewer-inner {
  transform: scale(1);
}

.image-viewer-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.image-viewer-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.image-viewer-close {
  background: var(--surface-hover);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.image-viewer-close:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.image-viewer-body {
  padding: 2rem;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.image-viewer-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Footer */
.footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer p {
  margin: 0.5rem 0;
}

/* Loading status */
.status-message {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-style: italic;
}

/* Responsive */
@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  
  .docs-sidebar {
    position: static;
    max-height: none;
    margin-bottom: 2rem;
  }
  
  .results-wrap {
    grid-template-columns: 1fr;
  }

  .nav-container, .page-nav-inner {
    padding: 1rem;
  }
  
  .menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
  }

  .menu.open {
    display: flex;
  }

  .menu-toggle {
    display: block;
  }
  
  .theme-toggle {
    display: none; /* Can be moved inside menu if needed */
  }
}

@media (max-width: 600px) {
  .hero {
    padding: 4rem 1rem;
  }
  
  .panel {
    padding: 1.5rem;
  }
  
  .docs-content {
    padding: 1.5rem;
  }
}
