:root {
  --bg-primary: #0e1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: rgba(22, 27, 34, 0.85);
  --border-subtle: rgba(212, 175, 55, 0.18);
  --border-strong: rgba(212, 175, 55, 0.4);
  --text-primary: #f0f3f6;
  --text-secondary: #c0c6d0;
  --text-muted: #8b949e;
  --brass-primary: #d4af37;
  --brass-glow: rgba(212, 175, 55, 0.25);
  --brass-light: #f3e5ab;
  --brass-dark: #997a15;
  --copper: #d97736;
  --accent-cyan: #38bdf8;
  --accent-emerald: #34d399;
  --accent-rose: #f43f5e;
  --font-serif: "Newsreader", "Charter", "Iowan Old Style", "Bitstream Charter", "Georgia", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Roboto Mono", Menlo, Consolas, monospace;
}

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

html {
  font-size: 18px;
  line-height: 1.65;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-serif);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #1c212c 0%, var(--bg-primary) 70%);
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--brass-primary);
  color: #000;
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  z-index: 100;
  transition: top 0.2s ease;
  text-decoration: none;
  border-radius: 4px;
}
.skip-link:focus {
  top: 1rem;
}

header.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(14, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.author-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s ease;
}
.author-link:hover, .author-link:focus-visible {
  color: var(--brass-primary);
}

.lang-switch {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  padding: 0.2rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.lang-btn {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: all 0.15s ease;
}
.lang-btn.active {
  background: var(--brass-primary);
  color: #0d1117;
}
.lang-btn:not(.active):hover {
  color: var(--text-primary);
}

main {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
  flex: 1;
}

/* Editorial Title & Lead */
.hero {
  margin-bottom: 3.5rem;
}

.eyebrow {
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--brass-primary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

h1.title {
  font-size: 2.75rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.lead {
  font-size: 1.28rem;
  line-height: 1.6;
  color: var(--text-secondary);
  font-style: normal;
  border-left: 2px solid var(--brass-primary);
  padding-left: 1.25rem;
  margin-top: 1.5rem;
}

/* Key Stat Callout */
.stat-banner {
  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-subtle);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brass-primary), transparent);
}

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

.stat-label {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Section Prose */
article section {
  margin: 3.5rem 0;
}

h2.section-title {
  font-size: 1.85rem;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3.sub-title {
  font-size: 1.3rem;
  line-height: 1.35;
  color: var(--brass-light);
  margin: 2rem 0 0.85rem;
  font-weight: 600;
}

p {
  margin-bottom: 1.35rem;
  color: var(--text-secondary);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Interactive Instruments */
.instrument-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 1.75rem;
  margin: 2.5rem 0;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

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

.instrument-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brass-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.instrument-subtitle {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Audio Synthesizer Controls */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 680px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
}

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

.control-label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brass-primary);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-choice {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1;
  min-width: 110px;
  text-align: center;
}
.btn-choice:hover {
  background: rgba(212, 175, 55, 0.15);
  color: var(--text-primary);
  border-color: var(--brass-primary);
}
.btn-choice.active {
  background: var(--brass-primary);
  color: #0d1117;
  font-weight: 700;
  border-color: var(--brass-light);
  box-shadow: 0 0 12px var(--brass-glow);
}

/* Play button */
.play-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
  gap: 1rem;
}

.btn-play {
  background: linear-gradient(135deg, var(--brass-primary), #b38f20);
  color: #0d1117;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn-play:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-play:active {
  transform: translateY(1px);
}
.btn-play.playing {
  background: linear-gradient(135deg, var(--accent-rose), #be123c);
  color: #fff;
}

.audio-status {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Oscilloscope / Waveform canvas */
.scope-wrapper {
  background: #080a0e;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 1.25rem 0;
  position: relative;
}

canvas#scope-canvas {
  width: 100%;
  height: 160px;
  display: block;
}

.scope-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding: 0 0.25rem;
}

.beat-rate-display {
  color: var(--accent-rose);
  font-weight: 700;
}
.beat-rate-display.pure {
  color: var(--accent-emerald);
}

/* Spiral SVG Explorer */
.spiral-wrapper {
  width: 100%;
  background: #080a0e;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow: hidden;
  position: relative;
}

svg#spiral-svg {
  width: 100%;
  height: auto;
  max-height: 480px;
  display: block;
}

.spiral-info-panel {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.85rem 1.15rem;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.info-item span.lbl {
  color: var(--text-muted);
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  font-family: var(--font-sans);
}
.info-item span.val {
  color: var(--brass-light);
  font-weight: 600;
  font-size: 0.95rem;
}

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

table.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  text-align: left;
}

table.comparison-table th {
  background: var(--bg-tertiary);
  color: var(--brass-light);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.comparison-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-feature-settings: "tnum";
}

table.comparison-table tr:hover td {
  background: rgba(212, 175, 55, 0.04);
  color: var(--text-primary);
}

table.comparison-table td.num {
  font-family: var(--font-mono);
  text-align: right;
}

table.comparison-table tr.highlight td {
  background: rgba(212, 175, 55, 0.08);
  font-weight: 600;
  color: var(--brass-light);
}

/* Method and Sources Section */
.method-box {
  background: rgba(22, 27, 34, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
}

.method-box h3 {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--brass-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.method-box p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}
.method-box p:last-child {
  margin-bottom: 0;
}

/* Footer */
footer.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  padding: 3rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
}

.footer-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.footer-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}
.footer-nav a:hover, .footer-nav a:focus-visible {
  color: var(--brass-primary);
}

.back-to-top {
  margin-left: auto;
  color: var(--brass-primary);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.footer-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .btn-play, .btn-choice, .skip-link {
    transition: none !important;
  }
}

/* Mobile responsiveness */
@media (max-width: 540px) {
  html {
    font-size: 16px;
  }
  h1.title {
    font-size: 2.1rem;
  }
  .lead {
    font-size: 1.15rem;
  }
  main {
    padding: 2rem 1rem 4rem;
  }
  .instrument-container {
    padding: 1.15rem;
  }
  .stat-banner {
    grid-template-columns: 1fr;
  }
}
