/* Audio tools (classid=36) - shared shell for six local browser tools.
   Built on Bootstrap 5.3; only tool-specific layout lives here. */
.at-shell {
    --at-accent: #0d6efd;
    --at-line: var(--bs-border-color, #dee2e6);
}

/* ---------- upload ---------- */
.at-drop {
    border: 2px dashed var(--at-line);
    border-radius: .6rem;
    text-align: center;
    padding: 1.1rem .75rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.at-drop:hover, .at-drop.is-over {
    border-color: var(--at-accent);
    background: rgba(13, 110, 253, .06);
}
.at-drop .at-drop-icon { font-size: 1.8rem; }
.at-formats { margin-top: .5rem; font-size: .78rem; color: var(--bs-secondary-color, #6c757d); }

/* ---------- file queue ---------- */
.at-queue { border: 1px solid var(--at-line); border-radius: .5rem; overflow: hidden; }
/* Empty queue is a deliberate placeholder, not another list row: give it
   breathing room and a soft surface so it never looks glued to the batch
   summary cards directly above it. */
.at-queue-empty {
    padding: 1.15rem .75rem; text-align: center; line-height: 1.5;
    font-size: .85rem; color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-tertiary-bg, #f8f9fa);
}
.at-row {
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem .65rem; border-bottom: 1px solid var(--at-line);
    background: var(--bs-body-bg, #fff);
}
.at-row:last-child { border-bottom: 0; }
.at-row.is-active { background: rgba(13, 110, 253, .05); }
.at-row.is-drag { opacity: .45; }
.at-row.is-over { box-shadow: inset 0 2px 0 var(--at-accent); }
.at-index {
    flex: 0 0 1.7rem; height: 1.7rem; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; background: rgba(13, 110, 253, .1); color: var(--at-accent);
}
.at-thumb {
    flex: 0 0 2.2rem; height: 2.2rem; border-radius: .4rem;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(13, 110, 253, .08); color: var(--at-accent);
}
.at-file-main { flex: 1 1 auto; min-width: 0; }
.at-file-name { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.at-file-meta { font-size: .75rem; color: var(--bs-secondary-color, #6c757d); display: flex; flex-wrap: wrap; gap: .55rem; }
.at-row-actions { display: flex; align-items: center; gap: .25rem; flex: 0 0 auto; }
.at-row .form-select-sm { width: auto; min-width: 6.4rem; }
.at-drag-handle { cursor: grab; color: var(--bs-secondary-color, #6c757d); }

/* ---------- settings + actions ---------- */
.at-settings { background: var(--bs-tertiary-bg, #f8f9fa); border-radius: .5rem; }
.at-settings-title { font-weight: 700; display: flex; align-items: center; gap: .45rem; }
.at-advanced-toggle { background: none; border: 0; padding: 0; font-weight: 600; color: var(--at-accent); }
.at-actions { border-top: 1px solid var(--at-line); padding-top: .75rem; margin-top: .75rem; }
.at-hint { font-size: .8rem; color: var(--bs-secondary-color, #6c757d); }
.at-progress { height: 8px; }

/* ---------- results ---------- */
.at-results { border-top: 1px solid var(--at-line); margin-top: 1rem; padding-top: .75rem; }
.at-result-row {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .5rem 0; border-bottom: 1px solid var(--at-line);
}
.at-result-row:last-child { border-bottom: 0; }
.at-stats { border-radius: .5rem; background: rgba(25, 135, 84, .07); padding: .75rem; text-align: center; }
.at-stats .at-stat-label { font-size: .75rem; color: var(--bs-secondary-color, #6c757d); }
.at-stats .at-stat-value { font-size: 1.05rem; font-weight: 700; }
.at-stats.is-negative { background: rgba(220, 53, 69, .07); }

/* ---------- player ---------- */
.at-player { width: 100%; height: 38px; }
.at-player-box { border: 1px solid var(--at-line); border-radius: .5rem; padding: .6rem; background: var(--bs-body-bg, #fff); }

/* ---------- waveform / multi-selection / zoom ---------- */
/* Zoom only widens at-wave-view and scrolls horizontally; every overlay still
   positions by percentage of the FULL timeline, so zoom never moves a cut. */
.at-wave-scroll { overflow-x: auto; overflow-y: hidden; border-radius: .5rem; -webkit-overflow-scrolling: touch; }
.at-wave-view { position: relative; width: 100%; }
.at-wave-wrap { position: relative; border: 1px solid var(--at-line); border-radius: .5rem; overflow: hidden; background: #0f172a; }
.at-wave { display: block; width: 100%; height: 132px; touch-action: pan-x; }
.at-wave-veil { position: absolute; top: 0; bottom: 0; background: rgba(15, 23, 42, .62); pointer-events: none; z-index: 1; }
.at-wave-segment {
    position: absolute; top: 0; bottom: 0; z-index: 2; min-width: 2px;
    border-left: 2px solid rgba(13, 110, 253, .7); border-right: 2px solid rgba(13, 110, 253, .7);
    background: rgba(13, 110, 253, .12); cursor: grab; touch-action: none;
}
.at-wave-segment.is-active {
    border-color: #0d6efd; background: rgba(13, 110, 253, .24);
    box-shadow: inset 0 0 0 1px rgba(13, 110, 253, .45);
}
.at-wave-segment:active { cursor: grabbing; }
.at-wave-seg-no {
    position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
    font-size: .65rem; font-weight: 700; line-height: 1; padding: .15rem .3rem;
    border-radius: .25rem; color: #fff; background: rgba(13, 110, 253, .85); pointer-events: none;
}
.at-wave-segment.is-active .at-wave-seg-no { background: #0d6efd; }
.at-wave-handle {
    position: absolute; top: 0; bottom: 0; width: 16px;
    cursor: ew-resize; background: #0d6efd; border-radius: 3px;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: .65rem;
    touch-action: none; z-index: 3;
}
.at-wave-handle-start { left: 0; margin-left: -8px; }
.at-wave-handle-end { right: 0; margin-right: -8px; }
.at-wave-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: #ffc107; pointer-events: none; z-index: 4; }
.at-wave-placeholder { padding: 2.4rem .75rem; text-align: center; color: #94a3b8; font-size: .85rem; pointer-events: none; }
.at-wave-scale {
    position: relative; height: 1.35rem; margin-top: .2rem;
    font-size: .7rem; color: var(--bs-secondary-color, #6c757d);
    font-variant-numeric: tabular-nums;
}
.at-wave-tick { position: absolute; top: 0; white-space: nowrap; transform: translateX(-50%); }
.at-wave-tick:first-child { transform: none; }
.at-wave-tick:last-child { transform: translateX(-100%); }
.at-selection-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .4rem; }
.at-time-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.at-time-grid .form-control { font-variant-numeric: tabular-nums; }

/* ---------- zoom toolbar / current audio info ---------- */
.at-zoom-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.at-zoom-bar .btn-group { flex: 0 0 auto; }
.at-zoom-label { font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--at-accent); }
.at-info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.at-info-item {
    border: 1px solid var(--at-line); border-radius: .5rem; padding: .5rem .65rem;
    background: var(--bs-tertiary-bg, #f8f9fa); min-width: 0;
}
.at-info-value { display: block; font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- segment list ---------- */
.at-seg-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
    border: 1px solid var(--at-line); border-radius: .5rem;
    padding: .5rem .6rem; margin-bottom: .5rem; background: var(--bs-body-bg, #fff);
}
.at-seg-row.is-active { border-color: var(--at-accent); background: rgba(13, 110, 253, .05); }
.at-seg-row .at-index { flex: 0 0 1.7rem; }
.at-seg-times { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; flex: 1 1 15rem; }
.at-seg-times .form-control { width: 8.2rem; font-variant-numeric: tabular-nums; }
.at-seg-row-actions { display: flex; flex-wrap: wrap; gap: .25rem; margin-left: auto; }
.at-warn { font-size: .8rem; color: #b45309; }

/* ---------- fade settings ---------- */
#tr_fade .form-select-sm, #tr_fade .form-control-sm { max-width: 11rem; }

/* ---------- editable text (STT / TTS) ---------- */
.at-textarea { min-height: 190px; resize: vertical; font-size: .9rem; line-height: 1.6; }
.at-char-count { font-size: .75rem; color: var(--bs-secondary-color, #6c757d); text-align: right; }
.at-transcript { min-height: 190px; }
.at-range-value { min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Converter: append bar, per-file target, per-file progress ---------- */
.at-append-bar { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; flex-wrap: wrap; }
.at-target-wrap { display: inline-flex; align-items: center; gap: .35rem; }
.at-target-label { font-size: .72rem; color: var(--bs-secondary-color, #6c757d); white-space: nowrap; }
.at-target-wrap .form-select-sm { min-width: 6.6rem; }
.at-row-progress { display: block; height: 4px; border-radius: 2px; background: rgba(13, 110, 253, .12); margin-top: .35rem; overflow: hidden; }
.at-row-progress-bar { height: 100%; background: var(--at-accent); transition: width .15s linear; }
.at-format-info { font-size: .82rem; font-weight: 600; color: var(--at-accent); margin-bottom: .2rem; }

/* ---------- Rich conversion results ---------- */
.at-result-card { border: 1px solid var(--at-line); border-radius: .5rem; padding: .65rem .75rem; margin-bottom: .5rem; background: var(--bs-body-bg, #fff); }
.at-result-card.is-failed { border-color: rgba(220, 53, 69, .4); background: rgba(220, 53, 69, .03); }
.at-compare { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .78rem; color: var(--bs-secondary-color, #6c757d); margin-top: .35rem; }
.at-delta { font-weight: 700; }
.at-delta.is-reduced { color: #198754; }
.at-delta.is-increased { color: #dc3545; }

/* ---------- Converter V1.0: summary, scope, compatibility, result status ---------- */
.at-summary { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .78rem; }
.at-summary .badge { font-weight: 600; }
.at-scope, .at-compat { margin-top: .7rem; border-top: 1px solid var(--at-line); padding-top: .55rem; }
.at-scope-title, .at-compat-title { font-size: .8rem; font-weight: 700; }
.at-scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem .8rem; margin-top: .35rem; }
.at-scope-item { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .75rem; color: var(--bs-secondary-color, #6c757d); }
.at-scope-item b { font-weight: 600; color: var(--bs-body-color, #212529); }
.at-compat-grid { display: grid; grid-template-columns: 1fr; gap: .1rem; margin-top: .35rem; }
.at-compat-item { display: flex; align-items: baseline; gap: .4rem; font-size: .75rem; color: var(--bs-secondary-color, #6c757d); }
.at-compat-dot { font-size: .45rem; line-height: 1.6; }
.at-compat-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.at-compat-item.is-active { color: #b45309; font-weight: 600; }
.at-compat-item.is-active .at-compat-dot { color: #b45309; }
.at-notice { margin-top: .6rem; border-radius: .4rem; padding: .45rem .6rem; font-size: .8rem; color: #b45309; background: rgba(245, 158, 11, .12); }
.at-notice.is-error { color: #b91c1c; background: rgba(220, 38, 38, .10); }
.at-run-note { font-size: .82rem; font-weight: 600; color: var(--bs-secondary-color, #6c757d); }
#ac_actions_card .at-actions { border-top: 0; padding-top: 0; margin-top: 0; }
.at-progress-detail { margin-top: .3rem; font-size: .75rem; color: var(--bs-secondary-color, #6c757d); }
.at-result-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .8rem; padding: .55rem .7rem; border-radius: .5rem; background: var(--bs-tertiary-bg, #f8f9fa); font-size: .8rem; }
.at-result-summary .badge { font-weight: 600; }
.at-result-card .badge { font-size: .7rem; }

/* ---------- Compressor: effect-first quality presets ---------- */
/* Four cards (smart + three manual presets): auto-fit keeps them on one row on
   desktop and stacks them on narrow screens without a second media query. */
.at-presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .5rem; }
.at-preset.is-recommended .at-preset-head { padding-right: 3.6rem; }
/* The size guard is a promise, not a warning: keep it readable but quiet. */
.at-guard-note { color: #0f5132; }
.at-file-spec { font-variant-numeric: tabular-nums; }
.at-preset {
    position: relative; display: flex; flex-direction: column; gap: .15rem;
    border: 1px solid var(--at-line); border-radius: .5rem;
    padding: .6rem .7rem; background: var(--bs-body-bg, #fff); cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.at-preset:hover { border-color: var(--at-accent); }
.at-preset input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.at-preset:has(input:checked) {
    border-color: var(--at-accent); background: rgba(13, 110, 253, .06);
    box-shadow: inset 0 0 0 1px var(--at-accent);
}
/* Fallback highlight where :has() is unavailable. */
.at-preset input:checked ~ .at-preset-head { color: var(--at-accent); }
.at-preset input:focus-visible ~ .at-preset-head { text-decoration: underline; }
.at-preset.is-recommended { border-color: rgba(25, 135, 84, .55); }
.at-preset-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; font-size: .875rem; }
.at-preset-rate { font-size: .75rem; color: var(--bs-secondary-color, #6c757d); }
.at-preset-desc, .at-preset-impact { font-size: .74rem; color: var(--bs-secondary-color, #6c757d); }
.at-preset-impact { color: var(--at-accent); }
.at-preset-badge {
    position: absolute; top: .35rem; right: .45rem;
    font-size: .65rem; font-weight: 700; color: #198754;
    background: rgba(25, 135, 84, .1); border-radius: .3rem; padding: .05rem .35rem;
}

/* ---------- Speech to Text: capability boundary + live/file modes ---------- */
.at-boundary {
    border: 1px solid rgba(13, 110, 253, .3); border-radius: .5rem;
    background: rgba(13, 110, 253, .05); padding: .65rem .8rem;
    font-size: .84rem; line-height: 1.55;
}
.at-modes { display: flex; flex-wrap: wrap; gap: .5rem; }
.at-mode {
    flex: 1 1 12rem; display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid var(--at-line); border-radius: .5rem;
    background: var(--bs-body-bg, #fff); color: inherit;
    padding: .55rem .7rem; font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.at-mode:hover { border-color: var(--at-accent); }
.at-mode.is-active { border-color: var(--at-accent); background: rgba(13, 110, 253, .07); color: var(--at-accent); }
.at-mode:disabled { opacity: .55; cursor: not-allowed; }
.at-mode-tag {
    margin-left: auto; font-size: .68rem; font-weight: 700; white-space: nowrap;
    color: #198754; background: rgba(25, 135, 84, .1); border-radius: .3rem; padding: .1rem .35rem;
}
.at-mode-tag.is-muted { color: var(--bs-secondary-color, #6c757d); background: rgba(108, 117, 125, .12); }
.at-mic-status {
    display: inline-block; font-size: .8rem; font-weight: 600;
    border-radius: .35rem; padding: .25rem .55rem;
}
.at-mic-need { color: #b45309; background: rgba(245, 158, 11, .12); }
.at-mic-ready { color: #198754; background: rgba(25, 135, 84, .12); }
.at-mic-denied { color: #dc3545; background: rgba(220, 53, 69, .12); }
.at-status { font-weight: 600; }
.at-status-listening { color: var(--at-accent); }
.at-status-done { color: #198754; }
.at-status-failed { color: #dc3545; }
.at-transcript-block { border-top: 1px solid var(--at-line); padding-top: .75rem; }

/* ---------- Compressor V1.0: batch summary, per-row output, honest notes ---------- */
.at-batch-summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; }
.at-batch-summary .at-summary-item {
    border: 1px solid var(--at-line); border-radius: .5rem; padding: .45rem .55rem;
    background: var(--bs-tertiary-bg, #f8f9fa); min-width: 0;
}
.at-batch-summary .at-summary-label {
    display: block; font-size: .7rem; color: var(--bs-secondary-color, #6c757d);
}
.at-batch-summary .at-summary-value {
    display: block; font-size: .9rem; font-weight: 700; font-variant-numeric: tabular-nums;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.at-row-out {
    margin-right: auto; font-size: .74rem; font-variant-numeric: tabular-nums;
    color: var(--bs-secondary-color, #6c757d);
}
.at-result-card.is-cancelled { border-color: rgba(255, 193, 7, .5); background: rgba(255, 193, 7, .05); }
/* "Original kept" — a successful, honest outcome, not a failure state. */
.at-result-card.is-kept { border-color: rgba(13, 202, 240, .45); background: rgba(13, 202, 240, .04); }
.at-format-warn { color: #b45309; }

/* ---------- Audio Joiner: queue specs, previews, compatibility, estimate ---------- */
.jn-summary { font-variant-numeric: tabular-nums; }
.jn-now { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.jn-tech { display: block; margin-top: .2rem; font-size: .72rem; color: var(--bs-secondary-color, #6c757d); }
.jn-track-time {
    display: block; margin-top: .15rem; font-size: .7rem;
    font-variant-numeric: tabular-nums; color: var(--at-accent);
}
.jn-compat-state { font-size: .82rem; font-weight: 600; color: #198754; }
.jn-compat-state.is-mixed { color: #b45309; }
.jn-compat-note { font-size: .8rem; margin-top: .25rem; color: var(--bs-secondary-color, #6c757d); }
.jn-estimate { font-size: .85rem; font-weight: 600; color: var(--at-accent); white-space: pre-line; }
.jn-name-group { min-width: 12rem; max-width: 22rem; }
.jn-name-feedback { flex-basis: 100%; margin-top: .25rem; }
.jn-result .at-compare { margin-top: .5rem; }

/* ---------- SEO ---------- */
.at-faq summary { cursor: pointer; font-weight: 600; padding: .5rem 0; }

@media (max-width: 767.98px) {
    .at-drop { padding: .9rem .5rem; }
    .at-append-bar .btn { width: 100%; }
    .at-target-wrap { width: 100%; justify-content: flex-end; }
    .at-target-wrap .form-select-sm { flex: 1 1 auto; }
    .at-result-card { padding: .55rem; }
    .at-row { flex-wrap: wrap; }
    .at-file-main { flex-basis: calc(100% - 4.5rem); }
    .at-row-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
    .at-row .form-select-sm { flex: 1 1 auto; min-width: 0; }
    .at-wave { height: 104px; }
    .at-wave-handle { width: 26px; font-size: .8rem; }
    .at-wave-handle-start { margin-left: -13px; }
    .at-wave-handle-end { margin-right: -13px; }
    .at-wave-segment { touch-action: none; }
    .at-selection-bar .at-hint { flex-basis: 100%; }
    .at-info-grid { grid-template-columns: 1fr 1fr; }
    .at-seg-row-actions { width: 100%; justify-content: flex-end; margin-left: 0; }
    .at-seg-times { flex-basis: 100%; }
    .at-seg-times .form-control { flex: 1 1 7rem; width: auto; min-width: 0; }
    .at-zoom-bar .btn-group { width: 100%; }
    .at-zoom-bar .btn { flex: 1 1 auto; }
    .at-time-grid { grid-template-columns: 1fr 1fr; }
    .at-time-grid > :last-child { grid-column: 1 / -1; }
    .at-batch-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .at-row-out { flex-basis: 100%; width: 100%; margin-right: 0; }
    .at-actions .btn-lg { width: 100%; }
    .at-scope-grid { grid-template-columns: 1fr; }
    .at-result-summary { gap: .3rem .5rem; }
    .at-presets { grid-template-columns: 1fr; }
    .at-preset { padding: .5rem .6rem; }
    .at-modes { flex-direction: column; }
    .at-mode { flex: 1 1 auto; width: 100%; }
    .at-textarea, .at-transcript { min-height: 150px; }
    .jn-now { flex-basis: 100%; max-width: 100%; }
    .jn-name-group { width: 100%; max-width: 100%; }
}

/* Narrow phones: millisecond values need a full row, otherwise the two
   time inputs squeeze the timestamps and become hard to tap and edit. */
@media (max-width: 480px) {
    .at-time-grid { grid-template-columns: 1fr; }
    .at-time-grid > :last-child { grid-column: auto; }
    .at-seg-times .form-control { flex-basis: 100%; }
    .at-seg-times { gap: .3rem; }
}
