:root {
    --bg-color: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-hover: rgba(255, 255, 255, 0.08);
    --accent-red: #e82127;
    --text-main: #ffffff;
    --text-dim: #888888;
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    overflow-x: hidden;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

header {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(20px);
    background: rgba(10, 10, 10, 0.8);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--accent-red);
    text-shadow: 0 0 15px rgba(232, 33, 39, 0.3);
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px rgba(232, 33, 39, 0.2);
    }

    to {
        text-shadow: 0 0 25px rgba(232, 33, 39, 0.6);
    }
}

.controls-global {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-grow: 1;
    max-width: 800px;
    margin-left: 40px;
}

.btn-primary {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: #ff2b33;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #444;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    color: white;
    border-color: white;
}

.timeline-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="range"] {
    flex-grow: 1;
    accent-color: var(--accent-red);
    cursor: pointer;
}

#time-display {
    font-size: 14px;
    min-width: 80px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.video-grid {
    flex-grow: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Connected rows */
    overflow-y: auto;
}

.row {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.video-placeholder {
    background: var(--card-bg);
    border: 1px dashed var(--glass-border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16/9;
}

.video-placeholder.has-video {
    border-style: solid;
    border-color: transparent;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.video-placeholder video {
    width: 100%;
    height: 100%;
    object-fit: fill;
    /* Take full size of container */
    display: none;
}

.video-placeholder.has-video video {
    display: block;
}

/* Custom Range Styling */
input[type="range"] {
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent-red);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-red);
}

.placeholder-content {
    text-align: center;
    pointer-events: none;
    z-index: 2;
}

.video-placeholder.has-video .placeholder-content {
    display: none;
    /* Hide labels when video is active */
}

.icon {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.label {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.hint {
    font-size: 12px;
    color: #555;
    margin-top: 4px;
}

/* Specific Layout Logic */
.row-1 {
    align-items: flex-end;
    /* Bottom aligned */
    gap: 0;
    /* Connected without gaps */
}

.row-2 {
    align-items: flex-start;
    /* Top aligned */
    gap: 0;
}

.row-1 .video-placeholder,
.row-2 .video-placeholder {
    aspect-ratio: 2896 / 1876;
    border: none !important;
    /* No gaps from borders */
    border-radius: 0;
    /* Seamless connection */
    max-width: none;
    background: black;
    box-shadow: none !important;
}

.camera-front {
    aspect-ratio: 2896 / 1780 !important;
    /* Shorter container to clip bottom */
    overflow: hidden;
}

.camera-front video {
    object-fit: cover;
    object-position: top;
    /* Anchor to top, clipping the bottom naturally */
}

.camera-rear video {
    transform: scaleX(-1);
    /* Mirror view for natural rearview perspective */
}

.camera-front,
.camera-rear {
    flex: 2;
    /* Exactly twice the width of side cameras */
}

.camera-pillar-left,
.camera-pillar-right,
.camera-repeater-left,
.camera-repeater-right {
    flex: 1;
}

footer {
    padding: 15px 40px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-dim);
    background: rgba(10, 10, 10, 0.9);
}

/* Overlay & Progress */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s;
}

.overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay-content h3 {
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.progress-bar-container {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

#export-percentage {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-red);
    min-width: 40px;
    text-align: right;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-red);
    box-shadow: 0 0 15px var(--accent-red);
    transition: width 0.3s ease;
}

#export-status {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 30px;
}