:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --panel2: #15171a;
  --text: #f5f6f7;
  --dim: #9aa3b2;
  --muted: #6b7280;
  --border: #2a2a2a;
  --line: #1e1e1e;
  --accent: #c7d2fe;
  --accent2: #e0e7ff;
  --shadow: rgba(0, 0, 0, 0.35);
  --good: #34d399;
  --bad: #fb7185;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

html, body { min-height: 100%; }
html { scrollbar-gutter: stable both-edges; overflow-y: scroll; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.45;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 18px 54px;
}

/* Skip link */
.skip-link {
  position: absolute; left: 12px; top: 10px;
  padding: 0.5rem 0.7rem; border-radius: 0.3rem;
  border: 2px solid var(--border); background: var(--panel); color: var(--text);
  transform: translateY(-140%); transition: transform 0.15s ease; z-index: 20000;
}
.skip-link:focus { transform: translateY(0); }

/* Header */
.site-header {
  display: flex; flex-direction: column; gap: 0.65rem;
  padding-top: calc(3.2rem + env(safe-area-inset-top, 0px));
}
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9000; padding-top: env(safe-area-inset-top, 0px);
  background: rgba(12, 13, 15, 0.85); backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--border);
}
.topbar-content {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 18px; gap: 1rem;
}
.brand {
  font-family: var(--mono); font-size: 1.1rem; font-weight: 800;
  color: var(--accent); white-space: nowrap;
}

/* Intro */
.intro { margin-bottom: 1.5rem; }
.intro-title {
  font-size: 1.6rem; font-weight: 800; margin: 0 0 0.4rem;
  color: var(--text);
}
.intro-subtitle {
  font-size: 0.95rem; color: var(--dim); margin: 0;
  max-width: 640px; line-height: 1.5;
}

/* Sections */
.section-card {
  background: var(--panel); border: 2px solid var(--border);
  border-radius: 0.35rem; padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.section-heading {
  font-size: 1.15rem; font-weight: 650; margin: 0 0 0.3rem;
  color: var(--accent);
}
.section-desc {
  font-size: 0.88rem; color: var(--dim); margin: 0 0 1rem;
  line-height: 1.55;
}
.section-desc strong { color: var(--text); font-weight: 600; }

/* Wave Visualizer */
.wave-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-bottom: 1rem;
}
.wave-panel {
  display: flex; flex-direction: column; gap: 0.35rem;
}
.wave-label {
  font-size: 0.78rem; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.wave-canvas {
  width: 100%; height: auto; aspect-ratio: 10 / 3;
  background: #0a0b0d; border-radius: 0.3rem;
  border: 2px solid var(--line);
}

/* Wave Controls */
.wave-controls {
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem;
  align-items: flex-end;
}
.control-group {
  display: flex; flex-direction: column; gap: 0.25rem;
  min-width: 140px; flex: 1;
}
.control-group label, .control-group legend {
  font-size: 0.78rem; font-weight: 600; color: var(--dim);
  margin: 0; padding: 0; border: 0;
}
.control-value {
  font-size: 0.78rem; color: var(--accent); font-family: var(--mono);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--border); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
  cursor: pointer;
}

/* Mod type radio group */
.mod-type-group {
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem;
}
.mod-type-group legend { flex-basis: 100%; }
.radio-label {
  font-size: 0.85rem; color: var(--text); cursor: pointer;
  display: flex; align-items: center; gap: 0.3rem;
}
.radio-label input[type="radio"] {
  accent-color: var(--accent);
}

/* Audio toggle */
.audio-btn {
  background: var(--panel2); border: 2px solid var(--border);
  color: var(--dim); border-radius: 0.3rem;
  padding: 0.45rem 1rem; font-size: 0.82rem; cursor: pointer;
  font-family: var(--sans); transition: color 0.15s, border-color 0.15s;
  align-self: flex-end;
}
.audio-btn:hover { color: var(--text); border-color: var(--accent); }
.audio-btn.active { color: var(--accent); border-color: var(--accent); }

/* Sound nudge tooltip */
.audio-btn-wrap {
  position: relative; align-self: flex-end;
  margin-top: 0.5rem;
}
.sound-nudge {
  position: absolute;
  top: 50%;
  right: calc(100% + 12px);
  transform: translateY(-50%);
  white-space: nowrap;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(199, 210, 254, 0.95), rgba(165, 180, 252, 0.92));
  color: #1a1a2e;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(165, 180, 252, 0.25);
  animation: nudge-float 2s ease-in-out infinite;
  pointer-events: none;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.sound-nudge.hidden {
  opacity: 0;
  pointer-events: none;
}
.sound-nudge::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.4rem;
  width: 0.7rem;
  height: 0.7rem;
  background: rgba(175, 190, 252, 0.93);
  transform: translateY(-50%) rotate(45deg);
  border-radius: 1px;
}

@keyframes nudge-float {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(-4px); }
}

/* Spectrum Map */
.spectrum-wrap { margin-bottom: 0.75rem; }
.spectrum-canvas {
  width: 100%; height: auto; aspect-ratio: 9 / 1;
  background: #0a0b0d; border-radius: 0.3rem;
  border: 2px solid var(--line); cursor: pointer;
}
.spectrum-legend {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1rem;
  margin-top: 0.6rem; font-size: 0.75rem;
}
.legend-item {
  display: flex; align-items: center; gap: 0.3rem; color: var(--dim);
}
.legend-swatch {
  width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
}

/* Spectrum detail panel */
.spectrum-detail {
  background: var(--panel2); border: 2px solid var(--border);
  border-radius: 0.3rem; padding: 1.25rem 1.5rem; margin-top: 0.75rem;
}
.spectrum-detail[hidden] { display: none; }
.detail-title {
  font-size: 1.05rem; font-weight: 650; color: var(--accent);
  margin: 0.5rem 0 0.25rem;
}
.detail-range {
  font-size: 0.82rem; font-family: var(--mono); color: var(--dim);
  margin: 0 0 0.5rem;
}
.detail-desc {
  font-size: 0.88rem; color: var(--text); margin: 0 0 0.5rem;
  line-height: 1.55;
}
.detail-fun {
  font-size: 0.82rem; color: var(--dim); font-style: italic;
  margin: 0;
}
.btn-sm {
  font-size: 0.78rem; padding: 0.3rem 0.75rem;
  background: var(--panel); border: 2px solid var(--border);
  color: var(--dim); border-radius: 0.2rem; cursor: pointer;
  font-family: var(--sans);
}
.btn-sm:hover { color: var(--text); border-color: var(--accent); }

/* Timeline */
.timeline-strip {
  display: flex; gap: 1rem; overflow-x: auto;
  scroll-snap-type: x mandatory; padding: 0.5rem 0 1rem;
  -webkit-overflow-scrolling: touch;
}
.timeline-strip::-webkit-scrollbar { height: 6px; }
.timeline-strip::-webkit-scrollbar-track { background: var(--panel2); border-radius: 3px; }
.timeline-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.timeline-card {
  flex: 0 0 260px; scroll-snap-align: start;
  background: var(--panel2); border: 2px solid var(--border);
  border-radius: 0.3rem; padding: 1rem 1.1rem;
  transition: border-color 0.25s;
}
.timeline-card.active {
  border-color: var(--accent);
}
.timeline-year {
  font-size: 1.3rem; font-weight: 800; color: var(--accent);
  font-family: var(--mono); margin: 0 0 0.2rem;
}
.timeline-title {
  font-size: 0.92rem; font-weight: 650; color: var(--text);
  margin: 0 0 0.4rem;
}
.timeline-blurb {
  font-size: 0.8rem; color: var(--dim); line-height: 1.5;
  margin: 0;
}

/* Community Bridge */
.community-content { min-height: 80px; }
.community-card {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.community-info { flex: 1; min-width: 180px; }
.community-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  margin: 0 0 0.2rem;
}
.community-artist {
  font-size: 0.82rem; color: var(--dim); margin: 0 0 0.5rem;
}
.community-link {
  font-size: 0.82rem;
}
.community-wave-wrap {
  flex: 0 0 280px; display: flex; flex-direction: column;
  align-items: center; gap: 0.4rem;
}
.community-canvas {
  width: 280px; height: 60px;
  background: #0a0b0d; border-radius: 0.2rem;
  border: 2px solid var(--line);
}
.community-play {
  background: var(--panel); border: 2px solid var(--border);
  color: var(--dim); border-radius: 0.2rem;
  padding: 0.35rem 1rem; font-size: 0.8rem; cursor: pointer;
  font-family: var(--sans); transition: color 0.15s, border-color 0.15s;
}
.community-play:hover { color: var(--text); border-color: var(--accent); }
.community-play.playing { color: var(--accent); border-color: var(--accent); }

.dim { color: var(--dim); }

/* Footer */
.fineprint {
  margin-top: 2rem; padding-top: 1rem;
  border-top: 2px solid var(--line);
  font-size: 0.78rem; color: var(--muted);
  text-align: center;
}

/* Highlighted spectrum bands */
.spectrum-canvas.highlighting { /* handled in JS via canvas overlay */ }

/* Responsive */
@media (max-width: 720px) {
  .wrap { padding: 14px 14px 40px; }
  .topbar-content { padding: 0.55rem 14px; }
  .intro-title { font-size: 1.3rem; }
  .section-card { padding: 1rem 1.1rem; }
  .wave-grid { grid-template-columns: 1fr; }
  .wave-controls { flex-direction: column; }
  .control-group { min-width: unset; }
  .timeline-card { flex: 0 0 220px; }
  .community-wave-wrap { flex: 1 1 100%; }
  .community-canvas { width: 100%; }
}

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