:root {
  --bg-primary: #0b0d11;
  --bg-surface: #141820;
  --bg-surface-elevated: #1b212d;
  --bg-glass: rgba(20, 24, 32, 0.85);
  --border-subtle: rgba(245, 158, 11, 0.16);
  --border-strong: rgba(245, 158, 11, 0.35);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --amber-glow: #f59e0b;
  --gold-crystal: #fbbf24;
  --blood-red: #ef4444;
  --cyan-analytical: #38bdf8;
  --emerald-safe: #10b981;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
  font-size: 16px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 10% 20%, rgba(239, 68, 68, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.04) 0%, transparent 50%),
    var(--bg-primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.container {
  width: 100%;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(11, 13, 17, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.875rem 0;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber-glow);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-toggle {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  transition: all 0.2s ease;
}

.lang-toggle:hover {
  color: var(--text-primary);
  border-color: var(--amber-glow);
  background: var(--bg-surface-elevated);
}

/* Hero & Editorial Answer-First */
.hero {
  padding: 3.5rem 0 2rem;
  text-align: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--amber-glow);
  background: rgba(245, 158, 11, 0.1);
  padding: 0.3rem 0.8rem;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: clamp(2.1rem, 4.5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.hero-title .highlight {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #fde68a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-deck {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  color: var(--text-secondary);
  max-width: 780px;
  margin: 0 auto 2.5rem;
  font-weight: 400;
  line-height: 1.5;
}

/* The Core Stat Callout Bar */
.stat-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 3.5rem;
}

.stat-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber-glow), transparent);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-crystal);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Interactive Laboratory Section */
.lab-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 3.5rem;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

.lab-header {
  margin-bottom: 1.75rem;
}

.lab-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lab-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Canvas Area */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 260px;
  background: #080a0e;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.15);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.control-val {
  font-family: var(--font-mono);
  color: var(--gold-crystal);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--amber-glow);
  height: 6px;
  border-radius: 3px;
  background: #1e293b;
  cursor: pointer;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.preset-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  color: var(--text-primary);
  border-color: var(--amber-glow);
}

.preset-btn.active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold-crystal);
  border-color: var(--amber-glow);
  font-weight: 600;
}

/* Dynamic Diagnostic Box */
.diagnostic-box {
  background: rgba(11, 13, 17, 0.8);
  border-left: 4px solid var(--amber-glow);
  padding: 1.25rem;
  border-radius: 0 8px 8px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.diag-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

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

.diag-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.diag-status {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Secondary Interactive Tool: Brain Apnea Clock & Personal Body Calculator */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3.5rem;
}

.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.75rem;
}

.tool-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.clock-display {
  background: #080a0e;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
}

.clock-timer {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--gold-crystal);
  letter-spacing: 0.05em;
}

.clock-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Narrative & Essay Flow */
.prose-section {
  max-width: 760px;
  margin: 0 auto 3.5rem;
}

.prose-section h2 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 2.5rem 0 1rem;
}

.prose-section h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-crystal);
  margin: 1.75rem 0 0.75rem;
}

.prose-section p {
  font-size: 1.05rem;
  color: #cbd5e1;
  margin-bottom: 1.25rem;
  line-height: 1.75;
}

.prose-section ul, .prose-section ol {
  margin: 1rem 0 1.5rem 1.5rem;
  color: #cbd5e1;
}

.prose-section li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.prose-section blockquote {
  border-left: 3px solid var(--amber-glow);
  background: rgba(245, 158, 11, 0.05);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: #e2e8f0;
}

/* Comparison Table */
.table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  padding: 0.85rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 0.85rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(245, 158, 11, 0.03);
}

/* Scientific References Box */
.references-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.75rem;
  margin: 3rem 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.references-box h4 {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.references-box ol {
  padding-left: 1.25rem;
}

.references-box li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 0;
  margin-top: auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-footer a:hover {
  color: var(--amber-glow);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0b0d11;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-action:active {
  transform: translateY(0);
}

/* Responsive & Reduced Motion */
@media (max-width: 640px) {
  .lab-section {
    padding: 1.25rem;
  }
  .canvas-wrapper {
    height: 200px;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
  .diagnostic-box {
    grid-template-columns: 1fr 1fr;
  }
  .stat-banner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
