/* ==========================================================================
   DS Simulations — Design System (shadcn / zinc theme)
   High-precision, minimalist scientific interface built with pure CSS.
   ========================================================================== */

/* ----- Design Tokens (shadcn zinc palette) ----- */
:root {
  /* Surface & Base */
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --card-elevated: #0f0f12;
  --card-hover: #141418;
  --card-foreground: #fafafa;
  --popover: #09090b;
  --popover-foreground: #fafafa;

  /* Primary (Crisp High-Contrast White) */
  --primary: #fafafa;
  --primary-foreground: #09090b;
  --primary-hover: #e4e4e7;

  /* Secondary & Muted */
  --secondary: #18181b;
  --secondary-foreground: #fafafa;
  --secondary-hover: #27272a;
  --muted: #18181b;
  --muted-foreground: #a1a1aa;
  --muted-subtle: #71717a;

  /* Accents & States */
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --border: #27272a;
  --border-subtle: #1f1f23;
  --border-hover: #3f3f46;
  --input: #27272a;
  --ring: #71717a;

  /* Data & Mathematical Semantic Accents */
  --chart-blue: #38bdf8;
  --chart-blue-subtle: rgba(56, 189, 248, 0.12);
  --chart-emerald: #10b981;
  --chart-emerald-subtle: rgba(16, 185, 129, 0.12);
  --chart-amber: #f59e0b;
  --chart-amber-subtle: rgba(245, 158, 11, 0.12);
  --chart-rose: #f43f5e;
  --chart-rose-subtle: rgba(244, 63, 94, 0.12);
  --chart-violet: #a855f7;

  /* Backward Compatibility Aliases */
  --bg-primary: var(--background);
  --bg-secondary: var(--secondary);
  --bg-card: var(--card-elevated);
  --text-primary: var(--foreground);
  --text-secondary: var(--muted-foreground);
  --accent-hover: var(--chart-blue);
  --success: var(--chart-emerald);
  --warning: var(--chart-amber);
  --danger: var(--chart-rose);

  /* Typography */
  --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Radii */
  --radius-sm: 0.375rem; /* 6px */
  --radius: 0.5rem;      /* 8px */
  --radius-lg: 0.75rem;  /* 12px */
  --radius-full: 9999px;

  /* Elevation (Restrained, subtle borders over harsh glows) */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  /* Subtle precision grid background */
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

img, svg {
  vertical-align: middle;
}

code, pre, kbd {
  font-family: var(--font-mono);
}

code {
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  border: 1px solid var(--border-subtle);
  color: #e4e4e7;
}

pre {
  background: #060608;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

p {
  margin-bottom: 1rem;
}

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

h1, h2, h3, h4, h5, h6 {
  color: var(--foreground);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

/* ----- Layout ----- */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

/* ----- Navigation (shadcn topbar) ----- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.nav .container,
.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.brand-icon {
  width: 22px;
  height: 22px;
  color: var(--foreground);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-dot {
  color: var(--muted-subtle);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--secondary);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.nav-link:hover,
.nav-link.active {
  color: var(--foreground);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ----- Hero Section ----- */
.hero {
  padding: 4.5rem 0 3rem;
  text-align: center;
  position: relative;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: rgba(24, 24, 27, 0.65);
  border: 1px solid var(--border);
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 1.5rem;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.hero-pill:hover {
  border-color: var(--border-hover);
  color: var(--foreground);
}

.hero-pill-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chart-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.hero-title {
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: var(--foreground);
  max-width: 840px;
  margin-left: auto;
  margin-right: auto;
}

.hero-title-accent {
  color: var(--muted-foreground);
  font-weight: 400;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--muted-foreground);
  max-width: 620px;
  margin: 0 auto 2rem;
  line-height: 1.6;
  font-weight: 400;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

/* ----- Interactive Hero Sandbox (Live Bernoulli Convergence) ----- */
.hero-sandbox {
  max-width: 720px;
  margin: 0 auto 1.5rem;
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.sandbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sandbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sandbox-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--foreground);
}

.sandbox-formula {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.sandbox-body {
  position: relative;
  margin-bottom: 1rem;
}

.sandbox-canvas {
  width: 100%;
  height: 90px;
  display: block;
  background: #050507;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.sandbox-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.sandbox-stat-item {
  background: rgba(24, 24, 27, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}

.sandbox-stat-label {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.sandbox-stat-val {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--foreground);
  line-height: 1.2;
}

.sandbox-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sandbox-btn-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sandbox-hint {
  font-size: 0.75rem;
  color: var(--muted-subtle);
  font-family: var(--font-mono);
}

/* ----- Section Structure ----- */
.section {
  padding: 3.5rem 0;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.section-title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--foreground);
  border-left: none;
  padding-left: 0;
  margin-bottom: 0;
}

.section-desc {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 0;
}

/* ----- shadcn Tabs (Filter Bar) ----- */
.tabs-list {
  display: inline-flex;
  align-items: center;
  background: var(--secondary);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--radius);
  gap: 2px;
}

.tabs-trigger {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tabs-trigger:hover {
  color: var(--foreground);
}

.tabs-trigger.active {
  background: #27272a;
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted-subtle);
  background: rgba(9, 9, 11, 0.5);
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-sm);
}

.tabs-trigger.active .tab-count {
  color: var(--muted-foreground);
}

/* ----- shadcn Card Components ----- */
.card,
.experiment-card {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  text-decoration: none;
  color: inherit;
  position: relative;
}

.experiment-card:hover {
  border-color: var(--border-hover);
  background: var(--card-hover);
  box-shadow: var(--shadow-sm);
  transform: none; /* No 3D transform tilt - pure shadcn restrained style */
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-meta-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--foreground);
  margin-bottom: 0;
}

.card-description {
  font-size: 0.84375rem;
  color: var(--muted-foreground);
  line-height: 1.55;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Bespoke SVG Preview Visual */
.card-visual {
  width: 100%;
  height: 120px;
  background: #050507;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-visual svg {
  width: 100%;
  height: 100%;
  display: block;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-grow: 1;
}

.formula-box {
  background: #060608;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #d4d4d8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.formula-box code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.formula-label {
  font-size: 0.65rem;
  color: var(--muted-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.spec-label {
  font-size: 0.6875rem;
  color: var(--muted-subtle);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-value {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #e4e4e7;
  font-family: var(--font-mono);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.card-link-text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color var(--transition-fast);
}

.card-link-arrow {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-fast);
}

.experiment-card:hover .card-link-arrow {
  transform: translateX(3px);
}

.experiment-card.coming-soon {
  opacity: 0.75;
  cursor: default;
}

.experiment-card.coming-soon:hover {
  border-color: var(--border);
  background: var(--card-elevated);
}

/* Legacy tag pill compatibility */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.card-tag {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
}

/* ----- shadcn Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1.25;
  white-space: nowrap;
}

.badge-outline {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
}

.badge-secondary {
  background: var(--secondary);
  border: 1px solid var(--border-subtle);
  color: #e4e4e7;
}

.badge-emerald {
  background: var(--chart-emerald-subtle);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.badge-blue {
  background: var(--chart-blue-subtle);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

.badge-amber {
  background: var(--chart-amber-subtle);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chart-emerald);
}

.status-dot.amber {
  background: var(--chart-amber);
}

/* ----- shadcn Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn:hover {
  background: var(--primary-hover);
  transform: none;
  box-shadow: none;
}

.btn:active {
  opacity: 0.9;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  border-color: var(--border-hover);
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--secondary);
  border-color: var(--border-hover);
  color: var(--foreground);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: 0.9375rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Backward compatibility */
.btn-success { background: var(--chart-emerald); color: #09090b; }
.btn-danger  { background: var(--chart-rose); color: #09090b; }

/* ----- Form Elements & Controls Panel (shadcn styling) ----- */
.controls-panel {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.controls-panel-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.015em;
  color: var(--foreground);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label,
label {
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: #fafafa;
  font-weight: 600;
}

/* Precision Range Slider (shadcn Slider aesthetic) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--secondary);
  outline: none;
  cursor: pointer;
  margin: 0.5rem 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fafafa;
  border: 2px solid #09090b;
  box-shadow: 0 0 0 1px var(--ring);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(250, 250, 250, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fafafa;
  border: 2px solid #09090b;
  box-shadow: 0 0 0 1px var(--ring);
  cursor: pointer;
}

/* Select & Inputs */
select,
input[type="number"],
input[type="text"] {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

select {
  padding-right: 2rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23a1a1aa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}

/* ----- Stats Display Panels ----- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: left;
  transition: border-color var(--transition-fast);
}

.stat-box:hover {
  border-color: var(--border-hover);
}

.stat-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--foreground);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-value.success { color: var(--chart-emerald); }
.stat-value.warning { color: var(--chart-amber); }
.stat-value.danger  { color: var(--chart-rose); }

/* ----- Chart Container ----- */
.chart-container {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  width: 100%;
  position: relative;
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--foreground);
  font-family: var(--font-mono);
}

.chart-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-row .chart-container {
  flex: 1;
  margin-bottom: 0;
}

/* ----- Experiment Detail Header & Theory Boxes ----- */
.experiment-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.experiment-header h1 {
  font-size: 2.25rem;
  margin-bottom: 0.35rem;
}

.experiment-header .subtitle {
  font-size: 1rem;
  color: var(--muted-foreground);
  margin-bottom: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-bottom: 0.75rem;
  list-style: none;
  font-family: var(--font-mono);
}

.breadcrumb a {
  color: var(--muted-foreground);
}

.breadcrumb a:hover {
  color: var(--foreground);
}

.breadcrumb-sep {
  color: var(--muted-subtle);
}

.breadcrumb-current {
  color: var(--foreground);
}

.theory-box {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.theory-box h3 {
  font-size: 1rem;
  margin-bottom: 0.65rem;
  margin-top: 1rem;
}

.theory-box h3:first-child {
  margin-top: 0;
}

.theory-box blockquote {
  border-left: 2px solid var(--border-hover);
  padding-left: 1rem;
  color: var(--muted-foreground);
  font-style: normal;
  margin: 0.75rem 0;
}

.info-box,
.warning-box {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.info-box {
  background: var(--chart-blue-subtle);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #bae6fd;
}

.warning-box {
  background: var(--chart-amber-subtle);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

/* ----- Features / Methodology Grid ----- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.feature-card {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.feature-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--foreground);
}

.feature-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.feature-desc {
  font-size: 0.84375rem;
  color: var(--muted-foreground);
  line-height: 1.6;
  margin-bottom: 0;
}

/* ----- Colophon / Footer ----- */
.footer {
  border-top: 1px solid var(--border);
  padding: 3rem 0;
  margin-top: 4rem;
  background: var(--background);
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-brand {
  max-width: 360px;
}

.footer-tagline {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
  line-height: 1.5;
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-subtle);
  margin-top: 0.75rem;
}

.footer-nav {
  display: flex;
  gap: 3rem;
}

.footer-nav-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-nav-title {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-subtle);
  margin-bottom: 0.25rem;
}

.footer-nav-link {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.footer-nav-link:hover {
  color: var(--foreground);
}

/* ----- Simulation Workspace Layout (Sidebar + Main Visualization) ----- */
.sim-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

.sim-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.sim-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.stats-panel-card {
  background: var(--card-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stats-panel-title {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-row-label {
  color: var(--muted-foreground);
}

.stats-row-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--foreground);
}

.radio-pill-group {
  display: flex;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
  gap: 0.25rem;
}

.radio-pill-group label {
  flex: 1;
  text-align: center;
  padding: 0.45rem 0.6rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: 0;
  color: var(--muted-foreground);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  user-select: none;
}

.radio-pill-group input[type="radio"] {
  display: none;
}

.radio-pill-group label.active,
.radio-pill-group label:has(input[type="radio"]:checked) {
  background: var(--border-hover);
  color: var(--foreground);
  font-weight: 600;
}

/* ----- Utility Classes ----- */
.text-center { text-align: center; }
.text-muted  { color: var(--muted-foreground); }
.font-mono   { font-family: var(--font-mono); }
.hidden      { display: none !important; }

/* ----- Responsive Breakpoints ----- */
@media (max-width: 980px) {
  .sim-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .hero-title { font-size: 2.25rem; }
  .grid-3, .features-grid { grid-template-columns: repeat(2, 1fr); }
  .sandbox-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .hero { padding: 3rem 0 2rem; }
  .hero-title { font-size: 1.85rem; }
  .hero-subtitle { font-size: 0.9375rem; }
  .grid-2, .grid-3, .features-grid { grid-template-columns: 1fr; }
  .chart-row { flex-direction: column; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .tabs-list { width: 100%; overflow-x: auto; }
  .sandbox-stats { grid-template-columns: 1fr 1fr; }
  .footer-inner { flex-direction: column; }
  .footer-nav { flex-direction: column; gap: 1.5rem; }
}
