body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
}

header {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 1.5rem 0;
    text-align: center;
}

h1 {
    margin: 0;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.sort-controls {
    text-align: center;
    margin-bottom: 2rem;
}

.sort-controls button {
    background-color: #34495e;
    color: #ecf0f1;
    border: none;
    padding: 0.75rem 1.5rem;
    margin: 0 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sort-controls button:hover {
    background-color: #4e6a85;
}

.sort-controls select {
    background-color: #34495e;
    color: #ecf0f1;
    border: none;
    padding: 0.75rem 1.5rem;
    margin: 0 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    /* Standard-Browser-Stile entfernen */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Kleiner Pfeil für Dropdown */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ecf0f1%22%20d%3D%22M287%2C197.3l-11.4-11.4c-2.4-2.4-6.2-2.4-8.6%2C0L146.2%2C268.9L25.4%2C185.9c-2.4-2.4-6.2-2.4-8.6%2C0L5%2C197.3c-2.4%2C2.4-2.4%2C6.2%2C0%2C8.6l137.9%2C137.9c1.2%2C1.2%2C2.8%2C1.8%2C4.3%2C1.8s3.1-0.6%2C4.3-1.8L287%2C205.9C289.4%2C203.5%2C289.4%2C199.7%2C287%2C197.3z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 0.75rem top 50%;
    background-size: 0.65rem auto;
}

.gallery {
    display: grid;
    /* Passt die Mindestbreite an, um auf kleineren Bildschirmen besser zu skalieren */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.gallery img {
    width: 100%;
    height: 100%; /* Stellt sicher, dass das Bild die Höhe des Grid-Items füllt */
    aspect-ratio: 4 / 3; /* Erzwingt ein 4:3-Seitenverhältnis für alle Bilder */
    object-fit: cover;   /* Füllt den Bereich aus, ohne das Bild zu verzerren (schneidet ggf. Ränder ab) */
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease-in-out;
    cursor: pointer;
}

.gallery img:hover {
    transform: scale(1.05);
}

/* --- Lightbox-Stile --- */

.lightbox {
    display: none; /* Standardmäßig versteckt */
    position: fixed; /* Bleibt an Ort und Stelle, auch beim Scrollen */
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Schwarzer, halbtransparenter Hintergrund */
    flex-direction: column; /* Stellt sicher, dass Bild und Text untereinander angeordnet sind */
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex; /* Wird sichtbar, wenn die "active"-Klasse hinzugefügt wird */
}

.spinner {
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid #3498db; /* Blue */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
    position: absolute;
    display: none; /* Standardmäßig versteckt */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.lightbox-content {
    max-width: 90%;
    max-height: 80%; /* Etwas weniger Höhe, um Platz für den Text zu schaffen */
    object-fit: contain; /* Stellt sicher, dass das ganze Bild sichtbar ist, ohne Verzerrung */
    display: none; /* Wird erst nach dem Laden sichtbar */
}

.lightbox-caption {
    position: absolute;
    bottom: 20px;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 5px;
    display: none; /* Wird erst sichtbar, wenn die Lightbox aktiv ist */
    /* Flexbox-Layout für die Buttons, wird per JS aktiviert */
    gap: 1.5rem;
    align-items: center;
}

.request-button {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
    /* Button-Reset für den neuen Button */
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.request-button:hover {
    color: #3498db;
}

.close-button {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-button:hover {
    color: #bbb;
}

/* --- Lightbox-Navigationspfeile --- */
.prev-button,
.next-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    user-select: none; /* Verhindert das Markieren des Pfeil-Textes */
    padding: 0 1.5rem;
    z-index: 1001; /* Stellt sicher, dass sie über dem Bild liegen */
}

.prev-button { left: 0; }
.next-button { right: 0; }

.prev-button:hover,
.next-button:hover {
    color: #bbb;
}

.lightbox-location-text {
    color: #ccc;
    padding: 10px 0;
    text-align: center;
    /* width: 100%; entfernt, damit es sich natürlich zentriert */
}

/* --- Responsive Anpassungen für kleinere Bildschirme --- */

@media (max-width: 600px) {
    header {
        padding: 1rem 0;
    }

    main {
        margin: 1rem auto;
        padding: 0 0.5rem; /* Reduziert den seitlichen Abstand */
    }

    .gallery {
        gap: 0.5rem; /* Verringert den Abstand zwischen den Bildern */
    }

    .prev-button,
    .next-button {
        font-size: 2rem;
        padding: 0 1rem;
    }
}

/* --- Footer-Stile --- */

footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9rem;
}

footer a {
    color: #555;
    text-decoration: none;
}