/* ═══════════════════════════════════════════════════════
   🎬 Нарезки Завод — Стили приложения
   ═══════════════════════════════════════════════════════ */

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-card: #22222e;
    --bg-hover: #2a2a38;
    --accent: #7c5cfc;
    --accent-hover: #9b7ffd;
    --accent-glow: rgba(124, 92, 252, 0.3);
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --text: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #5a5a70;
    --border: #2e2e3e;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Скроллбар ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ─── Шапка ─── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.header-logo span {
    font-size: 28px;
}

.header-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--radius);
}

.nav-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.nav-btn.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* ─── Контейнер ─── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* ─── Страницы ─── */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Скачивание ─── */
.download-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.download-main-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.url-input-group {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.url-input-group input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.url-input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.url-input-group input::placeholder {
    color: var(--text-muted);
}

.quality-select {
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

.dl-layout .format-btns {
    margin-top: 0;
}

.clip-panel {
    padding: 18px 20px 20px;
    background: linear-gradient(180deg, rgba(124, 92, 252, 0.08), transparent);
    border-top: 2px solid rgba(124, 92, 252, 0.35);
}

.clip-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.clip-panel-title {
    font-size: 16px;
    font-weight: 700;
}

.clip-mode-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.clip-mode-badge.clip-active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.clip-panel-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.clip-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.clip-field input {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    outline: none;
}

.clip-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.clip-range-wrap {
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.clip-range-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

#clip-range-duration {
    font-weight: 700;
    color: var(--accent);
}

.clip-range-track {
    position: relative;
    height: 36px;
}

.clip-range-fill {
    position: absolute;
    top: 14px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent2, #a78bfa));
    pointer-events: none;
}

.clip-range-track input[type="range"] {
    position: absolute;
    left: 0;
    right: 0;
    top: 8px;
    width: 100%;
    margin: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.clip-range-track input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
}

.clip-range-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -5px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    pointer-events: auto;
    cursor: pointer;
}

.clip-layout-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.clip-layout-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.clip-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}

.quality-select:focus {
    border-color: var(--accent);
}

/* ─── Кнопки ─── */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--success);
    color: #000;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

/* ─── Инфо видео ─── */
.video-info-card {
    display: none;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    gap: 20px;
}

.video-info-card.visible {
    display: flex;
}

.video-info-card .thumb {
    width: 240px;
    height: 135px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-primary);
}

.video-info-card .info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.video-info-card .info h3 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.video-info-card .info .meta {
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    gap: 16px;
}

.video-info-card .info .desc {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    max-height: 40px;
}

/* ─── Прогресс ─── */
.progress-bar-container {
    display: none;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}

.progress-bar-container.visible {
    display: block;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-fill.done {
    background: linear-gradient(90deg, var(--success), #22c55e);
}

.progress-fill.error {
    background: var(--danger);
}

/* ─── Список видео (история) ─── */
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.video-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.video-card .card-thumb {
    width: 100%;
    height: 170px;
    object-fit: cover;
    background: var(--bg-primary);
    display: block;
}

.video-card .card-body {
    padding: 14px;
}

.video-card .card-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-card .card-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 12px;
}

.video-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ─── Пустое состояние ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
}

/* ─── РЕДАКТОР ─── */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    min-height: calc(100vh - 140px);
}

.editor-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Превью видео */
.preview-container {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    aspect-ratio: 16/9;
}

.preview-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: auto;
}

/* Области кропа на видео */
.crop-overlay {
    position: absolute;
    border: 2px dashed var(--accent);
    background: rgba(124, 92, 252, 0.1);
    border-radius: 4px;
    pointer-events: auto;
    cursor: move;
    transition: border-color 0.2s;
}

.crop-overlay.webcam {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.1);
}

.crop-overlay.content {
    border-color: #22d3ee;
    background: rgba(34, 211, 238, 0.1);
}

.crop-overlay.text {
    border-color: #facc15;
    background: rgba(250, 204, 21, 0.12);
}

.crop-overlay.extra {
    border-color: #34d399;
    background: rgba(52, 211, 153, 0.12);
}

.crop-overlay .label {
    position: absolute;
    top: -22px;
    left: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    color: white;
}

.crop-overlay.webcam .label {
    background: #f97316;
}

.crop-overlay.content .label {
    background: #22d3ee;
    color: #000;
}

.crop-overlay.text .label {
    background: #facc15;
    color: #000;
}

.crop-overlay.extra .label {
    background: #34d399;
    color: #062b21;
}

/* Ручки изменения размера кропа */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid rgba(0,0,0,0.4);
    border-radius: 2px;
    pointer-events: auto;
    z-index: 2;
}
.crop-overlay.webcam .resize-handle {
    border-color: #f97316;
}
.crop-overlay.content .resize-handle {
    border-color: #22d3ee;
}
.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

/* Предпросмотр результата (canvas) */
.result-preview-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-height: 80px;
}
#result-canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Контроли видео */
.video-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.video-controls .play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.video-controls .play-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.time-display {
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 110px;
    flex-shrink: 0;
}

/* ─── Таймлайн ─── */
.timeline-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.timeline-header h4 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-actions {
    display: flex;
    gap: 6px;
}

.timeline-track {
    position: relative;
    height: 60px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

/* Визуализация волны звука */
.timeline-waveform {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 4px;
}

.timeline-waveform .bar {
    flex: 1;
    background: var(--text-muted);
    border-radius: 1px;
    min-height: 4px;
    opacity: 0.4;
}

/* Выделение (trim) */
.timeline-selection {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(124, 92, 252, 0.2);
    border-left: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
}

.timeline-selection .handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 12px;
    cursor: col-resize;
    z-index: 2;
}

.timeline-selection .handle-left {
    left: -8px;
}

.timeline-selection .handle-right {
    right: -8px;
}

.timeline-selection .handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
}

/* Позиция воспроизведения */
.timeline-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: white;
    z-index: 3;
    pointer-events: none;
}

.timeline-playhead::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

/* Время обрезки */
.trim-times {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.trim-input {
    display: flex;
    align-items: center;
    gap: 6px;
}

.trim-input label {
    color: var(--text-muted);
    font-size: 12px;
}

.trim-input input {
    width: 80px;
    padding: 4px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    outline: none;
}

.trim-input input:focus {
    border-color: var(--accent);
}

/* ─── Сайдбар редактора ─── */
.sidebar-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
}

.sidebar-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Пресеты */
.presets-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preset-btn {
    padding: 12px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-size: 13px;
}

.preset-btn:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.preset-btn.active {
    border-color: var(--accent);
    background: rgba(124, 92, 252, 0.1);
}

.preset-btn .preset-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
}

.preset-btn .preset-name {
    font-weight: 500;
    font-size: 12px;
}

/* Кроп настройки */
.crop-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.crop-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.crop-input-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crop-input-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.crop-input-group .value {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
}

/* Формат вывода */
.format-btns {
    display: flex;
    gap: 8px;
}

.format-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    transition: var(--transition);
}

.format-btn:hover {
    border-color: var(--text-muted);
}

.format-btn.active {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(124, 92, 252, 0.1);
}

.format-btn .ratio {
    font-size: 18px;
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

/* Пресеты уникализатора */
.uq-presets-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.uq-preset-btn {
    padding: 10px 8px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.uq-preset-btn:hover {
    border-color: var(--text-muted);
}

.uq-preset-btn.active {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(124, 92, 252, 0.1);
}

.uq-preset-btn .uq-preset-icon {
    font-size: 20px;
    line-height: 1;
}

.uq-preset-btn .uq-preset-name {
    font-weight: 600;
}

/* Опции */
.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.option-row label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 42px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    transition: var(--transition);
    border-radius: 12px;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    transition: var(--transition);
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background: white;
}

/* Кнопка экспорта */
.export-section {
    margin-top: auto;
}

.export-btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--radius);
}

/* ─── Уведомления (Toast) ─── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Модальное окно ─── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ─── Спиннер загрузки ─── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Адаптивность ─── */
@media (max-width: 1100px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
    .editor-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .editor-sidebar .sidebar-section {
        flex: 1;
        min-width: 280px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
        flex-direction: column;
        gap: 8px;
    }
    .header-logo {
        font-size: 17px;
    }
    .header-logo span {
        font-size: 22px;
    }
    .header-nav {
        width: 100%;
        justify-content: center;
    }
    .nav-btn {
        padding: 6px 12px;
        font-size: 13px;
        gap: 4px;
    }
    .container {
        padding: 12px 10px;
    }
    .url-input-group {
        flex-direction: column;
        padding: 12px;
        gap: 8px;
    }
    .url-input-group input {
        padding: 12px 14px;
        font-size: 14px;
    }
    .clip-panel-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
    .quality-select {
        min-width: unset;
    }
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    .video-grid {
        grid-template-columns: 1fr;
    }
    .video-info-card {
        flex-direction: column;
    }
    .video-info-card .thumb {
        width: 100%;
        height: 180px;
    }
    /* Редактор на мобильном */
    .editor-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .editor-sidebar {
        flex-direction: column;
    }
    .editor-sidebar .sidebar-section {
        min-width: unset;
    }
    .preview-container {
        aspect-ratio: 16/9;
    }
    .video-controls {
        gap: 6px;
        padding: 8px 10px;
        flex-wrap: wrap;
    }
    .video-controls .play-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .time-display {
        font-size: 12px;
        min-width: 90px;
    }
    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }
    .timeline-track {
        height: 50px;
    }
    .trim-times {
        flex-direction: column;
        gap: 6px;
    }
    .presets-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .crop-inputs {
        grid-template-columns: 1fr;
    }
    .format-btns {
        gap: 6px;
    }
    .format-btn {
        padding: 8px;
        font-size: 11px;
    }
    .format-btn .ratio {
        font-size: 15px;
    }
    .export-btn {
        padding: 14px;
        font-size: 15px;
    }
    .result-preview-wrapper {
        min-height: 60px;
    }
    /* Увеличиваем ручки для тач */
    .resize-handle {
        width: 16px;
        height: 16px;
    }
    .resize-handle.nw { top: -8px; left: -8px; }
    .resize-handle.ne { top: -8px; right: -8px; }
    .resize-handle.sw { bottom: -8px; left: -8px; }
    .resize-handle.se { bottom: -8px; right: -8px; }
    .crop-overlay .label {
        font-size: 10px;
        top: -20px;
    }
    .timeline-selection .handle {
        width: 20px;
    }
    .timeline-selection .handle-left { left: -12px; }
    .timeline-selection .handle-right { right: -12px; }
    /* Toast */
    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 12px;
    }
    .toast {
        max-width: 100%;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header-logo { font-size: 15px; }
    .nav-btn { padding: 5px 8px; font-size: 12px; }
    .container { padding: 8px 6px; }
    .presets-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════
   🎭 Уникализатор роликов
   ═══════════════════════════════════════════════════════ */

.unique-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

.unique-main {
    min-width: 0;
}

.unique-header {
    padding-bottom: 4px;
}

/* Сайдбар — липкий, с прокруткой при переполнении */
.unique-sidebar {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Превью выбранного файла */
.unique-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
}

.unique-file-preview img {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.unique-file-meta {
    min-width: 0;
}

.unique-file-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
    line-height: 1.4;
}

.unique-file-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Сетка пресетов */
.unique-presets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.unique-preset-btn {
    padding: 10px 4px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.unique-preset-btn:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.unique-preset-btn.active {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(124, 92, 252, 0.12);
}

.unique-preset-icon {
    font-size: 20px;
    line-height: 1;
}

/* Список активных техник */
.unique-techniques-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.technique-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(124, 92, 252, 0.12);
    border: 1px solid rgba(124, 92, 252, 0.3);
    color: #a78bfa;
}

.technique-tag.off {
    background: var(--bg-primary);
    border-color: var(--border);
    color: var(--text-muted);
    opacity: 0.5;
}

/* Строки параметров */
.param-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}

.param-row label {
    font-size: 12px;
    color: var(--text-secondary);
    width: 82px;
    flex-shrink: 0;
    line-height: 1.3;
}

.param-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    cursor: pointer;
}

.param-val {
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
    width: 44px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Кнопка уникализации */
.uq-run-btn {
    width: 100%;
    padding: 15px;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius);
    letter-spacing: 0.3px;
}

.uq-advanced {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 14px 14px;
    background: var(--bg-card);
}

.uq-advanced > summary {
    cursor: pointer;
    padding: 12px 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    list-style: none;
}

.uq-advanced > summary::-webkit-details-marker {
    display: none;
}

.uq-advanced > summary::before {
    content: "▸ ";
    color: var(--accent);
}

.uq-advanced[open] > summary::before {
    content: "▾ ";
}

.uq-fx-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.uq-fx {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    gap: 8px 10px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.uq-fx:last-child { border-bottom: none; }
.uq-fx input { margin-top: 2px; }
.uq-fx .uq-fx-label { font-weight: 600; }
.uq-fx .uq-fx-hint { grid-column: 2 / -1; font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.uq-fx .uq-fx-spoil { font-size: 11px; color: var(--text-muted); }

.video-card .card-actions .btn {
    width: 100%;
}

/* Подсветка выбранной карточки видео */
.video-card.uq-selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 4px 20px rgba(124, 92, 252, 0.25);
}

@media (max-width: 1100px) {
    .unique-layout {
        grid-template-columns: 1fr;
    }
    .unique-sidebar {
        position: static;
        max-height: none;
    }
    .unique-presets-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .unique-layout {
        gap: 12px;
    }
    .unique-presets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .param-row label {
        width: 68px;
        font-size: 11px;
    }
    .param-val {
        width: 38px;
        font-size: 11px;
    }
}

/* ═══════════════════════════════════════════════════════
   ✨ Новые улучшения: filmstrip, drag-drop, shortcuts
   ═══════════════════════════════════════════════════════ */

/* ─── Filmstrip (превью кадров на таймлайне) ─── */
.timeline-filmstrip {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    display: flex;
    overflow: hidden;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    z-index: 0;
    pointer-events: none;
}

.timeline-filmstrip.loading {
    background: var(--bg-hover);
    animation: filmstripPulse 1.5s ease-in-out infinite;
}

.filmstrip-frame {
    height: 44px;
    flex: 1;
    min-width: 0;
    object-fit: cover;
    display: block;
}

@keyframes filmstripPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Смещаем waveform ниже filmstrip */
.timeline-track .timeline-waveform {
    top: 44px;
    bottom: 0;
    height: auto;
}

/* ─── Состояния полос waveform ─── */
.timeline-waveform .bar.placeholder {
    opacity: 0.2;
    background: var(--text-muted);
}

.timeline-waveform .bar.no-audio {
    background: var(--text-muted) !important;
    opacity: 0.25;
    height: 6px !important;
}

.timeline-waveform.loading .bar {
    animation: waveformPulse 1.2s ease-in-out infinite;
}

@keyframes waveformPulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

/* ─── Drop zone overlay (drag-and-drop) ─── */
.drop-zone-overlay {
    position: fixed;
    inset: 0;
    background: rgba(124, 92, 252, 0.12);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    border: 3px dashed var(--accent);
    pointer-events: none;
}

.drop-zone-overlay.active {
    display: flex;
    animation: dropZoneFadeIn 0.15s ease;
}

@keyframes dropZoneFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.drop-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 60px;
    background: rgba(18, 18, 30, 0.85);
    border-radius: var(--radius);
    border: 2px solid var(--accent);
    box-shadow: 0 8px 40px rgba(124, 92, 252, 0.4);
}

.drop-zone-icon {
    font-size: 52px;
    line-height: 1;
}

.drop-zone-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.drop-zone-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* ─── Панель горячих клавиш ─── */
.shortcuts-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.shortcuts-panel.visible {
    display: flex;
    animation: shortcutsFadeIn 0.2s ease;
}

@keyframes shortcutsFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.shortcuts-panel-inner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    min-width: 380px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.shortcuts-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shortcuts-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

.shortcuts-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.shortcut-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin: 12px 0 6px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.shortcut-item:hover {
    background: var(--bg-hover);
}

.shortcut-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.shortcut-keys {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

kbd {
    display: inline-block;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 2px 7px;
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    white-space: nowrap;
}

.shortcut-sep {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── Ghost кнопка ─── */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--text-muted);
}

/* Увеличиваем высоту track под filmstrip */
.timeline-track {
    height: 80px !important;
}
