/* Fotos: Vorschaubilder, Verwaltungsseite und Overlay */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.gallery {
    margin: 20px 0;
}

.gallery h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gallery-item {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: var(--line);
}

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

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

.gallery-item:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.gallery-private {
    position: absolute;
    left: 6px;
    top: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.75rem;
}

.gallery-caption {
    margin: 4px 2px 0;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* Verwaltungsseite */
.check {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
}

.upload-status {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
}

.upload-status li {
    padding: 2px 0;
}

.upload-status .err {
    color: var(--danger);
}

.images-toolbar {
    margin: 20px 0 24px;
}

.images-toolbar .button {
    margin-top: 0;
}

.save-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.save-button .icon {
    flex: 0 0 auto;
}

.image-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.image-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.image-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    background: var(--line);
}

.image-card input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
}

.image-card input[type="text"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.images-admin > .hint {
    margin: 0 0 16px;
}

.image-buttons {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.image-buttons .button {
    padding: 6px 12px;
}

.image-buttons .button:last-child {
    margin-left: auto;
}

.image-buttons .button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Overlay */
html.lb-open {
    overflow: hidden;
}

.lb {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: rgba(9, 11, 14, 0.97);
    color: #fff;
}

.lb[hidden] {
    display: none;
}

.lb-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 56px;
}

.lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    touch-action: pan-y;
    user-select: none;
}

.lb-img.loaded {
    opacity: 1;
}

.lb-bar {
    flex: 0 0 auto;
    padding: 10px 16px 14px;
    text-align: center;
    min-height: 3.2em;
}

.lb-caption {
    margin: 0;
    overflow-wrap: anywhere;
}

.lb-count {
    margin: 2px 0 0;
    color: #b9c3cf;
    font-size: 0.85rem;
}

.lb-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.lb-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.lb-btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.lb-close {
    top: 10px;
    right: 10px;
    z-index: 1;
}

.lb-prev,
.lb-next {
    top: 50%;
    transform: translateY(-50%);
}

.lb-prev {
    left: 6px;
}

.lb-next {
    right: 6px;
}

@media (max-width: 600px) {
    .lb-stage {
        padding: 56px 0 4px;
    }

    .lb-prev,
    .lb-next {
        top: auto;
        bottom: 8px;
        transform: none;
        background: rgba(255, 255, 255, 0.2);
    }

    .lb-bar {
        padding-bottom: 60px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .lb-img,
    .gallery-item img {
        transition: none;
    }
}
