/* Controls: buttons, fields, knobs, meters, panels, overlays. */

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease), transform 60ms var(--ease), box-shadow var(--fast) var(--ease);
}

.btn:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel-3));
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: var(--accent-line);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px var(--accent-soft), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-soft);
  color: var(--text);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 8px;
}

.btn-lg {
  height: 48px;
  padding: 0 28px;
  font-size: 14px;
  border-radius: 12px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 28px;
}

.btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hi);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 84, 112, 0.08);
  border-color: var(--danger);
  color: var(--danger);
}

/* --------------------------------------------------------------- transport */

.transport {
  display: flex;
  align-items: center;
  gap: 6px;
}

.play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #2a3140, #171c25);
  border: 1px solid var(--line-2);
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    color var(--fast) var(--ease), transform 60ms var(--ease);
}

.play-btn:hover {
  border-color: #3d4a5e;
}

.play-btn:active {
  transform: scale(0.96);
}

.play-btn svg {
  width: 17px;
  height: 17px;
}

.play-btn.is-playing {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: var(--accent-line);
  color: var(--accent-ink);
  box-shadow: var(--glow);
}

/* ------------------------------------------------------------------ record */

.rec-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #2a3140, #171c25);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-1);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    transform 60ms var(--ease);
}

.rec-btn::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.rec-btn:hover {
  border-color: #3d4a5e;
}

.rec-btn:active {
  transform: scale(0.96);
}

.rec-btn.is-armed::after {
  animation: rec-pulse 900ms ease-in-out infinite;
}

.rec-btn.is-recording {
  border-color: var(--danger);
  box-shadow: 0 0 18px rgba(255, 84, 112, 0.45);
}

.rec-btn.is-recording::after {
  box-shadow: 0 0 10px rgba(255, 84, 112, 0.8);
}

@keyframes rec-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------ fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.field-label {
  font-size: 8px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
  padding-left: 2px;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 26px 0 10px;
  border-radius: 9px;
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a94a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 9px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.select:hover {
  border-color: var(--line-2);
  background-color: var(--panel-3);
}

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

.select option {
  background: var(--panel-2);
  color: var(--text);
}

/* ------------------------------------------------------------- stepper */

.field-bare {
  gap: 0;
}

.harmony-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
}

.harmony-row .field-bare:first-child {
  flex: 0 0 auto;
}

.harmony-row .field-bare:first-child .select {
  min-width: 54px;
}

.harmony-row .field-bare:last-child {
  flex: 1 1 0;
  min-width: 0;
}

.harmony-row .select {
  height: 34px;
  padding: 0 22px 0 8px;
  font-size: 12px;
}

/* Stack quick buttons: one row under the root/octave/scale controls. */
.stack-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.stack-btn {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.stack-btn:hover {
  border-color: var(--line-2);
  color: var(--text-2);
}

.stack-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hi);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.harmony-range {
  margin-top: 8px;
}

/* Loop settings row: three unlabelled selects, like the harmony row. */
.loop-settings .field-bare {
  flex: 1 1 0;
  min-width: 0;
}

.loop-settings .select {
  width: 100%;
}

.loop-pad-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.loop-pad-row .dragnum {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
}

.harmony-loops {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.loop-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 4px 0 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--panel-2);
}

.loop-row.is-selected {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.loop-row.is-muted {
  opacity: 0.5;
}

.loop-row.is-live {
  border-color: var(--danger);
  background: rgba(255, 84, 112, 0.08);
}

.loop-row-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-pulse 900ms ease-in-out infinite;
}

.loop-row-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}

.loop-row.is-selected .loop-row-name {
  color: var(--accent-hi);
}

.loop-row-len {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--dim);
}

.loop-row-btn {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.loop-row-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.loop-row-btn.is-on {
  color: var(--accent-hi);
}

.loop-row-del:hover {
  color: var(--danger);
  background: rgba(255, 84, 112, 0.1);
}

.stepper {
  display: inline-flex;
  align-items: center;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.stepper-btn {
  width: 30px;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.stepper-btn:active {
  background: var(--accent-soft);
  color: var(--accent-hi);
}

.stepper-value {
  min-width: 24px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* ------------------------------------------------------------- drag number */

.dragnum {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 58px;
  height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color var(--fast) var(--ease);
}

.dragnum:hover {
  border-color: var(--line-2);
}

.dragnum-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.dragnum-label {
  font-size: 7px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

/* ------------------------------------------------------------------- knobs */

.knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: ns-resize;
}

.knob-dial {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
}

.knob-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 225deg,
    var(--accent) calc(var(--p, 0) * 270deg),
    rgba(255, 255, 255, 0.07) 0
  );
  -webkit-mask: radial-gradient(closest-side, transparent 68%, #000 69%);
  mask: radial-gradient(closest-side, transparent 68%, #000 69%);
}

.knob-cap {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: linear-gradient(180deg, #2c3443, #141922);
  border: 1px solid #333d4e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.knob-cap::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 2px;
  height: 9px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: 50% 12px;
  transform: rotate(calc(-135deg + var(--p, 0) * 270deg));
  box-shadow: 0 0 6px var(--accent-line);
}

.knob.is-dragging .knob-cap {
  border-color: var(--accent-line);
}

.knob-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  width: 100%;
}

.knob-label {
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.knob-value {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--accent-hi);
  white-space: nowrap;
}

/* -------------------------------------------------------------- param panel */

.param-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-group {
  padding: 11px 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 60%), var(--panel-2);
  border: 1px solid var(--line-soft);
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

.group-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.knob-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 4px;
}

.knob-grid .field {
  grid-column: span 3;
}

/* A lone fourth knob sits centred instead of hanging off the left edge. */
.knob-grid > :nth-child(4):last-child {
  grid-column: 2;
}

.knob-grid > :only-child {
  grid-column: 2;
}

/* -------------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  flex: 0 0 auto;
}

.tab {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.tab:hover {
  color: var(--text-2);
}

.tab.is-active {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel-3));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* --------------------------------------------------------------- segmented */

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.segmented button {
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.segmented button:hover {
  color: var(--text-2);
}

.segmented button.is-active {
  background: var(--accent-soft);
  color: var(--accent-hi);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* ------------------------------------------------------------------- meter */

.meter {
  display: flex;
  gap: 2px;
  align-items: stretch;
  height: 30px;
  width: 22px;
  padding: 3px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.meter-bar {
  position: relative;
  flex: 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(0deg, #3ddc97 0%, #b8e986 55%, #ffd166 78%, #ff5470 100%);
  transition: height 70ms linear;
}

/* ------------------------------------------------------------ pattern tabs */

.pattern-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pattern-tab {
  position: relative;
  height: 40px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
    border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.pattern-tab:hover {
  border-color: var(--line-2);
  color: var(--text-2);
}

.pattern-tab.is-active {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: var(--accent-line);
  color: var(--accent-ink);
  box-shadow: var(--glow);
}

.pattern-tab .dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-2);
  opacity: 0.9;
  display: none;
}

.pattern-tab.has-notes .dot {
  display: block;
}

.pattern-tab.is-active .dot {
  background: var(--accent-ink);
}

/* ----------------------------------------------------------------- presets */

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.preset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  text-align: left;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.preset:hover {
  background: var(--panel-2);
  border-color: var(--line-soft);
}

.preset.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.preset-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.preset.is-active .preset-name {
  color: var(--accent-hi);
}

.preset-tag {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

/* ---------------------------------------------------------------- sidebar */

.side-section {
  padding: 11px 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 60%), var(--panel-2);
  border: 1px solid var(--line-soft);
}

.side-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
}

.side-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.side-row {
  display: flex;
  gap: 6px;
}

.side-row .btn {
  flex: 1;
}

.side-note {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--dim);
}

/* ------------------------------------------------------------------ stage */

.stage-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
  flex: 0 0 auto;
}

.stage-hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The piano roll's controls, hosted in the stage head beside Roll/Steps. */
.roll-tools {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

/* Inside the host the toolbar has to shrink so its own overflow-x can scroll;
   as a bare child of the roll it must not grow vertically. */
.roll-tools .roll-toolbar {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 900px) {
  .stage-head {
    flex-wrap: nowrap;
    gap: 6px;
  }
}

/* ------------------------------------------------------------------- pads */

.pads {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px;
  flex: 0 0 auto;
  min-height: 64px;
  scrollbar-width: none;
}

.pads::-webkit-scrollbar {
  display: none;
}

.pad {
  flex: 1 0 52px;
  min-width: 52px;
  height: 60px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
    border-color var(--fast) var(--ease), transform 60ms var(--ease);
}

.pad:hover {
  border-color: var(--line-2);
}

.pad.is-root {
  border-color: var(--accent-line);
}

.pad.is-down {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  border-color: var(--accent-line);
  color: var(--accent-ink);
  box-shadow: var(--glow);
  transform: translateY(1px);
}

.pad-note {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--mono);
}

.pad-deg {
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}

.pad.is-down .pad-deg {
  color: rgba(0, 0, 0, 0.65);
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

@media (max-width: 860px) {
  .toasts {
    right: 12px;
    bottom: 84px;
  }
}

.toast {
  padding: 9px 15px;
  border-radius: 10px;
  background: rgba(20, 24, 33, 0.96);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  color: var(--text-2);
  animation: toast-in 180ms var(--ease);
}

.toast.is-out {
  animation: toast-out 200ms var(--ease) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

/* ------------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fade-in 160ms var(--ease);
}

.modal {
  width: min(600px, 100%);
  max-height: 82dvh;
  overflow-y: auto;
  padding: 22px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%), var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  animation: modal-in 200ms var(--ease);
}

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

.modal-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal h3 {
  margin: 16px 0 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-hi);
  font-weight: 800;
}

.modal p,
.modal li {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.modal ul {
  margin: 0;
  padding-left: 18px;
}

.modal kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  text-align: center;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

/* -------------------------------------------------------------------- boot */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 50% 0%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, var(--accent-2-soft), transparent 60%),
    var(--bg);
  transition: opacity 420ms var(--ease), visibility 420ms var(--ease);
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  animation: drift 24s linear infinite;
}

@keyframes drift {
  to {
    background-position: 44px 44px, 44px 44px;
  }
}

.boot-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.boot-mark {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  gap: 4px;
  margin-bottom: 4px;
}

.boot-mark span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.18;
  animation: pulse 2.4s var(--ease) infinite;
}

.boot-mark span:nth-child(1) { animation-delay: 0s; }
.boot-mark span:nth-child(2) { animation-delay: 0.12s; }
.boot-mark span:nth-child(3) { animation-delay: 0.24s; }
.boot-mark span:nth-child(4) { animation-delay: 0.36s; }
.boot-mark span:nth-child(5) { animation-delay: 0.48s; }
.boot-mark span:nth-child(6) { animation-delay: 0.6s; }
.boot-mark span:nth-child(7) { animation-delay: 0.72s; }
.boot-mark span:nth-child(8) { animation-delay: 0.84s; }
.boot-mark span:nth-child(9) { animation-delay: 0.96s; }

@keyframes pulse {
  0%, 100% { opacity: 0.16; }
  50% { opacity: 1; box-shadow: 0 0 14px var(--accent-line); }
}

.boot-title {
  font-size: clamp(34px, 8vw, 62px);
  font-weight: 800;
  letter-spacing: 0.2em;
  padding-left: 0.2em;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 0%, var(--accent-hi) 55%, var(--accent-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.boot-sub {
  font-size: 13px;
  color: var(--muted);
  max-width: 34ch;
}

.boot-hint {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --------------------------------------------------------------- utilities */

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spacer {
  flex: 1;
}

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--muted);
}

.dim {
  color: var(--dim);
}

/* ------------------------------------------------------------- panel tabs */

.panel-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  width: max-content;
  max-width: 100%;
}

.panel-tab {
  height: 28px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}

.panel-tab:hover {
  color: var(--text-2);
}

.panel-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent-hi);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* -------------------------------------------------------------- field grid */

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-grid .field {
  min-width: 0;
}

.field-grid .field.is-wide {
  grid-column: span 2;
}

/* Landscape phones: keep transient toasts off the control panel. */
@media (orientation: landscape) and (max-height: 600px) {
  .toasts {
    top: 58px;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    align-items: center;
  }
}

/* Drawer triggers only exist on narrow screens. Declared last so it wins over
   the .btn display rule. */
.only-mobile {
  display: none;
}

@media (max-width: 1080px) {
  .only-mobile {
    display: inline-flex;
  }
}

/* The meter is decorative; on phones the space is better spent on controls. */
@media (max-width: 860px) {
  .meter {
    display: none;
  }
}

/* ------------------------------------------------------------------ toggle */

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.toggle:hover {
  border-color: var(--line-2);
}

.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 30px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-2);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}

.toggle.is-on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hi);
}

.toggle.is-on .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle.is-on .toggle-thumb {
  transform: translateX(14px);
  background: var(--accent-ink);
}

.toggle-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.knob-grid .toggle {
  grid-column: span 3;
}

/* ------------------------------------------------------------- brand menu */

.brand-btn {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  padding: 0 4px 0 0;
  border-radius: 10px;
  transition: background var(--fast) var(--ease);
}

.brand-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.brand-btn.is-open .brand-mark {
  box-shadow: 0 0 0 2px var(--accent-line), 0 4px 14px rgba(0, 0, 0, 0.3);
}

.brand-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 8px;
  z-index: 70;
  width: min(320px, calc(100vw - 16px));
  max-height: min(70dvh, 520px);
  overflow-y: auto;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 30%), var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  animation: menu-in 140ms var(--ease);
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.99);
  }
}

.brand-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}

.brand-menu-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand-menu-section {
  border-bottom: 1px solid var(--line-soft);
}

.brand-menu-section:last-child {
  border-bottom: 0;
}

.brand-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 36px;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.brand-menu-toggle:hover {
  color: var(--text);
}

.brand-menu-toggle .chev {
  color: var(--dim);
  transition: transform var(--fast) var(--ease);
}

.brand-menu-toggle.is-open .chev {
  transform: rotate(180deg);
}

.brand-menu-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 4px 10px;
}

.brand-menu-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

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

.accent-swatch {
  position: relative;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 60ms var(--ease), box-shadow var(--fast) var(--ease);
}

.accent-swatch:hover {
  transform: translateY(-1px);
}

.accent-swatch.is-active {
  box-shadow: 0 0 0 2px var(--text), 0 0 12px rgba(255, 255, 255, 0.2);
}

.accent-swatch.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------------------- patch bar */

.patch-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  padding: 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 60%), var(--panel-2);
  border: 1px solid var(--line-soft);
}

.patch-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.patch-row .field {
  flex: 1 1 88px;
  min-width: 0;
}

.patch-name-input {
  flex: 1 1 88px;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.patch-name-input:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.patch-actions {
  display: flex;
  gap: 6px;
}

.patch-actions .btn {
  flex: 1;
}

.patch-mix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

/* ------------------------------------------------------------------ mixer */

.patch-mixer {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 60%), var(--panel-2);
  border: 1px solid var(--line-soft);
}

.mixer-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 9px;
  border: 1px solid transparent;
}

.mixer-row.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.mixer-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}

.mixer-row.is-active .mixer-name {
  color: var(--accent-hi);
}

.mixer-row .dragnum {
  min-width: 46px;
  height: 34px;
  padding: 0 6px;
}

.mixer-row .dragnum-value {
  font-size: 12px;
}

.mixer-btn {
  width: 28px;
  padding: 0;
  flex: 0 0 auto;
}
