/* Audio Trimmer — layout that media-tools.css has no equivalent for:
   the stacked ruler/waveform stage, the transport strip, and the
   selection readout. Everything is prefixed .at- so it cannot leak. */

/* The sidebar is far taller than the transport strip, so the stage stretches to
   meet it and the waveform gets the extra height instead of dead space. */
body.__accessbox-audio-trimmer .media-main,
#editor {
  display: flex;
  flex-direction: column;
}

#editor { flex: 1 1 auto; min-height: 0; }
#editor[hidden] { display: none !important; }

.at-stage {
  position: relative;
  display: flex;
  min-height: 250px;
  /* Grows into the space the tall sidebar creates, but a waveform past this
     height is just stretched noise, so it stops there. */
  max-height: 420px;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--media-line);
  border-radius: 17px;
  background: linear-gradient(180deg, #fffdf8, #f7f3ea);
}

.at-ruler {
  display: block;
  width: 100%;
  height: 28px;
  flex: 0 0 28px;
  border-bottom: 1px solid var(--media-line);
  cursor: text;
  touch-action: none;
}

.at-wave-wrap {
  position: relative;
  min-height: 150px;
  flex: 1 1 auto;
  touch-action: none;
}

.at-wave,
.at-overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* The overlay only paints selection chrome, so pointer work stays on the wrap. */
.at-overlay { pointer-events: none; }
.at-wave-wrap { cursor: crosshair; }
.at-wave-wrap.is-grabbing { cursor: grabbing; }
.at-wave-wrap.is-handle { cursor: ew-resize; }
.at-wave-wrap.is-move { cursor: grab; }

.at-scroll {
  width: 100%;
  margin: 10px 0 0;
  accent-color: var(--media-accent);
}

.at-scroll[hidden] { display: none !important; }

.at-transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.at-transport .at-spacer { flex: 1 1 auto; }

.at-play {
  min-width: 104px;
}

.at-time {
  padding: 0 11px;
  border: 1px solid var(--media-line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--media-ink);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .72rem;
  line-height: 40px;
  white-space: nowrap;
}

.at-time .at-time-total { color: #948f85; }

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

.at-zoom-value {
  min-width: 52px;
  color: #8b867d;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .63rem;
  text-align: right;
}

.at-icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.at-toggle[aria-pressed="true"] {
  border-color: var(--media-accent);
  color: var(--media-accent-dark);
  background: color-mix(in srgb, var(--media-soft) 70%, white);
}

.at-selection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--media-line);
  border-radius: 14px;
  background: rgba(248, 245, 238, .68);
}

.at-field label {
  display: block;
  margin: 0 0 7px;
  color: #56534d;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .61rem;
  font-weight: 600;
  letter-spacing: .085em;
  text-transform: uppercase;
}

.at-field input {
  font-family: "DM Mono", ui-monospace, monospace;
  letter-spacing: -.01em;
}

.at-duration {
  display: flex;
  min-height: 43px;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--media-accent) 30%, var(--media-line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--media-soft) 55%, white);
}

.at-duration strong {
  color: var(--media-accent-dark);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .88rem;
  font-weight: 600;
}

.at-badge {
  padding: 3px 8px;
  border: 1px solid var(--media-line);
  border-radius: 999px;
  background: #fffdf8;
  color: #858077;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.at-badge.is-ok {
  border-color: #4f9c6d;
  color: #2f6a48;
  background: #e4f3e9;
}

.at-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.at-actions .btn { flex: 1; padding: 0 10px; white-space: nowrap; }

.at-vs-note {
  grid-column: 1 / -1;
  margin: 0;
  color: #7b766d;
  font-size: .68rem;
  line-height: 1.5;
}

.at-vs-note a {
  color: var(--media-accent-dark);
  font-weight: 700;
  text-underline-offset: 3px;
}

.at-ops {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.at-ops .btn { min-width: 0; padding: 0 10px; }
.at-ops .at-span-2 { grid-column: 1 / -1; }

.at-seg-2 { grid-template-columns: repeat(2, 1fr); }

.at-report {
  margin: 9px 0 0;
  padding: 9px 10px;
  border-radius: 9px;
  background: #eee9e0;
  color: #6f6b62;
  font-size: .64rem;
  line-height: 1.5;
}

.at-report.is-empty { color: #8c877e; }

.at-meta-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #7d786f;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: .62rem;
}

.at-meta-line + .at-meta-line { margin-top: 5px; }

/* In-page confirm — the shared CSS has no modal and native confirm() is banned. */
.at-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(35, 31, 25, .38);
  backdrop-filter: blur(3px);
}

.at-modal[hidden] { display: none !important; }

.at-modal-card {
  width: min(360px, 100%);
  padding: 22px;
  border: 1px solid var(--media-line);
  border-radius: 18px;
  background: var(--surface, #fffdf8);
  box-shadow: 0 26px 70px rgba(48, 42, 31, .28);
}

.at-modal-card h2 { margin: 0 0 8px; font-size: 1rem; letter-spacing: -.02em; }
.at-modal-card p { margin: 0 0 18px; color: var(--media-muted); font-size: .76rem; line-height: 1.55; }
.at-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 840px) {
  .at-stage { min-height: 220px; }
}

@media (max-width: 540px) {
  .at-stage { min-height: 190px; }
  .at-wave-wrap { min-height: 120px; }
  .at-transport .at-spacer { display: none; }
  .at-play { flex: 1 1 100%; }
  .at-selection { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
}
