:root {
    --bg-body: #000000;
    --bg-surface: #111111;
    --border: #333333;
    --text-main: #ffffff;
    --text-muted: #666666;
    --accent: #ffffff;
    --radius: 0px;
    --heart-color: #ff3b30;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Mobile viewport fix */
    overflow: hidden; /* Prevent scrolling */
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    padding: 120px 20px; /* Reduced desktop padding for better balance */
    display: flex;
    flex-direction: column;
}

/* Header (Compact) */
header {
    flex: 0 0 auto;
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    height: 24px;
    width: auto;
    display: block;
}

header h1 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag {
    background: var(--bg-surface);
    color: var(--text-muted);
    padding: 2px 6px;
    font-size: 10px;
    text-transform: uppercase;
    border: 1px solid var(--border);
}

.credit {
    font-size: 12px;
    color: var(--text-muted);
}

.credit a {
    color: var(--text-main);
    text-decoration: none;
}

/* Main Layout */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0; /* Crucial for nested flex scrolling/sizing */
}

/* Upload Area (Compact) */
.upload-area {
    flex: 0 0 120px; /* Fixed small height */
    width: 100%;
    max-width: 600px; /* Cap width so it's not too wide */
    margin: 0 auto;   /* Center it */
    border: 1px solid var(--border);
    background: var(--bg-surface);
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--text-muted);
}

.upload-area.drag-over {
    border-color: var(--text-main);
    background: #1a1a1a;
}

.upload-content {
    display: flex;
    align-items: center;
    gap: 20px;
    pointer-events: none;
}

.icon-wrapper {
    color: var(--text-muted);
}

.text-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.upload-text {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
}

.supported-formats {
    margin: 0;
    font-size: 10px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Video Preview */
.preview-container {
    width: 100%;
    height: 100%;
    position: relative;
}

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

.preview-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.preview-overlay span {
    background: black;
    color: white;
    padding: 6px 12px;
    font-size: 10px;
    text-transform: uppercase;
    border: 1px solid white;
}

/* Controls */
.controls {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
}

.file-info {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.primary-btn {
    background: var(--text-main);
    color: black;
    border: none;
    height: 36px;
    padding: 0 24px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto; /* Push to right */
}

.primary-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

.spinner {
    width: 10px;
    height: 10px;
    border: 2px solid rgba(0,0,0,0.3);
    border-top-color: black;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Results Grid */
.results-grid {
    flex: 1;
    display: flex;
    gap: 20px;
    min-height: 0;
    /* max-height removed to let images fill screen on desktop */
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.frame-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    height: 100%;
}

.card-header {
    flex: 0 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-family: monospace;
    color: var(--text-muted);
}

.label {
    color: var(--text-main);
    font-weight: 600;
}

.image-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Crucial */
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.download-btn {
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--text-main);
    text-decoration: none;
    font-size: 11px;
    text-transform: uppercase;
    border-top: 1px solid var(--border);
    transition: background 0.2s;
}

.download-btn:hover {
    background: var(--border);
}

.hidden {
    display: none !important;
}

/* Footer & Love Button */
.app-footer {
    flex: 0 0 auto;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    padding-top: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: monospace;
}

.love-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-muted);
}

.love-btn:hover {
    border-color: var(--heart-color);
    background: rgba(255, 59, 48, 0.1);
    transform: scale(1.05);
}

.love-btn:active {
    transform: scale(0.95);
}

.heart-icon {
    transition: all 0.2s;
    color: var(--text-muted);
}

.love-btn:hover .heart-icon {
    color: var(--heart-color);
    fill: var(--heart-color);
}

.love-btn.loved {
    border-color: var(--heart-color);
    background: rgba(255, 59, 48, 0.1);
    cursor: default;
}

.love-btn.loved .heart-icon {
    color: var(--heart-color);
    fill: var(--heart-color);
}

.love-count {
    font-family: monospace;
    font-size: 12px;
    font-weight: 500;
}

.footer-credit {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: monospace;
}

.app-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.app-footer a:hover {
    color: var(--text-main);
}

/* Floating Heart Animation */
.floating-heart {
    position: fixed;
    color: var(--heart-color);
    font-size: 20px;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 1000;
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -150px) scale(1.5);
        opacity: 0;
    }
}

/* Mobile Layout */
@media (max-width: 768px) {
    .container {
        /* Push content down from status bar significantly, and up from bottom bar */
        padding: 60px 16px 80px 16px; /* Increased bottom padding to 80px */
    }
    
    /* Bring the video preview lower on mobile - REMOVED extra margin */
    .upload-area {
        flex: 0 0 80px;
        margin-top: 0; 
    }

    /* Side-by-side on mobile as requested */
    .results-grid {
        flex-direction: row; 
        gap: 10px;
    }
    
    /* Ensure cards can shrink to fit side-by-side */
    .frame-card {
        min-width: 0;
    }

    .controls {
        height: auto;
        margin: 10px 0;
    }

    header {
        margin-bottom: 20px; /* Reduced gap between text and upload */
    }
}

/* Hidden processor fix for Safari to ensure rendering */
#videoProcessor {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    z-index: -100;
}
