:root {
  --bg-abyss: #070b14;
  --bg-card: #0d1424;
  --bg-card-hover: #131d33;
  --bg-card-subtle: #101a2e;
  --border-dim: #1c273e;
  --border-bright: #2d3e63;
  --text-main: #f0f4fc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --cyan-left: #00f0ff;
  --cyan-left-dim: rgba(0, 240, 255, 0.15);
  --coral-right: #ff5c38;
  --coral-right-dim: rgba(255, 92, 56, 0.15);
  --gold-sync: #ffd166;
  --gold-sync-dim: rgba(255, 209, 102, 0.15);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Menlo, monospace;
}

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

html {
  background-color: var(--bg-abyss);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Accessibility & Screen Reader Class - FM-001 Compliant */
.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;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 1rem;
  background: var(--gold-sync);
  color: #000;
  padding: 0.5rem 1rem;
  font-weight: 700;
  z-index: 100;
  transition: top 0.2s;
  border-radius: 4px;
}
.skip-link:focus {
  top: 1rem;
}

a {
  color: var(--cyan-left);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: #5cf4ff;
  text-decoration: underline;
}

/* Container */
.container {
  width: 100%;
  max-width: 1080px;
  padding: 0 1.25rem;
  margin: 0 auto;
}

/* Header & Nav */
header.site-header {
  width: 100%;
  border-bottom: 1px solid var(--border-dim);
  background: rgba(7, 11, 20, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}
.brand-link {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--border-dim);
  color: var(--text-muted);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.lang-toggle {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-weight: 600;
}
.lang-toggle:hover {
  color: var(--text-main);
  border-color: var(--border-bright);
  text-decoration: none;
}

/* Main Content */
main {
  width: 100%;
  padding: 3rem 0 5rem;
}

/* Hero Section (Answer First) */
.hero {
  margin-bottom: 3.5rem;
  text-align: left;
}
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan-left);
  background: var(--cyan-left-dim);
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  margin-bottom: 1.25rem;
}
.kicker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan-left);
  box-shadow: 0 0 8px var(--cyan-left);
  animation: pulse-dot 2s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

h1.hero-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
  color: #ffffff;
}
.hero-deck {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 860px;
  margin-bottom: 2rem;
}

/* Stat Grid (The Numbers) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2.5rem 0;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--border-dim);
}
.stat-card.cyan::before { background: var(--cyan-left); }
.stat-card.coral::before { background: var(--coral-right); }
.stat-card.gold::before { background: var(--gold-sync); }

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-bright);
}
.stat-val {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.4rem;
  color: #ffffff;
}
.stat-card.cyan .stat-val { color: var(--cyan-left); }
.stat-card.coral .stat-val { color: var(--coral-right); }
.stat-card.gold .stat-val { color: var(--gold-sync); }
.stat-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}
.stat-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Section Common */
.section-block {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 16px;
  padding: 2.25rem;
  margin-bottom: 3.5rem;
}
.section-header {
  margin-bottom: 1.75rem;
}
.section-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
  color: #ffffff;
}
.section-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Headphone Test Component */
.audio-lab {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 1.75rem;
}
.headphone-alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 209, 102, 0.1);
  border: 1px solid rgba(255, 209, 102, 0.3);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--gold-sync);
  margin-bottom: 1.5rem;
}
.headphone-alert svg {
  flex-shrink: 0;
}

.lab-controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
  .lab-controls-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.control-val-readout {
  font-family: var(--font-mono);
  color: var(--cyan-left);
  font-weight: 700;
}

.sound-type-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-bright);
}
.btn-toggle.active {
  background: var(--cyan-left-dim);
  border-color: var(--cyan-left);
  color: var(--cyan-left);
}

.play-action-area {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}
.btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--gold-sync);
  color: #070b14;
  border: none;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.85rem 1.75rem;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-play:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.4);
}
.btn-play.playing {
  background: #ff4757;
  color: #ffffff;
}

/* Microsecond Slider */
.slider-container {
  margin: 1.5rem 0;
  background: #090e1b;
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 1.5rem;
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}
.label-left { color: var(--cyan-left); }
.label-center { color: var(--gold-sync); }
.label-right { color: var(--coral-right); }

.range-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cyan-left) 0%, var(--gold-sync) 50%, var(--coral-right) 100%);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--bg-abyss);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: transform 0.1s;
}
.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.range-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--bg-abyss);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

/* Preset Buttons */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.btn-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.btn-preset:hover {
  border-color: var(--border-bright);
  color: var(--text-main);
  background: var(--bg-card-hover);
}
.btn-preset.active {
  border-color: var(--gold-sync);
  color: var(--gold-sync);
  background: var(--gold-sync-dim);
}

/* Head Acoustic Visualization Bar */
.acoustic-head-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #050810;
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 1.25rem 1.75rem;
  margin-top: 1.5rem;
}
.head-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.head-indicator.left { color: var(--cyan-left); }
.head-indicator.right { color: var(--coral-right); }

.cranium-track {
  flex-grow: 1;
  height: 48px;
  margin: 0 1.5rem;
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 24px;
  border: 1px dashed var(--border-dim);
}
.perceived-puck {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-sync);
  box-shadow: 0 0 14px var(--gold-sync);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.05s linear;
}
.perceived-puck svg {
  width: 16px;
  height: 16px;
  fill: #070b14;
}

/* Jeffress Circuit Canvas Section */
.canvas-wrapper {
  position: relative;
  width: 100%;
  background: #050810;
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  overflow: hidden;
  margin: 1.5rem 0;
}
canvas#jeffress-canvas {
  display: block;
  width: 100%;
  height: 380px;
}
.canvas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-dim);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-dot.left { background: var(--cyan-left); box-shadow: 0 0 6px var(--cyan-left); }
.legend-dot.right { background: var(--coral-right); box-shadow: 0 0 6px var(--coral-right); }
.legend-dot.mso { background: var(--gold-sync); box-shadow: 0 0 6px var(--gold-sync); }

/* Calculator Section */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}
@media (min-width: 840px) {
  .calc-grid {
    grid-template-columns: 1.1fr 1fr;
  }
}
.calc-inputs {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.calc-field {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 1.25rem;
}
.calc-field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}
.calc-field-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.calc-field-row input[type="range"] {
  flex-grow: 1;
}
.calc-field-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan-left);
  min-width: 70px;
  text-align: right;
}

.calc-results-card {
  background: #090e1b;
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.calc-results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.calc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-dim);
}
.calc-result-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.calc-result-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.calc-result-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-sync);
}

/* Comparative Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border-dim);
  border-radius: 12px;
}
table.bio-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}
table.bio-table th {
  background: #090e1b;
  color: var(--text-main);
  font-weight: 700;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--border-dim);
}
table.bio-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text-muted);
}
table.bio-table tr:last-child td {
  border-bottom: none;
}
table.bio-table tr:hover td {
  background: var(--bg-card-hover);
  color: var(--text-main);
}
.badge-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  color: var(--text-main);
}

/* Method & References */
.method-note {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-top: 1rem;
}
.method-note p {
  margin-bottom: 1rem;
}
.method-note p:last-child {
  margin-bottom: 0;
}

.ref-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.ref-list li {
  padding-left: 1.25rem;
  position: relative;
}
.ref-list li::before {
  content: "•";
  color: var(--cyan-left);
  position: absolute;
  left: 0;
  font-weight: bold;
}

/* Footer */
footer.site-footer {
  width: 100%;
  border-top: 1px solid var(--border-dim);
  padding: 3rem 0;
  background: #04070d;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
.footer-links {
  display: flex;
  gap: 1.25rem;
}

/* Reduced Motion */
@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;
  }
  .kicker-dot {
    animation: none;
  }
}
