:root {
  --bg-primary: #0e0d0c;
  --bg-surface: #171513;
  --bg-surface-raised: #211e1a;
  --bg-surface-hover: #2b2722;
  --border-subtle: #2d2822;
  --border-medium: #453c32;
  --border-accent: #78350f;
  
  --cortex-gold: #f59e0b;
  --cortex-gold-light: #fbbf24;
  --cortex-bg: rgba(245, 158, 11, 0.08);
  
  --medulla-amber: #d97706;
  --medulla-deep: #b45309;
  --papilla-crimson: #dc2626;
  
  --water-blue: #38bdf8;
  --water-blue-light: #7dd3fc;
  --water-bg: rgba(56, 189, 248, 0.08);
  
  --sodium-violet: #a855f7;
  --sodium-bg: rgba(168, 85, 247, 0.08);
  
  --text-main: #f5f5f4;
  --text-muted: #a8a29e;
  --text-faint: #78716c;
  --text-highlight: #fef08a;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-serif: "Newsreader", "Charis SIL", "Georgia", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.65;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: 
    radial-gradient(ellipse 90% 40% at 50% 0%, rgba(180, 83, 9, 0.12), transparent 70%),
    radial-gradient(circle 600px at 100% 20%, rgba(220, 38, 38, 0.04), transparent 80%),
    var(--bg-primary);
}

/* Accessibility & Screen Reader (FM-001 Prevention) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Header & Language Navigation */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(14, 13, 12, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

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

.brand-badge {
  background: var(--medulla-deep);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lang-nav {
  display: inline-flex;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 2px;
}

.lang-link {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-full);
  transition: all 0.15s ease;
}

.lang-link:hover {
  color: var(--text-main);
}

.lang-link.active {
  background: var(--cortex-gold);
  color: #0e0d0c;
}

/* Layout Containers */
.main-content {
  flex: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
  width: 100%;
}

.hero-section {
  text-align: center;
  margin-bottom: 3.5rem;
  padding: 1rem 0;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--cortex-gold-light);
  font-size: 0.825rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 5.5vw, 3.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 1.5rem;
}

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

.hero-lead {
  font-size: clamp(1.1rem, 2.2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Key Metrics Big Stat Strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cortex-gold), var(--medulla-amber));
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
}

.stat-card.alert-card::before {
  background: linear-gradient(90deg, #ea580c, #dc2626);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 3.2vw, 2.3rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.stat-value span.unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cortex-gold-light);
  margin-left: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.stat-subtext {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Interactive Simulator Container */
.interactive-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  margin: 3rem 0;
  box-shadow: var(--shadow-lg);
}

.panel-header {
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.panel-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.panel-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 620px;
}

/* Visual Nephron Flow Canvas & Stage */
.nephron-stage {
  position: relative;
  background: #090807;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.canvas-container {
  width: 100%;
  position: relative;
}

#nephronCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Osmotic Gradient Legend */
.gradient-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface-raised);
  border-radius: var(--radius-md);
  margin-top: 0.75rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.gradient-bar {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 40%, #b45309 70%, #dc2626 100%);
  margin: 0 0.75rem;
}

/* Perturbation Interactive Slider Controls */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.control-group {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.control-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--cortex-gold-light);
}

.slider-input {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-medium);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cortex-gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  transition: transform 0.1s ease;
}

.slider-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cortex-gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.control-hint {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.35;
}

/* Preset Buttons */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-preset {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset:hover {
  border-color: var(--cortex-gold);
  color: var(--text-main);
}

.btn-preset.active {
  background: var(--cortex-bg);
  border-color: var(--cortex-gold);
  color: var(--cortex-gold-light);
}

/* Live Dynamic Results Box */
.results-box {
  background: #090807;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.result-item {
  display: flex;
  flex-direction: column;
}

.result-tag {
  font-size: 0.725rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-bottom: 0.25rem;
}

.result-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.result-val.highlight-danger {
  color: #ef4444;
}

.result-val.highlight-warn {
  color: #f59e0b;
}

.result-val.highlight-ok {
  color: #10b981;
}

.result-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Scientific Article Sections */
.article-section {
  margin: 4rem 0;
}

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

.section-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cortex-gold-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: block;
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.prose {
  color: #d6d3d1;
  font-size: 1.05rem;
  line-height: 1.75;
}

.prose p {
  margin-bottom: 1.35rem;
}

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

.prose strong {
  color: #fff;
  font-weight: 700;
}

.prose em {
  font-style: italic;
  color: #fef08a;
}

/* Specialized Data Visuals: Segment Breakdown Table */
.data-table-container {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  min-width: 600px;
}

.data-table th {
  background: var(--bg-surface-raised);
  padding: 0.875rem 1rem;
  font-weight: 700;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-medium);
  font-family: var(--font-mono);
}

.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

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

.data-table tr:hover td {
  background: var(--bg-surface-hover);
}

.data-table td.num {
  font-family: var(--font-mono);
  font-weight: 600;
}

.data-table td.highlight {
  color: var(--cortex-gold-light);
  font-weight: 700;
}

/* Formula & Starling Forces Box */
.formula-card {
  background: var(--bg-surface-raised);
  border-left: 4px solid var(--cortex-gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.5rem;
  margin: 2rem 0;
}

.formula-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cortex-gold-light);
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
}

.formula-display {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  padding: 0.75rem 1rem;
  background: #090807;
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
  overflow-x: auto;
}

.formula-explanation {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Personal Renal Calculator */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.calc-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.calc-input-wrap label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.calc-input-field {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-medium);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease;
}

.calc-input-field:focus {
  border-color: var(--cortex-gold);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cortex-gold-light), var(--medulla-amber));
  color: #0e0d0c;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Scientific Method & References Section */
.method-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  margin-top: 4rem;
}

.method-card h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 1rem;
}

.references-list {
  list-style: none;
  font-size: 0.825rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.references-list li {
  padding-left: 1.25rem;
  position: relative;
  line-height: 1.5;
}

.references-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--cortex-gold);
}

.references-list a {
  color: var(--cortex-gold-light);
  text-decoration: none;
}

.references-list a:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 2.5rem 1.25rem;
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.footer-author a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
}

.footer-author a:hover {
  color: var(--cortex-gold-light);
}

.back-to-top-btn {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.back-to-top-btn:hover {
  color: var(--text-main);
  border-color: var(--cortex-gold);
}

/* Reduced Motion Mode */
@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;
  }
}

/* Responsive Adjustments */
@media (max-width: 640px) {
  .header-inner {
    padding: 0.75rem 1rem;
  }
  
  .main-content {
    padding: 1.75rem 1rem 3.5rem;
  }
  
  .interactive-panel {
    padding: 1.25rem 1rem;
  }
  
  .stats-strip {
    grid-template-columns: 1fr;
  }
  
  .results-box {
    grid-template-columns: 1fr;
  }
}
