:root {
  color-scheme: dark;
  --bg: #101114;
  --bg-deep: #08090b;
  --panel: #181b20;
  --panel-strong: #20242b;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f3ec;
  --muted: #a9abb5;
  --quiet: #777b87;
  --mint: #58f0c0;
  --cyan: #63c7ff;
  --amber: #ffc65a;
  --coral: #ff6f61;
  --pink: #ff7bbd;
  --green: #92e072;
  --shadow: rgba(0, 0, 0, 0.38);
  --radius: 8px;
  --track-label: 128px;
  --step-size: 42px;
  --row-size: 38px;
  --focus: 0 0 0 3px rgba(99, 199, 255, 0.38);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(88, 240, 192, 0.045) 0 1px, transparent 1px 18px),
    linear-gradient(225deg, rgba(255, 198, 90, 0.035) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, #15161a 0%, var(--bg) 38%, var(--bg-deep) 100%);
  color: var(--text);
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.grid-scroll:focus-visible,
.skip-link:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  transform: translateY(-160%);
  border-radius: var(--radius);
  background: var(--mint);
  color: #06110d;
  padding: 0.7rem 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

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

.site-header,
.tool-section,
.content-section,
.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: end;
  padding: 34px 0 18px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.45rem;
  color: var(--mint);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0.4rem;
  font-size: clamp(2.35rem, 6vw, 5rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.subtitle {
  max-width: 640px;
  margin-bottom: 0.35rem;
  color: #f0eae0;
  font-size: clamp(1.05rem, 2vw, 1.38rem);
}

.trust-line {
  margin-bottom: 0;
  color: var(--muted);
}

.header-actions {
  display: grid;
  gap: 0.75rem;
  min-width: 260px;
}

.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #23272f;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
  user-select: none;
  touch-action: manipulation;
}

.button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: #2b303a;
}

.button:active {
  transform: translateY(0);
}

.button[disabled] {
  cursor: wait;
  opacity: 0.65;
}

.button-primary {
  min-height: 52px;
  border-color: rgba(88, 240, 192, 0.55);
  background: linear-gradient(135deg, var(--mint), #b4ff7d);
  color: #06110d;
  box-shadow: 0 18px 48px rgba(88, 240, 192, 0.18);
}

.button-play {
  border-color: rgba(99, 199, 255, 0.45);
  background: linear-gradient(135deg, #1e4352, #286f60);
}

.button-danger {
  border-color: rgba(255, 111, 97, 0.48);
  color: #ffe8e5;
}

.status-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 27, 32, 0.78);
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  box-shadow: 0 14px 42px var(--shadow);
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 99px;
  background: var(--amber);
  box-shadow: 0 0 18px rgba(255, 198, 90, 0.65);
}

body.is-playing .status-dot {
  background: var(--mint);
  box-shadow: 0 0 20px rgba(88, 240, 192, 0.75);
}

.status-step {
  color: var(--quiet);
  font-size: 0.88rem;
  white-space: nowrap;
}

.tool-section {
  display: grid;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 20, 25, 0.72);
  box-shadow: 0 24px 70px var(--shadow);
  padding: 1rem;
}

.tool-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 1rem;
  align-items: center;
  padding: 0.25rem 0.25rem 0.75rem;
}

.tool-topline h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2.2vw, 1.9rem);
}

.meter {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  height: 72px;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  padding: 0.55rem;
  overflow: hidden;
}

.meter span {
  min-height: 12%;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--mint), var(--cyan));
  transform-origin: bottom;
  opacity: 0.62;
  transition: height 90ms linear, opacity 90ms linear;
}

body.is-playing .meter span {
  opacity: 0.92;
}

.preset-strip,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 27, 32, 0.86);
}

.preset-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  padding: 0.8rem;
}

.control-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.preset-buttons {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.05rem;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.preset-button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #20242b;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.85rem;
  font-weight: 800;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.preset-button[aria-pressed="true"] {
  border-color: rgba(255, 198, 90, 0.72);
  background: #3a2f17;
  color: #fff2ca;
}

.lab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
}

.panel {
  padding: 1rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.panel-heading h2 {
  margin-bottom: 0.1rem;
  font-size: 1rem;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.transport-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.transport-grid .button-danger,
.transport-grid #exportButton {
  grid-column: span 2;
}

.slider-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.range-control,
.select-control {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.range-control span,
.select-control span {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
}

.range-control strong {
  color: var(--text);
}

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

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

.track-controls {
  display: grid;
  gap: 0.55rem;
}

.track-control {
  display: grid;
  grid-template-columns: 78px auto minmax(80px, 1fr);
  gap: 0.55rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #15181e;
  padding: 0.55rem;
}

.track-name {
  color: var(--text);
  font-weight: 900;
}

.mute-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #22262e;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 850;
}

.mute-button[aria-pressed="true"] {
  border-color: rgba(255, 111, 97, 0.7);
  background: #3a201f;
  color: #ffd2cd;
}

.sequencer-panel {
  padding: 0;
  overflow: hidden;
}

.sequencer-heading {
  margin-bottom: 0;
  padding: 1rem 1rem 0.8rem;
}

.bar-counter {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 0.32rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.grid-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 0 1rem 1rem;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.sequencer-grid {
  display: grid;
  grid-template-columns: var(--track-label) repeat(16, var(--step-size));
  gap: 6px;
  min-width: calc(var(--track-label) + (16 * var(--step-size)) + (16 * 6px));
  user-select: none;
  touch-action: pan-x;
}

.grid-label,
.step-number {
  display: grid;
  align-items: center;
  min-height: 30px;
}

.grid-label {
  position: sticky;
  left: 0;
  z-index: 3;
  border-radius: var(--radius);
  background: #181b20;
  color: var(--muted);
  padding: 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 900;
}

.grid-label.pitch {
  color: #d5d8df;
  font-size: 0.78rem;
  font-weight: 800;
}

.step-number {
  justify-items: center;
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 900;
}

.step-number.downbeat {
  color: var(--amber);
}

.step-number.is-current {
  color: var(--text);
}

.step-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--step-size);
  height: var(--row-size);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11141a;
  color: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 90ms ease, background 90ms ease, border-color 90ms ease, box-shadow 90ms ease;
}

.step-cell::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.7);
  transition: transform 90ms ease, background 90ms ease;
}

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

.step-cell.is-active {
  border-color: rgba(88, 240, 192, 0.5);
  background: rgba(35, 100, 85, 0.82);
  box-shadow: inset 0 0 0 1px rgba(88, 240, 192, 0.18);
}

.step-cell.is-active::after {
  background: var(--mint);
  transform: scale(1.18);
}

.step-cell.track-snare.is-active {
  border-color: rgba(255, 111, 97, 0.58);
  background: rgba(116, 45, 48, 0.74);
}

.step-cell.track-snare.is-active::after {
  background: var(--coral);
}

.step-cell.track-hat.is-active {
  border-color: rgba(255, 198, 90, 0.58);
  background: rgba(108, 83, 29, 0.74);
}

.step-cell.track-hat.is-active::after {
  background: var(--amber);
}

.step-cell.track-bass.is-active {
  border-color: rgba(99, 199, 255, 0.58);
  background: rgba(30, 76, 112, 0.78);
}

.step-cell.track-bass.is-active::after {
  background: var(--cyan);
}

.step-cell.track-melody.is-active {
  border-color: rgba(255, 123, 189, 0.58);
  background: rgba(104, 43, 85, 0.78);
}

.step-cell.track-melody.is-active::after {
  background: var(--pink);
}

.step-cell.is-current {
  border-color: #fff1b4;
  box-shadow: 0 0 0 2px rgba(255, 198, 90, 0.36), 0 0 22px rgba(255, 198, 90, 0.2);
}

.step-cell.is-triggered {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 0 0 2px rgba(245, 243, 236, 0.32), 0 0 24px rgba(88, 240, 192, 0.34);
}

.step-cell.is-muted {
  opacity: 0.42;
}

.row-spacer {
  grid-column: 1 / -1;
  height: 4px;
}

.content-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 48px 0 20px;
}

.content-section article,
.faq {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.content-section h2 {
  margin-bottom: 0.45rem;
  font-size: 1.15rem;
}

.content-section p {
  color: var(--muted);
}

.faq {
  grid-column: 1 / -1;
}

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 0;
}

.faq summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 850;
}

.faq p {
  max-width: 780px;
  margin: 0.5rem 0 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding: 22px 0 36px;
  color: var(--quiet);
  font-size: 0.92rem;
}

@media (max-width: 900px) {
  .site-header,
  .tool-topline,
  .lab-layout,
  .content-section {
    grid-template-columns: 1fr;
  }

  .header-actions {
    min-width: 0;
  }

  .tool-topline {
    gap: 0.75rem;
  }

  .meter {
    max-width: none;
  }

  .slider-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --track-label: 104px;
    --step-size: 40px;
    --row-size: 40px;
  }

  .site-header,
  .tool-section,
  .content-section,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

  .site-header {
    padding-top: 22px;
  }

  .tool-section {
    padding: 0.7rem;
  }

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

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

  .transport-grid .button-danger,
  .transport-grid #exportButton {
    grid-column: span 2;
  }

  .track-control {
    grid-template-columns: 1fr auto;
  }

  .track-control input[type="range"] {
    grid-column: 1 / -1;
  }

  .sequencer-heading {
    display: grid;
  }

  .grid-scroll {
    padding-inline: 0.7rem;
  }
}

@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;
  }
}
