/* ========================================
   Browser Video Editor — Cinema Red Theme
   ======================================== */
:root {
    --primary: #DC2626;
    --primary-hover: #B91C1C;
    --primary-glow: rgba(220, 38, 38, 0.25);
    --secondary: #EF4444;
    --accent: #FCA5A5;
    --bg: #0A0A0A;
    --bg-card: rgba(18, 18, 18, 0.85);
    --bg-hover: #1A1A1A;
    --bg-input: rgba(10, 10, 10, 0.7);
    --border: rgba(220, 38, 38, 0.12);
    --border-hover: rgba(220, 38, 38, 0.3);
    --text: #F5F5F5;
    --text-secondary: #A3A3A3;
    --text-muted: #737373;
    --radius: 8px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    --font: 'Inter', -apple-system, sans-serif;
    --transition: 0.2s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background-image: radial-gradient(ellipse at 50% 0%, rgba(220, 38, 38, 0.04) 0%, transparent 60%);
}

.app {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.logo-icon {
    font-size: 1.6rem;
}

.logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    transition: all var(--transition);
    position: relative;
}

.upload-zone:hover,
.upload-zone:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
}

.upload-zone.drag-over {
    border-color: var(--secondary);
    background: rgba(220, 38, 38, 0.05);
    transform: scale(1.005);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.upload-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.browse-link {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Warning Banner */
.warning-banner {
    padding: 0.65rem 1rem;
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

.warning-banner a {
    color: var(--primary);
}

/* Editor */
.editor {
    margin-top: 1rem;
}

/* Video Preview */
.preview-section {
    margin-bottom: 1rem;
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 16/9;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.ctrl-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.ctrl-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.ctrl-btn.small {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
}

.time-display {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.spacer {
    flex: 1;
}

.meta-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid var(--border);
    padding: 0.15rem 0.45rem;
    border-radius: 100px;
}

/* Timeline */
.timeline-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.timeline-header h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.trim-values {
    display: flex;
    gap: 0.75rem;
}

.trim-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.trim-label strong {
    color: var(--primary);
    font-weight: 600;
}

.timeline-track {
    position: relative;
    height: 60px;
    background: #1A1A1A;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.thumbnail-strip {
    display: flex;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.thumbnail-strip canvas {
    height: 100%;
    flex-shrink: 0;
}

.trim-region {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    border: 2px solid var(--primary);
    border-radius: 3px;
    background: rgba(220, 38, 38, 0.08);
    pointer-events: none;
}

.trim-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 12px;
    background: var(--primary);
    cursor: ew-resize;
    pointer-events: all;
    z-index: 5;
    transition: background var(--transition);
}

.trim-handle:hover,
.trim-handle:focus {
    background: var(--secondary);
}

.trim-handle.left {
    left: -2px;
    border-radius: 4px 0 0 4px;
}

.trim-handle.right {
    right: -2px;
    border-radius: 0 4px 4px 0;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: white;
    z-index: 6;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    left: 0;
}

/* Export */
.export-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.export-section h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}

.export-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.option-group label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.option-group select,
.option-group input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    outline: none;
}

.option-group select:focus {
    border-color: var(--primary);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider-row input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

.slider-row span {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
    min-width: 56px;
}

input[type="checkbox"] {
    accent-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 0.65rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.progress-bar {
    position: relative;
    height: 32px;
    background: #1A1A1A;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 0.55rem 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    .app {
        padding: 1rem 0.85rem 2.5rem;
    }

    .export-grid {
        grid-template-columns: 1fr;
    }

    .timeline-track {
        height: 48px;
    }

    .trim-values {
        display: none;
    }
}