:root {
  --bg:#0b0d10;
  --fg:#eaeff4;
  --muted:#9aa7b0;
  --accent:#6ae3ff;
  --header-height: 70px;
  /* Central app max width: adjust once to scale whole layout */
  --app-max-width: 1120px;
}
/* Hide main content until JS sets initial slider values to avoid flicker */
body.app-init-hidden main { visibility: hidden; }
html, body { height: 100%; }

/* === UTILITY CLASSES === */
/* Flexbox utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-start { display: flex; align-items: center; justify-content: flex-start; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }

/* Gap utilities */
.gap-025 { gap: 0.25rem; }
.gap-05 { gap: 0.5rem; }
.gap-075 { gap: 0.75rem; }
.gap-1 { gap: 1rem; }
.gap-15 { gap: 1.5rem; }
.gap-2 { gap: 2rem; }

/* Color utilities */
.text-accent { color: var(--accent); }
.text-muted { color: var(--muted); }
.text-fg { color: var(--fg); }

/* Font size utilities */
.text-xs { font-size: 0.75em; }
.text-sm { font-size: 0.85em; }
.text-base { font-size: 0.9em; }
.text-md { font-size: 0.95em; }
.text-lg { font-size: 1.1em; }
.text-xl { font-size: 1.25em; }
.text-2xl { font-size: 1.5rem; }

/* Font weight utilities */
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Spacing utilities */
.m-0 { margin: 0; }
.mt-05 { margin-top: 0.5rem; }
.mt-1 { margin-top: 1rem; }
.ml-1 { margin-left: 1rem; }
.min-w-2ch { min-width: 2ch; }
.min-w-25 { min-width: 25px; }
.min-w-35 { min-width: 35px; }

/* Display utilities */
.hidden { display: none; }

/* Text utilities */
.text-center { text-align: center; }
.line-height-1 { line-height: 1; }

/* Flex utilities */
.flex-1 { flex: 1; }

/* === COMPONENT-SPECIFIC CLASSES === */
/* Brand logo in header */
.brand-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* Header flex container */
.header-flex-container {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* CPU/Voice stats display */
.stats-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  padding: 0.35rem 1rem;
  background: rgba(26, 31, 36, 0.6);
  border: 1px solid #2a3138;
  border-radius: 8px;
}

.stats-display .stat {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  line-height: 1;
}

.stats-display .stat-label {
  font-size: 0.72em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.stats-display .stat-value {
  font-size: 1.08em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* Octave control group */
.octave-controls {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: center;
}

.octave-btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.85em;
}

.octave-display {
  color: var(--accent);
  font-weight: 600;
  min-width: 2ch;
  text-align: center;
}

.octave-label {
  font-size: 0.9em;
  color: var(--muted);
  line-height: 1;
}

.octave-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Noise filter controls */
.noise-filter-label {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* Demo sections */
.demo-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;

  &.hidden {
    display: none;
  }

  h3 {
    margin-top: 0;
  }

  p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  .demo-container {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .demo-note {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 1rem;
    font-style: italic;
  }

  .demo-grid-preview {
    margin-top: 1.5rem;

    h4 {
      font-size: 0.9rem;
      color: var(--muted);
      margin-bottom: 0.5rem;
    }
  }
}

/* Pitch Bend sections */
.pitch-bend-section {
  &.hidden {
    display: none;
  }

  .row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
  }

  .pitch-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
}

.pitch-bend-mini-section {
  max-width: 320px;
  margin: 1.5rem auto;

  &.hidden {
    display: none;
  }

  h3 {
    font-size: 0.9rem;
    color: #6ae3ff;
    margin-bottom: 0.5rem;
  }

  .row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 19, 23, 0.7);
    border-radius: 10px;
  }
}

.pitch-bend-mini-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;

  .pitch-bend-label {
    font-size: 0.85em;
  }
}

.pitch-bend-mini {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px;
  height: 110px;
  padding: 0;
  margin: 0.3rem 0;
  background: linear-gradient(to top, #ff4444 0%, #2a3138 48%, #6ae3ff 52%, #44ff44 100%);
  border: 1px solid #1a1f24;
  border-radius: 999px;
}

.pitch-bend-mini-value {
  font-size: 0.95em;
  min-width: 40px;
  padding: 0.15rem 0.3rem;
}

.pitch-bend-mini-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  label {
    font-size: 0.85em;

    select {
      font-size: 0.85em;
      padding: 0.2rem 0.4rem;
      min-width: 70px;
    }
  }
}

.pitch-bend-range-info {
  font-size: 0.8em;
  color: #9aa7b0;
  text-align: center;
  margin-top: 0.3rem;
}
body {
  margin: 0;
  font: 14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  background: var(--bg);
  color: var(--fg);
  padding-top: var(--header-height);
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(to bottom, rgba(11, 13, 16, 0.95), rgba(11, 13, 16, 0.9));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #2a3138;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header-content {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 2rem;
  max-width: var(--app-max-width);
  width: 100%;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 1rem;

  /* background-color: red; */
}

main {
  max-width: var(--app-max-width);
  margin: 1rem auto;
  padding-bottom: calc(var(--vk-h) + 2rem);
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0 0 .75rem;
  color: var(--fg);
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 1.5rem 0 0.5rem;
  letter-spacing: .02em;
}

/* Section with tab-like header */
section {
  margin: 0.75rem 0;
  position: relative;

  & > h3 {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: linear-gradient(to bottom, rgba(26, 31, 36, 0.9), rgba(26, 31, 36, 0.7));
    border: 1px solid #2a3138;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 0.35rem 0.75rem;
    margin: 0 0 -1px 0.75rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    position: relative;
    z-index: 2;
    line-height: 1;
  }

  & > .row,
  & > .envelopes-container {
    position: relative;
    z-index: 1;
  }
}

.row {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(26, 31, 36, 0.5);
  border: 1px solid #2a3138;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0;
  transition: border-color .2s ease, box-shadow .2s ease;

  &:hover {
    border-color: #3b454f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  &.bit-crusher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
    margin: 0 0 0.5rem;

    label {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      white-space: nowrap;
      line-height: 1.3;

      & > span:first-of-type {
        min-width: 60px;
        font-weight: 500;
      }

      input[type="range"] {
        flex: 1;
      }

      .val {
        min-width: 50px;
        text-align: right;
        font-size: 0.95em;
        opacity: 0.85;
      }
    }
  }

  &.filter {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    align-items: start;
    margin: 0 0 1rem;

    label {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      white-space: nowrap;
      line-height: 1.3;

      & > span:first-of-type {
        min-width: 60px;
        font-weight: 500;
      }

      input[type="range"] {
        flex: 1;
      }

      .val {
        min-width: 50px;
        text-align: right;
        font-size: 0.95em;
        opacity: 0.85;
      }
    }

    input[type="range"] {
      width: 100%;
    }
  }

  &.noise {
    display: grid;
    grid-template-columns: 1fr 3fr 2fr;
    gap: 1rem;
    align-items: center;
    margin: 0 0 1rem;

    label {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      white-space: nowrap;
      line-height: 1.3;

      & > span:first-of-type {
        min-width: 50px;
        font-weight: 500;
        font-size: 0.9em;
      }

      input[type="range"] {
        flex: 1;
      }

      select {
        padding: 0.35rem 0.5rem;
        font-size: 0.9em;
        height: auto;
        min-height: 28px;
      }

      .val {
        min-width: 45px;
        text-align: right;
        font-size: 0.85em;
        opacity: 0.85;
      }
    }

    input[type="range"] {
      width: 100%;
    }
  }

  &.preset {
    display: grid;
    grid-template-columns: 1fr 3fr 2fr;
    gap: 1rem;
    align-items: center;
    margin: 0 0 1rem;

    label {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      white-space: nowrap;
      line-height: 1.3;

      & > span:first-of-type {
        min-width: 50px;
        font-weight: 500;
        font-size: 0.9em;
      }

      input[type="range"] {
        flex: 1;
      }

      select {
        padding: 0.35rem 0.5rem;
        font-size: 0.9em;
        height: auto;
        min-height: 28px;
      }

      .val {
        min-width: 45px;
        text-align: right;
        font-size: 0.85em;
        opacity: 0.85;
      }
    }

    input[type="range"] {
      width: 100%;
    }
  }

  &.oscillators {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
  }

  &.portamento {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 0.75rem;
    align-items: center;
    margin: 0 0 1rem;

    label {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      white-space: nowrap;
      line-height: 1.3;

      & > span:first-of-type {
        min-width: 40px;
        font-weight: 500;
      }

      input[type="range"] {
        flex: 1;
      }

      .val {
        min-width: 60px;
        text-align: right;
        font-size: 0.95em;
        opacity: 0.85;
      }
    }
  }

  &.main-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
  }

  &.delay {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    align-items: start;
    margin: 0 0 0.5rem;

    label {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      white-space: nowrap;
      line-height: 1.3;

      & > span:first-of-type {
        min-width: 60px;
        font-weight: 500;
      }

      input[type="range"] {
        flex: 1;
      }

      .val {
        min-width: 50px;
        text-align: right;
        font-size: 0.95em;
        opacity: 0.85;
      }
    }

    input[type="range"] {
      width: 100%;
    }

    input[type="checkbox"] {
      width: 20px;
      height: 20px;
      accent-color: var(--accent);
    }
  }
}

.osc-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  h4 {
    font-size: 1em;
    font-weight: 600;
    color: #8ab4f8;
    text-align: center;
    margin: 0 0 0.4rem 0;
  }

  label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    line-height: 1.3;

    & > span:first-of-type {
      min-width: 90px;
      font-weight: 500;
    }

    input[type="range"] {
      flex: 1;
    }

    select {
      flex: 1;
      padding: 0.35rem 0.5rem;
      font-size: 0.9em;
      height: auto;
      min-height: 28px;
    }

    .val {
      min-width: 60px;
      text-align: right;
      font-size: 0.95em;
      opacity: 0.85;
    }
  }
}

.main-col-tempo {
  display: flex;
  align-items: center;

  label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-weight: 500;
  }
}

.main-col-lfo {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  label {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    & > span:first-of-type {
      min-width: 120px;
      font-weight: 500;
    }

    input[type="range"] {
      flex: 1;
    }

    .val {
      min-width: 60px;
      text-align: right;
      font-size: 0.95em;
      opacity: 0.85;
    }
  }
}

.envelopes-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin: 0 0 1rem;
}

.envelope-column {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  background: rgba(26, 31, 36, 0.4);
  border: 1px solid #2a3138;
  border-radius: 8px;
  font-size: 0.88em;

  h4 {
    margin: 0 0 0.4rem 0;
    font-size: 1em;
    font-weight: 600;
    color: #8ab4f8;
    text-align: center;
  }

  label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.3;

    & > span:first-of-type {
      min-width: 28px;
      font-weight: 500;
    }

    input[type="range"] {
      flex: 1;
    }

    .val {
      min-width: 48px;
      text-align: right;
      font-size: 0.95em;
      opacity: 0.85;
    }

    input[type="checkbox"] {
      margin-right: 0.25rem;
    }
  }

  input[type="range"] {
    width: 100%;
  }
}

/* LFOs section - same layout as envelopes */
.lfos-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin: 0 0 1rem;
}

.lfo-column {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  background: rgba(26, 31, 36, 0.4);
  border: 1px solid #2a3138;
  border-radius: 8px;
  font-size: 0.88em;

  h4 {
    margin: 0 0 0.4rem 0;
    font-size: 1em;
    font-weight: 600;
    color: #8ab4f8;
    text-align: center;
  }

  label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.3;

    & > span:first-of-type {
      min-width: 50px;
      font-weight: 500;
    }

    input[type="range"] {
      flex: 1;
    }

    select {
      flex: 1;
      padding: 0.35rem 0.5rem;
      font-size: 0.9em;
    }

    .val {
      min-width: 32px;
      text-align: right;
      font-size: 0.95em;
      opacity: 0.85;
    }
  }

  input[type="range"] {
    width: 100%;
  }
}

.matrix-section {
  position: relative;
  width: 100%;

  .matrix-container {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    align-items: center;
    width: 100%;

    .matrix-cell {
      border: 1px solid #2a3138;
    }
  }
}

.mod-matrix {
  display: grid;
  grid-template-columns: auto repeat(14, 1fr);
  gap: 0.25rem;
  font-size: 0.7rem;
  background: rgba(26, 31, 36, 0.6);
  border: 1px solid #2a3138;
  border-radius: 12px;
  padding: 1rem;
  transition: border-color .2s ease;

  &:hover {
    border-color: #3b454f;
  }
}

.mod-matrix-header {
  font-weight: 600;
  text-align: center;
  padding: 0.3rem 0.45rem;
  color: var(--accent);
  background: rgba(42, 49, 56, 0.4);
  border-radius: 5px;
}

.mod-matrix-label {
  font-weight: 500;
  padding: 0.3rem;
  color: var(--fg);
  background: rgba(42, 49, 56, 0.3);
  border-radius: 5px;
  display: flex;
  align-items: center;
}

.mod-matrix-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 220px;
  height: 6px;
  background: #1a1f24;
  border-radius: 999px;
  border: 1px solid #2a3138;
  outline: none;
  transition: border-color .15s ease, box-shadow .2s ease;

  &:hover {
    border-color: #3b454f;
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* WebKit (Chrome, Edge, Safari) */
  &::-webkit-slider-runnable-track {
    height: 6px;
    border: 1px solid #2a3138;
    border-radius: 999px;
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 0%), #1a1f24 var(--fill, 0%), #1a1f24 100%);
  }

  &::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--fg);
    border: 1px solid #2a3138;
    box-shadow: 0 0 0 2px #1a1f24 inset;
    transition: transform .1s ease, box-shadow .2s ease;
    margin-top: -6px;
  }

  &:hover::-webkit-slider-thumb {
    box-shadow: 0 0 0 2px #1a1f24 inset, 0 0 0 6px rgba(106,227,255,.15);
  }

  &:active::-webkit-slider-thumb {
    transform: scale(.96);
  }

  &:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 2px #1a1f24 inset, 0 0 0 6px rgba(106,227,255,.35);
  }

  /* Firefox */
  &::-moz-range-track {
    height: 6px;
    background: #1a1f24;
    border: 1px solid #2a3138;
    border-radius: 999px;
  }

  &::-moz-range-progress {
    height: 6px;
    background: var(--accent);
    border-radius: 999px;
  }

  &::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--fg);
    border: 1px solid #2a3138;
    box-shadow: 0 0 0 2px #1a1f24 inset, 0 0 0 0 rgba(106,227,255,.0);
    transition: transform .1s ease, box-shadow .2s ease;
  }

  &:hover::-moz-range-thumb {
    box-shadow: 0 0 0 2px #1a1f24 inset, 0 0 0 6px rgba(106,227,255,.15);
  }

  &:active::-moz-range-thumb {
    transform: scale(.96);
  }

  &:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 2px #1a1f24 inset, 0 0 0 6px rgba(106,227,255,.35);
  }

  /* Pitch Bend Slider - Special vertical design */
  &.pitch-bend {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 8px;
    height: 200px;
    padding: 0;
    margin: 0.5rem 0;
    background: linear-gradient(to top,
      #ff4444 0%,
      #ff4444 25%,
      #2a3138 25%,
      #2a3138 48%,
      var(--accent) 48%,
      var(--accent) 52%,
      #2a3138 52%,
      #2a3138 75%,
      #44ff44 75%,
      #44ff44 100%
    );
    border: 2px solid #1a1f24;
    border-radius: 999px;

    &::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: var(--fg);
      border: 2px solid var(--accent);
      box-shadow: 0 0 8px rgba(106, 227, 255, 0.6), inset 0 0 0 2px #1a1f24;
      cursor: grab;
    }

    &:active::-webkit-slider-thumb {
      cursor: grabbing;
      transform: scale(1.1);
      box-shadow: 0 0 16px rgba(106, 227, 255, 0.9), inset 0 0 0 2px #1a1f24;
    }

    &::-moz-range-thumb {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: var(--fg);
      border: 2px solid var(--accent);
      box-shadow: 0 0 8px rgba(106, 227, 255, 0.6), inset 0 0 0 2px #1a1f24;
      cursor: grab;
    }

    &:active::-moz-range-thumb {
      cursor: grabbing;
      transform: scale(1.1);
      box-shadow: 0 0 16px rgba(106, 227, 255, 0.9), inset 0 0 0 2px #1a1f24;
    }
  }
}

/* Pitch Bend Container */
.pitch-bend-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(15, 19, 23, 0.8);
  border: 2px solid #2a3138;
  border-radius: 12px;
  min-width: 120px;
  transition: border-color .2s ease, box-shadow .2s ease;

  &:hover {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(106, 227, 255, 0.2);
  }
}

.pitch-bend-label {
  font-weight: 600;
  font-size: 0.9em;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pitch-bend-value {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  min-width: 60px;
  padding: 0.25rem 0.5rem;
  background: rgba(26, 31, 36, 0.8);
  border-radius: 6px;
  border: 1px solid #2a3138;
}

.pitch-bend-range-label {
  font-size: 0.75em;
  color: var(--muted);
  text-align: center;
}

button {
  background: #1a1f24;
  color: var(--fg);
  border: 1px solid #2a3138;
  padding: .4rem .75rem;
  border-radius: .5rem;
  cursor: pointer;
  transition: box-shadow .2s ease, border-color .15s ease;
  font-size: 0.9em;

  &:hover {
    border-color: #3b454f;
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  &:disabled {
    opacity: .6;
    cursor: default;
  }

  &.primary {
    background: var(--accent);
    color: #052029;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(106,227,255,.35), 0 0 0 1px rgba(0,0,0,.15) inset;
    transition: transform .05s ease, box-shadow .2s ease, filter .15s ease;

    &:hover {
      filter: brightness(.95);
      box-shadow: 0 8px 22px rgba(106,227,255,.45), 0 0 0 1px rgba(0,0,0,.15) inset;
    }

    &:active {
      transform: translateY(1px);
    }

    &:focus-visible {
      outline: 2px solid #9ff2ff;
      outline-offset: 2px;
    }
  }
}

label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
}

select {
  background: #1a1f24;
  color: var(--fg);
  border: 1px solid #2a3138;
  padding: .4rem .7rem;
  border-radius: .5rem;
  cursor: pointer;
  transition: border-color .15s ease;
  font: inherit;

  &:hover {
    border-color: #3b454f;
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

input[type="checkbox"] {
  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: .25rem;
  }
}

.hint {
  margin-top: .75rem;
  color: var(--muted);
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  background: rgba(26, 31, 36, 0.5);
  border: 1px solid #2a3138;
  border-radius: 8px;
  user-select: none;
  transition: background 0.2s ease;
  color: inherit;
  font: inherit;
  width: 100%;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;

  &:hover {
    background: rgba(26, 31, 36, 0.7);
  }

  span:first-child {
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

.status-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  transition: background 0.3s ease;

  &.ok {
    background: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
  }

  &.error {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  }
}

.toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.8em;
}

#status {
  max-height: 500px;
  overflow: auto;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
  margin-top: 0.5rem;

  &.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    overflow: hidden;

    ~ .status-header .toggle-icon {
      transform: rotate(-90deg);
    }
  }
}

.status-header:has(~ #status.collapsed) .toggle-icon {
  transform: rotate(-90deg);
}

kbd {
  background: #11161b;
  border: 1px solid #2a3138;
  padding: .15rem .35rem;
  border-radius: .35rem;
  font-family: ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;
  font-size: .9em;
  color: var(--accent);
}

pre {
  margin-top: .5rem;
  background: #0f1317;
  border: 1px solid #222a31;
  padding: .5rem .6rem;
  border-radius: .6rem;
  color: var(--muted);
  overflow: auto;
  white-space: pre-wrap;
}

/* Meter */
.meter-wrap {
  width: 100%;
  margin-top: .75rem;

  &.header-meter {
    margin-top: 10px;
    flex: 1 1 auto;
    width: auto;
  }
}

.meter {
  width: 100%;
  height: 12px;
  background: #1a1f24;
  border: 1px solid #2a3138;
  border-radius: 999px;
  overflow: hidden;
  position: relative;

  &.header-compact {
    height: 8px;
    width: 100%;
  }

  &.clip1 .meter-fill {
    background: linear-gradient(to right, #ffd166, #fca311);
  }

  &.clip2 .meter-fill {
    background: linear-gradient(to right, #ff6b6b, #ff3b3b);
  }
}

.meter-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(to right, #4aa3ff, #6ae3ff);
  transition: transform 0.08s linear, background 0.12s ease;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: .85em;
  color: var(--muted);
  margin-top: .25rem;

  &.header-compact {
    font-size: .75em;
    margin-top: .1rem;
  }
}

.meter-readout {
  margin-top: .25rem;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.val {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Peak-hold marker */
.meter-hold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ffe08a;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.5rem;

  button:not(.octave-btn) {
    padding: .55rem 1rem;
    border-radius: .6rem;
  }
}

.brand {
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

/* Voice slots */
.voice-slots {
  display: flex;
  gap: .4rem;
  justify-content: center;
  flex-wrap: wrap;
}

.voice-slot {
  min-width: 50px;
  height: 22px;
  background: #1a1f24;
  border: 2px solid #2a3138;
  border-radius: 6px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  font-size: .85em;
  color: var(--muted);
  transition: all .15s ease;
  position: relative;

  .slot-num {
    font-weight: 700;
    font-size: 1em;
  }

  .slot-note {
    font-size: 0.9em;
    opacity: .8;
    margin-left: 0.25rem;
  }

  &.active {
    background: #1e3a44;
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 2px rgba(106,227,255,.15);
  }

  &.retrigger {
    animation: retrigger-flash .2s ease;
  }
}

@keyframes retrigger-flash {
  0%, 100% { background: #1e3a44; }
  50% { background: #2a5563; box-shadow: 0 0 12px rgba(106,227,255,.5); }
}

/* === Virtual keyboard (fixed bottom) === */
:root { --vk-h: 80px; }

.vk-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: #161a1f;
  border-top: 1px solid #2a3138;
  box-shadow: 0 -8px 24px rgba(0,0,0,.35);
  touch-action: none;
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.vk-inner {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  max-width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.keyboard {
  display: flex;
  gap: 1px;
  padding: 0;
  background: #161a1f;
  user-select: none;
  --white-w: 30px;
  --white-h: 80px;
  --black-w: calc(var(--white-w) * 0.6);
}

.octave {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, var(--white-w));
  grid-auto-rows: var(--white-h);
  gap: 1px;
  background: #0f1317;
  border-radius: 6px;
}

.key {
  position: relative;
  border: 1px solid #2a3138;

  .label {
    font-size: 10px;
    line-height: 1;
    opacity: 0.9;
    user-select: none;
    pointer-events: none;
  }

  &.white {
    background: linear-gradient(#f5f7fa, #e7edf3);
    border-radius: 0 0 5px 5px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    z-index: 1;
    color: #0b0d10;

    &.active {
      background: linear-gradient(#e6f7ff, #cfefff);
      box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
    }
  }

  &.black {
    position: absolute;
    top: 0;
    width: var(--black-w);
    height: calc(var(--white-h) * 0.6);
    background: linear-gradient(#333, #000);
    border: 1px solid #0b0d10;
    border-radius: 0 0 4px 4px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 5px;
    color: #fff;
    z-index: 5;
    left: calc(var(--i) * (var(--white-w) + 1px) - var(--black-w) / 2);

    .label {
      font-size: 9px;
    }

    &.active {
      filter: brightness(1.25);
    }
  }
}

/* === DRAG NUMBER (for modulation matrix) === */
.drag-num-container {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  user-select: none;
}

.drag-num {
  min-width: 60px;
  padding: 5px 7px;
  background: #1a1f24;
  border: 1px solid #2a3138;
  border-radius: 4px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: #8a9199;
  transition: all 0.12s ease;
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1;
  touch-action: none;
  user-select: none;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #1e2529;
  }

  &:active {
    border-color: var(--accent);
    color: #fff;
    background: #0e1518;
    box-shadow: 0 0 6px rgba(106, 227, 255, 0.25);
  }

  &:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

.drag-num-label {
  font-size: 0.55rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  opacity: 0.8;
}

/* Matrix Modulation Slot Styles */
.mod-slot-demo {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.mod-slot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #0f1317;
  border: 1px solid #2a3138;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  min-width: 280px;
}

.mod-source, .mod-dest {
  background: #1a1f24;
  border: 1px solid #2a3138;
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  color: var(--fg);
  min-width: 70px;
  max-width: 80px;

  &:focus {
    outline: 1px solid var(--accent);
    border-color: var(--accent);
  }
}

.mod-arrow {
  color: var(--muted);
  font-size: 0.8rem;
  user-select: none;
  opacity: 0.7;
}

.mod-amount {
  margin-left: 0.2rem;
}

/* Grid demo styles */
.mod-grid-demo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 900px;

  .mod-slot {
    min-width: auto;
    padding: 0.3rem 0.4rem;
  }

  .mod-source,
  .mod-dest {
    min-width: 50px;
    max-width: 60px;
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
  }

  .drag-num {
    font-size: 0.5rem;
    font-weight: 500;
    padding: 1px 3px;
  }
}

/* Sequencer Styles */
.sequencer-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: center;
  background: linear-gradient(to bottom, rgba(26, 31, 36, 0.9), rgba(26, 31, 36, 0.7));
  border: 1px solid #2a3138;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 30px;
}

.sequencer-controls {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 3rem;
  margin-bottom: 1rem;
}

.transport-controls {
  display: flex;
  gap: 0.5rem;
}

.transport-btn {
  background: #1a1f24;
  border: 1px solid #2a3138;
  border-radius: 4px;
  color: var(--fg);
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.12s ease;
  min-width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #1e2529;
  }

  &:active {
    background: #0e1518;
    box-shadow: 0 0 6px rgba(106, 227, 255, 0.25);
  }
}

.seq-info {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.sequencer-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.seq-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.seq-row-label {
  width: 80px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
  flex-shrink: 0;
}

.seq-steps-container {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
  flex: 1;
  max-width: calc(100% - 100px);
}

.seq-step-vel {
  display: flex;
  align-items: center;
  justify-content: center;
}

.seq-vel-control {
  width: 100%;
  min-width: 35px;
  max-width: 60px;
  padding: 3px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #1a1f24;
  border: 1px solid #2a3138;
  border-radius: 3px;
  color: #8a9199;
  cursor: ns-resize;
  user-select: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: all 0.12s ease;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #1e2529;
  }

  &:active {
    border-color: var(--accent);
    color: #fff;
    background: #0e1518;
    box-shadow: 0 0 4px rgba(106, 227, 255, 0.25);
  }
}

.seq-step-note {
  background: #1a1f24;
  border: 1px solid #2a3138;
  border-radius: 3px;
  color: var(--fg);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  font-variant-numeric: tabular-nums;

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #1e2529;
  }

  &[data-note=""] {
    color: #555;
    background: #0f1214;

    &:hover {
      color: var(--muted);
      background: #1a1f24;
    }
  }

  &.active {
    background: var(--accent);
    color: #0b0d10;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(106, 227, 255, 0.4);
  }

  &.current-step {
    border-color: #ff6b6b;
    box-shadow: 0 0 6px rgba(255, 107, 107, 0.3);
  }
}

@media (max-width: 768px) {
  .sequencer-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .seq-steps-container {
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
  }

  .seq-row-label {
    width: 60px;
    font-size: 0.7rem;
  }
}

/* === PRESET SECTION === */
.preset-section {
  margin-bottom: 1.5rem;
  position: relative;

  h3 {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: linear-gradient(to bottom, rgba(26, 31, 36, 0.9), rgba(26, 31, 36, 0.7));
    border: 1px solid #2a3138;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 0.35rem 0.75rem;
    margin: 0 0 -1px 0.75rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    position: relative;
    z-index: 2;
    line-height: 1;
  }
}

.preset-content {
  display: flex;
  gap: 2rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1rem;
  position: relative;
  z-index: 1;
}

.left-content {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.right-content {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.preset-btn {
  background: linear-gradient(135deg, #2a2d32 0%, #1e2025 100%);
  border: 1px solid rgba(106, 227, 255, 0.3);
  border-radius: 5px;
  color: var(--fg);
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
}

.preset-btn:hover {
  background: linear-gradient(135deg, #3a3d42 0%, #2e3035 100%);
  border-color: rgba(106, 227, 255, 0.5);
  transform: translateY(-1px);
}

.preset-btn:active {
  transform: translateY(0);
  background: linear-gradient(135deg, #1a1d22 0%, #0e1015 100%);
}

.preset-btn.active {
  background: linear-gradient(135deg, rgba(106, 227, 255, 0.2) 0%, rgba(106, 227, 255, 0.1) 100%);
  border-color: var(--accent);
  color: var(--accent);
}

.preset-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--fg);
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.preset-action-btn:active {
  background: rgba(255, 255, 255, 0.05);
}

.preset-action-btn#presetExport:hover {
  border-color: rgba(106, 227, 255, 0.4);
  color: var(--accent);
}

.preset-action-btn#presetImport:hover {
  border-color: rgba(255, 193, 7, 0.4);
  color: #ffc107;
}

.preset-action-btn#presetInit:hover {
  border-color: rgba(255, 107, 107, 0.4);
  color: #ff6b6b;
}

@media (max-width: 768px) {
  .preset-content {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .right-content {
    margin-left: 0;
    justify-content: center;
  }

  .left-content {
    justify-content: center;
  }
}
