:root {
    --bg-color: #f8f9fa;
    --card-bg: white;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --border-color: #444;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background-color 0.3s, color 0.3s;
}

header {
    background: var(--card-bg);
    padding: 0.25rem 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

#blur-toggle,
#theme-toggle,
#download-all,
#share-site {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#blur-toggle:active,
#theme-toggle:active,
#download-all:active,
#share-site:active {
    transform: scale(0.95);
}

#download-all:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gallery.blurred .photo img {
    filter: blur(8px);
    transition: filter 0.3s;
}

.gallery.blurred .photo:hover img {
    filter: blur(0);
}

main {
    padding: 1rem 0.5rem;
    max-width: 100%;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 2px;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery.loaded {
    opacity: 1;
}

.photo {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    background: #f0f0f0;
    touch-action: manipulation;
}

.photo:active {
    transform: scale(0.98);
}

.photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.photo img.loading {
    opacity: 0;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 1.1rem;
}

.download-progress {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: var(--shadow);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    animation: fadeIn 0.3s;
    touch-action: manipulation;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#lightbox-img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 4px;
    touch-action: pan-x pan-y;
}

.close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    color: white;
    font-size: 1.75rem;
    cursor: pointer;
    z-index: 1001;
    padding: 0.75rem;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.close:active {
    background: rgba(0,0,0,0.7);
}

.nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    padding: 0 1rem;
}

.nav button {
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    pointer-events: all;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.nav button:active {
    background: rgba(0,0,0,0.7);
}

.nav button:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.info {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    text-align: center;
    background: rgba(0,0,0,0.5);
    padding: 0.5rem 1rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#photo-name {
    font-size: 0.9rem;
    font-weight: 500;
}

#photo-count {
    font-size: 0.8rem;
    opacity: 0.8;
}

.tooltip {
    position: fixed;
    background: red;
    color: black;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 10000;
    opacity: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: opacity 0.3s;
    pointer-events: none;
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: red;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* SEO hidden elements */
.seo-hidden {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    white-space: nowrap !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

@media (min-width: 768px) {
    header {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.5rem 2rem;
    }
    
    h1 {
        font-size: 1.5rem;
        text-align: left;
    }
    
    .logo {
        height: 48px;
    }
    
    .controls {
        justify-content: flex-end;
        gap: 1rem;
    }
    

    main {
        padding: 2rem;
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 8px;
    }
    
    .photo:hover {
        transform: scale(1.02);
        box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    }
    
    .nav {
        padding: 0 2rem;
    }
    
    .nav button {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    
    .close {
        top: 2rem;
        right: 2rem;
        font-size: 2rem;
        width: 56px;
        height: 56px;
    }
}