:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #171717;
  --panel-2: #242424;
  --line: #5d5a52;
  --text: #f4ead2;
  --muted: #c7baa1;
  --accent: #c7392f;
  --accent-2: #e7d9b9;
  --accent-3: #ef4d3f;
  --metal: #9c9688;
  --black-key: #22262b;
  --white-key: #f7f0d8;
  --wood-dark: #3c1e0f;
  --wood-mid: #6f3d1d;
  --wood-light: #9b6436;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(199, 57, 47, 0.18), transparent 26%),
    linear-gradient(180deg, #141414, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1360px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 48px 18px;
  position: relative;
  background:
    linear-gradient(90deg, var(--wood-dark), var(--wood-mid) 18px, var(--wood-light) 25px, var(--wood-dark) 38px, transparent 38px calc(100% - 38px), var(--wood-dark) calc(100% - 38px), var(--wood-light) calc(100% - 25px), var(--wood-mid) calc(100% - 18px), var(--wood-dark)),
    linear-gradient(180deg, #151515, #080808);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 44px 0 22px rgba(0, 0, 0, 0.18),
    inset -44px 0 22px rgba(0, 0, 0, 0.18),
    0 24px 70px rgba(0, 0, 0, 0.55);
}

.site-back-link {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.site-back-link:hover {
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  padding: 10px 14px 8px;
  background: #0d0d0d;
  border: 1px solid #4f4a41;
  border-radius: 2px;
  box-shadow: inset 0 -4px 0 rgba(199, 57, 47, 0.85);
}

.eyebrow,
.step-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 3.2vw, 3.35rem);
  line-height: 0.94;
  color: #f8ead0;
  font-weight: 900;
}

h2 {
  margin-bottom: 0;
}

.power-button,
.small-button,
.icon-button,
.preset-button {
  border: 1px solid #5a5147;
  background: linear-gradient(180deg, #252525, #101010);
  color: var(--text);
  cursor: pointer;
}

.power-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 3px;
  font-weight: 800;
}

.power-button[aria-pressed="true"] {
  border-color: rgba(199, 57, 47, 0.9);
}

.power-light {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #5b6158;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.power-button[aria-pressed="true"] .power-light {
  background: var(--accent-3);
  box-shadow: 0 0 18px rgba(239, 77, 63, 0.9);
}

.learn-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #171717, #0e0e0e);
  border: 1px solid #4f4a41;
  border-radius: 2px;
  margin-bottom: 8px;
}

.lesson-copy p:last-child {
  color: var(--muted);
  margin: 4px 0 0;
  max-width: 980px;
  line-height: 1.35;
  font-size: 0.9rem;
}

.lesson-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 3px;
  font-size: 1.8rem;
  line-height: 1;
}

.signal-flow {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr auto 1fr auto;
  align-items: center;
  gap: 6px;
  margin: 6px 0 8px;
}

.flow-node {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 26px;
  border: 1px solid #585047;
  border-radius: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.flow-node.active {
  color: #fff2d5;
  border-color: var(--accent);
  background: var(--accent);
}

.flow-line {
  height: 2px;
  background: var(--line);
}

.workspace {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
  align-items: start;
}

.preset-panel,
.module {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 20%),
    linear-gradient(180deg, var(--panel-2), #101010 44%, var(--panel));
  border: 1px solid #5a5147;
  border-radius: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -3px 0 rgba(199, 57, 47, 0.4),
    inset 0 -18px 32px rgba(0, 0, 0, 0.28),
    0 16px 42px rgba(0, 0, 0, 0.24);
}

.preset-panel {
  padding: 10px;
  position: sticky;
  top: 16px;
}

.preset-panel h2 {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.preset-button {
  min-height: 32px;
  padding: 0 8px;
  border-radius: 3px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.preset-button.active {
  color: #fff0d0;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 14px rgba(199, 57, 47, 0.25);
}

.tip-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tip-box h3 {
  margin-bottom: 5px;
  color: var(--accent);
}

.tip-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
  font-size: 0.78rem;
}

.synth-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(112px, 1fr));
  gap: 8px;
}

.module {
  padding: 10px;
  min-width: 0;
}

.module-wide {
  grid-column: span 4;
}

.module-filter {
  grid-column: span 2;
}

.module-envelope,
.module-lfo,
.module-effects,
.visualizer {
  grid-column: span 2;
}

.module-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(231, 217, 185, 0.28);
}

.module-header h2 {
  font-size: 0.98rem;
  color: #fff0d3;
  text-transform: uppercase;
}

.module-header span {
  color: var(--muted);
  font-size: 0.74rem;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 6px;
  align-items: start;
}

.control {
  display: grid;
  gap: 5px;
}

.control:not(.knob-control):not(.selector-control) {
  align-content: start;
}

.control span {
  color: #f1dfbb;
  font-size: 0.72rem;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 56px;
  padding: 0 10px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, #292a24, #171813);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.selector-control {
  justify-items: center;
  align-content: start;
  min-height: 108px;
  padding: 7px 6px 6px;
  border: 1px solid rgba(231, 217, 185, 0.18);
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(0, 0, 0, 0.18));
}

.selector-control > span {
  color: #f1dfbb;
  text-transform: uppercase;
}

.selector-control select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.selector-value {
  display: grid;
  place-items: center;
  min-width: 84px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 2px;
  color: #fff0d0;
  background: linear-gradient(180deg, #b33a32, #6e1f1b);
  border: 1px solid #d4675a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 6px rgba(0, 0, 0, 0.35);
  font-size: 0.72rem;
  font-weight: 900;
}

.module > .knob-control {
  display: inline-grid;
  width: calc(50% - 8px);
  margin: 0 8px 8px 0;
  vertical-align: top;
}

.module > .knob-control:nth-of-type(even) {
  margin-right: 0;
}

.knob-control {
  justify-items: center;
  align-content: start;
  min-height: 108px;
  padding: 7px 6px 6px;
  border: 1px solid rgba(231, 217, 185, 0.18);
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(0, 0, 0, 0.08));
}

.knob-control > span {
  color: #f1dfbb;
  text-transform: uppercase;
}

.knob-control input[type="range"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.knob-shell {
  --angle: -135deg;
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  outline: none;
  border: 0;
  padding: 0;
  background: transparent;
}

.knob-shell:active {
  cursor: grabbing;
}

.knob-shell:focus-visible .knob-face {
  box-shadow:
    0 0 0 3px rgba(199, 57, 47, 0.35),
    inset 8px 12px 18px rgba(255, 255, 255, 0.08),
    inset -10px -16px 22px rgba(0, 0, 0, 0.42),
    0 13px 22px rgba(0, 0, 0, 0.32);
}

.knob-ticks {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 225deg, var(--accent) 0deg, var(--accent) var(--meter, 0deg), rgba(231, 217, 185, 0.2) var(--meter, 0deg), rgba(231, 217, 185, 0.2) 270deg, transparent 270deg);
  mask: radial-gradient(circle, transparent 58%, #000 60%, #000 66%, transparent 68%);
}

.selector-control .knob-ticks {
  background:
    conic-gradient(from 225deg, rgba(231, 217, 185, 0.22) 0deg, rgba(231, 217, 185, 0.22) 270deg, transparent 270deg);
}

.selector-control .knob-face::before {
  background: var(--accent-3);
  box-shadow: 0 0 8px rgba(239, 77, 63, 0.55);
}

.knob-face {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.22), transparent 24%),
    linear-gradient(145deg, #5f5f59, #1b1b1b 54%, #050505);
  border: 1px solid #0e0f0c;
  box-shadow:
    inset 8px 12px 18px rgba(255, 255, 255, 0.08),
    inset -10px -16px 22px rgba(0, 0, 0, 0.42),
    0 13px 22px rgba(0, 0, 0, 0.32);
  transform: rotate(var(--angle));
}

.knob-face::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 4px;
  height: 15px;
  border-radius: 999px;
  background: #f6ead0;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(246, 234, 208, 0.45);
}

.knob-face::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.knob-control output {
  display: grid;
  place-items: center;
  min-width: 76px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 2px;
  color: #fff0d0;
  background: linear-gradient(180deg, #b33a32, #6e1f1b);
  border: 1px solid #d4675a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 6px rgba(0, 0, 0, 0.35);
  font-size: 0.7rem;
  font-weight: 900;
}

output {
  color: var(--text);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

canvas {
  width: 100%;
  height: 82px;
  display: block;
  background: #11140f;
  border: 1px solid #30392e;
  border-radius: 2px;
}

.waveform-icon {
  width: 78px;
  height: 24px;
  background: #10130f;
  border: 1px solid #30392e;
  border-radius: 2px;
}

.filter-curve {
  display: block;
  width: 100%;
  height: 58px;
  margin-bottom: 7px;
  border: 1px solid #30392e;
  border-radius: 2px;
  background: #10130f;
}

.filter-curve rect {
  fill: #10130f;
}

.filter-curve path {
  fill: none;
  stroke: #f1dfbb;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.filter-curve line {
  stroke: rgba(239, 77, 63, 0.82);
  stroke-width: 2;
}

.keyboard-section {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 28%),
    linear-gradient(180deg, #222, #0f0f0f);
  border: 1px solid #5a5147;
  border-radius: 2px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

.keyboard-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.keyboard-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.small-button {
  min-height: 28px;
  padding: 0 12px;
  border-radius: 3px;
}

.keyboard-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.danger-button {
  border-color: rgba(239, 77, 63, 0.75);
  background: linear-gradient(180deg, #8e2b25, #4a1714);
  color: #ffd7c9;
  font-weight: 900;
}

.danger-button:active {
  background: var(--accent-3);
  color: #fff0d0;
}

.small-button[aria-pressed="true"] {
  color: #fff0d0;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 900;
}

.keyboard {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  min-height: 105px;
}

.key {
  position: relative;
  border: 1px solid #b4aa89;
  background: var(--white-key);
  color: #171813;
  border-radius: 0 0 2px 2px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  font-weight: 900;
}

.key.black {
  position: absolute;
  z-index: 2;
  top: 0;
  width: 8.5%;
  height: 62%;
  background: var(--black-key);
  border-color: #0f1114;
  color: #f5eecf;
  border-radius: 0 0 2px 2px;
}

.key.active {
  background: #f1dfbb;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.16);
}

.key.black.active {
  background: var(--accent-3);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .synth-panel {
    grid-template-columns: repeat(4, minmax(104px, 1fr));
  }

  .module-wide {
    grid-column: 1 / -1;
  }

  .module-filter,
  .module-envelope,
  .module-lfo,
  .module-effects,
  .visualizer {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .workspace,
  .synth-panel {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(104px, 1fr));
  }

  .module > .knob-control {
    width: calc(50% - 8px);
  }

  .preset-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1260px);
    padding: 16px 12px;
  }

  .topbar,
  .learn-panel,
  .keyboard-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .signal-flow {
    grid-template-columns: 1fr;
  }

  .flow-line {
    height: 10px;
    width: 2px;
    justify-self: center;
  }

  .keyboard {
    min-height: 92px;
  }

  .key {
    font-size: 0.78rem;
    padding-bottom: 10px;
  }
}
