/* ---------- Título simples de seção (substitui as antigas tabs) ---------- */
.panel-section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.panel-section-title svg { color: var(--accent); }
.panel-section-title h2 { font-size: 15px; color: var(--text-primary); }

/* ---------- Recorder stage ---------- */
.recorder-stage { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-5); }

.record-status { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); flex-wrap: wrap; row-gap: var(--sp-3); }

.record-dot {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--danger);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 0 rgba(240, 69, 82, .5);
}
.record-dot-inner {
  width: 18px;
  height: 18px;
  border-radius: 50%; /* pronto para gravar: círculo */
  background: #fff;
  transition: border-radius var(--dur) var(--ease), width var(--dur) var(--ease), height var(--dur) var(--ease);
}
.record-dot.is-recording .record-dot-inner {
  width: 16px;
  height: 16px;
  border-radius: 4px; /* gravando: quadrado (ação = parar) */
}
.record-dot.is-recording { animation: pulse-ring 1.6s var(--ease) infinite; }
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(240, 69, 82, .45); }
  70%  { box-shadow: 0 0 0 16px rgba(240, 69, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 69, 82, 0); }
}

.record-readout { display: flex; flex-direction: column; align-items: flex-start; }
.record-time { font-family: var(--font-display); font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; }
.record-state { font-size: 13px; color: var(--text-secondary); }
.record-state.is-live { color: var(--danger); }

/* ---------- Waveform ---------- */
.waveform-wrap {
  position: relative;
  height: 160px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
#waveform { width: 100%; height: 100%; display: block; cursor: grab; }
#waveform:active { cursor: grabbing; }
.waveform-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 0 var(--sp-6);
  pointer-events: none;
}

/* ---------- Playback + edição (ao lado do botão de gravar) ---------- */
.playback-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  row-gap: var(--sp-2);
}

/* Separador visual sutil entre os controles de transporte e as ferramentas de edição */
#btn-cut { margin-left: var(--sp-2); }
@media (max-width: 480px) {
  #btn-cut { margin-left: 0; }
}

#btn-delete-segment:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover:not(:disabled) { border-color: var(--border-strong); }
.btn-icon:active:not(:disabled) { transform: scale(.94); }
.btn-icon:disabled { opacity: .35; }

/* ---------- Botões genéricos ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn svg { color: currentColor; }
.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(155deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(245, 48, 76, .55);
  flex: 1;
}
.btn-link { color: var(--accent); font-size: 13px; padding: var(--sp-2) 0; }
.btn-link:hover { text-decoration: underline; }

/* ---------- IO row (device + mic meter) ---------- */
.io-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field-label { font-size: 12px; color: var(--text-secondary); }

.field-label-row { display: flex; align-items: center; justify-content: space-between; }

.mono-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.mono-toggle-text { font-size: 11px; color: var(--text-secondary); }
.mono-toggle .switch { --w: 28px; --h: 16px; }
.mono-toggle .switch::after { width: 12px; height: 12px; }
.mono-toggle.is-on .mono-toggle-text { color: var(--text-primary); }

.field-control {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.field-control svg { color: var(--accent); }
.field-control select { color: var(--text-primary); }
.field-control select option { background: var(--bg-panel); }

.mic-meter-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.mic-meter-track {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Régua com o MESMO padding horizontal do .mic-meter logo abaixo — é isso
   que garante que os números fiquem alinhados com os LEDs de verdade,
   não com a largura da linha inteira (que inclui o texto do valor). Cada
   marca é posicionada na mesma escala usada pelos LEDs (-48dB a 0dB) —
   ver METER_FLOOR_DB/METER_CEIL_DB em app.js caso a escala mude. */
.mic-meter-scale {
  position: relative;
  height: 11px;
  padding: 0 var(--sp-3);
}
.mic-meter-scale span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mic-meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 42px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.mic-meter-bar {
  flex: 1;
  height: 18%; /* nível de repouso — o JS (core/recorder.js e live-engine.js) atualiza height/cor em tempo real */
  border-radius: 2px;
  background: var(--text-tertiary);
  transition: height 90ms linear, background 90ms linear;
}

.mic-meter-value {
  flex-shrink: 0;
  width: 56px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  display: block; /* <output> é inline por padrão */
}

/* ---------- Hint banner ---------- */
.hint-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--accent-soft);
  border: 1px solid rgba(245, 48, 76, .3);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
}
.hint-banner[hidden] { display: none; }
.hint-banner svg { color: var(--accent); margin-top: 1px; }

.hint-banner.is-error {
  color: #FFD9DB;
  background: rgba(240, 69, 82, .12);
  border-color: rgba(240, 69, 82, .35);
}
.hint-banner.is-error svg { color: var(--danger); }

/* ---------- Cabeçalho de seção com toggle (EQ / Compressor / Normalizer) ----------
 * O toggle liga/desliga o efeito; o botão ao lado abre/fecha a seção — são
 * duas ações distintas, por isso dois <button> lado a lado, não um só.
 */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.section-header .collapsible-header { flex: 1; }

.fx-switch-btn {
  display: grid;
  place-items: center;
  padding: var(--sp-2);
  flex-shrink: 0;
}

/* ---------- Limiter (único efeito sem parâmetros — fica como linha simples) ---------- */
/* ---------- Limiter (único efeito sem parâmetros — mesma estrutura de 2 elementos das outras seções) ---------- */
.fx-label-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.fx-label-row svg { color: var(--accent); }

/* ---------- Switch (toggle) ---------- */
.switch {
  --w: 34px; --h: 20px;
  position: relative;
  width: var(--w); height: var(--h);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch.is-on { background: var(--accent); border-color: var(--accent); }
.switch.is-on::after { transform: translateX(14px); background: #fff; }

/* ---------- Collapsible ---------- */
.collapsible { border-top: 1px solid var(--border-subtle); }
.collapsible:first-of-type { border-top: none; }

.collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) 0;
  font-size: 13.5px;
  font-weight: 600;
}
.collapsible-header svg:first-child { color: var(--accent); }
.collapsible-header span { flex: 1; text-align: left; }
.chevron { color: var(--text-tertiary); transition: transform var(--dur) var(--ease); }
.collapsible.is-open .chevron { transform: rotate(180deg); }

.collapsible-body {
  overflow: hidden;
  max-height: 600px;
  transition: max-height var(--dur) var(--ease);
  padding-bottom: var(--sp-4);
}
.collapsible:not(.is-open) .collapsible-body { max-height: 0; padding-bottom: 0; }

/* ---------- EQ bands ---------- */
.eq-bands {
  display: flex;
  gap: var(--sp-3);
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-1);
  overflow-x: auto;
}
.eq-band { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); flex: 0 0 auto; width: 32px; }
.eq-band output { font-size: 10.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.eq-band input[type="range"] {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px;
  height: 140px;
  accent-color: var(--accent);
  background: var(--bg-raised);
  border-radius: var(--radius-pill);
}
.eq-band-label { font-size: 10px; color: var(--text-tertiary); text-align: center; white-space: nowrap; }

/* ---------- Compressor (sliders horizontais de parâmetro) ---------- */
.param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4) var(--sp-3);
  padding-top: var(--sp-1);
}
.param-grid-1 { grid-template-columns: 1fr; }
.param-row { display: flex; flex-direction: column; gap: var(--sp-1); }
.param-row label { font-size: 11.5px; color: var(--text-secondary); }
.param-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.param-row output {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  align-self: flex-end;
}

/* ---------- Footer export controls ---------- */
.field-inline { flex-direction: row; align-items: center; gap: var(--sp-2); }
.field-inline .field-label { white-space: nowrap; }
.field-inline select {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
}

/* =========================================================
   MOBILE — prioridade de toque: alvos maiores, grids simples
   ========================================================= */
@media (max-width: 860px) {
  .recorder-stage { padding: var(--sp-4); gap: var(--sp-4); }
  .waveform-wrap { height: 120px; }
  .io-row { grid-template-columns: 1fr; }
  .btn { padding: var(--sp-4); min-height: 48px; } /* alvo de toque >= 48px */
  .record-dot { width: 64px; height: 64px; }
  .btn-icon { width: 44px; height: 44px; }

  /* 8 botões em grade fixa: Novo/Play/Pause/Stop em cima, Loop/Gilete/Lixeira/Desfazer embaixo */
  .playback-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    justify-items: center;
    row-gap: var(--sp-2);
    width: 100%;
  }
  #btn-cut { margin-left: 0; }
}

@media (max-width: 480px) {
  .record-status { gap: var(--sp-2); }
  .playback-controls { gap: var(--sp-1); }
  .param-grid { grid-template-columns: 1fr; }
}

/* ---------- Modal de confirmação ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(5, 2, 2, .72);
  backdrop-filter: blur(3px);
}
.modal-overlay[hidden] { display: none; }

.modal-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .6);
  animation: modal-pop 160ms var(--ease);
}
@keyframes modal-pop {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-box h3 { font-size: 17px; color: var(--text-primary); margin-bottom: var(--sp-2); }
.modal-box p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }

.modal-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}
.modal-btn {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.modal-btn:active { transform: scale(.97); }
.modal-btn-cancel {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.modal-btn-cancel:hover { border-color: var(--border-strong); }
.modal-btn-confirm {
  background: linear-gradient(155deg, var(--danger), #B8222E);
  color: #fff;
}
.modal-btn-confirm:hover { filter: brightness(1.08); }
