.gallery-index {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0;
    margin: 10px 0;
}

.gallery-item {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
}

.thumb-link {
    text-decoration: none;
    display: block;
}

.thumb-wrapper {
    position: relative;
    background: #2c3e50;
    border-radius: 0; /* Changed from 8px to 0 */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s ease;
}

.thumb-wrapper:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.thumb-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    aspect-ratio: auto;
}

/* Portrait Thumbnails (taller than wide) */
.thumb-portrait .thumb-wrapper {
    aspect-ratio: 3 / 4;
}

.thumb-portrait .thumb-image {
    height: 100%;
    object-fit: cover;
}

/* Landscape Thumbnails (wider than tall) */
.thumb-landscape .thumb-wrapper {
    aspect-ratio: 16 / 9;
}

.thumb-landscape .thumb-image {
    width: 100%;
    object-fit: cover;
}

.thumb-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 8px 8px 4px 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.thumb-wrapper:hover .thumb-overlay {
    opacity: 1;
}

.thumb-title {
    color: #ecf0f1;
    font-size: 0.75em;
    font-weight: 500;
    display: block;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-thumbs {
    text-align: center;
    padding: 40px;
    color: #ecf0f1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0; /* Changed from 8px to 0 - optional */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gallery-index {{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0; /* Changed from 12px to 0 - optional */
    margin: 10px 0;
}
    
    .thumb-title {
        font-size: 0.7em;
        white-space: normal;
        line-height: 1.3;
    }
    
    .thumb-overlay {
        opacity: 1; /* Always visible on mobile */
        background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.2));
        padding: 6px;
    }
}

@media (max-width: 480px) {
    .gallery-index {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
        padding: 8px;
    }
    
    .thumb-title {
        font-size: 0.65em;
    }
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {
    .thumb-overlay {
        opacity: 1;
    }
    
    .gallery-item:active {
        transform: scale(0.98);
    }
}