@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/onest-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #96a0b8;
  --bg: #080911;
  --panel: rgba(17, 20, 32, 0.92);
  --panel-strong: rgba(25, 29, 45, 0.96);
  --line: rgba(159, 187, 255, 0.22);
  --cyan: #2de2ff;
  --pink: #ff2f92;
  --amber: #ffd166;
  --green: #6ef3a5;
  --red: #ff5d6c;
  --violet: #9876ff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Onest", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(45, 226, 255, 0.08), transparent 28%, rgba(255, 47, 146, 0.08) 72%, transparent),
    linear-gradient(180deg, #0c0d18 0%, #090a12 54%, #130b18 100%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.grid-floor {
  position: fixed;
  inset: 48vh -12vw -14vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.34;
  transform: perspective(460px) rotateX(62deg);
  transform-origin: center top;
  background-image:
    linear-gradient(rgba(45, 226, 255, 0.32) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 47, 146, 0.3) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, transparent 0%, black 16%, black 70%, transparent 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar,
.status-line,
.module {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  padding: 14px 18px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: baseline;
  min-width: max-content;
}

.brand-mark {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.brand-main {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(45, 226, 255, 0.45);
}

.brand-suffix {
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 47, 146, 0.45);
}

.transport {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.tab-button,
.mini-button,
.sample-button span {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(244, 247, 251, 0.18);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.button:hover,
.tab-button:hover,
.mini-button:hover,
.sample-button:hover span {
  border-color: var(--cyan);
  color: #071018;
  background: var(--cyan);
}

.button.primary {
  border-color: rgba(110, 243, 165, 0.8);
  color: #06120c;
  background: var(--green);
}

.button.recording,
.button.armed.active {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
  box-shadow: 0 0 18px rgba(255, 93, 108, 0.3);
}

.button.playing {
  border-color: var(--amber);
  color: #171000;
  background: var(--amber);
}

.button.danger:hover {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.mini-button.danger:hover {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.55fr);
  gap: 14px;
  margin-top: 14px;
}

.module {
  border-radius: 8px;
  padding: 16px;
}

.synth-module {
  min-width: 0;
}

.mix-module {
  min-width: 0;
}

.drums-module,
.sequencer-module {
  grid-column: 1 / -1;
}

.module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.module-head.compact {
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.1;
}

.select {
  min-height: 38px;
  max-width: 100%;
  border: 1px solid rgba(244, 247, 251, 0.2);
  border-radius: 6px;
  color: var(--ink);
  background: #111522;
  padding: 0 34px 0 10px;
}

.scope {
  display: block;
  width: 100%;
  height: clamp(130px, 18vw, 220px);
  border: 1px solid rgba(45, 226, 255, 0.22);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(45, 226, 255, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(45, 226, 255, 0.06) 1px, transparent 1px),
    #070a10;
  background-size: 40px 40px;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.control-stack {
  display: grid;
  gap: 12px;
}

.control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.control span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.control output {
  color: var(--ink);
}

.control .select {
  width: 100%;
}

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

.piano {
  position: relative;
  width: 100%;
  height: clamp(170px, 20vw, 240px);
  user-select: none;
  touch-action: none;
}

.piano-key {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 3px 10px;
  border: 1px solid rgba(8, 9, 17, 0.75);
  border-radius: 0 0 5px 5px;
  font-size: clamp(0.6rem, 1.2vw, 0.78rem);
  font-weight: 900;
  text-transform: uppercase;
  transition: transform 80ms ease, box-shadow 80ms ease, background 80ms ease;
}

.piano-key.white {
  z-index: 1;
  height: 100%;
  color: #111522;
  background: linear-gradient(180deg, #ffffff 0%, #cfd7e6 100%);
}

.piano-key.black {
  z-index: 2;
  height: 63%;
  color: var(--ink);
  background: linear-gradient(180deg, #161827 0%, #04050a 100%);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.42);
}

.piano-key.active {
  transform: translateY(3px);
  box-shadow: 0 0 24px rgba(45, 226, 255, 0.55);
  background: var(--cyan);
  color: #051016;
}

.status-badge {
  min-width: 64px;
  padding: 7px 9px;
  border: 1px solid rgba(110, 243, 165, 0.45);
  border-radius: 6px;
  color: var(--green);
  text-align: center;
  font-size: 0.74rem;
  font-weight: 900;
}

.meter-strip {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  height: 82px;
  align-items: end;
  margin-top: 16px;
  padding: 10px;
  border: 1px solid rgba(244, 247, 251, 0.12);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.meter-strip span {
  display: block;
  min-height: 8px;
  border-radius: 3px 3px 0 0;
  background: var(--green);
  transform-origin: bottom;
}

.meter-strip span:nth-child(3n + 1) {
  background: var(--cyan);
}

.meter-strip span:nth-child(4n) {
  background: var(--pink);
}

.download-link {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--amber);
  border-radius: 6px;
  color: #110d00;
  background: var(--amber);
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.sample-button {
  display: inline-flex;
}

.sample-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sample-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drum-pads {
  display: grid;
  grid-template-columns: repeat(8, minmax(104px, 1fr));
  gap: 10px;
}

.drum-pad {
  min-height: 82px;
  border: 1px solid rgba(244, 247, 251, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(45, 226, 255, 0.08), rgba(255, 47, 146, 0.08)),
    var(--panel-strong);
  text-align: left;
  padding: 11px;
}

.drum-pad strong,
.drum-pad span {
  display: block;
}

.drum-pad strong {
  font-size: 0.96rem;
  line-height: 1.15;
}

.drum-pad span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.drum-pad.active {
  border-color: var(--amber);
  background: var(--amber);
  color: #120e00;
}

.drum-pad.sampled span {
  color: var(--green);
}

.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-button.active {
  border-color: var(--pink);
  color: #fff;
  background: var(--pink);
}

.melody-trackbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  margin: -2px 0 12px;
}

.melody-trackbar[hidden] {
  display: none;
}

.melody-tabs,
.melody-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.melody-tabs {
  min-width: 0;
}

.melody-tab-item {
  display: grid;
  grid-template-columns: minmax(104px, 1fr) 54px;
  min-height: 46px;
  border: 1px solid rgba(244, 247, 251, 0.18);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
}

.melody-tab-item.active {
  border-color: var(--pink);
  background: rgba(255, 47, 146, 0.22);
  box-shadow: inset 0 -3px 0 var(--pink);
}

.melody-tab-item.muted {
  opacity: 0.62;
}

.melody-tab {
  min-height: 46px;
  padding: 7px 10px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.melody-tab strong,
.melody-tab span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.melody-tab strong {
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.melody-tab span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.melody-tab-mute {
  min-height: 46px;
  border: 0;
  border-left: 1px solid rgba(244, 247, 251, 0.14);
  color: #050b08;
  background: var(--green);
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.melody-tab-mute:not(.active) {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.mini-button.active {
  border-color: var(--amber);
  color: #171000;
  background: var(--amber);
}

.element-editor {
  position: fixed;
  z-index: 20;
  display: grid;
  width: min(320px, calc(100vw - 18px));
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 209, 102, 0.42);
  border-radius: 8px;
  background: rgba(12, 14, 24, 0.98);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.48), 0 0 22px rgba(255, 209, 102, 0.12);
  backdrop-filter: blur(18px);
}

.element-editor[hidden] {
  display: none;
}

.element-summary h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.15;
}

.element-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: end;
}

.element-controls .control[hidden] {
  display: none;
}

.sequencer {
  display: none;
  overflow: auto;
  max-height: none;
  padding-bottom: 6px;
}

.sequencer.active {
  display: block;
}

.step-grid {
  display: grid;
  gap: 4px;
  min-width: max-content;
}

.step-label,
.step-cell,
.step-number {
  min-width: 30px;
  height: 28px;
  border-radius: 4px;
}

.step-label {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 108px;
  padding: 0 8px;
  color: var(--muted);
  background: #111522;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.step-label.muted {
  opacity: 0.58;
}

.drum-row-label,
.melody-row-label {
  cursor: pointer;
  padding-right: 4px;
}

.drum-row-label.selected-row,
.melody-row-label.selected-row {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
  color: var(--ink);
  background: rgba(255, 209, 102, 0.14);
}

.drum-row-label.selected-row.muted,
.melody-row-label.selected-row.muted {
  opacity: 0.78;
}

.drum-row-label.editing-row,
.melody-row-label.editing-row {
  box-shadow: inset 0 0 0 2px rgba(45, 226, 255, 0.55);
}

.drum-row-label > span,
.melody-row-label > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drum-row-mute,
.melody-row-mute {
  flex: 0 0 auto;
  min-width: 34px;
  height: 20px;
  border: 0;
  border-radius: 4px;
  color: #050b08;
  background: var(--green);
  font-size: 0.56rem;
  font-weight: 900;
  text-transform: uppercase;
}

.drum-row-mute:not(.active),
.melody-row-mute:not(.active) {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}

.step-number {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  font-weight: 900;
}

.step-cell {
  border: 1px solid rgba(244, 247, 251, 0.13);
  background: rgba(255, 255, 255, 0.045);
}

.step-cell:hover {
  border-color: var(--cyan);
}

.step-cell.on {
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(45, 226, 255, 0.28);
}

.step-cell.note-on {
  border-color: var(--pink);
  background: var(--pink);
  box-shadow: 0 0 14px rgba(255, 47, 146, 0.28);
}

.step-cell.tweaked {
  box-shadow: inset 0 0 0 2px rgba(255, 209, 102, 0.72);
}

.step-cell.selected {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.step-cell.playhead,
.step-number.playhead {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.step-cell.downbeat {
  border-color: rgba(255, 209, 102, 0.42);
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

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

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

  .element-editor {
    width: min(320px, calc(100vw - 18px));
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100vw - 16px, 1500px);
    padding-top: 8px;
  }

  .topbar,
  .module-head {
    align-items: stretch;
    flex-direction: column;
  }

  .transport {
    justify-content: flex-start;
  }

  .button,
  .tab-button,
  .mini-button,
  .sample-button span {
    flex: 1 1 auto;
  }

  .melody-trackbar {
    flex-direction: column;
  }

  .macro-grid,
  .drum-pads {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-label {
    width: 86px;
  }
}
