:root {
    --bg-color: #0d1117;
    --card-bg: #161b22;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #238636;
    --accent-hover: #2ea043;
    --border: #30363d;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #58a6ff, #d2a8ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.upload-btn {
    background-color: var(--accent);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
}

.upload-btn:hover {
    background-color: var(--accent-hover);
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Upload Section */
.upload-container {
    background: var(--card-bg);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    margin-bottom: 3rem;
    transition: border-color 0.3s, background-color 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-container:hover,
.upload-container.dragover {
    border-color: #58a6ff;
    background-color: rgba(88, 166, 255, 0.05);
}

.upload-icon {
    font-size: 3rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-subtext {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#fileInput {
    display: none;
}

/* Progress Area */
.progress-area {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-icon {
    font-size: 1.5rem;
}

.file-info {
    flex: 1;
    text-align: left;
}

.file-name {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.progress-bar-container {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    width: 100%;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #58a6ff;
    width: 0%;
    transition: width 0.2s;
}

.upload-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.media-card {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    break-inside: avoid;
}

.media-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: #58a6ff;
}

.media-content {
    width: 100%;
    height: 250px;
    /* Fixed height for uniformity or use aspect-ratio */
    object-fit: cover;
    background: #000;
    display: block;
}

.video-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}


.media-info {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.media-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.media-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-weight: 500;
}

.media-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.download-link {
    color: var(--text-secondary);
    transition: color 0.2s;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 10px;
}

.download-link:hover {
    color: #58a6ff;
    background: rgba(88, 166, 255, 0.1);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 5rem;
    color: var(--text-secondary);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.toast {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--accent);
}

.toast.error {
    border-left: 4px solid #da3633;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .media-content {
        height: 15px;
        /* Adjust for mobile */
        height: 150px;
    }
}

/* ── Download Progress Toast ── */
.dl-toast {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid #58a6ff;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    min-width: 280px;
    max-width: 340px;
    animation: slideIn 0.3s ease-out;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.dl-toast.done {
    border-left-color: var(--accent);
}

.dl-toast.error {
    border-left-color: #da3633;
}

.dl-toast-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.dl-toast-icon {
    font-size: 1.1rem;
    color: #58a6ff;
    flex-shrink: 0;
}

.dl-toast.done .dl-toast-icon  { color: var(--accent); }
.dl-toast.error .dl-toast-icon { color: #da3633; }

.dl-toast-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.dl-toast-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
}

.dl-toast-bar-wrap {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.dl-toast-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, #58a6ff, #d2a8ff);
    transition: width 0.15s ease;
}

.dl-toast.done .dl-toast-bar  { background: var(--accent); width: 100% !important; }
.dl-toast.error .dl-toast-bar { background: #da3633; }

.dl-toast-status {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}