/* Caption editor layers above the page: menus, the colour picker, the caption frame and toolbar, dialogs. */
.ed-pop-wrap { position: relative; display: inline-flex; }
.ed-menu {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 170px;
    display: grid; gap: 2px; padding: 6px; background: #242424;
    border: 1px solid var(--ed-line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.ed-menu[hidden], .ed-menu > [hidden] { display: none; }
.ed-menu-right { left: auto; right: 0; }
.ed-menu-up { top: auto; bottom: calc(100% + 6px); left: auto; right: 0; }
.ed-menu > a, .ed-menu > button {
    display: flex; align-items: center; gap: 8px; min-height: var(--ed-hit); padding: 0 10px;
    border: 0; border-radius: 6px; background: none; color: var(--ed-ink); text-align: start; text-decoration: none; white-space: nowrap;
}
.ed-menu > a:hover, .ed-menu > button:not(:disabled):hover { background: var(--ed-field); }
.ed-menu [aria-checked=true]::after { content: "✓"; margin-left: auto; color: var(--ed-dim); }
.ed-menu .ed-ic { width: 16px; height: 16px; color: var(--ed-dim); }
.ed-menu-title { padding: 4px 8px 6px; color: var(--ed-faint); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.ed-case-glyph { min-width: 28px; color: var(--ed-dim); font-weight: 700; }
#ed-export-menu .ed-ic { width: 13px; height: 13px; margin-left: auto; color: var(--ed-upgrade); fill: var(--ed-upgrade); }
.ed-keys { min-width: 250px; font-size: 13px; }
.ed-keys strong { padding: 2px 6px 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ed-faint); }
.ed-keys > span { display: flex; justify-content: space-between; gap: 12px; padding: 5px 6px; color: var(--ed-dim); }
.ed-keys kbd { order: 2; font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--ed-ink); }
.ed-keys small { padding: 6px; color: var(--ed-faint); }

/* Colour picker */
.ed-picker {
    position: fixed; z-index: 60; display: grid; gap: 10px; width: 236px; padding: 10px;
    background: #242424; border: 1px solid var(--ed-line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.ed-picker[hidden], .ed-picker [hidden] { display: none !important; }
.ed-picker-sv {
    position: relative; height: 150px; border-radius: 8px; cursor: crosshair; touch-action: none;
    background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}
.ed-picker-dot {
    position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid #fff; border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); pointer-events: none;
}
.ed-picker-hue {
    width: 100%; height: 14px; margin: 0; border-radius: 7px; -webkit-appearance: none; appearance: none; cursor: pointer;
    background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.ed-picker-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; background: transparent; }
.ed-picker-hue::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: transparent; }
.ed-picker-row { display: flex; align-items: center; gap: 6px; }
.ed-picker-chip { width: 30px; height: 30px; flex: none; border: 1px solid rgba(255, 255, 255, .22); border-radius: 6px; }
.ed-picker .ed-hex { flex: 1; width: 0; font: 12.5px ui-monospace, Menlo, Consolas, monospace; }

/* Caption frame and toolbar on the preview */
.ed-select { position: absolute; z-index: 3; border: 2px solid #8b5cf6; border-radius: 4px; pointer-events: none; }
.ed-select[hidden], .ed-toolbar[hidden] { display: none; }
.ed-select i { position: absolute; width: 8px; height: 8px; border: 2px solid #8b5cf6; background: #fff; }
.ed-select i:nth-child(1) { top: -5px; left: -5px; }
.ed-select i:nth-child(2) { top: -5px; right: -5px; }
.ed-select i:nth-child(3) { bottom: -5px; left: -5px; }
.ed-select i:nth-child(4) { bottom: -5px; right: -5px; }
/* The toolbar wraps onto a second row on a narrow screen, so nothing hides and its menu is never clipped. */
.ed-toolbar {
    position: absolute; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px;
    max-width: min(calc(100% - 8px), 600px); background: #1f1f1f; border: 1px solid #333; border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
.ed-tb-btn {
    display: inline-grid; place-items: center; min-width: var(--ed-hit); height: var(--ed-hit); padding: 0 6px;
    border: 0; border-radius: 6px; background: none; color: var(--ed-ink); flex: none;
}
.ed-tb-btn:hover, .ed-tb-btn[aria-pressed=true] { background: #333; }
.ed-tb-btn[aria-pressed=true] { color: var(--ed-head); }
.ed-tb-text { padding: 0 10px; font-size: 13px; }
.ed-tb-size { width: 46px; height: var(--ed-hit); padding: 0 4px; border: 1px solid var(--ed-line); border-radius: 6px; background: var(--ed-field); text-align: center; }
.ed-tb-font { max-width: 130px; height: var(--ed-hit); padding: 0 6px; border: 1px solid var(--ed-line); border-radius: 6px; background: var(--ed-field); }

/* New video: a drop zone, as in AutoSubtitles. */
.ed-dialog.ed-new-dialog { width: min(448px, calc(100vw - 32px)); max-width: none; border-radius: 16px; background: #171717; }
.ed-dialog-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -4px 16px 0; padding-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.ed-dialog-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.ed-new-dialog .ed-label { color: #a3a3a3; font-size: 14px; font-weight: 500; }
.ed-new-dialog select.ed-input { min-height: max(42px, var(--ed-hit)); border-color: rgba(255, 255, 255, .08); border-radius: 12px; }
.ed-dropzone {
    display: grid; justify-items: center; gap: 8px; width: 100%; min-height: 180px; padding: 32px 16px; align-content: center; cursor: pointer;
    border: 2px dashed rgba(255, 255, 255, .08); border-radius: 12px; background: rgba(255, 255, 255, .04); color: var(--ed-dim); text-align: center;
}
.ed-dropzone:hover, .ed-dropzone.is-over { border-color: var(--ed-accent); background: rgba(255, 255, 255, .15); color: var(--ed-ink); }
.ed-dropzone .ed-ic { box-sizing: content-box; width: 20px; height: 20px; padding: 12px; border-radius: 50%; background: rgba(255, 255, 255, .06); color: var(--ed-dim); }
.ed-dropzone.is-over .ed-ic { background: rgba(96, 93, 255, .25); color: var(--ed-ink); }
.ed-dropzone strong { color: var(--ed-ink); font-size: 15px; }
.ed-dropzone small { color: var(--ed-faint); }
.ed-new-language { margin-bottom: 12px; }
.ed-new-note { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 0; color: var(--ed-dim); font-size: 13px; }
.ed-new-note .ed-ic { width: 16px; height: 16px; margin-top: 1px; color: #4ade80; }
/* A touch screen has nothing to drop a file from. */
@media (pointer: coarse) { .ed-drop-hint { display: none; } }
/* Or a link: our server fetches the video and the tab opens it like a file. */
.ed-link-form { display: grid; gap: 6px; margin-top: 16px; }
.ed-link-row { display: flex; gap: 8px; }
.ed-link-row .ed-input { flex: 1 1 auto; }
.ed-link-row .ed-primary { flex: none; }
.ed-dialog .ed-link-note { margin: 2px 0 0; font-size: 13px; }
.ed-link-note a { display: inline-flex; align-items: center; min-height: var(--ed-hit); color: var(--ed-accent); font-weight: 600; touch-action: manipulation; }
.ed-link-form progress { width: 100%; height: 6px; }
/* Both progress bars: a thin dark track with a rounded fill, as in AutoSubtitles. */
.ed-link-form progress, .ed-export-bar { appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .06); }
.ed-link-form progress::-webkit-progress-bar, .ed-export-bar::-webkit-progress-bar { background: rgba(255, 255, 255, .06); }
.ed-link-form progress::-webkit-progress-value, .ed-export-bar::-webkit-progress-value { border-radius: 999px; background: var(--ed-accent); }
.ed-link-form progress::-moz-progress-bar, .ed-export-bar::-moz-progress-bar { border-radius: 999px; background: var(--ed-accent); }
.ed-part-range { width: 100%; min-height: var(--ed-hit); accent-color: var(--ed-accent); }
.ed-part-upsell a { display: inline-flex; align-items: center; min-height: var(--ed-hit); color: var(--ed-ink); font-weight: 600; touch-action: manipulation; }

/* Dialog */
.ed-dialog { max-width: min(420px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--ed-line); border-radius: 14px; background: #1f1f1f; color: var(--ed-ink); }
.ed-dialog::backdrop { background: rgba(0, 0, 0, .4); backdrop-filter: blur(4px); }
.ed-dialog h2 { margin: 0 0 6px; font-size: 17px; }
.ed-dialog p { margin: 0 0 18px; color: var(--ed-dim); }
.ed-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (pointer: coarse) {
    .ed-tb-size, .ed-tb-font, .ed-picker .ed-hex { font-size: 16px; }
    .ed-picker { width: min(280px, calc(100vw - 16px)); }
    .ed-picker-hue { height: 44px; border-radius: 12px; }
}
