/* styles.css */
@font-face {
  font-family: 'Inter';
  src: url('./fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('./fonts/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('./fonts/JetBrainsMono-VariableFont_wght.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('./fonts/JetBrainsMono-Italic-VariableFont_wght.ttf') format('truetype');
  font-style: italic;
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg-body: #121418;
  --bg-panel: #1c1f26;
  --bg-inset: #111317;

  --text-main: #e0e6ed;
  --text-muted: #6f7885;

  --accent: #ff9f1c;
  --accent-glow: rgba(255, 159, 28, 0.4);
  /* Active/ON color (used by filter power switches + fade mode glow) */
  --active: #3b82f6;
  --danger: #e71d36;

  --border: rgba(255,255,255,0.08);
  --knob-size: 60px;
}

* {
  box-sizing: border-box;
  /* UX: prevent accidental selection while dragging/adjusting controls */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Some browsers still allow selection on certain controls without this */
input, button, select, option, canvas {
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  height: 100vh;
  background-color: var(--bg-body);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
}

/* ===== Export Overlay ===== */
.overlay{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  /* keep panels fully inside viewport on small screens */
  padding: 14px;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.overlayPanel{
  width: min(420px, 92vw);
  max-width: 100%;
  background: var(--bg-panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-top: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 18px 18px 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.65);
}
.overlayTitle{
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 10px;
}
.overlayStatus{
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  text-align: center;
  padding: 8px 10px;
  background: #000;
  border: 1px solid #333;
  border-radius: 4px;
  box-shadow: inset 0 0 10px rgba(255, 159, 28, 0.08);
}
.overlayBar{
  width: 100%;
  margin: 12px auto 8px;
  height: 8px;
  background: #000;
  border: 1px solid #222;
  border-radius: 6px;
  overflow: hidden;
}

.overlayActions{
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 2px;
}

.overlayActions .btn{
  padding: 8px 12px;
  font-size: 12px;
}

.overlayStatBadge{
  min-width: 78px;
  padding: 7px 10px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #000;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1;
  text-align: center;
  box-shadow: inset 0 0 10px rgba(255, 159, 28, 0.06);
}
.matchBar{
  margin-top: 10px;
}

.overlayBarFill{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,159,28,0.2), rgba(255,159,28,0.9), rgba(46,196,182,0.9));
  transition: width 180ms linear;
  position: relative;
}

.overlayBarFill::after{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 35%, rgba(255,255,255,0.22) 50%, rgba(255,255,255,0.08) 65%, transparent 100%);
  transform: translateX(-150%);
  opacity: 0;
  pointer-events: none;
}

.overlayBarFill.isRunning::after{
  opacity: 1;
  animation: overlayFillSweep 1.15s linear infinite;
}

.overlayBarFill.indeterminate{
  width: 45%;
  animation: moveBar 1.0s linear infinite;
}

@keyframes moveBar{
  0% { transform: translateX(-120%); }
  100% { transform: translateX(260%); }
}

@keyframes overlayFillSweep{
  0% { transform: translateX(-150%); }
  100% { transform: translateX(170%); }
}

.overlayLog{
  margin-top: 10px;
  height: 120px;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #cfcfcf;
  background: #000;
  border: 1px solid #222;
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: inset 0 0 10px rgba(255, 159, 28, 0.06);
  line-height: 1.35;
  white-space: pre-wrap;
}
.overlayHint{
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Help Overlay ===== */
.helpPanel{
  width: min(720px, 92vw);
  max-height: min(78vh, 680px);
  overflow: hidden;
}
.helpTop{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.helpTop .overlayTitle{ margin: 0; text-align: left; }
.helpBody{
  background: #000;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 12px 12px 24px;
  box-sizing: border-box;
  max-height: calc(min(78vh, 680px) - 70px);
  overflow: auto;
  overflow-x: hidden;
  /* prevent long words/HTML entities from forcing horizontal scroll */
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-main);
}
.helpBody h3{
  margin: 0 0 8px 0;
  font-size: 14px;
}
.helpBody .small{ font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-muted); }

/* ===== Header ===== */
.top {
  max-width: 1200px;
  margin: 20px auto;
  padding: 16px 24px;
  background: var(--bg-panel);
  border-bottom: 2px solid #000;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.brand { display: flex; gap: 16px; align-items: center; }
.logo {
  width: 40px; height: 40px;
  background: var(--accent);
  color: #000;
  font-weight: 900;
  font-family: 'JetBrains Mono', monospace;
  display: grid; place-items: center;
  border-radius: 2px;
  box-shadow: 0 0 15px var(--accent-glow);
}
.title { font-weight: 800; font-size: 15px; letter-spacing: 0.6px; }
.subtitle { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.transport { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end;  position: relative; }


.helpBtn{
  /* in-flow help button (no overlay) */
}

.btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 8px 12px;
  background: #0c0d10;
  color: var(--text-main);
  border: 1px solid #222;
  border-radius: 2px;
  cursor: pointer;
  transition: .15s;
  box-shadow: inset 0 0 0 rgba(255,255,255,0.1);
}
.btn:hover { border-color: #444; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 12px rgba(255,159,28,0.25); }
.btn.mini { padding: 6px 10px; font-size: 10px; }
.btn.ghost { background: transparent; border-color: #333; color: var(--text-muted); }
.btn.ghost:hover { color: var(--text-main); border-color: #555; }

.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid #222;
  background: #0c0d10;
  color: var(--text-main);
}
.small { font-size: 11px; }
.muted { color: var(--text-muted); }

/* ===== Layout ===== */
.grid {
  max-width: 1200px;
  margin: 0 auto 30px;
  padding: 0 14px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom: 2px solid #000;
  border-radius: 4px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.card h2 {
  font-size: 13px;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.twoCol { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* Prevent long, unbroken strings (e.g. imported filenames) from expanding grid columns */
.twoCol > * { min-width: 0; }
.threeCol { display: grid; grid-template-columns: 1fr 220px 1fr; gap: 14px; }
@media (max-width: 920px){ .twoCol { grid-template-columns: 1fr; } .threeCol { grid-template-columns: 1fr; } }

.drop {
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 4px;
  padding: 14px;
  background: #14161b;
  cursor: pointer;
  min-width: 0;
}
.drop .pill{ max-width: 100%; }
.drop:hover { border-color: rgba(255,159,28,0.6); }

.fileTrigger{
  display:block;
  cursor:pointer;
}
.fileTrigger:hover{
  border-color:#444;
  color:var(--text-main);
}
.waveBtnRow{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.waveTime{
  min-width:110px;
  text-align:center;
}
.transportIconBtn{
  min-width:40px;
  min-height:32px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
}
.iconPlay,
.iconStop,
.iconRestartSelection{
  display:inline-block;
  position:relative;
}
.iconPlay{
  width:0;
  height:0;
  border-top:8px solid transparent;
  border-bottom:8px solid transparent;
  border-left:13px solid currentColor;
  margin-left:2px;
}
.iconStop{
  width:14px;
  height:14px;
  background:currentColor;
}
.iconRestartSelection{
  width:18px;
  height:14px;
}
.iconRestartSelection::before,
.iconRestartSelection::after{
  content:"";
  position:absolute;
  top:0;
}
.iconRestartSelection::before{
  left:0;
  width:3px;
  height:14px;
  background:currentColor;
}
.iconRestartSelection::after{
  left:4px;
  width:0;
  height:0;
  border-top:7px solid transparent;
  border-bottom:7px solid transparent;
  border-right:11px solid currentColor;
}
.dropTitle { font-family: 'JetBrains Mono'; font-weight: 800; font-size: 12px; }
.dropSub { color: var(--text-muted); margin-top: 4px; font-size: 11px; }
.drop.dragTarget {
  border-color: rgba(255,159,28,0.95);
  box-shadow: 0 0 0 1px rgba(255,159,28,0.35), inset 0 0 22px rgba(255,159,28,0.08);
}
.drop.dragTarget .dropTitle { color: var(--accent); }

.sessionTools{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-top:8px;
  border-top:1px solid rgba(255,255,255,0.08);
}
.sessionToolRow{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.sessionToolRow .btn{
  flex:0 0 auto;
}
.sessionStatusOk{ color: var(--accent); }
.sessionStatusWarn{ color: #f6c453; }
.sessionStatusError{ color: #ff6b6b; }

.hlabel {
  display: block;
  margin: 8px 0 6px;
  font-family: 'JetBrains Mono';
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1px;
}

.hslider {
  width: 100%;
  appearance: none;
  height: 6px;
  background: #0b0c10;
  border: 1px solid #222;
  border-radius: 2px;
  outline: none;
}
.hslider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 20px;
  background: #555;
  border: 1px solid #111;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
.headRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* add a little headroom so in-header help buttons don't feel cramped */
  margin-bottom: 12px;
}
.headTools{ display:flex; gap:8px; align-items:center; justify-content:flex-end; }
.headTools .small{ white-space:nowrap; }


.meterBox {
  background: #000;
  border: 1px solid #333;
  border-radius: 2px;
  padding: 4px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

/* IMPORTANT: do NOT force 30px height (waveform needs full height) */
.meterBox canvas { width: 100%; display: block; }

.meterTitle { font-family: 'JetBrains Mono'; font-size: 9px; color: #555; margin-bottom: 2px; }

/* ===== EQ ===== */
.eqGrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 8px;

  /* old look */
  background: #111317;
  padding: 20px 10px;
  border-radius: 4px;
  border: 1px solid #000;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.eqFader {
  /* old look / sizing */
  width: 40px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  justify-self: center;
}

.eqVal{
  font-family: 'JetBrains Mono';
  font-size: 9px;
  color: #888;
  line-height: 1;
  margin-top: 2px;
  min-height: 10px;
}

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

.eqFader input[type="range"]{
  /* old fader style */
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 40px;
  background: transparent;
  transform: rotate(-90deg);
  margin-top: 60px;
  cursor: ns-resize;
}

/* WebKit track + thumb */
.eqFader input[type="range"]::-webkit-slider-runnable-track{
  width: 100%;
  height: 6px;
  background: #000;
  border-radius: 10px;
  border: 1px solid #222;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}
.eqFader input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  height: 30px;
  width: 14px;
  background: linear-gradient(180deg, #444 0%, #222 100%);
  margin-top: -13px;
  border-radius: 1px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.8);
  border: 1px solid #555;
  border-bottom: 1px solid #000;
}

/* Firefox track + thumb */
.eqFader input[type="range"]::-moz-range-track{
  height: 6px;
  background: #000;
  border-radius: 10px;
  border: 1px solid #222;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}
.eqFader input[type="range"]::-moz-range-thumb{
  height: 30px;
  width: 14px;
  background: linear-gradient(180deg, #444 0%, #222 100%);
  border-radius: 1px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.8);
  border: 1px solid #555;
}

.eqLabel{
  margin-top: auto;
  font-family: 'JetBrains Mono';
  font-size: 9px;
  color: #666;
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
  min-height: unset;
}

.presetRow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ===== Filters Layout ===== */
.filterRow { display: flex; gap: 16px; flex-wrap: wrap; }
.filterBlock {
  flex: 1; min-width: 200px;
  display: flex;
  flex-direction: column;
  background: #16181d;
  border: 1px solid #000;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
  border-radius: 4px;
  padding: 12px;
  position: relative;
}

/* Keep presets + dropdown controls anchored to the bottom of each filter block */
.filterBottom{
  margin-top: auto;
  display: flex;
  flex-direction: column;
}
.filterHead {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; border-bottom: 1px solid #222; padding-bottom: 8px;
  position: relative;
}
.filterName { font-weight: 800; font-size: 12px; color: var(--text-muted); }

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

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
  margin-left: auto;
}
.switch input { display: none; }
.switchRow{display:flex;align-items:center;gap:6px;}
.switchText{font-size:12px;opacity:.85;user-select:none;}
.switch .slider {
  position: absolute; inset: 0; background: #222;
  border-radius: 2px; cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.switch .slider:before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: #444;
  border-radius: 1px; transition: .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.switch input:checked + .slider { background: #1a2522; }
.switch input:checked + .slider:before {
  transform: translateX(16px);
  background: var(--active);
  box-shadow: 0 0 8px var(--active);
}

/* ===== Knobs ===== */
.knobGrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 10px 4px; justify-items: center; margin-bottom: 12px;
}
.knobMount {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative;
  /* Reserve space for the absolute value readout so it doesn't overlap other rows */
  padding-top: 14px;
}
.knob {
  width: 50px; height: 50px;
  border-radius: 50%;
  position: relative;
  background: conic-gradient(#2b2f38 0%, #1a1c23 40%, #4a505e 50%, #1a1c23 60%, #2b2f38 100%);
  box-shadow:
    0 5px 10px rgba(0,0,0,0.6),
    inset 0 1px 1px rgba(255,255,255,0.1);
  border: 1px solid #000;
  cursor: ns-resize;
}
.knob::after {
  content: ""; position: absolute;
  top: 5px; left: 50%; width: 2px; height: 18px;
  background: var(--accent);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(var(--deg));
  box-shadow: 0 0 4px var(--accent);
}
.knobLabel { font-size: 9px; font-weight: 600; color: #555; text-transform: uppercase; margin-top: 4px; }
.knobValue {
  font-family: 'JetBrains Mono'; font-size: 9px; color: var(--accent);
  opacity: 1;
  position: absolute; top: 2px;
}

/* Mastering block needs a little more headroom so value readouts don't collide with the header */
.masteringCard .knobGrid{ padding-top: 14px; }

/* Avoid focus outline flashes on EQ sliders when using A/B shortcuts */
.eqFader input:focus,
.eqFader input:focus-visible{
  outline: none;
  box-shadow: none;
}

/* Transport: Level Match */
.abMatch {
  display:flex;
  gap:8px;
  align-items:center;
}

/* ===== Footer ===== */
.foot {
  max-width: 1200px;
  margin: 0 auto 20px;
  padding: 10px 14px;
  color: #555;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-align: center;
}

/* Fix: verhindert Breiten-Springen bei Loop/Limiter (On/Off Textlänge) */
#btnLoop,
#btnLimiter{
  min-width: 120px;
}

/* ===================================================================== */
/* ============================ MOBILE LAYOUT =========================== */
/* Desktop bleibt unverändert – alles hier greift nur auf kleinen Screens */
/* ===================================================================== */

@media (max-width: 760px){

  /* Header: untereinander, Buttons dürfen umbrechen */
  .top{
    margin: 12px auto;
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .transport{
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }
  #time{
    width: 100%;
    text-align: center;
  }

  /* Alle Cards in voller Breite – überschreibt inline grid-column Styles */
  .grid > .card{
    grid-column: span 12 !important;
  }

  /* Source & Waveform: Import oben, Waveform darunter (überschreibt inline grid-template) */
  .twoCol{
    grid-template-columns: 1fr !important;
  }

  /* Waveform Box: etwas kompakter, aber klar sichtbar */
  .meterBox{
    height: 120px;
  }

  /* EQ: MUSS in eine Reihe passen -> 7 Spalten bleiben,
     aber alles wird enger (kein Scroll nötig) */
  .eqGrid{
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 12px 6px;
  }
  .eqFader{
    width: auto;              /* nimmt Grid-Breite */
    height: 150px;            /* kompakter */
    min-width: 0;
  }
  .eqFader input[type="range"]{
    width: 120px;             /* kleiner damit 7 Stück passen */
    margin-top: 46px;
  }
  .eqLabel{
    font-size: 8px;
    line-height: 1.1;
    white-space: nowrap;
  }

  /* Filterblöcke: wirklich untereinander, volle Breite */
  .filterRow{
    flex-direction: column;
    gap: 12px;
  }
  /* Signal Chain: mobile should be a clean vertical stack (no "stripes") */
  .filterSortable{
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }
  .filterMovable,
  .filterSortable .filterBlock{
    width: 100%;
    max-width: 100%;
  }
  .filterBlock{
    min-width: 0;
  }

  /* Knob grids: slightly larger touch targets on mobile */
  .knobGrid{
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px 8px;
  }
  .knob{
    width: 56px;
    height: 56px;
  }

  /* Kleine UI-Feinheiten */
  .card{ padding: 12px; }
  .btn{ padding: 8px 10px; }
  .pill{ padding: 8px 10px; }

  /* Header rows: wrap cleanly so help buttons stay in the top-right, not floating mid-card */
  .headRow{
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .headRow h2{
    flex: 0 0 100%;
  }
  .headRow > div{
    flex: 0 0 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Waveform toolbar: stack text + controls, prevent horizontal overflow/cropping */
  .waveTools{
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
  }
  .waveTools .small{
    width: 100%;
    white-space: normal;
    line-height: 1.25;
  }
  .waveBtnRow{
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Filter headers: keep toggle + help aligned on the right */
  .filterTools{
    justify-content: flex-end;
  }
  .filterTools .switch{
    margin-left: 0;
  }
}

/* Extra-klein: EQ noch tighter, falls nötig (sehr schmale Phones) */
@media (max-width: 420px){
  .eqGrid{
    gap: 5px;
    padding: 10px 5px;
  }
  .eqFader{
    height: 140px;
  }
  .eqFader input[type="range"]{
    width: 110px;
    margin-top: 44px;
  }
  .eqLabel{
    font-size: 7.5px;
  }
}

/* ===================================================================== */
/* ============================ UX FIXES ================================ */
/* 1) Presets klickbar (kein unsichtbares Layer frisst Klicks)            */
/* 2) Regler/Knobs: Drag soll NICHT die Seite scrollen (ohne Layoutjump)  */
/* ===================================================================== */

/* Presets: sicher nach vorne; knobGrid frisst keine Klicks außerhalb Knobs */
.filterBlock{
  position: relative;
}
.filterBlock .presetRow{
  position: relative;
  z-index: 20;
}
.filterBlock .knobGrid{
  position: relative;
  z-index: 5;
  pointer-events: none;
}
.filterBlock .knobMount,
.filterBlock .knob,
.filterBlock .knob *{
  pointer-events: auto;
}

/* Seite darf scrollen, aber Controls lösen kein Scroll-Gesture aus */
html, body{
  touch-action: pan-y;
}
.hslider,
.eqFader input[type="range"],
.knob{
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}



.exportRow{
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 760px){
  .exportRow{
    justify-content: stretch;
  }
  .exportRow .btn,
  .exportRow .pill{
    width: 100%;
    text-align: center;
  }
}


/* Drag & Drop Signal Chain */
.filterSortable{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:stretch;
}

/* Prevent accidental overflow/overlap inside flex rows */
.filterSortable .filterBlock{
  min-width:0;
  box-sizing:border-box;
}
.filterMovable{ }
.dragHandle{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  margin-right:8px;
  border:1px solid #333;
  border-radius:4px;
  font-size:14px;
  line-height:1;
  color:var(--text-muted);
  cursor:grab;
  user-select:none;
  touch-action:none;
}
.dragHandle:active{ cursor:grabbing; }

.filterBlock.dragging{
  opacity:0.55;
  transform:scale(0.98);
}
.filterPlaceholder{
  border:1px dashed #555;
  border-radius:10px;
  background:rgba(255,255,255,0.03);
}


/* Drag & Drop (Signal Chain) */
.dragHandle{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  margin-right:8px;
  cursor:grab;
  user-select:none;
  opacity:0.85;
}
.filterMovable.dragging{
  opacity:0.55;
  transform:scale(0.99);
}
.dragPlaceholder{
  border:2px dashed rgba(255,159,28,0.75);
  border-radius:10px;
  background:rgba(255,159,28,0.06);
  min-height:120px;
}
.filterMovable{
  position:relative;
}


/* Desktop: max 4 blocks per row */
@media (min-width: 980px){
  .filterSortable .filterBlock{
    flex: 0 0 calc(25% - 9px);
    max-width: calc(25% - 9px);
  }
}

/* Utilities */
.hidden{ display:none !important; }

.advWrap{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #222;
}
.advHeader{
  display:flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 6px;
}
.advTitle{
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--text-main);
  padding: 2px 10px;
  border: 1px solid #222;
  background: #0c0d10;
  border-radius: 2px;
}

.advWrap.advDisabled{
  opacity: 0.35;
  filter: grayscale(1);
  pointer-events: none;
}
.advWrap.advDisabled .advTitle{
  color: var(--text-muted);
}
.masteringCard .advKnobGrid{
  padding-top: 6px;
}




/* Waveform toolbar */
.waveTools { display:flex; gap:10px; align-items:center; justify-content:space-between; width:100%; }
.waveBtnRow { display:flex; gap:6px; align-items:center; }

/* Segmented toggle (Pre/Post) */
.segToggle { display:inline-flex; border:1px solid rgba(255,255,255,0.15); border-radius:10px; overflow:hidden; background:rgba(0,0,0,0.25); }
.segBtn { padding:4px 10px; font-size:12px; line-height:1; border:0; background:transparent; color:rgba(255,255,255,0.7); cursor:pointer; }
.segBtn.active { background:rgba(59,130,246,0.22); color:#fff; }
.segToggle.glow { box-shadow: 0 0 0 1px rgba(59,130,246,0.55), 0 0 18px rgba(59,130,246,0.35); border-color: rgba(59,130,246,0.65); }


/* MATCH FEATURE */
.matchLogPanel{
  width:min(900px, 94vw);
  max-height:min(84vh, 780px);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.matchLogArea{
  height:min(60vh, 580px);
  max-height:min(60vh, 580px);
  white-space:pre-wrap;
  word-break:break-word;
}
#btnMatchReference{ min-width:96px; }
#btnMatchReference.isRunning{ color: var(--accent); border-color: var(--accent); }
#matchHint{ min-height: 14px; }


/* Theme switcher */
.footInner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

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

.themeLabel {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: inherit;
  opacity: 0.9;
}

.themeSelect {
  min-width: 150px;
}

@media (max-width: 680px) {
  .footInner {
    flex-direction: column;
    align-items: flex-start;
  }

  .themeSwitcher {
    width: 100%;
  }

  .themeSelect {
    min-width: 0;
    width: 100%;
  }
}


/* Added: welcome/legal overlays + footer legal buttons */
.legalPanel{max-width:min(760px, calc(100vw - 24px));}
.welcomePanel{max-width:min(820px, calc(100vw - 24px));}
.legalActions{display:flex; gap:10px; flex-wrap:wrap; justify-content:center;}
.legalCallout{margin-top:10px; padding:12px; border:1px solid var(--line); border-radius:12px; background:rgba(255,255,255,.03);}
.footTools{display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end;}
.legalSection{margin-bottom:18px;}
.legalSection:last-child{margin-bottom:0;}
.legalSection h3,.legalSection h4{margin:0 0 10px 0;}
.legalSection p{margin:0 0 10px 0;}
.legalSection ul{margin:0 0 10px 18px; padding:0;}
.legalSection li{margin:0 0 6px 0;}
@media (max-width: 900px){
  .footTools{justify-content:center;}
}


/* Legal popup refinements */
.legalTabs{display:flex; gap:8px; flex-wrap:wrap; justify-content:center; margin:0 0 14px 0;}
.legalTabs .btn.active{box-shadow:0 0 0 1px var(--accent, #999) inset;}
.footerLegalLink{appearance:none; background:transparent; border:0; padding:0; margin:0 6px 0 0; font:inherit; font-size:11px; letter-spacing:.08em; text-transform:lowercase; opacity:.4; cursor:pointer; color:inherit;}
.footerLegalLink:hover,.footerLegalLink:focus-visible{opacity:.72; text-decoration:underline;}
.legalPanel .helpBody{padding-bottom:28px;}


/* Legal popup viewport fix for browser zoom */
.legalPanel{
  width:min(760px, calc(100vw - 24px));
  max-width:min(760px, calc(100vw - 24px));
  max-height:calc(100dvh - 28px);
  display:flex;
  flex-direction:column;
  box-sizing:border-box;
}
.legalPanel .helpBody{
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  padding-bottom:56px;
  box-sizing:border-box;
}
