/* Layout utilities — prefer these over inline style= */
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stack-sm { gap: 8px; }
.stack-md { gap: 12px; }
.stack-lg { gap: 15px; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row-end { align-items: flex-end; }
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pad-8 { padding: 8px; }
.pad-12 { padding: 12px; }
.pad-16 { padding: 16px; }

.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.flex-1 { flex: 1; min-width: 0; }
.flex-col {
  display: flex;
  flex-direction: column;
}
.fill-height {
  height: 100%;
  min-height: 0;
}
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }

.text-muted-ui {
  font-size: 12px;
  color: var(--text-muted, #aaa);
}
.text-hint {
  font-size: 11px;
  opacity: 0.65;
}
.muted-empty {
  padding: 16px;
  opacity: 0.6;
  text-align: center;
}
.muted-empty--left {
  text-align: left;
  padding: 16px;
  opacity: 0.6;
}

.border-panel {
  border: 1px solid var(--border-main, #333);
  border-radius: 6px;
}

.btn-block-left {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
}
.settings-fieldset legend {
  font-weight: bold;
  color: var(--accent, #00ffcc);
}
.settings-fieldset legend.plain {
  color: inherit;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}
.settings-row--column {
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.settings-btn-save {
  padding: 10px;
  cursor: pointer;
  background: #2a3b4c;
  color: #fff;
  border: 1px solid #4a5b6c;
  border-radius: 4px;
  text-align: left;
}
.settings-btn-export {
  padding: 10px;
  cursor: pointer;
  background: #2c4c3b;
  color: #fff;
  border: 1px solid #4c6c5b;
  border-radius: 4px;
  text-align: left;
}
.settings-btn-load {
  padding: 10px;
  cursor: pointer;
  background: #333;
  color: #ccc;
  border: 1px solid #555;
  border-radius: 4px;
  text-align: left;
  margin-top: 5px;
}
.settings-btn-breakout {
  padding: 8px 12px;
  cursor: pointer;
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 4px;
  font-weight: bold;
}
.settings-btn-breakout.is-active {
  background: #00cc66;
  color: #000;
  border-color: #00ff88;
}
.settings-btn-clear-loops {
  padding: 8px 12px;
  cursor: pointer;
  background: #442222;
  color: #ff8888;
  border: 1px solid #663333;
  border-radius: 4px;
}
.settings-hotkey-input {
  width: 100px;
  text-align: center;
  background: #222;
  color: #00ffcc;
  border: 1px solid #444;
  border-radius: 3px;
  padding: 4px;
}
.fx-editor {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fx-editor-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fx-row-layout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 4px;
  background: var(--bg-surface, #222);
  border-radius: 6px;
  border: 1px solid var(--border-main, #333);
}
.fx-row-name {
  flex: 1;
  cursor: default;
  user-select: none;
}
.fx-row-drag {
  opacity: 0.5;
  cursor: grab;
  user-select: none;
  padding: 0 4px;
}
.fx-wet-label {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.fx-empty {
  padding: 16px;
  opacity: 0.6;
  text-align: center;
}
.fx-rack-hint {
  font-size: 12px;
  color: var(--text-muted);
}
.preset-browser-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  min-height: 360px;
}
.preset-browser-header {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.preset-browser-search {
  flex: 1;
  padding: 6px 8px;
}
.preset-browser-save-row {
  display: flex;
  gap: 8px;
}
.preset-browser-list {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-main, #333);
  border-radius: 6px;
  min-height: 220px;
}
.preset-item-row--browser {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #333;
  cursor: pointer;
}
.preset-item-actions-inline {
  display: flex;
  gap: 6px;
}
.window-content.is-fill {
  height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
}
.timeline-item.is-colliding {
  box-shadow: inset 0 0 0 3px red, 0 0 10px rgba(255, 0, 0, 0.8);
  opacity: 0.7;
  z-index: 999;
}
.transport-bar .separator {
  opacity: 0.5;
  margin: 0 4px;
}
.snap-label,
.wrap-tails-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.wrap-tails-label {
  margin-left: 10px;
}
.bpm-input {
  width: 50px;
  margin-left: 10px;
}
.metronome-btn {
  margin-left: 10px;
}
.metronome-btn.is-on {
  background: #4a90e2;
  color: white;
}
.settings-btn {
  margin-left: 10px;
}
.view-mode-btn.is-active {
  outline: 2px solid var(--accent, #00ff88);
}
.fx-rack {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px;
  gap: 8px;
  box-sizing: border-box;
}
.fx-catalog-name { font-weight: 600; }
.seq-step.is-silenced { opacity: 0.35; }

.view-host {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.view-host--window { height: 100%; }
.view-host--tiled {
  flex: 0 0 42%;
  min-width: 280px;
  min-height: 0;
  border-left: 1px solid var(--border-main, #333);
}
.view-host--embedded {
  height: 100%;
  min-height: 0;
}
.view-host--embedded .window-header { display: none; } /* if reusing chrome */
.noise-card-title { color: #ff4d7a; }

.settings-legend {
  font-weight: bold;
  color: var(--accent, #00ffcc);
}

.fx-row.is-dragging { opacity: 0.5; }

.instrument-rack-toolbar,
.session-step-seq-chrome,
.waveform-editor-toolbar,
.fx-editor-toolbar,
.fx-rack-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-main, #333);
  background: var(--bg-elevated, #2a2a2a);
}

.instrument-rack-root,
.waveform-editor-host-root,
.fx-editor-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.instrument-rack-root > .macro-panel,
.waveform-editor-host-root > .plugin-body,
.fx-editor-root > *:last-child {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.daw-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.daw-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.arrange-view-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-main, #333);
  background: var(--bg-elevated, #2a2a2a);
}
.arrange-view-root .timeline-area {
  flex: 1;
  min-height: 0;
}

.primary-view-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.primary-headers-slot {
  flex: 0 0 280px;
  min-width: 280px;
  max-width: 280px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 2px solid var(--border-dark, #111);
}

.primary-headers-slot .track-headers-container {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 100%;
}

.arrange-view-root .timeline-area,
.seq-session-host-root .seq-session-root {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* When primary is floating + maximized, same fill as docked */
.floating-window.maximized .primary-view-body {
  flex: 1;
  min-height: 0;
}
.tb-btn {
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    background: var(--bg-elevated, #2a2a2a);
    color: var(--text, #eee);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.tb-btn:hover { border-color: var(--accent, #00ff88); }
.tb-transport { font-size: 12px; }
.metronome-btn.is-on { background: rgba(0, 255, 136, 0.25); border-color: var(--accent); }
.primary-headers-slot .track-headers-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.seq-pattern-select {
    max-width: 140px;
}
.midi-keyboard-strip.is-horizontal {
    position: relative;
    flex: 1 1 auto;
    min-height: 88px;
    max-height: 140px;
    height: 100%;
    background: #1a1a1a;
    border-top: 1px solid #333;
    user-select: none;
    touch-action: none;
    overflow: hidden;
}
.midi-keyboard-strip.is-horizontal .midi-key-row.whites {
    display: flex;
    align-items: stretch;
    height: 100%;
    width: 100%;
    position: relative;
}
.midi-keyboard-strip.is-horizontal .midi-key {
    box-sizing: border-box;
    cursor: pointer;
    flex-shrink: 0;
}
.midi-keyboard-strip.is-horizontal .midi-key.white {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    border: 1px solid #333;
    border-top: none;
    background: #e8e8e8;
    border-radius: 0 0 4px 4px;
    position: relative;
    z-index: 1;
}
.midi-keyboard-strip.is-horizontal .midi-key.black {
    flex: 0 0 auto;
    width: 1.6%;           /* ~ half white; adjust if needed */
    min-width: 10px;
    max-width: 22px;
    height: 58%;
    margin-left: -0.8%;
    margin-right: -0.8%;
    background: #111;
    border: 1px solid #000;
    border-radius: 0 0 3px 3px;
    z-index: 2;
    position: relative;
    align-self: flex-start;
}
.midi-keyboard-strip.is-horizontal .midi-key-row.blacks {
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 58%;
    display: flex;
    pointer-events: none;
}
.midi-keyboard-strip.is-horizontal .midi-key-row.blacks .midi-key {
    pointer-events: auto;
}
.midi-keyboard-strip.is-horizontal .midi-key.active {
    background: var(--accent, #00ff88) !important;
}

.midi-keyboard-strip.is-vertical {
    display: flex;
    flex-direction: column;
    width: 56px;
    overflow: hidden;
}
.midi-keyboard-strip.is-vertical .midi-key {
    height: var(--key-height, 16px);
    flex-shrink: 0;
    box-sizing: border-box;
    border-bottom: 1px solid #111;
}
.midi-keyboard-strip.is-vertical .midi-key.white { background: #dcdcdc; }
.midi-keyboard-strip.is-vertical .midi-key.black { background: #1e1e1e; }
.midi-keyboard-strip .midi-key.active {
    background: var(--accent, #00ff88) !important;
}
.performance-root {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-base, #1a1a1a);
}
.perf-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-main, #333);
    background: var(--bg-elevated, #2a2a2a);
}
.perf-toolbar .btn.is-active {
    outline: 2px solid var(--accent, #00ff88);
}
.perf-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* keys sit at bottom, not top */
    padding: 8px;
}
.perf-stage > .midi-keyboard-strip {
    width: 100%;
}
.performance-root {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-base, #1a1a1a);
}
.perf-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-main, #333);
    background: var(--bg-elevated, #2a2a2a);
}
.perf-toolbar .btn.is-active {
    outline: 2px solid var(--accent, #00ff88);
}
.perf-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* keys sit at bottom, not top */
    padding: 8px;
}
.perf-stage > .midi-keyboard-strip {
    width: 100%;
}

/* Performance pads + shared velocity ribbon panel */
.perf-pad-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 8px;
    padding: 8px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}
.perf-pad-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted, #aaa);
}
.perf-pad-controls label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.perf-pad-controls input[type="number"],
.perf-pad-controls select {
    width: 52px;
    padding: 4px 6px;
}
.perf-vel-ribbon-host {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 4px 8px;
    border-top: 1px solid var(--border-main, #333);
    background: var(--bg-elevated, #2a2a2a);
}
.perf-vel-ribbon-host .ui-label {
    min-width: 28px;
}

/* Centered, aspect-aware pad matrix */
.perf-pad-grid {
    display: grid;
    gap: 8px;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    aspect-ratio: unset;
    max-height: 100%;
    align-content: center;
    justify-content: center;
    justify-items: stretch;
    align-items: stretch;
    grid-auto-rows: 1fr;
}
.perf-pad {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
    min-height: 0;
    min-width: 0;
    max-height: 100%;
    border-radius: 8px;
    border: 1px solid #0a0a0c;
    background: linear-gradient(180deg, #4a4e58 0%, #2c2f36 45%, #1a1c20 100%);
    color: rgba(255, 255, 255, 0.75);
    font-weight: 700;
    font-size: clamp(9px, 2.2vmin, 13px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 2px 4px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 2px;
}
.perf-pad:active,
.perf-pad.active {
    background: var(--accent, #00ff88);
    color: #111;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}
.perf-pad.is-latched {
    outline: 2px solid #ffcc33;
    outline-offset: 1px;
}

.perf-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.perf-toolbar-group label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted, #aaa);
}
.perf-toolbar-group input[type="number"] {
    width: 48px;
    padding: 4px 6px;
}

.midi-keyboard-strip .midi-key {
    touch-action: none;
}
.performance-window .window-content {
    height: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    padding: 0;
}