/* Wivrix audio tools (Audio Editor, Clean Voice, Vocal Remover).
 * Same pattern as the Image Converter: one drop zone until a file is open,
 * then the shared .tool-stage (preview + numbered option groups + one
 * primary action). Only the audio-specific pieces are styled here. */

.aud {
  --aud-wave: #4f46e5;
  --aud-ghost: rgba(95, 102, 128, 0.32);
  --aud-mid: rgba(15, 20, 36, 0.10);
  --aud-sel: rgba(15, 20, 36, 0.07);
  --aud-accent: #4f46e5;
  --aud-marker: #5f6680;
  --aud-head: #0f1424;
}
html[data-theme="dark"] .aud {
  --aud-wave: #818cf8;
  --aud-ghost: rgba(170, 177, 198, 0.30);
  --aud-mid: rgba(255, 255, 255, 0.12);
  --aud-sel: rgba(255, 255, 255, 0.08);
  --aud-accent: #818cf8;
  --aud-marker: #aab1c6;
  --aud-head: #e9ecf5;
}

.aud { position: relative; }
.aud-hidden-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.aud [hidden],
.aud .tool-stage[hidden] { display: none !important; }
.aud .wv-dropzone { margin: 0; }
.aud-stage.tool-stage { margin: 0; }

/* ---- empty state: optional record link under the drop zone ---- */
.aud-alt { display: flex; justify-content: center; margin: 12px 0 0; }
.aud-rec-btn { gap: 8px; }
.aud-rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  flex: none;
}
#aeRecSlotLoaded .aud-rec-more,
.aud-rec-btn.is-rec .aud-rec-more { display: none; }
.aud-rec-btn.is-rec { color: #dc2626; border-color: #dc2626; }
.aud-rec {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
  font-size: .9rem;
  color: var(--ink-soft);
}
.aud-rec-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.aud-rec-meter {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: var(--aud-mid);
  overflow: hidden;
}
.aud-rec-meter i { display: block; height: 100%; width: 0; background: var(--ink); }
.aud-rec .tool-btn { min-height: 36px; padding: 6px 14px; }
@media (prefers-reduced-motion: no-preference) {
  .aud-rec-dot.is-live { animation: aud-blink 1.2s ease-in-out infinite; }
}
@keyframes aud-blink { 50% { opacity: .35; } }

/* ---- quiet bordered buttons (same look as the converter's icon buttons) ---- */
.aud-tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.aud-tbtn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.aud-tbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.aud-tbtn:disabled { opacity: .4; cursor: default; }
.aud-tbtn.aud-icon { width: 36px; padding: 0; }
.aud-ico { width: 16px; height: 16px; flex: none; }

/* ---- file bar above the waveform ---- */
.aud-filebar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  min-width: 0;
}
.aud-filemeta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.aud-file {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: .95rem;
  color: var(--ink);
}
.aud-info { font-size: .8rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.aud-filebar-act { display: flex; align-items: center; gap: 6px; flex: none; }
.aud-tr-sep { width: 1px; height: 20px; margin: 0 2px; background: var(--line); flex: none; }

/* ---- waveform ---- */
.aud-wave {
  position: relative;
  height: 168px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
  touch-action: pan-y;
}
.aud-wave-canvas { position: absolute; inset: 12px 0; }
.aud-wave-canvas canvas { position: absolute; left: 0; top: 0; display: block; }
.aud-wave-over { cursor: text; }
.aud-wave.is-static .aud-wave-over { cursor: pointer; }

/* ---- transport ---- */
.aud-transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 10px 0 0;
  min-width: 0;
}
.aud-play {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex: none;
}
.aud-play:hover { border-color: var(--accent); color: var(--accent); }
.aud-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.aud-play .aud-i-pause,
.aud-mixplay .aud-i-pause { display: none; }
.aud-play.is-playing .aud-i-play,
.aud-mixplay.is-playing .aud-i-play { display: none; }
.aud-play.is-playing .aud-i-pause,
.aud-mixplay.is-playing .aud-i-pause { display: block; }
.aud-time { font-size: .9rem; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.aud-time .aud-dim { color: var(--ink-muted); }
.aud-sel-info { font-size: .8rem; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.aud-sel-info:empty { display: none; }
.aud-tr-right { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.aud-ab { width: auto; margin: 0; }
.aud-ab .tool-seg-btn { min-height: 36px; padding: 6px 14px; }
.aud-sub { margin: 8px 0 0; }
.aud-sub:empty { display: none; }

/* ---- edit buttons (audio editor) ---- */
.aud-edit {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0 0;
}
.aud-edit .aud-tbtn { padding: 0 6px; }
.aud-keys { margin: 10px 0 0; }
@media (max-width: 760px), (hover: none) { .aud-keys { display: none; } }

/* ---- option panel bits ---- */
.aud .aud-val { font-weight: 500; color: var(--ink-muted); font-variant-numeric: tabular-nums; margin-left: 4px; }
.aud .tool-field + .tool-lock-check { margin-top: 4px; }
.aud .tool-lock-check { display: flex; margin: 8px 0 0; }
.aud .tool-lock-check + .tool-field { margin-top: 12px; }
.aud-block { width: 100%; margin-top: 4px; }
.aud-pair { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.aud-pair .tool-btn { gap: 6px; }
.aud-rec-slot:empty { display: none; }
.aud-fmt:has(select[hidden]) { display: none; }
.aud-has-fmt .tool-group:has(.aud-fmt select[hidden]) { display: none; }
.aud .tool-action-row .tool-btn { flex: 1 1 auto; }
.aud-rights { margin: 12px 0 0; }

/* ---- progress ---- */
.aud-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  margin: 4px 0 12px;
}
.aud-progress-track {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 2px;
  background: var(--aud-mid);
  overflow: hidden;
  position: relative;
}
.aud-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.2s linear;
}
.aud-progress.is-indet .aud-progress-fill { animation: aud-indet 1.4s ease-in-out infinite; position: absolute; width: 30%; }
@keyframes aud-indet { 0% { left: -30%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .aud-progress.is-indet .aud-progress-fill { animation: none; width: 100% !important; opacity: .35; } }
.aud-progress-text { display: flex; flex-wrap: wrap; gap: 4px 10px; min-width: 0; font-size: .85rem; color: var(--ink-muted); }
.aud-progress-label { color: var(--ink-soft); }
.aud-progress-eta { font-variant-numeric: tabular-nums; }
.aud-cancel.tool-btn { min-height: 32px; padding: 4px 12px; font-size: .85rem; }

/* ---- status line (same quiet text as the converter's) ---- */
.aud-status-slot .aud-status { margin-top: 10px; }
.aud-status { margin: 12px 0 0; font-size: .9rem; color: var(--ink-soft); line-height: 1.45; }
.aud-status.is-error { color: var(--danger, #b42318); }
.aud-status.is-ok { color: var(--success, #15803d); }

/* ---- stems (vocal remover) ---- */
.aud-stems { margin: 16px 0 0; }
.aud-stems-head { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.aud-stems-title { margin: 0; font-size: .95rem; font-weight: 600; color: var(--ink); flex: 1 1 auto; min-width: 0; }
.aud-stems-title .aud-info { font-weight: 400; margin-left: 6px; }
.aud-stems-act { display: flex; gap: 6px; flex: none; }
#vrStemRows { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.aud-stem {
  display: grid;
  grid-template-columns: 36px 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.aud-stem:first-child { border-top: 0; }
.aud-stem-name { font-size: .9rem; font-weight: 500; color: var(--ink); }
.aud-stem-name small { display: block; font-weight: 400; color: var(--ink-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.aud-stem .aud-wave { height: 44px; border: 0; border-radius: 0; background: transparent; }
.aud-stem .aud-wave-canvas { inset: 0; }
.aud-stem.is-muted .aud-wave { opacity: 0.35; }
.aud-stem.is-muted .aud-stem-name { color: var(--ink-muted); }
.aud-mute.is-on { color: var(--ink); }
.aud-stem.is-muted .aud-mute { color: var(--ink-muted); }
.aud-stem-actions { display: inline-flex; gap: 4px; }

/* ---- phones ---- */
@media (max-width: 640px) {
  .aud-wave { height: 128px; }
  .aud-edit { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .aud-filebar-act .aud-tbtn:not(.aud-icon) { width: 36px; padding: 0; }
  .aud-filebar-act .aud-tbtn:not(.aud-icon) span { display: none; }
  .aud-transport .aud-sel-info { order: 5; flex-basis: 100%; }
  .aud-stem { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .aud-stem .aud-wave { grid-column: 1 / -1; grid-row: 2; height: 36px; }
  .aud-stem-actions .aud-tbtn .enc-btn-label { display: none; }
  .aud-stem-actions .aud-tbtn { width: 36px; padding: 0; }
}

/* Before/after switch only once there is a cleaned result. */
.aud-ab:has(#nrB:disabled) { display: none; }
#vrEngineInfo:not(:empty)::after { content: "."; }
@media (max-width: 640px) {
  .aud-stems-title .aud-info { display: block; margin: 2px 0 0; }
  .aud-stem-name small { display: inline; margin-left: 6px; }
}
