:root {
  color-scheme: dark;
  --bg: #101312;
  --bg-2: #151918;
  --panel: #1c211f;
  --panel-strong: #232927;
  --line: #34403b;
  --line-soft: rgba(177, 205, 191, 0.18);
  --text: #f2f7f2;
  --muted: #aebbb3;
  --muted-2: #7d8c84;
  --cyan: #46d9d0;
  --lime: #b8f071;
  --coral: #ff8a67;
  --amber: #f6cf62;
  --danger: #ff6b7a;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --white-key-width: clamp(44px, 5.2vw, 56px);
  --white-key-height: clamp(166px, 24vw, 205px);
  --black-key-width: calc(var(--white-key-width) * 0.62);
  --black-key-height: calc(var(--white-key-height) * 0.62);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(70, 217, 208, 0.08), transparent 360px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 72px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="checkbox"],
summary {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 30;
  transform: translateY(-140%);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  color: #08100f;
  background: var(--lime);
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  padding: 1.2rem 1rem 0.6rem;
}

.header-inner,
.instrument-shell,
.learn-inner,
.faq-inner {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.brand-line {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-mark {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(70, 217, 208, 0.8);
}

.hero-copy {
  padding: clamp(2.1rem, 7vw, 5.2rem) 0 clamp(1.2rem, 3vw, 2.1rem);
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.6rem;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 11ch;
  margin-bottom: 0.75rem;
  font-size: clamp(3rem, 12vw, 7.2rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
}

.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.primary-action,
.panic-button,
.preset-button {
  border: 0;
  border-radius: var(--radius);
  font-weight: 900;
}

.primary-action {
  min-height: 3.35rem;
  padding: 0.95rem 1.3rem;
  color: #061211;
  background: linear-gradient(135deg, var(--lime), var(--cyan));
  box-shadow: 0 12px 28px rgba(70, 217, 208, 0.22);
}

.primary-action.is-ready {
  background: linear-gradient(135deg, #e5f98c, #7ce7a0);
}

.status-pill {
  display: inline-flex;
  min-height: 3.35rem;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--muted);
  background: rgba(28, 33, 31, 0.82);
}

.status-light {
  width: 0.72rem;
  height: 0.72rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 rgba(70, 217, 208, 0);
}

body.synth-ready .status-light {
  background: var(--lime);
  box-shadow: 0 0 18px rgba(184, 240, 113, 0.65);
}

.support-message,
.unlock-hint {
  margin: 0.9rem 0 0;
  color: var(--amber);
}

.page-main {
  padding-bottom: 4rem;
}

.instrument-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.performance-column,
.control-column {
  min-width: 0;
  display: grid;
  gap: 1rem;
  align-content: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 52%),
    var(--panel);
  box-shadow: var(--shadow);
}

.preset-panel,
.keyboard-panel,
.visualizer-panel,
.controls-panel {
  padding: clamp(1rem, 3vw, 1.35rem);
}

.section-heading {
  margin-bottom: 1rem;
}

.section-heading.compact {
  margin-bottom: 0.75rem;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 3vw, 1.85rem);
  line-height: 1.1;
}

.keyboard-hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.preset-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.preset-button {
  min-height: 3.15rem;
  border: 1px solid var(--line-soft);
  padding: 0.8rem 0.9rem;
  color: var(--text);
  background: var(--panel-strong);
  text-align: left;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease,
    background 150ms ease;
}

.preset-button:hover {
  transform: translateY(-1px);
  border-color: rgba(70, 217, 208, 0.55);
}

.preset-button.is-active {
  border-color: rgba(184, 240, 113, 0.85);
  color: #08100f;
  background: linear-gradient(135deg, var(--lime), #8ae7c6);
}

.keyboard-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.45rem 0.15rem 0.85rem;
  scrollbar-color: var(--cyan) rgba(255, 255, 255, 0.08);
}

.keyboard {
  position: relative;
  width: calc(var(--white-key-width) * 14);
  height: var(--white-key-height);
  touch-action: none;
  user-select: none;
}

.piano-key {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.58);
  border-radius: 0 0 7px 7px;
  padding: 0.45rem 0.2rem;
  transition:
    transform 80ms ease,
    box-shadow 80ms ease,
    background 80ms ease;
  touch-action: none;
}

.piano-key.white {
  z-index: 1;
  width: calc(var(--white-key-width) - 3px);
  height: var(--white-key-height);
  color: #1a211e;
  background: linear-gradient(180deg, #f9fff7, #c7d6cc);
}

.piano-key.black {
  z-index: 3;
  width: var(--black-key-width);
  height: var(--black-key-height);
  color: #ecfff9;
  background: linear-gradient(180deg, #303936, #070908);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.42);
}

.piano-key.is-active {
  transform: translateY(2px);
  box-shadow: 0 0 22px rgba(70, 217, 208, 0.78);
}

.piano-key.white.is-active {
  background: linear-gradient(180deg, #f3ffd7, #6fe5d6);
}

.piano-key.black.is-active {
  background: linear-gradient(180deg, #34534c, #46d9d0);
  color: #061211;
}

.key-note {
  display: block;
  font-size: 0.74rem;
  font-weight: 900;
  pointer-events: none;
}

.key-map {
  display: block;
  margin-top: 0.16rem;
  color: currentColor;
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.72;
  pointer-events: none;
}

.visualizer {
  display: block;
  width: 100%;
  min-height: 190px;
  border: 1px solid rgba(70, 217, 208, 0.18);
  border-radius: var(--radius);
  background: #0d1211;
}

.visualizer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.controls-form {
  display: grid;
  gap: 1rem;
}

.control-group {
  min-width: 0;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
  padding: 1rem 0 0;
}

.control-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.control-group legend {
  margin-bottom: 0.9rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
}

.field-label,
.range-head,
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.75rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
}

.field-label:first-of-type {
  margin-top: 0;
}

.range-head output {
  color: var(--lime);
  font-variant-numeric: tabular-nums;
}

select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 0.75rem;
  color: var(--text);
  background: #121715;
}

input[type="range"] {
  width: 100%;
  height: 2.1rem;
  accent-color: var(--cyan);
}

.switch-row {
  justify-content: flex-start;
  min-height: 2.5rem;
}

.switch-row input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--lime);
}

.mini-graph {
  display: block;
  width: 100%;
  height: 132px;
  margin-top: 0.95rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #0e1312;
}

.mini-graph text {
  fill: var(--muted-2);
  font-size: 0.58rem;
  font-weight: 800;
}

.graph-grid {
  fill: none;
  stroke: rgba(177, 205, 191, 0.14);
  stroke-width: 1;
}

.filter-curve,
.adsr-line {
  fill: none;
  stroke: var(--cyan);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.adsr-fill {
  fill: rgba(184, 240, 113, 0.15);
  stroke: none;
}

.filter-marker {
  stroke: rgba(246, 207, 98, 0.76);
  stroke-dasharray: 4 5;
  stroke-width: 2;
}

.master-group {
  padding-bottom: 0.1rem;
}

.panic-button {
  width: 100%;
  min-height: 3rem;
  margin-top: 0.8rem;
  color: #190709;
  background: linear-gradient(135deg, var(--danger), var(--coral));
}

.learn-section,
.faq-section {
  margin-top: 1rem;
  padding: 2rem 0 0;
}

.learn-inner,
.faq-inner {
  border-top: 1px solid var(--line-soft);
  padding-top: 2rem;
}

.learn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

.learn-grid article,
.faq-list details {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1rem;
  background: rgba(28, 33, 31, 0.72);
}

.learn-grid h3 {
  margin-bottom: 0.45rem;
  font-size: 1.05rem;
}

.learn-grid p,
.faq-list p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.faq-list {
  display: grid;
  gap: 0.65rem;
}

.faq-list summary {
  color: var(--text);
  font-weight: 900;
}

.faq-list p {
  margin-top: 0.7rem;
}

@media (min-width: 760px) {
  .site-header {
    padding-top: 1.5rem;
  }

  .preset-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .controls-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .visual-control,
  .master-group {
    grid-column: 1 / -1;
  }

  .learn-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1080px) {
  .instrument-shell {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
    align-items: start;
  }

  .controls-form {
    grid-template-columns: 1fr;
  }

  .visual-control,
  .master-group {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .header-inner,
  .instrument-shell,
  .learn-inner,
  .faq-inner {
    width: min(100% - 1rem, 1180px);
  }

  .site-header {
    padding-inline: 0.5rem;
  }

  .primary-action,
  .status-pill {
    width: 100%;
    justify-content: center;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }

  .keyboard-hint {
    font-size: 0.82rem;
  }

  .visualizer {
    min-height: 155px;
  }
}

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