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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #fafafa;
    color: #333;
    min-height: 100vh;
}

/* Header */
header {
    position: sticky;
    top: 0;
    background: #fafafa;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    border-bottom: 1px solid #eee;
    z-index: 100;
}

h1 {
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#search {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.875rem;
    width: 200px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
    outline: none;
    border-color: #999;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

#sort {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

/* Gallery - Masonry Layout */
.gallery {
    column-count: 4;
    column-gap: 1rem;
    padding: 1.5rem 2rem;
}

@media (max-width: 1200px) {
    .gallery {
        column-count: 3;
    }
}

@media (max-width: 800px) {
    .gallery {
        column-count: 2;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .controls {
        width: 100%;
    }

    #search {
        flex: 1;
    }
}

@media (max-width: 500px) {
    .gallery {
        column-count: 1;
        padding: 1rem;
    }
}

/* Gallery Item */
.gallery-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    cursor: pointer;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
}

.gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.2s ease;
}

.gallery-item:hover img {
    transform: scale(1.02);
}

.gallery-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 0.75rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-item:hover .overlay {
    opacity: 1;
}

.gallery-item .overlay .date {
    font-size: 0.75rem;
    opacity: 0.8;
}

.gallery-item .overlay .preview {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-content img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
}

.modal-info {
    margin-top: 1rem;
    text-align: center;
    color: white;
    max-width: 600px;
}

.modal-info p {
    font-size: 1rem;
    line-height: 1.5;
}

.modal-info .date {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.6;
}

.delete-btn {
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

.delete-btn:hover {
    background: #c82333;
}

.modal-close {
    position: absolute;
    top: -2.5rem;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    line-height: 1;
}

.modal-close:hover {
    opacity: 1;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.empty-state .subtle {
    font-size: 0.875rem;
    color: #999;
}

/* Loading state for images */
.gallery-item.loading {
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    min-height: 200px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
