:root {
  /* App backdrop */
  --bg: #131316;
  --fg: #1f2329;
  --muted: #5a606d;
  --accent: #22cc88;
  --grid: #b6bbc6;

  /* 303 faceplate look */
  --face: #d7d9df;
  --face-2: #cfd2d8;
  --face-edge: #b9bdc7;
  --text: #222428;
  --led-off: #2b2b2b;
  --led-on: #ff5a3d;
  --btn-start: #e8832b;
  --btn-stop: #e0463a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(#0f1013, #171821);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: linear-gradient(180deg, #e7eaef, #cfd4dc);
  border-bottom: 1px solid #b3b9c4;
  box-shadow: inset 0 1px 0 #ffffffb3, inset 0 -1px 0 #00000012;
  position: relative;
}
.app-footer { display: none; }
/* Faceplate screws */
.app-header::before, .app-header::after { content: none; }

.transport { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; flex-wrap: nowrap; }
.tr-group { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(180deg,#eef2f7,#d5dbe3); border: 1px solid #b7bcc6; border-radius: 6px; box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011; }
.tr-transport { gap: 6px; background: none; border: none; border-radius: 0; box-shadow: none; padding: 0; }
.tr-sliders label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: #444; }
.tr-sync { gap: 10px; }
.tr-sync label { display: inline-flex; align-items: center; gap: 6px; }
.sync-badge {
  margin-left: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid #b3b9c4;
  background: #eff2f7;
  color: #445;
  min-width: 90px;
  text-align: center;
  box-shadow: inset 0 1px 0 #ffffffc4, inset 0 -1px 0 #00000014;
  cursor: pointer;
}
.sync-badge.state-wait { background: #fff1b5; border-color: #d7b356; color: #6b4b00; }
.sync-badge.state-error { background: #ffd6d2; border-color: #e49992; color: #7b1f12; }
.sync-badge.state-follow { background: #d6f6ff; border-color: #82c1d8; color: #0b546f; }
.sync-badge.state-master { background: #e0ffdd; border-color: #75c163; color: #1e5c23; }
.tr-oct { gap: 6px; font-size: 11px; color: #444; }
.transport .tempo { font-size: 11px; }
.transport .master { font-size: 11px; }
.transport #tempoVal { cursor: pointer; display: inline-block; min-width: 28px; text-align: center; }
.transport #tempoVal .tempo-edit { width: 48px; padding: 0 4px; font-size: 11px; }
.badge { padding: 2px 6px; font-size: 11px; border-radius: 4px; background: #ffe7a6; color: #6b4b00; border: 1px solid #d7b56a; box-shadow: inset 0 1px 0 #fff6; }
.transpose { display: inline-flex; align-items: center; gap: 6px; }
.transport input[type="range"] { vertical-align: middle; }

/* Start/Stop metallic buttons */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; border: none; background: radial-gradient(circle at 30% 30%, #f5f6f9, #c7ccd6); color: #2b2f39; box-shadow: inset 0 1px 0 #ffffffaa; cursor: pointer; }
.icon-btn:disabled { opacity: .6; cursor: default; }
.icon-btn.btn-start { box-shadow: inset 0 1px 0 #ffffffaa; color: #1e7b3d; }
.icon-btn.btn-stop { box-shadow: inset 0 1px 0 #ffffffaa; color: #7b2a1e; }
.icon-btn:active { transform: translateY(1px); }

/* Meter compact styling */

.level .label-vert { display: inline-flex; flex-direction: column; line-height: 1.05; }
.level .label-vert span { font-size: 11px; color: #444; }
.level .meter {
  position: relative;
  width: 140px;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, #dfe4ea, #c9d0d9);
  border: 1px solid #aeb6c2;
  box-shadow: inset 0 2px 2px #ffffffaa, inset 0 -1px 1px #00000010, 0 1px 1px rgba(0,0,0,.12);
  overflow: hidden;
}
/* Segment grid */
.level .meter::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to right,
    rgba(0,0,0,.18) 0 12px,
    rgba(0,0,0,.28) 12px 14px
  );
  opacity: .45;
  pointer-events: none;
}
/* Glass glare */
.level .meter::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0));
  pointer-events: none;
}
.level #meterFill {
  height: 100%;
  background: linear-gradient(90deg, #1fc659 0%, #36f07f 100%);
  box-shadow: 0 0 10px rgba(47,208,103,.35);
  -webkit-mask-image: repeating-linear-gradient(to right, #000 0 12px, transparent 12px 14px);
  mask-image: repeating-linear-gradient(to right, #000 0 12px, transparent 12px 14px);
  transition: box-shadow .15s linear, width .08s linear;
}
.level #meterFill.vu-mid {
  background: linear-gradient(90deg, #f7c948 0%, #ff9b2a 100%);
  box-shadow: 0 0 12px rgba(255, 159, 41, .55);
}
.level #meterFill.vu-high {
  background: linear-gradient(90deg, #ff6a00 0%, #ff3d2e 45%, #ff0a0a 100%);
  box-shadow: 0 0 14px rgba(255, 61, 46, .6);
}
/* Custom dark-grey sliders for Master and Tempo (no page-wide fills) */
#master, #tempo {
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  /* Top layer: dark fill + light track (6px tall) */
  background:
    linear-gradient(to right,
      #8a94a6 0%, #8a94a6 var(--p,0%),
      #d0d3d9 var(--p,0%), #d0d3d9 100%) no-repeat,
    /* Bottom layer: pill backplate (curved background lines) */
    linear-gradient(180deg, #f4f6fa, #cfd4dc) no-repeat;
  background-position: center, center;
  background-size: 100% 6px, 100% 100%;
  border: 1px solid #aab0bb;
  border-radius: 10px;
  outline: none;
}
#master::-webkit-slider-runnable-track,
#tempo::-webkit-slider-runnable-track { height: 6px; background: transparent; border-radius: 3px; }
#master::-webkit-slider-thumb,
#tempo::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #6b7380; /* lighter grey */
  border: 1px solid #a7adb8;
  margin-top: -2.5px; /* center on 6px track */
}
#master:focus, #tempo:focus { box-shadow: 0 0 0 2px rgba(0,0,0,.06); }

/* Firefox */
#master::-moz-range-track,
#tempo::-moz-range-track { height: 6px; background: #d0d3d9; border-radius: 3px; }
#master::-moz-range-progress,
#tempo::-moz-range-progress { height: 6px; background: #8a94a6; border-radius: 3px; }
#master::-moz-range-thumb,
#tempo::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: #6b7380; border: 1px solid #a7adb8; }

.app-main { padding: 12px 16px; color: var(--text); flex: 1; overflow-x: hidden; overflow-y: auto; }

/* Layout: left (controls + sequencer) and right (tool panels) */
.ui-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 230px);
  column-gap: clamp(6px, 1vw, 12px);
  row-gap: 12px;
  align-items: start;
  min-height: 0;
}
@media (max-width: 1120px) {
  .ui-grid {
    grid-template-columns: 1fr;
  }
}
.left {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0;
  min-height: 0;
  min-width: 0;
}

.mix-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #5b4731, #372819);
  border: 2px solid #20150d;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.55), 0 8px 24px rgba(0,0,0,0.55);
}
.mix-summary {
  font-size: 12px;
  color: #f6d8a3;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.mix-empty {
  padding: 14px;
  border: 1px dashed rgba(246, 216, 163, 0.5);
  border-radius: 8px;
  font-size: 13px;
  color: #f6d8a3;
  background: rgba(0,0,0,0.35);
}
.mix-empty a {
  color: #fff;
  text-decoration: underline;
}
.mix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.mix-card {
  padding: 8px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.45), rgba(255,255,255,0)) top,
    linear-gradient(180deg, #f8fafc 0%, #d5dae6 100%);
  border: 1px solid #a1a7b5;
  box-shadow:
    inset 0 1px 0 #ffffffcc,
    inset 0 -1px 0 #7d8293,
    0 10px 20px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 144px;
}
.mix-card-header { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.mix-head-text { display:flex; flex-wrap:wrap; align-items:baseline; gap:6px; }
.mix-head-text h4 {
  margin: 0;
  font-size: 14px;
  color: #f4f5f8;
  white-space: nowrap;
}
.mix-card .mix-meta {
  font-size: 11px;
  color: #636a78;
  white-space: nowrap;
}
.mixblocks-body {
  margin: 0;
  min-height: 100vh;
  padding: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}
.mixblocks-body .app-main {
  overflow-y: hidden;
}
.app-main {
  padding-bottom: 220px;
}
@keyframes auto-record-pulse {
  0% { opacity: 1; transform: scale(1); }
  60% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0.2; transform: scale(0.85); }
}

.automation-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 16px 20px 20px;
  border-radius: 0;
  background: #131824;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 900;
}
.automation-transport {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: linear-gradient(180deg, #5a4934, #2f2418);
  border: 1px solid #1a140d;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 6px 18px rgba(0,0,0,0.45);
}
.automation-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 2px 12px 4px;
}
.automation-filter-row .auto-status {
  margin-left: auto;
}
.automation-zoom {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.zoom-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: linear-gradient(180deg, #1e2815, #050806);
  color: #c4e7c0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 1px 3px rgba(0,0,0,0.4);
}
.zoom-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.automation-filter {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 200px;
  color: #dfe3f2;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.automation-filter::before {
  content: 'LANES';
  font-weight: 600;
  color: rgba(223,227,242,0.65);
  margin-right: 4px;
}
.marker-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
  padding-left: 12px;
  min-width: 220px;
  justify-content: flex-end;
  flex: 1 1 auto;
}
.marker-controls {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex: 0 0 auto;
}
.marker-ctrl {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: linear-gradient(180deg, #f3efe4, #b1a78f);
  color: #2a2416;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 3px rgba(0,0,0,0.45);
}
.marker-ctrl:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 2px rgba(0,0,0,0.4);
}
.marker-ctrl.loop-active {
  background: linear-gradient(180deg, #c8ffcb, #4aaf4f);
  color: #082a12;
}
.marker-btn {
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff1d4, #c27a0e);
  color: #2b1600;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 12px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px rgba(0,0,0,0.4);
}
.marker-btn.is-armed {
  background: linear-gradient(180deg, #ffe094, #c27a0e);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), 0 0 0 2px rgba(255,255,255,0.2), 0 2px 5px rgba(0,0,0,0.4);
}
.marker-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 1px 3px rgba(0,0,0,0.4);
}
.marker-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 20px;
  justify-content: flex-end;
  flex: 1 1 auto;
}
.marker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  color: #f3d7a6;
  background: rgba(0,0,0,0.35);
  position: relative;
}
.marker-chip.is-active {
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 6px rgba(255,255,255,0.2);
}
.marker-chip.is-loop {
  border-color: rgba(116,208,149,0.9);
  background: rgba(24,55,28,0.7);
  box-shadow: 0 0 8px rgba(104,186,137,0.4);
}
.marker-chip-trigger {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.marker-label-text {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.marker-chip .marker-remove {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.marker-chip .marker-remove:hover {
  color: #ff9a7a;
}
.marker-chip .marker-remove:focus-visible,
.marker-chip-trigger:focus-visible,
.marker-btn:focus-visible {
  outline: 2px solid rgba(255,255,255,0.75);
  outline-offset: 2px;
}
.marker-empty {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}
.filter-chip {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.03);
  color: inherit;
  font-size: 10px;
  padding: 3px 10px 3px 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
  position: relative;
}
.filter-chip .chip-dot {
  position: absolute;
  left: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chip-color, #fff);
  box-shadow: 0 0 6px var(--chip-color, rgba(255,255,255,0.6));
}
.filter-chip:not(.active) {
  opacity: 0.45;
}
.filter-chip.active {
  color: #111318;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(205,211,224,0.9));
  border-color: rgba(255,255,255,0.65);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 4px rgba(0,0,0,0.35);
}
.filter-chip:focus-visible {
  outline: 2px solid rgba(255,255,255,0.55);
  outline-offset: 2px;
}

.transport-pad {
  width: 46px;
  height: 46px;
  border-radius: 4px;
  border: 1px solid #090909;
  background: linear-gradient(180deg, #ededed, #bdb9b0);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    inset 0 -1px 0 rgba(0,0,0,0.35),
    0 3px 8px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: #151820;
  font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  transition: transform 120ms ease, box-shadow 120ms ease;
  text-align: center;
  position: relative;
}
.transport-pad::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  top: 6px;
  right: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.9), rgba(255,0,0,0.35));
  box-shadow: 0 0 6px rgba(255,0,0,0.5);
  opacity: 0;
  transition: opacity 80ms ease;
  pointer-events: none;
}
.transport-pad.btn-toggle.active::after,
.transport-pad.pad-play:active::after,
.transport-pad.pad-stop:active::after {
  opacity: 1;
}
.transport-pad .pad-icon {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.transport-pad .pad-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-top: 3px;
}
.transport-pad:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    inset 0 -2px 2px rgba(0,0,0,0.4),
    0 2px 5px rgba(0,0,0,0.35);
}
.transport-pad.btn-toggle.active {
  box-shadow:
    inset 0 0 6px rgba(0,0,0,0.35),
    0 3px 8px rgba(0,0,0,0.45);
}
.pad-record {
  background: linear-gradient(180deg, #f9c6be, #a03128);
  color: #2b0806;
}
.pad-record.is-armed-play::after {
  opacity: 1;
  background: radial-gradient(circle, rgba(255,233,168,0.95), rgba(240,164,41,0.8));
  box-shadow: 0 0 8px rgba(240,164,41,0.55);
  animation: none;
}
.pad-record.is-recording::after {
  opacity: 1;
  background: radial-gradient(circle, rgba(203,255,221,1), rgba(34,204,136,0.9));
  box-shadow: 0 0 10px rgba(34,204,136,0.75);
  animation: auto-record-pulse 0.8s ease-in-out infinite;
}
.pad-arm {
  background: linear-gradient(180deg, #f6e9ff, #7b6cac);
  color: #271342;
}
.pad-arm.active {
  transform: translateY(1px);
  background: linear-gradient(180deg, #ded2ff, #5c4e8b);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    inset 0 -2px 2px rgba(0,0,0,0.45),
    0 2px 5px rgba(0,0,0,0.35);
}
.pad-overdub {
  background: linear-gradient(180deg, #fff3c8, #c7a231);
  color: #3a2300;
}
.pad-play {
  background: linear-gradient(180deg, #dff7e0, #298346);
  color: #052713;
}
.pad-stop {
  background: linear-gradient(180deg, #f4f4f6, #868b94);
  color: #121418;
}
.pad-clear {
  background: linear-gradient(180deg, #ffe7c4, #c27d29);
  color: #3b1b00;
}
.auto-option {
  color: #d9dce6;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.auto-status {
  margin-left: auto;
  font-family: "Courier New", monospace;
  color: #f5c89b;
}
.auto-loop-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.3);
  pointer-events: none;
}
.auto-loop-block {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255,255,255,0.06);
  border-right: 1px solid rgba(255,255,255,0.15);
  pointer-events: none;
}
.automation-timeline {
  position: relative;
  height: 48px;
  border-radius: 10px;
  background: repeating-linear-gradient(
    to right,
    rgba(255,255,255,0.08) 0,
    rgba(255,255,255,0.08) 20px,
    rgba(255,255,255,0) 20px,
    rgba(255,255,255,0) 40px
  );
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}
#autoTimelineProgress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,135,48,0.5), rgba(255,49,42,0.5));
  pointer-events: none;
}
.automation-timeline.marker-armed {
  border-color: rgba(255, 187, 92, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 187, 92, 0.4), 0 0 12px rgba(255, 187, 92, 0.3);
}
.automation-timeline.marker-selecting {
  border-color: rgba(141, 197, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(141, 197, 255, 0.5), 0 0 12px rgba(141, 197, 255, 0.4);
}
.auto-automation-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.auto-automation-layer canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.automation-timeline .auto-loop-block { z-index: 1; }
.automation-timeline .auto-loop-marker { z-index: 2; }
#autoMarkerLayer { z-index: 3; }
#autoTimelineProgress { z-index: 3; }
.auto-timeline-loop-range { z-index: 4; }
.auto-marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.auto-marker-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.35), 0 0 8px rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
  pointer-events: auto;
  cursor: pointer;
}
.auto-marker-block.is-active {
  border-color: rgba(255,255,255,0.7);
  box-shadow: inset 0 0 8px rgba(255,255,255,0.3), 0 0 10px rgba(255,255,255,0.4);
}
.auto-marker-block.is-loop {
  border-color: rgba(116,208,149,0.9);
  background: rgba(24,55,28,0.7);
  box-shadow: inset 0 0 12px rgba(116,208,149,0.35), 0 0 10px rgba(104,186,137,0.35);
}
.auto-marker-block.is-point {
  width: 2px !important;
  min-width: 2px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
  transform: translateX(-50%);
}
.auto-marker-block .marker-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f4d5a3;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
}
.auto-marker-block.is-point .marker-label {
  transform: translate(-50%, -125%);
  position: absolute;
  left: 50%;
  top: -2px;
}
.auto-timeline-hover { z-index: 5; }
.auto-timeline-hover {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: linear-gradient(180deg, #3df487, #00d26a);
  box-shadow: 0 0 8px rgba(0,255,170,0.6);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-1px);
  transition: opacity 120ms ease;
}
.automation-timeline.show-hover .auto-timeline-hover {
  opacity: 1;
}
.auto-timeline-loop-range {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(0,255,190,0.12), rgba(0,255,146,0.2));
  border-left: 1px solid rgba(0,255,170,0.35);
  border-right: 1px solid rgba(0,255,170,0.35);
  box-shadow: inset 0 0 12px rgba(0,255,140,0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
}
.automation-timeline.selecting-loop .auto-timeline-loop-range {
  opacity: 0.4;
}
.automation-timeline.has-loop .auto-timeline-loop-range {
  opacity: 0.55;
}
.mix-card-actions {
  display: flex;
  gap: 6px;
}
.mix-pill {
  border: 1px solid #8d93a3;
  border-radius: 999px;
  padding: 3px 8px;
  background: linear-gradient(180deg, #f6f7fb, #ccd1db);
  color: #1b2231;
  font-weight: 600;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.mix-pill:hover {
  color: #fff;
  background: #585f73;
}
.mix-pill.active {
  background: #2f3545;
  color: #fff;
  border-color: #2f3545;
}
.mix-card.is-muted {
  opacity: 0.45;
}
.mix-card.is-dim {
  opacity: 0.65;
}
.mix-card.is-solo {
  box-shadow: 0 0 0 2px #ffda7a inset, 0 12px 24px rgba(0,0,0,0.35);
}
.mix-card h4 {
  margin: 0;
  font-size: 15px;
  color: #272b33;
}
.mix-card .mix-meta {
  font-size: 11px;
  color: #636a78;
}
 .mix-eq-row { display:flex; flex-direction:column; gap:4px; margin-bottom:2px; padding:2px 4px; border-radius:7px; background:linear-gradient(180deg,#c8a068,#8b6537); border:1px solid #5a3c20; box-shadow:inset 0 1px 3px rgba(255,255,255,0.3), inset 0 -1px 3px rgba(0,0,0,0.35); }
  .mix-eq-title {
    text-align: center;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #fff3d2;
  }
  .mix-eq-knobs {
    display: flex;
    justify-content: space-between;
    gap: 6px;
  }
.mix-eq-knob {
  width: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  color: #4a4035;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
}
.mix-eq-knob span {
  text-align: center;
  color: #fff1d0;
}
.knob-value {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(15,15,20,0.85);
  color: #fefefe;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.mix-eq-knob .knob-value {
  background: rgba(0,0,0,0.55);
}
.mix-comp-knob .knob-value {
  background: rgba(0,0,0,0.6);
  color: #ffd8a8;
}
.knob-value.is-visible {
  opacity: 1;
}
.knob-value.value-left {
  left: -38px;
}
.knob-value.value-right {
  right: -38px;
}
.mix-eq-dial {
  --eq-value: 0.5;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(0,0,0,0)),
    linear-gradient(180deg, #f8e1b3 0%, #c08a42 45%, #a3621d 100%);
  border: 1px solid #5a3a1d;
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.7),
    inset 0 -4px 6px rgba(0,0,0,0.4),
    0 2px 6px rgba(0,0,0,0.5);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s ease;
  touch-action: none;
}
.mix-eq-dial::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 9px;
  border-radius: 2px;
  background: linear-gradient(180deg, #1f1a16, #d2c2ad);
  top: 50%;
  left: 50%;
  transform-origin: center calc(100% - 1px);
  transform: translate(-50%, -48%) rotate(calc(-135deg + (270deg * var(--eq-value))));
  box-shadow: 0 1px 2px rgba(0,0,0,0.55);
}
.mix-eq-dial:focus-visible {
  outline: 2px solid #f8d58c;
  outline-offset: 2px;
}
.mix-eq-dial:hover {
  box-shadow:
    inset 0 3px 6px rgba(255,255,255,0.75),
    inset 0 -5px 8px rgba(0,0,0,0.4),
    0 3px 8px rgba(0,0,0,0.6);
}
.mix-comp-row {
  margin: 4px 0 6px;
  padding: 5px 6px;
  border-radius: 7px;
  border: 1px solid #21130c;
  background: linear-gradient(180deg, #22140d, #0d0805);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.04), inset 0 -1px 2px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mix-comp-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #f5c89b;
  text-align: center;
}
.mix-comp-knobs {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
}
.mix-comp-reset {
  display: flex;
  justify-content: center;
}
.mix-comp-reset button {
  border: 1px solid #f5c89b;
  background: rgba(0,0,0,0.4);
  color: #f5c89b;
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.mix-comp-reset button:hover {
  background: rgba(245,200,155,0.15);
}
.mix-comp-knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 9px;
  color: #f1dfc2;
  position: relative;
}
.mix-comp-knob span:nth-child(2) {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mix-comp-value {
  font-size: 9px;
  font-weight: 600;
  color: #ffd8a8;
  text-transform: none;
}
.mix-comp-dial {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: none;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(0,0,0,0)),
    linear-gradient(180deg, #f7ede0, #bfa788);
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.7),
    inset 0 -4px 6px rgba(0,0,0,0.4),
    0 2px 6px rgba(0,0,0,0.5);
  cursor: ns-resize;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.mix-comp-dial::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(180deg, #1f1a16, #d2c2ad);
  top: 50%;
  left: 50%;
  transform-origin: center calc(100% - 2px);
  transform: translate(-50%, -50%) rotate(calc(-135deg + (270deg * var(--comp-value, 0.5))));
  box-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.mix-comp-dial:focus-visible {
  outline: 2px solid #ffe3a3;
  outline-offset: 2px;
}

.mix-card .mix-level-readout {
  font-size: 9px;
  font-weight: 600;
  color: #1e2330;
  text-align: center;
  padding: 3px 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #e0e4ed, #c8ceda);
  border: 1px solid #b2b9c6;
  box-shadow: inset 0 1px 0 #ffffffa8, inset 0 -1px 0 #00000014;
}
.mix-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 4px;
  position: relative;
}

.mix-fader {
  position: relative;
  width: 27px;
  height: 116px;
  padding: 5px 5px;
  border-radius: 12px;
  background: linear-gradient(180deg, #4c3f31, #2a2118);
  border: 1px solid #120d08;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.65), inset 0 -2px 3px rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.mix-fader::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  width: 2px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.6),
    rgba(255,255,255,0.6) 8px,
    rgba(255,255,255,0) 8px,
    rgba(255,255,255,0) 16px
  );
  opacity: 0.35;
}

.mix-auto-clear {
  position: absolute;
  left: 50%;
  transform: translate(-80px, -50%);
  top: 50%;
  padding: 3px 6px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.35);
  color: #f5e4c3;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}
.mix-auto-clear.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.mix-auto-clear:hover {
  background: rgba(128,8,8,0.75);
}

.mix-slider {
  writing-mode: vertical-lr;
  direction: rtl;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: ns-resize;
  pointer-events: none;
}
.mix-slider::-webkit-slider-runnable-track {
  width: 5px;
  height: calc(100% - 8px);
  margin: 4px auto;
  border-radius: 10px;
  border: 1px solid #1f2026;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), rgba(0,0,0,0.25)) padding-box,
    linear-gradient(180deg, #d3d8e2 0%, #8f96a5 100%);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.6),
    0 1px 0 rgba(255,255,255,0.3);
}
.mix-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 14px;
  border-radius: 4px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(0,0,0,0.1)),
    linear-gradient(180deg, #fefefe 0%, #ccd1db 100%);
  border: 1px solid #5a5f6d;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -2px 2px rgba(0,0,0,0.35),
    0 3px 6px rgba(0,0,0,0.6);
  margin-top: -1px;
  margin-left: -6px;
}
.mix-slider::-moz-range-track {
  width: 5px;
  height: calc(100% - 8px);
  border-radius: 10px;
  border: 1px solid #1f2026;
  background: linear-gradient(180deg, #d3d8e2 0%, #8f96a5 100%);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.6),
    0 1px 0 rgba(255,255,255,0.3);
}
.mix-slider::-moz-range-thumb {
  width: 20px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, #fefefe 0%, #ccd1db 100%);
  border: 1px solid #5a5f6d;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -2px 2px rgba(0,0,0,0.35),
    0 3px 6px rgba(0,0,0,0.6);
  transform: translateX(-6px);
}
.mix-meter-vert {
  position: relative;
  width: 10px;
  height: 116px;
  border-radius: 8px;
  border: 1px solid #282b34;
  background: linear-gradient(180deg, #161925, #06070c);
  box-shadow: inset 0 1px 0 #ffffff1a, inset 0 -3px 5px #000000b0;
  overflow: hidden;
}
.mix-meter-fill {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  background: linear-gradient(180deg, #27c05a, #1a8f3f);
  border-radius: 0 0 6px 6px;
  transition: height 0.12s ease;
}
.mix-meter-fill.hot {
  background: linear-gradient(180deg, #ff8730, #ff312a);
}
.mix-card footer {
  font-size: 11px;
  color: #767c8a;
  text-align: center;
}
.right {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
/* Visually merge the top control panels into one block */
.left .panel:nth-of-type(1) { border-bottom: none; border-radius: 8px 8px 0 0; }
.left .panel:nth-of-type(2) { border-top: none; border-radius: 0 0 8px 8px; }
.left .panel:nth-of-type(n+2) h3 { display: none; }
/* Ensure right panels never overflow their track */
.right .panel { max-width: none; overflow: hidden; }
.right, .right .panel, .controls-row, .panel .buttons { min-width: 0; }

.panel { background: linear-gradient(180deg, var(--face), var(--face-2)); border: 1px solid var(--face-edge); border-radius: 8px; box-shadow: inset 0 1px 0 #fff6, inset 0 -1px 0 #0002; padding: 8px; }
.panel h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #4b4f58; }
.panel-headline { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.panel-headline p { margin: 0; font-size: 12px; color: #5f6168; }
.panel .group { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.panel .buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.panel .controls { background: none; border: 0; box-shadow: none; padding: 0; }
.drum-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.drum-card {
  border: 1px solid var(--face-edge);
  border-radius: 8px;
  padding: 8px;
  background: linear-gradient(180deg, #fbfcff, #e9edf5);
  box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.drum-card h4 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #30323a;
  display: flex;
  align-items: center;
  gap: 8px;
}
.drum-card h4 .voice-badge {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  border: none;
  background: #343844;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  font-family: inherit;
  appearance: none;
  box-shadow: inset 0 1px 0 #ffffff55, inset 0 -1px 0 #00000022;
  transition: transform .1s ease, box-shadow .15s ease;
}
.drum-card h4 .voice-badge:hover {
  transform: translateY(-1px);
}
.drum-card h4 .voice-badge:focus-visible {
  outline: 2px solid #8fb5ff;
  outline-offset: 1px;
}
.drum-card h4 .voice-badge.muted {
  box-shadow: inset 0 1px 0 #ffffff22, inset 0 -1px 0 #00000033;
  color: #d6dae4;
}
.drum-card h4 .voice-name {
  flex: 1;
}
.mix-card.master-card {
  grid-column: -1;
  background: linear-gradient(180deg, #f9f1d2 0%, #d7a951 100%);
  border: 1px solid #c18c3d;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    inset 0 -1px 0 rgba(0,0,0,0.25),
    0 10px 24px rgba(0,0,0,0.55);
}
.master-card .mix-slider-wrap {
  align-items: center;
}
.master-card .mix-meter-vert {
  height: 160px;
}
.master-card .mix-level-readout {
  background: linear-gradient(180deg, #fff3ce, #f3c164);
  border-color: #c88728;
  color: #5a3202;
}
.master-card footer {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: #5a3202;
}
.drum-card .knob { margin: 0; }
.drum-card .voice-knobs {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: stretch;
}
.drum-card .voice-knobs .knob {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
}
.drum-card .voice-knobs .knob label {
  font-size: 9px;
  letter-spacing: .05em;
  margin-bottom: 2px;
}
.drum-card .voice-knobs .knob input[type="range"] {
  height: 14px;
}
/* One-line controls row */
.controls-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; overflow: hidden; }
.controls-row .knob { flex: 0 1 auto; min-width: 0; }
.tidy-row .ctl-group { flex: 0 1 auto; min-width: 0; }
.controls-row.one-line { flex-wrap: nowrap; gap: 6px; }
/* Reserve-space hidden state (keeps layout width stable without showing content) */
.hidden-reserve { visibility: hidden; pointer-events: none; }
/* Fix widths for PWM knobs so layout width stays constant */
.knob.pwm { flex: 0 0 92px; min-width: 92px; }
body.compact .knob.pwm { flex-basis: 84px; min-width: 84px; }

/* Prevent overlap on narrower screens: allow control strip to wrap if needed */
@media (max-width: 1280px) {
  #controlStrip .controls-row.one-line { flex-wrap: wrap; }
}

/* PWM secondary row */
.pwm-row { display: none; gap: 8px; align-items: center; margin-top: 4px; }
.pwm-row.show { display: flex; }
body.compact .pwm-row { gap: 6px; }
.controls-row.one-line .knob { min-width: 72px; }
.controls-row.one-line select { width: 100px; }
/* Tidy control strip groups */
.tidy-row .ctl-group { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; background: linear-gradient(180deg, #f4f6fa, #e6e9f1); border: 1px solid var(--face-edge); border-radius: 8px; box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011; }
.tidy-row .ctl-group + .ctl-group { margin-left: 8px; }
.tidy-row .group-wave select { width: 120px; }
.tidy-row .group-filter .knob, .tidy-row .group-fx .knob { min-width: 72px; }
body.compact .tidy-row .ctl-group { padding: 4px 6px; border-radius: 6px; }
.controls-row .knob { min-width: 80px; }
.controls-row select { width: 110px; }
/* Inline rows for grouped buttons (e.g., Shift left/right) */
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls-row { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.controls-row .knob { min-width: 90px; }
.controls-row select { width: 110px; }

.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; background: none; padding: 0; border: 0; box-shadow: none; }
.knob { text-align: center; }
.knob label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .08em; }
.knob input[type="range"] { width: 100%; }
.knob select { width: 100%; }

/* Sequencer Tools toolbar (single line at typical widths) */
#seqToolsBottom .buttons { display: none; }
#seqToolsBottom .controls-row { display: none; }
.tools-bar { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; overflow: visible; }
.tools-bar .group { display: inline-flex; align-items: center; gap: 6px; }
.tools-bar input[type="text"] { width: 180px; max-width: 30vw; }
.btn-sm { padding: 3px 6px; font-size: 11px; }
.btn-xs { padding: 2px 4px; font-size: 10px; line-height: 1.1; }
.btn.active { filter: brightness(1.05); box-shadow: inset 0 1px 0 #fff8, 0 0 0 2px rgba(34,204,136,.18); }
/* Highlighted arrangement area */
.tools-bar .arr-group {
  background: linear-gradient(180deg, #f4f6fa, #e6e9f1);
  border: 1px solid var(--face-edge);
  border-radius: 6px;
  padding: 4px 6px;
  box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011;
}
.tools-bar .arr-group label { margin-right: 2px; }

/* TB-303 styled dropdowns (silver face, custom arrow) */
.transport select,
.panel select,
.knob select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  color: #333;
  background:
    linear-gradient(180deg, #eef1f5, #cbd0d8) padding-box,
    linear-gradient(180deg, #ffffffaa, #00000011) border-box;
  border: 1px solid var(--face-edge);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011, 0 1px 1px rgba(0,0,0,.1);
  outline: none;
  cursor: pointer;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px 14px;
}
.transport select:hover,
.panel select:hover,
.knob select:hover { filter: brightness(1.02); }
.transport select:focus,
.panel select:focus,
.knob select:focus { box-shadow: 0 0 0 2px rgba(34, 204, 136, .25), inset 0 1px 0 #fff; }
.transport select:disabled,
.panel select:disabled,
.knob select:disabled { opacity: .6; cursor: default; }

/* Compact tweaks for dropdowns */
body.compact .transport select,
body.compact .panel select,
body.compact .knob select { padding: 4px 24px 4px 8px; font-size: 11px; }

/* TB-303 style rotary knobs */
.dial { display: none; }
.dial .cap { display: none; }
.dial .marker { display: none; }
.dial .ticks, .dial .tick { display: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.sequencer {
  margin-top: 5px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
}

/* Space between sequencer and tools panel */
#seqToolsBottom { margin-top: 5px; }
/* Flat top, rounded bottom for Sequencer Tools panel */
#seqToolsBottom.panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Tweak step minimum width as screen narrows */
@media (max-width: 1200px) {
  .sequencer { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
}
@media (max-width: 900px) {
  .sequencer { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .step { padding: 6px 4px 6px; }
  .pbtn { padding: 5px 4px; font-size: 9px; }
  .pitch .mini, .oct .mini { padding: 3px; font-size: 9px; }
}
@media (max-width: 600px) {
  .sequencer { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .step header { font-size: 10px; }
}

.step {
  background: linear-gradient(180deg, var(--face), var(--face-2));
  border: 1px solid var(--face-edge);
  border-radius: 6px;
  padding: 6px 6px 8px;
  display: grid;
  gap: 6px;
  box-shadow: inset 0 1px 0 #fff6, inset 0 -1px 0 #0002;
}
.step { min-width: 90px; }
.step.active { outline: 2px solid rgba(34,204,136,.35); }
.step[draggable="true"] { cursor: grab; }
.step.dragging { opacity: .6; cursor: grabbing; }
.step.drag-over { outline: 2px dashed var(--accent); }
.step.drag-over::after { content: ""; display: block; height: 0; }
.step header { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); gap: 4px; flex-direction: column; }
.step header .led { width: 14px; height: 14px; border-radius: 50%; background: #5b1f1f; border: 1px solid #7a3a3a; box-shadow: inset 0 -2px 3px rgba(0,0,0,.6); display: inline-block; }
.step header .led.lit { background: var(--led-on); box-shadow: 0 0 8px var(--led-on), inset 0 -1px 2px rgba(0,0,0,.6); border-color: #b83a2a; }
.step .index { font-size: 10px; color: #777; letter-spacing: .06em; }
.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
  gap: 4px;
}
.step .voice-btn {
  font-size: 9px;
  padding: 4px;
  border-color: rgba(0,0,0,.1);
}
.step .voice-btn.active {
  color: #fff;
  background: var(--voice-color, var(--accent));
  border-color: var(--voice-color, var(--accent));
  box-shadow: 0 0 6px rgba(0,0,0,.2);
}
.row { display: grid; grid-template-columns: 1fr; gap: 4px; }
.row.toggles { display: flex; gap: 4px; }
.row.toggles.single { display: flex; }
.row.toggles.single .pbtn { flex: 1; }
.row.toggles.duo { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.pitch.row, .oct.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 4px 0;
}
.pitch-label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: #444;
}
.pitch.row .pbtn.mini,
.oct.row .pbtn.mini {
  flex: 0 0 28px;
  padding: 4px;
}
.row select, .row input[type="checkbox"] { width: 100%; }
/* Hide legacy form controls inside steps; replaced by TB-style buttons */
.row.toggles label, .row.toggles input[type="checkbox"] { display: none; }
.row select { display: none; }

/* TB-303 like push buttons for sequencer */
.pbtn {
  background: linear-gradient(#eef1f5, #cbd0d8);
  border: 1px solid var(--face-edge);
  border-radius: 4px;
  padding: 6px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #333;
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 #0001, 0 1px 1px rgba(0,0,0,.15);
  cursor: pointer;
}
.pbtn.active { background: linear-gradient(#e4d6ff, #c2a9ff); border-color: #9c85db; color: #3d2f70; }
.pbtn:active { transform: translateY(1px); }

.led2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 22px;
  margin-right: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 13px;
  letter-spacing: 1px;
  color: #ff3b30;
  background: #0a0a0c;
  border: 1px solid #2a2a2f;
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgba(255,0,0,.15), inset 0 -2px 4px rgba(0,0,0,.5);
  text-shadow: 0 0 6px rgba(255,0,0,.5);
}

.pitch { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; }
.pitch .mini { padding: 4px; font-size: 10px; }
.pitch .label { font-size: 11px; text-align: center; color: #444; }
.oct { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.oct .mini { padding: 4px; font-size: 10px; }

button,
.btn {
  background: linear-gradient(#e8e8ee, #cfd2d8);
  color: var(--text);
  border: 1px solid var(--face-edge);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 #fff8;
}
.icon-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { display: block; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:hover:not(:disabled) { filter: brightness(1.03); }
.btn.btn-start { background: linear-gradient(#ffb27c, var(--btn-start)); color: #fff; border-color: #ce6a16; }
.btn.btn-stop { background: linear-gradient(#ff8e86, var(--btn-stop)); color: #fff; border-color: #c22f25; }
.btn.btn-small { padding: 4px 8px; font-size: 12px; }
.btn-rec { background: linear-gradient(#2b6fb8, #1a57a0); color: #fff; border-color: #164c8c; }
.btn-rec.active { filter: none; box-shadow: 0 0 0 2px rgba(43,111,184,.28); }
.btn-rec.recording { background: linear-gradient(#1f7d4f, #175b3a); border-color: #134b30; }
.btn-del { background: linear-gradient(#b83b3b, #962b2b); color: #fff; border-color: #7f2323; }

/* Arrangement blocks (drag reorder) */
/* Octave button press feedback */
.btn.btn-small.oct-active-1 { background: linear-gradient(#e3d2ff, #c0a0ff); color: #352964; border-color: #9f8ad8; box-shadow: 0 0 0 2px rgba(159,138,216,.28) inset; }
.btn.btn-small.oct-active-2 { background: linear-gradient(#d9c4ff, #b48cff); color: #2c2156; border-color: #9277d1; box-shadow: 0 0 0 2px rgba(146,119,209,.38) inset; }

/* Metallic TB-303 style for transport icons */
.btn.icon-btn,
.btn.btn-start.icon-btn,
.btn.btn-stop.icon-btn {
  background: radial-gradient(circle at 30% 30%, #f4f5f7, #c6c9cf);
  border: 1px solid #aab0bb;
  color: #333;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,.15),
    inset 0 -2px 3px rgba(255,255,255,.4),
    0 1px 2px rgba(0,0,0,.15);
}
.btn.icon-btn svg { color: currentColor; }
.btn.icon-btn:hover:not(:disabled) {
  filter: none;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,.18),
    inset 0 -2px 3px rgba(255,255,255,.5),
    0 2px 3px rgba(0,0,0,.2);
}
.btn.icon-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 3px 6px rgba(0,0,0,.25),
    inset 0 -1px 2px rgba(255,255,255,.45),
    0 1px 1px rgba(0,0,0,.1);
}

input[type="file"] { color: var(--muted); }

/* Additions: hint, level meter, status */
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 10px; }

.status { margin-top: 8px; color: #364; background: #eaf7ef; border: 1px solid #b7e1c2; padding: 6px 8px; border-radius: 6px; font-size: 12px; }
.status.error { color: #632; background: #fbeeed; border-color: #f1c4c0; }

/* Drag-to-DAW handles */

/* SVG knob skin */
.k {
  width: 34px;
  height: 34px;
  position: relative;
  margin: 0 auto 4px;
  cursor: grab;
  touch-action: none;
}
.k.dragging { cursor: grabbing; }
.k-svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.k:hover { filter: brightness(1.04); }
.k-plate { fill: #bfc5cf; stroke: #9ba2b0; stroke-width: 1.4; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.k-ring { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 2; }
.k-knurl { fill: none; stroke: #8d93a2; stroke-width: 8; stroke-dasharray: 3 6; opacity: .55; }
.k-face { stroke: #8e94a2; stroke-width: 1.2; }
.k-highlight { fill: none; stroke: rgba(255,255,255,.55); stroke-width: 3; stroke-linecap: round; }
.k-tick { stroke: rgba(0,0,0,.25); stroke-width: 1.4; stroke-linecap: round; }
.k-pointer { stroke: #1f2024; stroke-width: 2.6; stroke-linecap: round; }
.k-pointer-dot { fill: #1f2024; }
.k-cap { stroke: #7d838f; stroke-width: 1; }
.k-value {
  font-size: 10px;
  color: #333;
  min-height: 12px;
  line-height: 12px;
  letter-spacing: .04em;
}
body.compact .k { width: 26px; height: 26px; }

/* Ultra-compact layout to fit everything on one screen */
.compact-grid { display: grid; grid-template-rows: auto auto 1fr; gap: 8px; height: 100%; }
body.compact .panel { padding: 6px; }
body.compact .panel h3 { font-size: 10px; margin-bottom: 4px; }
body.compact .panel .group { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
body.compact .panel .buttons { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
body.compact .dial { width: 36px; height: 36px; }
body.compact .dial .cap { width: 20px; height: 20px; }
body.compact .dial .marker { height: 13px; transform-origin: 50% 13px; transform: translate(-50%, -13px) rotate(0deg); }
body.compact .dial .tick { height: 3px; transform-origin: 50% 14px; }
body.compact .knob label { font-size: 10px; }
body.compact .btn, body.compact button { padding: 4px 6px; font-size: 12px; }
body.compact .icon-btn { width: 36px; height: 36px; }
body.compact .sequencer { grid-template-columns: repeat(8, minmax(100px, 1fr)); gap: 6px; }
body.compact .step { padding: 4px; }
/* In compact mode, keep note and octave controls visible */
body.compact .row.pitch, body.compact .row.oct { display: grid; }
body.compact .pbtn { padding: 4px 3px; font-size: 9px; }

/* --- Right-side 303-styled modules --- */
.panel-303 { padding: 6px; }
.panel-303 h3 { margin: 0 0 6px; padding: 4px 6px; font-size: 10px; letter-spacing: .14em; color: #555b66; background: linear-gradient(180deg, #e9edf3, #cfd4dc); border: 1px solid #b7bcc6; border-radius: 4px; box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011; display: inline-block; }
.panel-303 .mod-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; align-items: center; }
/* Make randomize buttons fit on one line */
#panelRandom .mod-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
#panelRandom .mod-body .btn-303 { white-space: normal; width: 100%; justify-self: stretch; padding: 6px 8px; }
#panelRandom #randomizePattern.btn-dark { background: linear-gradient(#d5d9df, #b9bec7); border-color: #aab0bb; color: #222; }

#randomizePattern {
  position: relative;
  overflow: hidden;
  z-index: 0;
}

#randomizePattern::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 8px;
  background: linear-gradient(120deg, #ff007a, #ffae00, #00e1ff, #9d00ff, #ff007a);
  background-size: 300% 300%;
  animation: rainbowPulse 3s ease infinite;
  z-index: -1;
  filter: blur(6px);
  opacity: 0.6;
}

#randomizePattern:focus-visible::after,
#randomizePattern:hover::after {
  opacity: 0.85;
}

@keyframes rainbowPulse {
  0% { transform: scale(0.95); background-position: 0% 50%; }
  50% { transform: scale(1.05); background-position: 100% 50%; }
  100% { transform: scale(0.95); background-position: 0% 50%; }
}

/* 303-style compact buttons */
.btn-303 { background: linear-gradient(#eef1f5, #cbd0d8); border: 1px solid var(--face-edge); border-radius: 6px; box-shadow: inset 0 1px 0 #fff8, 0 1px 1px rgba(0,0,0,.12); font-size: 12px; padding: 6px 8px; }
.btn-303:active { transform: translateY(1px); }
.btn-303.btn-sm { padding: 4px 6px; font-size: 11px; }

/* Improved drag handles */
/* drag handles removed */


/* Recent menu popover */
.recent-wrap { position: relative; display: inline-block; }
.recent-menu {
  position: fixed; /* overlay above panels; positioned via JS */
  z-index: 10000;
  min-width: 260px;
  max-width: 340px;
  max-height: 240px;
  overflow: auto;
  background: linear-gradient(180deg, var(--face), var(--face-2));
  border: 1px solid var(--face-edge);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25), inset 0 1px 0 #fff6, inset 0 -1px 0 #0002;
  padding: 6px;
}
.recent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.recent-item:hover { background: rgba(0,0,0,.06); }
.recent-name { font-size: 12px; color: #222; }
.recent-time { font-size: 11px; color: #666; }
.recent-empty { font-size: 12px; color: #666; padding: 6px; }
/* LCD-like status */
.status.lcd { background: linear-gradient(180deg, #1c2b22, #16251d); color: #8ff0a4; border-color: #2f4a3c; box-shadow: inset 0 1px 2px rgba(0,0,0,.4); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
/* FILE panel 303 styling */
#panelFile .file-rows { display: grid; grid-template-columns: 1fr; gap: 0; }
#panelFile .mod-body.file-rows { grid-template-columns: 1fr !important; }
#panelFile .file-row.meta { grid-column: 1; }
#panelFile .file-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; align-items: center; }
#panelFile .btn-303 { justify-content: center; display: inline-flex; align-items: center; padding: 4px; font-size: 10px; width: 100%; }
#panelFile .btn-303.btn-wide { min-width: 0; }
#panelFile .recent-wrap { position: relative; display: inline-flex; }
#panelFile .recent-wrap .btn-303 { width: 100%; }
#panelFile .btn-303 .btn-ico { margin-right: 6px; vertical-align: -2px; display: inline-block; width: 14px; height: 14px; flex: 0 0 auto; }
#panelFile .btn-303 svg { display: inline-block; width: 14px; height: 14px; margin-right: 6px; }
#panelFile .recent-wrap { flex: 1 1 0; min-width: 0; }
#panelFile .file-row.meta {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--face-edge);
}
#panelFile .badge-plate {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  color: #3c4250;
  background: linear-gradient(180deg, #eef1f5, #cbd0d8);
  border: 1px solid var(--face-edge);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011;
  white-space: nowrap;
}
#panelFile .wt-label {
  display: block;
  padding: 6px 8px;
  background: #f3f6fa;
  border: 1px dashed var(--face-edge);
  border-radius: 6px;
}

/* Separate Wavetable panel styling */
#panelWT .wt-body { display: grid; grid-template-columns: 1fr; gap: 8px; }
#panelWT .wt-label { display: block; padding: 8px; background: #f3f6fa; border: 1px dashed var(--face-edge); border-radius: 6px; }
#panelWT .wt-help { font-size: 11px; color: #555; }

#panelWT .panel-desc { font-size: 11px; color: #555; margin: 6px 0 8px; }

.arr-inline {
  background: linear-gradient(180deg, #f4f6fa, #e6e9f1);
  border: 1px solid var(--face-edge);
  border-radius: 6px;
  padding: 4px 6px;
  box-shadow: inset 0 1px 0 #ffffffaa, inset 0 -1px 0 #00000011;
  gap: 6px;
}
.arr-inline-track {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 160px;
  max-width: 240px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 6px;
  cursor: pointer;
}
.arr-inline-track:active { cursor: grabbing; }
.arr-inline-track::-webkit-scrollbar { height: 4px; }
.arr-inline-track::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 4px; }
.arr-inline-actions { display: inline-flex; gap: 4px; }
.arr-label { font-size: 11px; color: #555; text-transform: uppercase; letter-spacing: .08em; }
.arr-block {
  min-width: 28px;
  padding: 3px 4px;
  border-radius: 6px;
  border: 1px solid #a7aebc;
  background: linear-gradient(180deg, #f8f9fd, #dfe4ee);
  font-size: 11px;
  font-weight: 600;
  color: #4c5466;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(12,15,22,.2);
}
.arr-block.playing { border-color: #22cc88; box-shadow: 0 0 0 2px rgba(34,204,136,.25); }
.arr-block.active-edit { background: linear-gradient(180deg, #f4fffb, #d7f7eb); }
.arr-block.selected-remove { outline: 1px solid #d94b4b; }
.arr-block.drag-over { outline: 1px dashed rgba(76,84,102,.5); }


/* Render panel: keep three buttons on one line */
#panelRender .mod-body { display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; }
#panelRender .mod-body .btn-303 { flex: 1 1 120px; min-width: 0; white-space: normal; }
#panelRender .render-progress {
  position: relative;
  width: 100%;
  margin-top: 4px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #dfe4ee, #c6ccd9);
  box-shadow: inset 0 1px 0 #ffffffb3, inset 0 -1px 0 #0000001a;
  overflow: hidden;
  font-size: 11px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
}
#panelRender .render-progress[hidden] { display: none; }
.render-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #26c46d, #1ba1f2);
  transition: width 0.15s ease;
}
#renderProgressLabel {
  position: relative;
  font-weight: 600;
}







