/**
 * Audio tools — extends media-tools.css (import/link both).
 * Prefix: .atool-* for audio-only chrome; reuses .mtool-* shell.
 */

/* Audio player preview */
.mtool-preview-wrap audio,
.mtool-result audio {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.mtool-result audio {
  margin-top: 12px;
}

/* Waveform-ish bar decoration under player (animates only while playing) */
.atool-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 40px;
  margin: 10px auto 0;
  max-width: 280px;
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.atool-wave span {
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--mtool-accent-2), var(--mtool-accent));
  transform-origin: bottom center;
  transform: scaleY(0.55);
}

.atool-wave span:nth-child(1) { height: 30%; }
.atool-wave span:nth-child(2) { height: 55%; }
.atool-wave span:nth-child(3) { height: 80%; }
.atool-wave span:nth-child(4) { height: 45%; }
.atool-wave span:nth-child(5) { height: 70%; }
.atool-wave span:nth-child(6) { height: 40%; }
.atool-wave span:nth-child(7) { height: 60%; }
.atool-wave span:nth-child(8) { height: 35%; }

.mtool-wrap.is-playing .atool-wave {
  opacity: 0.7;
}

.mtool-wrap.is-playing .atool-wave span {
  animation: atool-wave 1.1s ease-in-out infinite;
}

.mtool-wrap.is-playing .atool-wave span:nth-child(1) { animation-delay: 0s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(2) { animation-delay: 0.08s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(3) { animation-delay: 0.16s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(4) { animation-delay: 0.24s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(5) { animation-delay: 0.32s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(6) { animation-delay: 0.4s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(7) { animation-delay: 0.48s; }
.mtool-wrap.is-playing .atool-wave span:nth-child(8) { animation-delay: 0.56s; }

@keyframes atool-wave {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1); }
}

/* Preview shell */
.mtool-preview-wrap {
  flex-direction: column;
  min-height: 120px;
  padding-bottom: 10px;
}

.mtool-preview-wrap audio {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

/* Savings badge (compress) */
.atool-savings {
  display: none;
  margin: 0 18px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.35;
  color: #b8f0c8;
  background: rgba(40, 167, 69, 0.12);
  border: 1px solid rgba(40, 167, 69, 0.28);
}

.atool-savings.is-visible {
  display: block;
}

.atool-savings strong {
  color: #d8f5e0;
  font-weight: 800;
}

/* Trim helpers */
.atool-trim-helpers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 4px;
}

.atool-trim-helpers .mtool-btn {
  font-size: 0.78rem;
  padding: 7px 11px;
}

.atool-clip-label {
  margin-left: auto;
  align-self: center;
  font-size: 0.8rem;
  color: var(--mtool-faint);
  font-variant-numeric: tabular-nums;
}

/* Dual range track (simple overlay) */
.atool-range-wrap {
  position: relative;
  margin: 4px 18px 8px;
  height: 28px;
}

.atool-range-wrap input[type="range"] {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;
  top: 6px;
  height: 16px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.atool-range-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.atool-range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--mtool-accent);
  border: 2px solid #fff;
  margin-top: -5px;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.atool-range-wrap input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.atool-range-wrap input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--mtool-accent);
  border: 2px solid #fff;
  pointer-events: auto;
  cursor: pointer;
}

.atool-range-wrap #atool-range-end {
  z-index: 2;
}

/* List summary (juntar) */
.atool-list-summary {
  margin: 0 18px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--mtool-line);
  font-size: 0.84rem;
  color: var(--mtool-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.atool-list-summary strong {
  color: var(--mtool-text);
  font-weight: 700;
}

/* Recorder polish */
.atool-rec-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.atool-rec-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mtool-faint);
}

.atool-rec-status.is-live {
  color: #fca5a5;
}

.atool-rec-status.is-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  animation: atool-live 1.2s ease-in-out infinite;
}

@keyframes atool-live {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Section labels / fields */
.atool-section-label {
  padding: 16px 18px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mtool-faint);
}

.atool-formats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 0 18px;
}

.atool-fmt {
  position: relative;
  background: var(--mtool-card);
  border: 1px solid var(--mtool-line);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  color: var(--mtool-text);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.atool-fmt:hover {
  background: rgba(255, 255, 255, 0.09);
}

.atool-fmt:focus-visible {
  outline: 2px solid var(--mtool-accent-2);
  outline-offset: 2px;
}

.atool-fmt.is-selected {
  border-color: var(--mtool-accent);
  background: rgba(250, 91, 15, 0.1);
  box-shadow: inset 0 0 0 1px var(--mtool-accent);
}

.atool-fmt-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.atool-fmt-desc {
  margin-top: 3px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--mtool-muted);
}

.atool-fmt-badge {
  position: absolute;
  top: -8px;
  right: 10px;
  background: var(--mtool-accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
}

.atool-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  padding: 14px 18px 8px;
}

.atool-field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mtool-faint);
  margin: 0 0 4px 2px;
}

.atool-field input,
.atool-field select {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border: 1px solid var(--mtool-line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  min-width: 0;
}

.atool-field input {
  width: 110px;
}

.atool-field select {
  cursor: pointer;
  min-width: 120px;
}

.atool-field select:disabled,
.atool-field input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.atool-field select option {
  color: #111;
}

.atool-field input:focus-visible,
.atool-field select:focus-visible {
  outline: 2px solid var(--mtool-accent-2);
}

.atool-estimate {
  font-size: 0.78rem;
  color: var(--mtool-faint);
  padding-bottom: 12px;
  min-width: 120px;
}

.atool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 18px 16px;
  align-items: center;
}

/* Bitrate chips */
.atool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 4px;
}

.atool-chip-btn {
  appearance: none;
  border: 1px solid var(--mtool-line);
  background: var(--mtool-card);
  color: var(--mtool-text);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.atool-chip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.atool-chip-btn.is-selected {
  border-color: var(--mtool-accent);
  background: rgba(250, 91, 15, 0.15);
  color: #fff;
}

.atool-chip-btn:focus-visible {
  outline: 2px solid var(--mtool-accent-2);
  outline-offset: 2px;
}

/* Multi-file list (juntar) */
.atool-list {
  margin: 0 18px 8px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.atool-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--mtool-card);
  border: 1px solid var(--mtool-line);
}

.atool-list-idx {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(250, 91, 15, 0.15);
  color: var(--mtool-accent-2);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.atool-list-main {
  flex: 1;
  min-width: 0;
}

.atool-list-name {
  font-size: 0.86rem;
  font-weight: 600;
  word-break: break-all;
}

.atool-list-meta {
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--mtool-faint);
}

.atool-list-btns {
  display: flex;
  gap: 4px;
  flex: none;
}

.atool-icon-btn {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--mtool-text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.atool-icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.atool-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.atool-icon-btn:focus-visible {
  outline: 2px solid var(--mtool-accent-2);
}

/* Recorder */
.atool-rec-panel {
  padding: 28px 18px 18px;
  text-align: center;
}

.atool-rec-timer {
  font-size: 2.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #fff;
  margin: 0 0 8px;
}

.atool-rec-level-wrap {
  height: 10px;
  max-width: 280px;
  margin: 12px auto 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.atool-rec-level {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, var(--mtool-accent));
  transition: width 0.08s linear;
}

.atool-rec-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: #dc2626;
  cursor: pointer;
  position: relative;
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35);
  transition: transform 0.12s ease, background 0.12s ease;
}

.atool-rec-btn::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: #fff;
  transition: border-radius 0.12s ease, inset 0.12s ease;
}

.atool-rec-btn.is-recording {
  background: #b91c1c;
  animation: atool-pulse 1.2s ease-in-out infinite;
}

.atool-rec-btn.is-recording::after {
  inset: 20px;
  border-radius: 4px;
}

.atool-rec-btn:focus-visible {
  outline: 2px solid var(--mtool-accent-2);
  outline-offset: 3px;
}

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

@keyframes atool-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}

.atool-rec-hint {
  margin-top: 14px;
  font-size: 0.86rem;
  color: var(--mtool-muted);
}

@media (max-width: 640px) {
  .atool-formats {
    grid-template-columns: repeat(2, 1fr);
  }

  .atool-fields,
  .atool-actions,
  .atool-section-label,
  .atool-chips,
  .atool-trim-helpers {
    padding-left: 12px;
    padding-right: 12px;
  }

  .atool-list,
  .atool-list-summary,
  .atool-savings,
  .atool-range-wrap {
    margin-left: 12px;
    margin-right: 12px;
  }

  .atool-clip-label {
    margin-left: 0;
    width: 100%;
  }

  .atool-rec-timer {
    font-size: 2rem;
  }
}

/* Sticky primary on mobile when editor open */
@media (max-width: 720px) {
  .mtool-wrap .atool-actions .mtool-btn-primary {
    position: sticky;
    bottom: 12px;
    z-index: 20;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}
