:root {
    /* Modern Dark Palette */
    --bg-gradient-start: #0f2027;
    --bg-gradient-mid: #203a43;
    --bg-gradient-end: #2c5364;
    
    /* Glassmorphism (оставляем только для подложек карточек) */
    --glass-bg: rgba(30, 30, 35, 0.85); /* Более непрозрачный для читаемости */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --blur: 12px;

    --text-color: #ffffff;
    --text-secondary: #a1a1aa;
    
    --border-radius: 16px;
    --btn-radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
    background-attachment: fixed;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    min-height: 100vh; /* Минимальная высота, а не фиксированная */
    display: flex;
    flex-direction: column;
    /* Убрали overflow: hidden, чтобы вернуть скролл */
}

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    padding-bottom: 10px;
}

.queue-status-pill {
    margin-left: auto;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1;
    user-select: none;
    white-space: nowrap;
}

.queue-status-pill[data-busy="true"] {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.25);
    background: rgba(251, 191, 36, 0.06);
}

.queue-status-pill[data-busy="false"] {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.25);
    background: rgba(52, 211, 153, 0.06);
}

/* Workspace Grid */
.workspace {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); /* Чуть шире колонки */
    gap: 24px;
    align-items: start; /* Не растягиваем по высоте насильно */
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
}

.card-header h3 {
    margin: 0;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.video-wrapper {
    width: 100%;
    /* Убрали жесткий aspect-ratio, пусть видео само задает высоту, но ограничиваем */
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px; /* Чтобы было видно placeholder */
}

video {
    width: 100%;
    height: auto;
    max-height: 70vh; /* Ограничение высоты плеера */
    display: block;
}

/* Placeholder для пустых видео */
.placeholder {
    position: absolute;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.03);
    z-index: 1;
}
/* Когда видео загружено, скрываем placeholder. JS будет переключать видимость видео */
video:not([src]) + .placeholder {
    display: flex;
}
video[src] + .placeholder {
    display: none;
}
/* Скрываем видео если нет src */
video:not([src]) {
    display: none; 
}

.card-actions,
.timeline-controls {
    margin-top: 10px;
}

/* Buttons - Darker Solid Colors */
button {
    border: none;
    padding: 12px 20px;
    border-radius: var(--btn-radius);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    color: white; /* Текст всегда белый */
}

button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
    opacity: 0.9;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    filter: grayscale(0.5);
}

/* Более темные, глубокие цвета */
.btn-primary, .btn-accent { 
    background: #0056b3; /* Deep Blue */
    /* Градиент для объема, но темный */
    background: linear-gradient(180deg, #0060df 0%, #004db3 100%);
}

.btn-secondary { 
    background: #3a3a3c; 
    color: #e5e5e7; 
    box-shadow: none;
}
.btn-secondary:hover {
    background: #48484a;
}

.btn-danger { 
    background: #b3261e; /* Deep Red */
    background: linear-gradient(180deg, #d72b22 0%, #b31d15 100%);
}

.btn-success { 
    background: #1e7b31; /* Deep Green */
    background: linear-gradient(180deg, #28a745 0%, #1e7e34 100%);
}

.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 12px; }

/* Timeline & Controls */
.timeline-controls {
    background: rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.markers-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.marker-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.marker-inline .time-input {
    width: 70px;
    min-width: 60px;
    max-width: 80px;
}

.time-display {
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    padding: 0 8px;
    flex-shrink: 0;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.action-buttons button {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
}

/* Адаптивность для узких экранов */
@media (max-width: 700px) {
    .controls-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .markers-compact {
        width: 100%;
        justify-content: center;
    }
    
    .action-buttons {
        width: 100%;
        justify-content: stretch;
    }
    
    .action-buttons button {
        flex: 1;
    }
}

/* Inputs for Time */
.time-input {
    width: 100%;
    max-width: 120px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #60a5fa;
    font-family: monospace;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 8px;
    text-align: center;
    outline: none;
    transition: all 0.2s;
}

.time-input:focus {
    border-color: #0060df;
    background: rgba(0, 0, 0, 0.5);
}
.time-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Loading Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: #0060df;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin-bottom: 24px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-card {
    background: #1c1c1e;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center everything horizontally */
}

.modal-card h3 { margin-top: 0; margin-bottom: 10px; }
.modal-card p { color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: stretch;
    width: 100%;
}
.modal-actions button { flex: 1; }

.success-icon, .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Save Row с переключателем формата */
.save-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.format-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 3px;
    flex-shrink: 0;
}

.format-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: none;
}

.format-btn:hover {
    color: white;
    transform: none;
    box-shadow: none;
}

.format-btn.active {
    background: #0060df;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.save-row .btn-success {
    flex: 1;
}

/* Адаптивность save-row */
@media (max-width: 700px) {
    .save-row {
        flex-direction: column;
    }
    
    .format-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .save-row .btn-success {
        width: 100%;
    }
}

.hidden { display: none !important; }