/* =====================================================================
   sound_algo · live — surface de contrôle web
   Thème sombre, tactile, animations subtiles
   ===================================================================== */

:root {
  color-scheme: dark;
  --bg: #0a0e14;
  --bg-2: #0d1219;
  --panel: #141a22;
  --panel-2: #1a2230;
  --panel-3: #232d3d;
  --border: #2a3444;
  --border-strong: #3a475c;
  --text: #e8edf3;
  --muted: #7d8a9c;
  --accent: #4dd0e1;
  --accent-glow: rgba(77, 208, 225, 0.35);
  --lime: #aed581;
  --lime-glow: rgba(174, 213, 129, 0.35);
  --warn: #ffb74d;
  --danger: #ef5350;
  --danger-glow: rgba(239, 83, 80, 0.4);
  --magenta: #ce93d8;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --t: 150ms ease;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, #11202c 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: 4rem;
}

/* ============================== HEADER ============================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 0.7rem; }
.logo {
  width: 22px; height: 22px;
  border-radius: 6px;
  background:
    conic-gradient(from 0deg, var(--accent), var(--lime), var(--magenta), var(--accent));
  box-shadow: 0 0 18px var(--accent-glow);
  animation: spin 18s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 .sub { color: var(--muted); font-weight: 400; }

.hud { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.hud-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.hud-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.hud-value {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 2.5ch;
  text-align: right;
}

.bpm-display .hud-value { color: var(--lime); }

.beat-pulse {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--panel-3);
  transition: transform 100ms ease, background 100ms ease, box-shadow 100ms ease;
}
.beat-pulse.flash {
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
  transform: scale(1.4);
}

.ws-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger-glow);
}
.ws-dot.online {
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime-glow);
  animation: ws-pulse 2s ease-in-out infinite;
}
@keyframes ws-pulse {
  0%, 100% { box-shadow: 0 0 6px var(--lime-glow); }
  50% { box-shadow: 0 0 16px var(--lime-glow); }
}
.ws-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

.teardown { letter-spacing: 0.08em; font-weight: 700; }

/* ============================== TABS ============================== */
.tabs {
  position: sticky;
  top: 56px;
  z-index: 20;
  display: flex;
  gap: 0.15rem;
  padding: 0.4rem 1rem 0;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.7rem 0.95rem;
  font: 500 0.85rem var(--sans);
  cursor: pointer;
  white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--t), background var(--t);
  min-height: 44px;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active { color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tab-underline {
  position: absolute;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: left 220ms cubic-bezier(.4,0,.2,1), width 220ms cubic-bezier(.4,0,.2,1);
  pointer-events: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ============================== MAIN / TABPANES ============================== */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.25rem;
}

.tabpane { display: none; animation: fadein 200ms ease; }
.tabpane.active { display: block; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================== CARDS / GRID ============================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 4px 16px rgba(0,0,0,0.25);
}

h2 {
  margin: 0 0 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
h3 {
  margin: 1.1rem 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0.3rem 0;
}

.hint { color: var(--muted); font-size: 0.78rem; margin: 0.4rem 0 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }

/* ============================== CONTROLS ============================== */
.ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.5rem 0;
}
.ctrl.mini { flex: 0 0 auto; min-width: 90px; margin: 0; gap: 0.25rem; }
.ctrl.mini > span { font-size: 0.7rem; color: var(--muted); }
.ctrl-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
}
.ctrl output { color: var(--accent); font-family: var(--mono); }

/* Slider custom */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), var(--panel-3) var(--fill, 0%));
  border-radius: 4px;
  outline: none;
  margin: 0.3rem 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 0 var(--accent-glow);
  transition: transform var(--t), box-shadow var(--t);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 6px var(--accent-glow);
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
}

input[type="text"], input[type="number"], select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font: 500 0.85rem var(--sans);
  min-height: 44px;
  transition: border-color var(--t), box-shadow var(--t);
}
input[type="text"], input[type="number"] { font-family: var(--mono); }
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Buttons */
.btn, .chip {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.95rem;
  cursor: pointer;
  font: 500 0.85rem var(--sans);
  min-height: 44px;
  transition: all var(--t);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover, .chip:hover {
  background: var(--panel-3);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.btn:active, .chip:active { transform: translateY(0); }
.btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.accent {
  background: linear-gradient(180deg, rgba(77,208,225,0.18), rgba(77,208,225,0.08));
  border-color: var(--accent);
  color: var(--accent);
}
.btn.accent:hover { background: rgba(77,208,225,0.25); box-shadow: 0 0 16px var(--accent-glow); }

.btn.warn {
  background: linear-gradient(180deg, rgba(255,183,77,0.15), rgba(255,183,77,0.06));
  border-color: var(--warn);
  color: var(--warn);
}

.btn.danger {
  background: linear-gradient(180deg, rgba(239,83,80,0.18), rgba(239,83,80,0.08));
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}
.btn.danger:hover {
  background: rgba(239,83,80,0.3);
  box-shadow: 0 0 18px var(--danger-glow);
}

.btn.ghost { background: transparent; }

.btn.big {
  padding: 1rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 64px;
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip {
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 999px;
  font-family: var(--mono);
}
.chip.active {
  background: linear-gradient(180deg, var(--lime), #82b754);
  color: #0a0e14;
  border-color: var(--lime);
  font-weight: 600;
  box-shadow: 0 0 14px var(--lime-glow);
}
.chip.active.alt {
  background: linear-gradient(180deg, var(--accent), #2c8a99);
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

/* Toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; }

/* ============================== MIXER ============================== */
.mixer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.8rem;
}
.mixer-voice {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0.85rem 0.7rem;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
}
.mixer-voice .name {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}
.mixer-voice .playing-dot {
  position: absolute;
  top: 8px; right: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--panel-3);
  transition: all var(--t);
}
.mixer-voice.playing .playing-dot {
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime-glow);
}

.mixer-body {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 0.5rem;
  align-items: stretch;
  height: 160px;
}

.vu {
  width: 100%;
  height: 100%;
  background: var(--panel-3);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.vu-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(0deg, var(--lime) 0%, #ffd54f 60%, var(--danger) 100%);
  transition: height 60ms linear;
  border-radius: 0 0 4px 4px;
}

.vfader {
  position: relative;
  height: 100%;
  display: flex;
  justify-content: center;
}
.vfader input[type="range"] {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  writing-mode: bt-lr;
  width: 100%;
  height: 100%;
  background: linear-gradient(0deg, var(--accent) var(--fill, 66%), var(--panel-3) var(--fill, 66%));
  border-radius: 4px;
}

.mixer-voice .vol-display {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.mixer-voice .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}
.mixer-voice .actions button {
  font-size: 0.75rem;
  padding: 0.4rem;
  min-height: 36px;
}
.mixer-voice .actions button.active {
  background: var(--accent);
  color: #0a0e14;
  border-color: var(--accent);
  font-weight: 700;
}
.mixer-voice .actions button.solo.active {
  background: var(--magenta);
  border-color: var(--magenta);
}

.mixer-voice .voice-pdef {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}
.mixer-voice .voice-pdef button {
  font-size: 0.7rem;
  padding: 0.35rem;
  min-height: 32px;
}

/* ============================== STEP SEQUENCER ============================== */
.seq-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.seq-grid {
  display: grid;
  grid-template-columns: 80px repeat(16, minmax(28px, 1fr));
  gap: 4px;
  padding: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.seq-row { display: contents; }
.seq-label {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  align-self: center;
  padding-right: 0.5rem;
  text-align: right;
}
.seq-label.synced { color: var(--accent); transition: color 0.6s ease; }
.seq-cell {
  aspect-ratio: 1;
  min-height: 32px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: background 80ms, border-color 80ms, transform 80ms;
}
.seq-cell:hover { border-color: var(--accent); }
.seq-cell:active { transform: scale(0.92); }
.seq-cell.on {
  background: linear-gradient(180deg, var(--accent), #2c8a99);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.seq-cell.beat-marker { box-shadow: inset 0 0 0 2px var(--lime); }
.seq-cell.on.beat-marker { box-shadow: inset 0 0 0 2px var(--lime), 0 0 14px var(--lime-glow); }
/* division en groupes de 4 */
.seq-cell:nth-child(17n+2),
.seq-cell:nth-child(17n+6),
.seq-cell:nth-child(17n+10),
.seq-cell:nth-child(17n+14) { /* groupe de 4 visuel via opacity de fond */ }
.seq-cell.divider { border-left-color: var(--border-strong); }

/* ============================== FX par voie ============================== */
.fx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}
.fx-voice {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}
.fx-voice .name {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
  letter-spacing: 0.08em;
}

/* ============================== SENDS ============================== */
.sends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
}
.send-cell {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
}
.send-cell .name {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: 0.06em;
}
.send-cell .key { color: var(--muted); font-family: var(--mono); font-size: 0.7rem; }

/* ============================== TRICKS ============================== */
.tricks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
}
.tricks-grid .btn {
  min-height: 80px;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-lg);
  flex-direction: column;
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
  position: relative;
  overflow: hidden;
}
.tricks-grid .btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, var(--accent-glow), transparent 60%);
  opacity: 0;
  transition: opacity var(--t);
}
.tricks-grid .btn:hover::before { opacity: 1; }
.tricks-grid .btn small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.25rem;
}

/* ============================== MELODIES apply grid ============================== */
.m-apply-grid {
  display: grid;
  grid-template-columns: 80px repeat(8, 1fr);
  gap: 0.4rem;
  align-items: center;
}
.m-apply-grid .row-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  padding-right: 0.5rem;
}
.m-apply-grid .btn { min-height: 40px; padding: 0.4rem; }

/* ============================== JUMP ============================== */
.jump-letters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.4rem;
}
.jump-letters .btn {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  min-height: 56px;
  padding: 0;
  text-transform: uppercase;
}
.jump-letters .btn.active {
  background: linear-gradient(180deg, var(--accent), #2c8a99);
  color: #0a0e14;
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ============================== CHAINS ============================== */
.chains-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.7rem;
}
.chains-grid .btn { min-height: 72px; font-weight: 600; font-size: 0.95rem; }

/* ============================== ALBUM ============================== */
.album-toolbar .row { gap: 0.9rem; }
.album-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  font-style: italic;
}

.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.album-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 16px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--t), box-shadow var(--t);
}
.album-card:hover { border-color: var(--border-strong); }

.album-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.album-badge {
  flex: 0 0 48px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px var(--accent-glow);
}
.album-meta {
  flex: 1;
  min-width: 0;
}
.album-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.album-stats {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.album-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}
.album-actions .btn { min-height: 40px; padding: 0.5rem 0.8rem; font-size: 0.8rem; }

.album-tracks {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 200ms ease;
}
.album-card.expanded .album-tracks {
  max-height: 720px;
  overflow-y: auto;
}
.album-track {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 100ms, border-color 100ms;
}
.album-track:hover {
  background: rgba(255,255,255,0.03);
  border-left-color: var(--accent);
}
.album-track .num {
  color: var(--muted);
  font-size: 0.72rem;
  min-width: 2ch;
}
.album-track .slug {
  color: var(--text);
}
.album-track.last {
  background: rgba(174, 213, 129, 0.08);
  border-left-color: var(--lime);
}
.album-track.last .slug { color: var(--lime); }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.6rem; padding: 0.7rem 0.9rem; }
  .hud { width: 100%; justify-content: space-between; }
  main { padding: 0.8rem; }
  .grid { grid-template-columns: 1fr; }
  .albums-grid { grid-template-columns: 1fr; }
  .seq-grid { grid-template-columns: 60px repeat(16, minmax(22px, 1fr)); }
  .seq-label { font-size: 0.6rem; padding-right: 0.25rem; }
  .tabs { top: 96px; }
  h1 { font-size: 1rem; }
}

@media (max-width: 460px) {
  .seq-grid { grid-template-columns: 50px repeat(8, 1fr); }
  /* on n'altère pas la logique : le scroll horizontal prend le relais */
  .seq-grid { grid-template-columns: 60px repeat(16, 26px); }
}

/* ============================== MIXER · FX par voie ============================== */
.mixer-voice .voice-fx {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.3rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}
.mixer-voice .voice-fx .ctrl.mini {
  margin: 0;
  min-width: 0;
}
.mixer-voice .voice-fx .ctrl-row {
  font-size: 0.65rem;
}
.mixer-voice .voice-fx input[type="range"] {
  height: 4px;
  margin: 0.15rem 0;
}
.mixer-voice .voice-fx input[type="range"]::-webkit-slider-thumb {
  width: 14px; height: 14px;
}

/* ============================== MIXER · Master returns ============================== */
.master-returns-card { margin-top: 1rem; }
.master-returns-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (max-width: 1100px) {
  .master-returns-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .master-returns-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.master-return-cell {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.master-return-cell .name {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem;
}
.master-return-cell .key {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
}
.master-return-cell .ctrl-row {
  font-size: 0.7rem;
}

/* ============================== ACID ============================== */
.acid-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.7rem;
}
.acid-toolbar .ctrl.mini { display: flex; flex-direction: row; align-items: center; gap: 0.4rem; }
.acid-toolbar .ctrl.mini > span { min-width: 56px; }
.acid-toolbar .ctrl.mini > input[type="range"] { width: 110px; }

.acid-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(28px, 1fr));
  gap: 4px;
  padding: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  transition: box-shadow 0.6s ease, border-color 0.6s ease;
}
.acid-grid.synced {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}
.acid-cell {
  aspect-ratio: 1;
  min-height: 44px;
  background: #1a212c;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 80ms, border-color 80ms, transform 80ms, color 80ms;
  user-select: none;
}
.acid-cell:hover { border-color: var(--accent); }
.acid-cell:active { transform: scale(0.92); }
.acid-cell.divider { border-left-color: var(--border-strong); }
.acid-cell.note.on {
  background: linear-gradient(180deg, rgba(77,208,225,0.35), rgba(77,208,225,0.15));
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.acid-cell.toggle.accent.on {
  background: #ffd54f;
  border-color: #ffd54f;
  color: #0a0e14;
  box-shadow: 0 0 10px rgba(255,213,79,0.45);
}
.acid-cell.toggle.slide.on {
  background: #4dd0e1;
  border-color: #4dd0e1;
  color: #0a0e14;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ============================== HARMONY ============================== */
.harmony-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(46px, 1fr));
  gap: 4px;
  padding: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.6s ease, border-color 0.6s ease;
}
.harmony-grid.synced {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}
.harmony-cell {
  background: #1a212c;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px;
  display: flex;
  align-items: stretch;
  transition: background 80ms, border-color 80ms;
}
.harmony-cell.divider { border-left-color: var(--border-strong); }
.harmony-cell.on {
  background: linear-gradient(180deg, rgba(77,208,225,0.18), rgba(77,208,225,0.05));
  border-color: var(--accent);
}
.harmony-cell input[type="number"] {
  width: 100%;
  min-height: 36px;
  background: transparent;
  border: none;
  padding: 0.2rem 0.3rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  text-align: center;
  -moz-appearance: textfield;
}
.harmony-cell input[type="number"]::-webkit-inner-spin-button,
.harmony-cell input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.harmony-cell input[type="number"]:focus {
  outline: none;
  background: rgba(77,208,225,0.08);
}
@media (max-width: 720px) {
  .acid-grid { grid-template-columns: repeat(8, minmax(28px, 1fr)); }
  .harmony-grid { grid-template-columns: repeat(4, minmax(46px, 1fr)); }
}

/* ============================== CATALOGUE (mélodies + SynthDefs) ============================== */
.melody-catalog .cat-row,
.synthdef-catalog .cat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.cat-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.cat-header h2 { margin: 0; flex: 1; }
.cat-counter {
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(77, 208, 225, 0.08);
  border: 1px solid rgba(77, 208, 225, 0.2);
  transition: background 250ms ease, color 250ms ease;
}
.cat-counter.synced {
  background: rgba(166, 218, 149, 0.25);
  color: #a6da95;
  animation: catFlash 600ms ease;
}
@keyframes catFlash {
  0%   { background: rgba(166, 218, 149, 0.5); }
  100% { background: rgba(77, 208, 225, 0.08); }
}
.cat-label {
  font-size: 0.78rem;
  color: var(--muted, #999);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cat-chips,
.cat-len-chips,
.cat-cat-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cat-search {
  flex: 1;
  min-width: 200px;
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: var(--text, #ddd);
  font-size: 0.85rem;
}
.cat-search:focus {
  outline: none;
  border-color: rgba(77, 208, 225, 0.6);
  background: rgba(77, 208, 225, 0.05);
}
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
  margin: 0.6rem 0;
  content-visibility: auto;
  contain-intrinsic-size: 800px;
}
.cat-cell {
  padding: 0.4rem 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text, #ddd);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.cat-cell:hover,
.cat-cell:focus {
  background: rgba(77, 208, 225, 0.08);
  border-color: rgba(77, 208, 225, 0.4);
  color: #4dd0e1;
  outline: none;
}
.cat-cell.active {
  background: rgba(255, 167, 38, 0.18);
  border-color: rgba(255, 167, 38, 0.7);
  color: #ffa726;
  font-weight: 700;
}
/* Couleur par catégorie SynthDef */
.cat-cell.cat-drums:hover  { border-color: rgba(255, 167, 38, 0.5); color: #ffa726; }
.cat-cell.cat-bass:hover   { border-color: rgba(166, 218, 149, 0.5); color: #a6da95; }
.cat-cell.cat-lead:hover   { border-color: rgba(77, 208, 225, 0.5); color: #4dd0e1; }
.cat-cell.cat-pad:hover    { border-color: rgba(196, 167, 231, 0.5); color: #c4a7e7; }
.cat-cell.cat-world:hover  { border-color: rgba(245, 169, 127, 0.5); color: #f5a97f; }
.cat-cell.cat-master:hover { border-color: rgba(238, 153, 160, 0.5); color: #ee99a0; }

.cat-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.cat-pager .btn { padding: 0.2rem 0.6rem; }

/* ======================== UX additions =============================== */

/* Toasts (transient notifications) */
.toasts {
    position: fixed;
    top: 76px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
}
.toast {
    background: rgba(20, 24, 36, 0.95);
    color: #e7eef7;
    padding: 8px 14px;
    border-radius: 8px;
    border-left: 3px solid #5cd0ff;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    animation: toast-in 0.18s ease-out;
    max-width: 320px;
}
.toast-success { border-left-color: #5fe8a3; }
.toast-warn    { border-left-color: #ffc24a; }
.toast-danger  { border-left-color: #ee99a0; color: #ffd5d8; }
.toast.leaving { animation: toast-out 0.3s ease-in forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); }
                       to   { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); }
                       to   { opacity: 0; transform: translateX(20px); } }

/* TEARDOWN armed state */
.btn.danger.armed {
    background: #ee99a0 !important;
    color: #1a0506 !important;
    box-shadow: 0 0 0 4px rgba(238, 153, 160, 0.3),
                0 0 24px rgba(238, 153, 160, 0.6) !important;
    animation: armed-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes armed-pulse {
    from { box-shadow: 0 0 0 4px rgba(238, 153, 160, 0.3),
                       0 0 24px rgba(238, 153, 160, 0.6); }
    to   { box-shadow: 0 0 0 8px rgba(238, 153, 160, 0.15),
                       0 0 32px rgba(238, 153, 160, 0.9); }
}

/* Pills active state — applies to any button with [data-pill-group] */
button[data-pill-group].active {
    background: rgba(92, 208, 255, 0.18) !important;
    border-color: rgba(92, 208, 255, 0.7) !important;
    color: #5cd0ff !important;
    box-shadow: inset 0 0 0 1px rgba(92, 208, 255, 0.4),
                0 0 12px rgba(92, 208, 255, 0.25);
}

/* Highlight last-clicked pill briefly even without explicit grouping */
.btn.just-clicked {
    animation: just-clicked 0.6s ease-out;
}
@keyframes just-clicked {
    0%   { box-shadow: 0 0 0 0 rgba(92, 208, 255, 0.7); }
    100% { box-shadow: 0 0 0 12px rgba(92, 208, 255, 0); }
}

/* ======================== Hamburger + Help modal =================== */

/* Hamburger button (hidden ≥ 1200px) */
.tab-menu-btn {
    position: fixed;
    top: 14px;
    left: 14px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(20, 24, 36, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    z-index: 100;
}
.tab-menu-btn span {
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}
.tab-menu-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.tab-menu-btn.open span:nth-child(2) { opacity: 0; }
.tab-menu-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Help button (always visible) */
.help-btn {
    position: fixed;
    bottom: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 50%;
    background: rgba(20, 24, 36, 0.85);
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 80;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: transform 0.15s;
}
.help-btn:hover { transform: scale(1.08); border-color: var(--accent); }

/* Help modal */
.help-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fade-in 0.15s ease-out;
}
.help-modal[hidden] { display: none; }
.help-modal-card {
    background: var(--bg-2, #131722);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow: auto;
}
.help-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px 8px;
}
.help-modal-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.01em; }
.help-modal-body { padding: 8px 18px 18px; }
.kbd-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.kbd-table td { padding: 8px 4px; border-top: 1px solid rgba(255,255,255,0.06); }
.kbd-table td:first-child { width: 130px; white-space: nowrap; }
.kbd-table tr:first-child td { border-top: 0; }
kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid rgba(255,255,255,0.15);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    font: 600 0.78rem ui-monospace, JetBrains Mono, monospace;
    color: var(--text);
}
.help-note {
    color: var(--muted);
    font-size: 0.8rem;
    margin: 12px 0 0;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ======================== Responsive : < 1200px ===================== */
@media (max-width: 1199px) {
    .tab-menu-btn { display: flex; }
    .topbar { padding-left: 64px; }

    /* Tabs become a vertical drawer on the left */
    .tabs {
        position: fixed;
        top: 0;
        left: 0;
        width: 240px;
        height: 100vh;
        background: rgba(15, 18, 26, 0.96);
        backdrop-filter: blur(12px);
        border-right: 1px solid rgba(255,255,255,0.08);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 64px 8px 16px;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.22s ease-out;
        z-index: 90;
    }
    .tabs.open { transform: translateX(0); }
    .tabs .tab {
        text-align: left;
        padding: 12px 16px;
        border-radius: 6px;
        border-bottom: 1px solid rgba(255,255,255,0.04);
    }
    .tabs .tab.active {
        background: rgba(92, 208, 255, 0.12);
        color: var(--accent);
    }
    .tab-underline { display: none; }
}

/* Tighten on very narrow viewports */
@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; padding-left: 64px; }
    .topbar .hud { gap: 8px; }
    .toasts { top: 90px; right: 8px; }
}

/* ========== Warn button (REBOOT) — between accent and danger ========== */
.btn.warn {
    background: rgba(255, 194, 74, 0.12);
    color: #ffc24a;
    border: 1px solid rgba(255, 194, 74, 0.4);
    font-weight: 700;
    letter-spacing: 0.04em;
}
.btn.warn:hover {
    background: rgba(255, 194, 74, 0.22);
    border-color: rgba(255, 194, 74, 0.7);
}
.btn.warn.armed-warn,
.btn.warn.armed {
    background: #ffc24a !important;
    color: #1a1206 !important;
    box-shadow: 0 0 0 4px rgba(255, 194, 74, 0.25),
                0 0 24px rgba(255, 194, 74, 0.55) !important;
    animation: armed-pulse 0.5s ease-in-out infinite alternate;
}

/* Smaller variant of warn button (scsynth reboot) */
.btn.warn.small {
    padding: 4px 8px;
    font-size: 0.78rem;
}

/* ======================== LIVE PADS ================================= */

.live-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
}
.live-head h2 { margin: 0; }
.live-hint {
    font-size: 0.78rem;
    color: var(--muted);
    flex: 1;
    line-height: 1.4;
}

.live-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
}

.live-pad {
    position: relative;
    aspect-ratio: 1;
    min-height: 88px;
    padding: 10px 6px 22px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(20, 24, 36, 0.6);
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.06s, box-shadow 0.12s, border-color 0.12s, background 0.12s;
    user-select: none;
    overflow: hidden;
}
.live-pad:hover {
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.18);
}
.live-pad:active { transform: translateY(0); }
.live-pad.hit {
    animation: pad-hit 0.25s ease-out;
}
@keyframes pad-hit {
    0%   { transform: scale(0.94); }
    40%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.live-pad-label {
    font: 700 0.85rem ui-monospace, JetBrains Mono, monospace;
    letter-spacing: 0.04em;
    line-height: 1.1;
    text-align: center;
}
.live-pad-sub {
    font-size: 0.66rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.live-pad-key {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font: 600 0.66rem ui-monospace, JetBrains Mono, monospace;
    color: var(--muted);
    border: 1px solid rgba(255,255,255,0.15);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
    background: rgba(0,0,0,0.4);
}

/* Section colors */
.live-pad-chain {
    border-color: rgba(92, 208, 255, 0.35);
    background: linear-gradient(160deg, rgba(92, 208, 255, 0.08), rgba(20, 24, 36, 0.6));
}
.live-pad-chain:hover { border-color: rgba(92, 208, 255, 0.7); box-shadow: 0 0 16px rgba(92, 208, 255, 0.18); }
.live-pad-chain .live-pad-label { color: #8ee1ff; }

.live-pad-shot {
    border-color: rgba(255, 168, 80, 0.35);
    background: linear-gradient(160deg, rgba(255, 168, 80, 0.08), rgba(20, 24, 36, 0.6));
}
.live-pad-shot:hover { border-color: rgba(255, 168, 80, 0.7); box-shadow: 0 0 16px rgba(255, 168, 80, 0.18); }
.live-pad-shot .live-pad-label { color: #ffc890; }

.live-pad-mute {
    border-color: rgba(190, 130, 255, 0.35);
    background: linear-gradient(160deg, rgba(190, 130, 255, 0.08), rgba(20, 24, 36, 0.6));
}
.live-pad-mute:hover { border-color: rgba(190, 130, 255, 0.7); box-shadow: 0 0 16px rgba(190, 130, 255, 0.18); }
.live-pad-mute .live-pad-label { color: #d0b3ff; }

/* Mute toggle active state */
.live-pad.muted {
    background: rgba(238, 153, 160, 0.18) !important;
    border-color: rgba(238, 153, 160, 0.7) !important;
}
.live-pad.muted .live-pad-label { color: #ee99a0 !important; }
.live-pad.muted .live-pad-label::before { content: "🔇 "; }

/* Compact pad on narrow screens */
@media (max-width: 1199px) {
    .live-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 720px) {
    .live-grid { grid-template-columns: repeat(2, 1fr); }
}
