/* Audio Editor: waveform editor (overview, ruler, waveform, transport) + the effects panel. */
.ae-track, .ae-eq, .ae-overview {
  --ae-bg: var(--surface);
  --ae-wave: hsl(var(--tool-hue) 62% 36%);
  --ae-wave-sel: hsl(var(--tool-hue) 85% 22%);
  --ae-sel: hsl(var(--tool-hue) 70% 45% / .17);
  --ae-edge: hsl(var(--tool-hue) 75% 30%);
  --ae-grid: color-mix(in srgb, var(--text) 13%, transparent);
  --ae-grid-soft: color-mix(in srgb, var(--text) 5%, transparent);
  --ae-out: var(--surface-sunken);
  --ae-label: var(--text-faint);
  --ae-marker: #d97706;
  --ae-ruler-text: var(--text-soft);
  --ae-tick: color-mix(in srgb, var(--text) 30%, transparent);
  --ae-ov-wave: hsl(var(--tool-hue) 40% 55% / .75);
  --ae-ov-sel: hsl(var(--tool-hue) 70% 45% / .22);
  --ae-eq-ring: var(--surface);
}
:root[data-theme="dark"] :is(.ae-track, .ae-eq, .ae-overview) {
  --ae-bg: #10141c;
  --ae-wave: hsl(var(--tool-hue) 55% 56%);
  --ae-wave-sel: hsl(var(--tool-hue) 90% 78%);
  --ae-sel: hsl(var(--tool-hue) 70% 50% / .2);
  --ae-edge: hsl(var(--tool-hue) 80% 65%);
  --ae-out: #0b0e13;
  --ae-marker: #f59e0b;
  --ae-ov-wave: hsl(var(--tool-hue) 40% 55% / .6);
}
.ae-stage { --ae-head: #e11d48; display: grid; grid-template-columns: minmax(0, 1fr) 340px; overflow: hidden; }
:root[data-theme="dark"] .ae-stage { --ae-head: #fb7185; }

/* ---------- editor ---------- */
.ae-editor { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; padding: 12px; }
.ae-overview {
  position: relative; flex: none; height: 40px; overflow: hidden; cursor: pointer; touch-action: pan-y;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.ae-overview canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ae-ov-win {
  position: absolute; top: 0; bottom: 0; pointer-events: none; border-radius: 7px;
  border: 2px solid var(--app-accent); background: color-mix(in srgb, var(--app-accent) 8%, transparent);
}
.ae-ov-head { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--ae-head); pointer-events: none; }
.ae-track {
  position: relative; flex: 1 1 auto; min-height: 150px; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--ae-bg); box-shadow: var(--shadow-sm);
}
.ae-ruler { flex: none; display: block; width: 100%; height: 26px; background: var(--surface-2); border-bottom: 1px solid var(--border); cursor: pointer; touch-action: pan-y; }
.ae-wave { flex: 1 1 0; display: block; width: 100%; height: 0; min-height: 0; cursor: text; touch-action: pan-y; } /* up/down still scrolls the page; sideways selects */
.ae-cursor, .ae-head { position: absolute; top: 0; bottom: 0; left: 0; pointer-events: none; will-change: transform; }
.ae-cursor { width: 1.5px; background: var(--text); opacity: .8; }
.ae-head { width: 2px; margin-left: -1px; background: var(--ae-head); box-shadow: 0 0 0 .5px color-mix(in srgb, var(--ae-bg) 60%, transparent); }
.ae-head::before { content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top: 8px solid var(--ae-head); border-bottom: 0; }

/* busy */
.ae-busy { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--ae-bg) 72%, transparent); backdrop-filter: blur(2px); }
.ae-busy[hidden] { display: none; }
.ae-busy-card { width: min(380px, 100%); display: grid; gap: 10px; justify-items: center; padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.ae-busy-card [data-ae-busy-progress] { width: 100%; }
.ae-busy-title { margin: 0; font-weight: 650; }

/* transport */
/* Wraps (the selection boxes go to their own line) instead of running under the side panel on laptop-sized screens. */
.ae-transport {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; min-width: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.ae-buttons { display: flex; align-items: center; gap: 2px; }
.ae-tbtn {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-soft); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s, transform .15s var(--ease-spring);
}
.ae-tbtn .icon { width: 19px; height: 19px; }
@media (hover: hover) { .ae-tbtn:hover { background: var(--bg-soft); color: var(--text); } }
.ae-tbtn:active { transform: scale(.93); }
.ae-tbtn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); }
.ae-tbtn[aria-pressed="true"] { background: var(--app-accent-soft); color: var(--app-accent); }
.ae-play { width: 46px; height: 46px; margin: 0 4px; border-radius: 50%; background: var(--app-accent); color: var(--app-on-accent); box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--app-accent) 60%, transparent); }
.ae-play .icon { width: 22px; height: 22px; }
@media (hover: hover) { .ae-play:hover { background: var(--app-accent-hover); color: var(--app-on-accent); } }
.ae-rec .icon { color: #e11d48; }
.ae-time {
  flex: none; min-width: 8.6ch; padding: 7px 12px; border-radius: 10px; background: var(--surface-sunken);
  font: 600 1.4rem/1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--text); text-align: center;
}
.ae-selbox { display: flex; gap: 8px; margin-left: auto; min-width: 0; }
.ae-selbox label { min-width: 0; }
.ae-selbox label { display: grid; gap: 2px; font-size: .64rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.ae-selbox input {
  width: 7rem; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: 500 .84rem var(--font-mono); font-variant-numeric: tabular-nums;
}
.ae-selbox input:hover { border-color: var(--border-strong); }
.ae-selbox input:focus { outline: none; border-color: var(--app-accent); box-shadow: var(--ring); background: var(--surface); }
.ae-meter { flex: none; display: grid; gap: 4px; width: 96px; }
.ae-meter i { position: relative; display: block; height: 6px; overflow: hidden; border-radius: 3px; background: var(--surface-sunken); }
.ae-meter i::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #10b981 0 72%, #f59e0b 72% 90%, #ef4444 90%);
  clip-path: inset(0 calc((1 - var(--lvl, 0)) * 100%) 0 0);
}
.ae-meter i.is-clip { box-shadow: inset -4px 0 0 #ef4444; }

/* ---------- panel ---------- */
.ae-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-left: 1px solid var(--border); }
.ae-panel-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 12px 8px; }
.ae-tabs { flex: 1; display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-sunken); }
.ae-tabs button { flex: 1; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); font: 600 .82rem var(--font-sans); cursor: pointer; }
.ae-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ae-tabs button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); }
.ae-panel-toggle { display: none; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--text-soft); cursor: pointer; }
.ae-panel-toggle .icon { transition: rotate .2s var(--ease); }
.ae-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px 18px; }

.ae-search { position: relative; margin: 4px 0 2px; }
.ae-search > .icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.ae-search-input { width: 100%; height: 38px; padding: 0 10px 0 34px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; }
.ae-search-input:focus { outline: none; border-color: var(--app-accent); box-shadow: var(--ring); background: var(--surface); }
.ae-group-title { margin: 16px 2px 7px; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }
.ae-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ae-tile {
  display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); color: var(--text); font: 550 .8rem/1.2 var(--font-sans); text-align: left; cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .15s var(--ease-spring); -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .ae-tile:hover { border-color: color-mix(in srgb, var(--app-accent) 45%, var(--border)); background: var(--app-accent-softer); } }
.ae-tile:active { transform: scale(.97); }
.ae-tile:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); }
.ae-tile-icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--app-accent-soft); color: var(--app-accent); }
.ae-tile-icon .icon { width: 16px; height: 16px; }
.ae-empty { margin: 14px 2px; color: var(--text-faint); font-size: .85rem; line-height: 1.5; }

/* one effect */
.ae-fx-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.ae-back { flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin-left: -6px; border: 0; border-radius: 9px; background: transparent; color: var(--text-soft); cursor: pointer; }
@media (hover: hover) { .ae-back:hover { background: var(--bg-soft); color: var(--text); } }
.ae-fx-icon { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--app-accent-soft); color: var(--app-accent); }
.ae-fx-icon .icon { width: 17px; height: 17px; }
.ae-fx-title { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.ae-fx-desc { margin: 0 0 10px; color: var(--text-soft); font-size: .85rem; line-height: 1.45; }
.ae-applies { display: flex; align-items: center; gap: 7px; margin: 0 0 12px; padding: 7px 10px; border-radius: 9px; background: var(--surface-sunken); color: var(--text-soft); font-size: .79rem; line-height: 1.35; }
.ae-applies .icon { flex: none; width: 15px; height: 15px; color: var(--app-accent); }
.ae-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.ae-chip { height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--text-soft); font: 550 .76rem var(--font-sans); cursor: pointer; }
@media (hover: hover) { .ae-chip:hover { border-color: var(--app-accent); color: var(--app-accent); } }
.ae-chip:active { background: var(--app-accent-soft); }
.ae-params { display: grid; gap: 12px; }
.ae-field { display: grid; gap: 6px; }
.ae-field-label { font-size: .86rem; font-weight: 600; }
.ae-range .range-head label { font-size: .86rem; }
.ae-seg { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-sunken); }
.ae-seg button { flex: 1; min-height: 32px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); font: 600 .78rem/1.15 var(--font-sans); cursor: pointer; }
.ae-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ae-seg button:disabled { opacity: .45; cursor: default; }
.ae-seg button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); }
.ae-check { display: flex; align-items: flex-start; gap: 9px; font-size: .86rem; line-height: 1.35; cursor: pointer; }
.ae-check input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--app-accent); }
.ae-param-btn { justify-self: start; }
.ae-info { margin: 12px 0 0; color: var(--text-soft); font-size: .8rem; line-height: 1.45; }
.ae-info.is-warn { padding: 7px 10px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); }
.ae-note { margin: 0; color: var(--text-faint); font-size: .79rem; line-height: 1.45; }
.ae-fx-actions {
  position: sticky; bottom: -18px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 14px; padding: 12px 0 6px; background: linear-gradient(transparent, var(--surface) 28%);
}
.ae-fx-actions .btn-primary { margin-left: auto; min-width: 7rem; }
.ae-compare[aria-pressed="true"] { background: var(--warning-soft); color: var(--warning); }
.ae-link { display: block; margin-top: 8px; padding: 0; border: 0; background: none; color: var(--text-faint); font: 500 .79rem var(--font-sans); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ae-wide { width: 100%; justify-content: flex-start; }
.ae-stack { display: grid; gap: 6px; margin: 10px 0 12px; }
.ae-row2, .ae-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ae-cover { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0; }
.ae-cover img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; box-shadow: var(--shadow-sm); }

/* equalizer */
.ae-eq-wrap { display: grid; gap: 4px; }
.ae-eq { display: block; width: 100%; height: 150px; border: 1px solid var(--border); border-radius: 10px; background: var(--ae-bg); cursor: ns-resize; touch-action: none; }
.ae-eq:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); }
.ae-eq-labels { position: relative; height: 14px; color: var(--text-faint); font-size: .64rem; font-variant-numeric: tabular-nums; }
.ae-eq-labels span { position: absolute; top: 0; translate: -50% 0; }
.ae-eq-readout { margin: 2px 0 0; color: var(--text-soft); font-size: .78rem; font-variant-numeric: tabular-nums; }

/* markers + history */
.ae-mlist, .ae-hlist { display: grid; gap: 4px; margin: 12px 0 0; padding: 0; list-style: none; }
.ae-mlist li { display: flex; align-items: center; gap: 6px; }
.ae-mtime { flex: none; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: 500 .8rem var(--font-mono); font-variant-numeric: tabular-nums; cursor: pointer; }
@media (hover: hover) { .ae-mtime:hover { border-color: var(--ae-marker, #d97706); } }
.ae-mname { flex: 1; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: .85rem; }
.ae-mname:hover, .ae-mname:focus { outline: none; border-color: var(--border); background: var(--surface); }
.ae-mdel { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-faint); cursor: pointer; }
@media (hover: hover) { .ae-mdel:hover { background: var(--danger-soft); color: var(--danger); } }
.ae-mdel .icon { width: 16px; height: 16px; }
.ae-hitem { width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); font: 500 .84rem var(--font-sans); text-align: left; cursor: pointer; }
@media (hover: hover) { .ae-hitem:hover { background: var(--bg-soft); color: var(--text); } }
.ae-hitem.is-current { background: var(--app-accent-soft); color: var(--app-accent); font-weight: 650; }

/* status line */
.ae-status .ae-hint { margin-left: auto; }

/* recorder + download dialogs */
.ae-recorder { display: grid; justify-items: center; gap: 10px; min-width: min(340px, 78vw); padding: 6px 0 2px; }
.ae-rec-btn { display: grid; place-items: center; width: 78px; height: 78px; border: 4px solid color-mix(in srgb, #e11d48 28%, transparent); border-radius: 50%; background: var(--surface); cursor: pointer; }
.ae-rec-btn span { width: 34px; height: 34px; border-radius: 50%; background: #e11d48; transition: width .2s var(--ease), height .2s var(--ease), border-radius .2s var(--ease); }
.ae-rec-btn.is-on span { width: 26px; height: 26px; border-radius: 6px; }
.ae-rec-btn.is-on { animation: ae-pulse 1.4s ease-in-out infinite; }
@keyframes ae-pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, #e11d48 16%, transparent); } }
@media (prefers-reduced-motion: reduce) { .ae-rec-btn.is-on { animation: none; } }
.ae-rec-time { margin: 0; font: 600 1.6rem/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.ae-rec-meter { width: 100%; height: 8px; overflow: hidden; border-radius: 4px; background: var(--surface-sunken); }
.ae-rec-meter i { display: block; width: calc(var(--lvl, 0) * 100%); height: 100%; background: linear-gradient(90deg, #10b981, #f59e0b 80%, #ef4444); }
.ae-recorder .ae-note { text-align: center; }
.ae-export { display: grid; gap: 12px; }
.ae-export > *, .ae-grid2 > * { min-width: 0; }
.ae-export .hint { margin-top: -4px; }
.ae-more summary { color: var(--text-soft); font-size: .86rem; font-weight: 600; cursor: pointer; }
.ae-more .ae-grid2 { margin-top: 10px; }
.ae-export .ae-info { margin: 0; }

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .ae-stage { grid-template-columns: minmax(0, 1fr) 300px; }
  .ae-meter { display: none; }
  .ae-selbox input { width: 6.4rem; }
}
@media (max-width: 1000px) {
  .ae-transport { flex-wrap: wrap; row-gap: 8px; }
  .ae-selbox { flex: 1 1 100%; margin-left: 0; }
  .ae-selbox label { flex: 1; }
  .ae-selbox input { width: 100%; }
}
@media (max-width: 920px) {
  .ae-stage { display: flex; flex-direction: column; }
  .ae-editor { flex: 1 0 auto; }
  .ae-panel { flex: 0 1 auto; max-height: min(46vh, 440px); max-height: min(46dvh, 440px); border-left: 0; border-top: 1px solid var(--border); box-shadow: 0 -8px 20px -14px rgb(16 24 40 / .25); }
  .ae-panel-head { padding: 8px 10px; }
  .ae-panel-toggle { display: grid; }
  .ae-stage[data-panel="collapsed"] .ae-panel-body { display: none; }
  .ae-stage[data-panel="collapsed"] .ae-panel-toggle .icon { rotate: 0deg; }
  .ae-stage:not([data-panel="collapsed"]) .ae-panel-toggle .icon { rotate: 180deg; }
  .ae-status .ae-hint { display: none; }
}
@media (max-width: 640px) {
  .ae-editor { gap: 8px; padding: 8px; }
  .ae-overview { height: 34px; }
  .ae-track { min-height: 130px; }
  .ae-transport { gap: 8px; padding: 6px 8px; }
  .ae-buttons { flex: 1; justify-content: space-between; }
  .ae-tbtn { width: 36px; height: 36px; }
  .ae-play { width: 44px; height: 44px; margin: 0 2px; }
  .ae-buttons [data-act="stop"], .ae-buttons [data-act="marker"] { display: none; }
  .ae-time { min-width: 0; padding: 6px 8px; font-size: 1.05rem; }
  .ae-selbox { gap: 6px; }
  .ae-selbox input { height: 34px; padding: 0 6px; font-size: .8rem; }
  .ae-panel-body { padding: 2px 12px 16px; }
  .ae-grid2 { grid-template-columns: 1fr; }
}
