:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --accent: #2c2c2c;
    --accent-hover: #000000;
    --star-active: #f1c40f;
    --star-inactive: rgba(255, 255, 255, 0.7);
    --padding: 15px;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.header {
    padding: var(--padding);
    padding-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid #eaeaea;
    padding-bottom: 10px;
}

.banner {
    width: 100%;
    height: 300px;
    overflow: hidden;
    position: relative;
}

.banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: brightness(0.9);
}

.title-area h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.format-selection {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.format-selection select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    font-size: 0.9rem;
}

.stats {
    font-size: 0.9rem;
    color: #666;
}

/* GRID */
.gallery-container {
    padding: var(--padding);
}

.grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.grid::after {
    content: '';
    flex-grow: 999999999;
}

.grid-item {
    position: relative;
    flex-grow: var(--ratio, 1.5);
    flex-shrink: 1;
    flex-basis: calc(200px * var(--ratio, 1.5));
    aspect-ratio: var(--ratio, 1.5);
    overflow: hidden;
    background: #f4f4f4;
    cursor: pointer;
}

@media (max-width: 768px) {
    .grid-item {
        flex-basis: 100%;
        aspect-ratio: var(--ratio, 1.5);
    }
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

.grid-item:hover img {
    transform: scale(1.03);
}

/* OVERLAY */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.3) 100%);
    opacity: 0;
    transition: opacity 0s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    pointer-events: none; /* Let clicks pass to item */
}

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

/* If item is selected, overlay stays visible faintly or star stays */
.grid-item.selected .overlay {
    opacity: 1;
    background: inset 0 0 0 3px var(--accent); /* border effect */
}

.grid-item.selected img {
    transform: scale(0.95);
}

.star-btn, .dl-btn {
    pointer-events: auto; /* Buttons are clickable */
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background-color: rgba(0,0,0,0.4);
}

.star-btn:hover, .dl-btn:hover {
    background-color: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

.star-btn svg, .dl-btn svg { width: 20px; height: 20px; }

.star-btn.active svg { fill: var(--star-active); stroke: var(--star-active); }

.dl-btn { align-self: flex-end; }
.star-btn { align-self: flex-end; margin-bottom: auto;} /* Top right */


/* BATCH BAR */
.batch-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.batch-bar.hidden {
    transform: translate(-50%, 150%);
}

#batch-download-btn {
    background: white;
    color: var(--accent);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}
#batch-download-btn:hover { background: #eee; }

.close-batch-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    margin-left: -10px;
    opacity: 0.8;
}
.close-batch-btn:hover { opacity: 1; }

/* LIGHTBOX */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.lightbox.hidden { display: none; }

.lightbox-top-bar {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    align-items: center;
}

.lightbox-actions { display: flex; gap: 15px; }

.close-btn {
    background: none; border: none; font-size: 2rem; cursor: pointer; line-height: 1; color: var(--text-color);
}

.lightbox-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    overflow: hidden;
}

.lightbox-img-container {
    flex: 1;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.nav-btn {
    background: none; border: none; font-size: 3rem; cursor: pointer; color: #888;
    padding: 0 20px; transition: color 0.2s;
}
.nav-btn:hover { color: #000; }

/* FILMSTRIP */
.filmstrip-container {
    height: 90px;
    background: rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    overflow-x: auto;
    padding: 0 10px;
    border-top: 1px solid #eee;
}

.filmstrip {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    margin: 0 auto; /* Center if few */
}

.fs-thumb {
    height: 60px;
    width: auto;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s;
    border-radius: 4px;
}
.fs-thumb.active {
    opacity: 1;
    border: 2px solid var(--accent);
    transform: scale(1.05);
}

/* Spinner Overlay */
#loading-overlay {
    position: fixed; inset:0; background: rgba(255,255,255,0.9);
    z-index: 2000; display: flex; flex-direction: column; justify-content: center; align-items: center;
}
#loading-overlay.hidden { display: none; }
.spinner {
    width: 50px; height: 50px; border: 5px solid #eaeaea; border-top-color: var(--accent);
    border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Lightbox Star/DL colors overrides because bg is white */
.star-btn.large, .dl-btn.large {
    background-color: #eee;
    color: var(--text-color);
}
.star-btn.large:hover, .dl-btn.large:hover {
    background-color: #ddd;
}
