/*
 * Trim video, Compress video, Video to MP3 and the Audio converter (video-tools.js). Used on their pages and the home page
 * tabs. Builds on spokly.css.
 */

.vt, .vt-upload, .vt-editor, .vt-preview, .vt-range-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.vt-limit, .vt-hint { margin: 0; }
.vt-preview video { display: block; width: 100%; max-height: 56vh; border-radius: 12px; background: #000; }
.vt-preview audio { width: 100%; }

/* The timeline: thumbnails with the start and end handles */
.vt-track { position: relative; height: 64px; margin-inline: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-subtle); touch-action: pan-y; cursor: pointer; }
.vt-track canvas { display: block; width: 100%; height: 100%; border-radius: 11px; }
.vt-shade { position: absolute; top: 0; bottom: 0; left: 0; background: var(--bg); opacity: .72; pointer-events: none; }
.vt-pick { position: absolute; top: -1px; bottom: -1px; border-block: 2px solid var(--primary); pointer-events: none; }
.vt-head { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--danger); pointer-events: none; }
.vt-handle { position: absolute; top: -8px; bottom: -8px; width: 44px; margin-left: -22px; border-radius: 8px; touch-action: none; cursor: ew-resize; }
.vt-handle::after { content: ""; position: absolute; top: 8px; bottom: 8px; left: 18px; width: 8px; border-radius: 4px; background: var(--primary); }
.vt-handle:hover::after, .vt-handle.is-drag::after, .vt-handle:focus-visible::after { box-shadow: 0 0 0 3px var(--overlay); }

.vt-times { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 560px) { .vt-times { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.vt-time { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; min-width: 0; }
.vt-time .field { flex: 0 1 112px; min-width: 0; }
.vt-time .input { width: 100%; font-variant-numeric: tabular-nums; }
.vt-length, .vt-before { margin: 0; font-variant-numeric: tabular-nums; }
.vt-length { font-size: 14px; color: var(--text-2); }
.vt-before { font-size: 16px; font-weight: 600; }

.vt-range summary { cursor: pointer; font-size: 14px; font-weight: 500; }

/* Audio converter: four formats fit at 360 px, and the list of files when several are chosen */
.vt-convert .segmented { display: flex; width: 100%; }
.vt-convert .segmented > [role="radio"] { padding: 0 10px; }
.vt-batch { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; }
.vt-batch li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 14px; min-width: 0; }
.vt-batch li + li { border-top: 1px solid var(--border); }
.vt-row-name { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.vt-row-meta { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.vt-row-state { flex: 1 0 100%; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.vt-row-state.is-error { color: var(--danger); }
.vt-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.vt-range-body { margin-top: 12px; }
.vt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.vt-next { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.vt-next p { margin: 0; }

/* Add audio to video (add-audio.js) */
.aa .aa-options { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.aa-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 16px; }
@media (min-width: 560px) { .aa-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.aa-slider input[type="range"] { width: 100%; accent-color: var(--primary); }
.aa-slider output { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 400; margin-inline-start: 6px; }
.aa .input { width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.aa-audio-drop { min-height: 120px; }
.aa-rights { margin: 0; }
.aa [hidden] { display: none !important; }
.vt-mute-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.vt-addaudio { padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
.vt-addaudio[hidden] { display: none; }
/* Each added audio: a card with its strip (the result's length, the audio where it plays, as a waveform; drag to slide). */
.aa-track { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.aa-track + .aa-more, .aa-more + .aa-track { margin-top: 4px; }
.aa-track[data-aa="track2"] { padding-top: 16px; border-top: 1px solid var(--border); }
.aa-track-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.aa-track-head .small { color: var(--text-2); font-weight: 400; margin-inline-start: 6px; }
.aa-more { align-self: flex-start; }
.aa-lane { position: relative; height: 48px; border: 1px solid var(--border); border-radius: 10px; background: repeating-linear-gradient(90deg, var(--bg-subtle) 0 calc(10% - 1px), var(--border) calc(10% - 1px) 10%); overflow: hidden; touch-action: pan-y; }
.aa-clip { position: absolute; top: 4px; bottom: 4px; min-width: 6px; border-radius: 7px; background: var(--primary); cursor: grab; touch-action: none; outline-offset: 2px; }
.aa-clip.is-loop { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.14) 0 6px, transparent 6px 12px); }
.aa-clip.is-drag { cursor: grabbing; box-shadow: 0 0 0 3px var(--overlay); }
.aa-clip canvas { display: block; width: 100%; height: 100%; border-radius: 7px; pointer-events: none; }
.aa-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--danger); pointer-events: none; }
.aa-lane-times { display: flex; justify-content: space-between; color: var(--text-2); margin-top: 2px; }
.aa-nudge { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.aa-nudge > .field { flex: 1 1 180px; }
.aa-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.aa-steps .btn { min-width: 52px; justify-content: center; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .aa-steps .btn { height: 44px; } .aa-lane { height: 56px; } }
.aa .segmented { display: flex; width: 100%; }
.aa .segmented > [role="radio"] { white-space: normal; height: auto; min-height: 36px; padding: 6px 12px; line-height: 1.2; text-align: center; }

/* Trim's editor (trim-editor.js): parts in order, split, undo, a crop and fades. Touch targets are 44 px on phones. */
.vt [hidden] { display: none !important; }
.vt-preview { position: relative; }
.vt-tx, .vt-frames, .vt-parts-add, .vt-part-actions, .vt-restore-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vt-icon { width: 36px; padding: 0; justify-content: center; }
.vt-tx .btn, .vt-frames .btn, .vt-parts-add .btn, .vt-part-actions .btn { height: 36px; }
.vt-play { margin-inline-start: auto; }
@media (pointer: coarse) {
  .vt-tx .btn, .vt-frames .btn, .vt-parts-add .btn, .vt-part-actions .btn, .vt-restore-actions .btn, .vt-tip .btn { height: 44px; }
  .vt-icon { width: 44px; }
}
.vt-keys { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-subtle); }
.vt-keys p { margin: 0 0 8px; }
.vt-keys dl { display: grid; gap: 6px; margin: 0; font-size: 13px; }
.vt-keys dl > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.vt-keys dt, .vt-keys dd { margin: 0; }
.vt-keys dd { color: var(--text-2); }
.vt-keys kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.vt-time .vt-frames { gap: 4px; }

/* The parts, in order: their widths follow their lengths */
.vt-parts { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.vt-parts-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.vt-parts-head .field-label { margin: 0; }
.vt-strip-wrap { position: relative; min-width: 0; }
.vt-strip { display: flex; gap: 4px; margin: 0; padding: 2px; list-style: none; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.vt-strip li { flex: 1 1 0; min-width: 44px; }
.vt-block { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; height: 52px; padding: 0 4px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--field); color: var(--text); font: inherit; font-variant-numeric: tabular-nums;
  cursor: grab; overflow: hidden; touch-action: pan-x; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: box-shadow .15s var(--ease); }
.vt-block.is-other { background: color-mix(in srgb, var(--accent-2) 24%, var(--field)); }
.vt-block[aria-current="true"] { border: 2px solid var(--primary); background: var(--surface); }
.vt-block.is-other[aria-current="true"] { background: color-mix(in srgb, var(--accent-2) 14%, var(--surface)); }
.vt-block:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.vt-block.is-drag { z-index: 2; cursor: grabbing; box-shadow: var(--shadow-lg); transition: none; }
.vt-block-n { font-size: 14px; font-weight: 600; line-height: 1; }
.vt-block-t { max-width: 100%; font-size: 12px; line-height: 1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vt-strip-head { position: absolute; top: 2px; bottom: 2px; left: 0; width: 2px; margin-left: -1px; background: var(--danger); pointer-events: none; }
.vt-strip-drop { position: absolute; top: -2px; bottom: -2px; left: 0; width: 3px; margin-left: -2px; border-radius: 2px; background: var(--primary); pointer-events: none; }
.vt-parts.is-busy .vt-strip { opacity: .6; pointer-events: none; }
.vt-part-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.vt-part-text { font-size: 14px; font-variant-numeric: tabular-nums; min-width: 0; }
.vt-tip { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; }

/* On the timeline: the other parts (a band along the top) and the sound (along the bottom) */
.vt-marks { position: absolute; left: 0; right: 0; top: 0; height: 4px; pointer-events: none; }
.vt-marks i { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--accent-1); }
.vt-track canvas.vt-wave { position: absolute; left: 0; bottom: 0; height: 18px; border-radius: 0 0 11px 11px; pointer-events: none; }

/* The crop over the preview: what's outside it is dimmed; its handle moves it */
.vt-crop { position: absolute; overflow: hidden; border-radius: 12px; pointer-events: none; }
.vt-crop-win { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); outline: 2px solid #fff; outline-offset: -2px; }
.vt-crop-grip { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .92); color: #0C0A09; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); cursor: grab; pointer-events: auto; touch-action: none; }
.vt-crop[data-axis="y"] .vt-crop-grip .icon { transform: rotate(90deg); }
.vt-crop-grip:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.vt-crop-grip .icon { width: 20px; height: 20px; }

/* Shape and fades */
.vt-look { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.vt-look .segmented { display: flex; width: 100%; }
.vt-croppos input[type="range"] { width: 100%; accent-color: var(--primary); }
.vt-fades { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.vt-restore { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-subtle); }

/* Crop video (crop-video.js): the preview turned and flipped like the result, the crop frame over it in the result's own
   axes, and its controls. Handles are 44 px to touch (bigger dots on touch screens); the outside is dimmed. */
.cv-preview { align-items: center; }
.cv-wrap { position: relative; max-width: 100%; margin-inline: auto; }
.cv-stage { position: absolute; left: 50%; top: 50%; overflow: hidden; border-radius: 12px; background: #000; transform-origin: 50% 50%; cursor: pointer; }
.cv-preview .cv-stage video { display: block; width: 100%; height: 100%; max-height: none; border-radius: 0; object-fit: fill; }
.cv-overlay { position: absolute; inset: 0; pointer-events: none; }
.cv-clip { position: absolute; inset: 0; overflow: hidden; border-radius: 12px; }
.cv-shade { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); }
.cv-win { position: absolute; outline: 2px solid #fff; outline-offset: -1px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); cursor: move; pointer-events: auto; touch-action: none; }
.cv-win:focus-visible { outline: 3px solid var(--accent-2); }
.cv-grid { position: absolute; inset: 0; opacity: 0; transition: opacity .15s var(--ease); pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.333% - .5px), rgba(255, 255, 255, .6) calc(33.333% - .5px), rgba(255, 255, 255, .6) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.667% - .5px), rgba(255, 255, 255, .6) calc(66.667% - .5px), rgba(255, 255, 255, .6) calc(66.667% + .5px), transparent calc(66.667% + .5px)),
    linear-gradient(to bottom, transparent calc(33.333% - .5px), rgba(255, 255, 255, .6) calc(33.333% - .5px), rgba(255, 255, 255, .6) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.667% - .5px), rgba(255, 255, 255, .6) calc(66.667% - .5px), rgba(255, 255, 255, .6) calc(66.667% + .5px), transparent calc(66.667% + .5px)); }
.cv-overlay.is-drag .cv-grid, .cv-win:focus-visible .cv-grid { opacity: 1; }
.cv-h { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; pointer-events: auto; touch-action: none; }
.cv-h::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45), 0 0 0 1px rgba(0, 0, 0, .18); }
.cv-h-nw { left: 0; top: 0; cursor: nwse-resize; } .cv-h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.cv-h-ne { left: 100%; top: 0; cursor: nesw-resize; } .cv-h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.cv-h-n { left: 50%; top: 0; cursor: ns-resize; } .cv-h-s { left: 50%; top: 100%; cursor: ns-resize; }
.cv-h-w { left: 0; top: 50%; cursor: ew-resize; } .cv-h-e { left: 100%; top: 50%; cursor: ew-resize; }
.cv-h-n::after, .cv-h-s::after { width: 24px; height: 8px; margin: -4px 0 0 -12px; border-radius: 4px; }
.cv-h-w::after, .cv-h-e::after { width: 8px; height: 24px; margin: -12px 0 0 -4px; border-radius: 4px; }
.cv-overlay.is-small .cv-h-n, .cv-overlay.is-small .cv-h-s, .cv-overlay.is-small .cv-h-w, .cv-overlay.is-small .cv-h-e { display: none; }
.cv-overlay.is-busy .cv-win, .cv-overlay.is-busy .cv-h { pointer-events: none; }
.cv-overlay.is-busy { opacity: .6; }
@media (pointer: coarse) {
  .cv-h::after { width: 22px; height: 22px; margin: -11px 0 0 -11px; }
  .cv-h-n::after, .cv-h-s::after { width: 30px; height: 10px; margin: -5px 0 0 -15px; }
  .cv-h-w::after, .cv-h-e::after { width: 10px; height: 30px; margin: -15px 0 0 -5px; }
}
.cv-play-row { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; }
.cv-play-row input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: var(--primary); }
.cv-play { flex: none; min-width: 92px; }
.cv-clock { flex: none; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cv-box { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cv-box > .field { gap: 8px; }
.cv-box .vt-hint { margin: -6px 0 0; }
.cv-turns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .cv-turns { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cv-turns .btn { height: auto; min-height: 36px; padding: 6px 8px; white-space: normal; line-height: 1.2; text-align: center; }
.cv-turns .btn[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cv-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .cv-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cv-fields .field { min-width: 0; }
.cv-fields .input { width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.cv-out { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.cv-size { margin: 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) {
  .cv-turns .btn, .cv-play-row .btn, .cv-out .btn { min-height: 44px; }
  .cv-box .chip { height: 40px; padding: 0 12px; }
  .cv-box .chips { gap: 6px; }
}
