[x-cloak] {
    display: none !important;
}

.text-headline {
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    color: #111827;
}

.text-meta {
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 500;
    color: #6b7280;
}

.text-label {
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 600;
    color: #4b5563;
}

/* Sticky Section (bisher: Map) — bleibt beim Scrollen am Seitenrand.
   Defensive Stacking: isolation: isolate erzwingt einen eigenen Stacking-
   Context, z-index: 30 liegt ueber allen anderen Sections. Der bg deckt
   den gesamten Section-Bereich inkl. Header-Zeile blickdicht ab, damit beim
   Scrollen KEIN Inhalt aus dahinterliegenden Sections (Photos, Tabellen,
   Text) durchschimmert — auch nicht durch die Toggle-Button-Zeile. */
.trip-section-sticky {
    position: sticky;
    top: calc(var(--trip-section-sticky-top, 0px) + env(safe-area-inset-top, 0px));
    z-index: 30;
    isolation: isolate;
    background: #f9fafb;
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
}
/* Der innere Header-Bereich (Titel + Einklappen-Button) bekommt EXPLIZIT
   denselben bg, damit auch bei Safari/Firefox-Rendering-Quirks nichts
   durchscheint. Die section-bg allein reicht bei manchen Engines nicht, wenn
   Nachbar-Elemente einen eigenen Stacking-Context mit hoeherer Tiefe haben. */
.trip-section-sticky > div:first-child {
    background: #f9fafb;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   Apple Photos Grid — layout-kritisches CSS für HTMX-Partials.
   Muss in app.css (Head), nicht im Partial (<style>), weil Safari dynamisch
   per innerHTML eingefügte <style>-Tags nicht zuverlässig verarbeitet.
   ========================================================================== */

/* Responsives Foto-Grid.
   minmax(0, 1fr) statt 1fr: 1fr = minmax(auto, 1fr) und respektiert die
   intrinsische Mindestgröße von Bildern → Spalten werden zu breit.
   minmax(0, 1fr) erzwingt Minimum 0 → Grid kann korrekt schrumpfen. */
.ap-grid {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px)  { .ap-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 768px)  { .ap-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .ap-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* Foto-Kachel: quadratisch, Inhalt clipped.
   min-width: 0 verhindert dass der Grid-Item über die Spaltenbreite hinauswächst. */
.ap-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 0.25rem;
    background: #f3f4f6;
    min-width: 0;
}

/* Bild absolut positioniert → beeinflusst nicht die Tile-Größe */
.ap-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Klick-Button über das gesamte Bild */
.ap-tile-btn {
    position: absolute;
    inset: 0;
}

/* Lightbox-Overlay (fixed, über Leaflet z-index 1000) */
.ap-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgb(0 0 0 / 0.85);
}

/* Lightbox-Fenster */
.ap-lightbox-inner {
    position: relative;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-width: 816px;
    max-height: 95vh;
    width: 100%;
}

/* Dunkelgrauer Medien-Bereich innerhalb Lightbox */
.ap-lightbox-media {
    background: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

/* Bild/Video in der Lightbox */
.ap-lightbox-img {
    max-height: 84vh;
    max-width: 100%;
    object-fit: contain;
    border-radius: 0.25rem;
}
.ap-lightbox-video {
    max-height: 84vh;
    max-width: 100%;
    border-radius: 0.25rem;
}

/* Lade-Spinner für Video-Buffering */
@keyframes ap-spin { to { transform: rotate(360deg); } }
.ap-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid rgb(255 255 255 / 0.25);
    border-top-color: white;
    border-radius: 9999px;
    animation: ap-spin 0.8s linear infinite;
}
/* Video-Lade-Overlay: Poster + Spinner überlagert das unsichtbare Video */
.ap-video-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #111827;
    border-radius: 0.25rem;
}

/* Kachel-Overlays: Badges, Zeitstempel, Löschen-Button */
.ap-badge {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    pointer-events: none;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
}
.ap-badge-video { background: rgb(220 38 38 / 0.9); }
.ap-badge-live  { background: rgb(147 51 234 / 0.9); }
.ap-badge-foto  { background: rgb(0 0 0 / 0.55); box-shadow: none; }

.ap-fav {
    position: absolute;
    top: 0.25rem;
    right: 2rem;
    color: #facc15;
    font-size: 1.125rem;
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.5));
}

.ap-time {
    position: absolute;
    bottom: 0.25rem;
    left: 0.25rem;
    background: rgb(0 0 0 / 0.55);
    color: white;
    font-size: 10px;
    padding: 0 0.25rem;
    border-radius: 0.25rem;
    pointer-events: none;
}

.ap-delete {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: rgb(0 0 0 / 0.6);
    color: white;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
}
.group:hover .ap-delete { opacity: 1; }
.ap-delete:hover { background: rgb(220 38 38); }

/* Foto-Metadaten unterhalb der Kachel (Personen, Keywords, Labels) */
.ap-meta {
    margin-top: 0.25rem;
    padding: 0 0.125rem;
    font-size: 10px;
    line-height: 1.3;
}
.ap-meta-title {
    font-weight: 500;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ap-meta-persons {
    color: #2563eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ap-meta-keywords {
    color: #d97706;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ap-meta-labels {
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Lightbox: Navigations-Buttons (Prev/Next) */
.ap-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    background: rgb(0 0 0 / 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    cursor: pointer;
}
.ap-nav:hover:not(:disabled) { background: rgb(0 0 0 / 0.8); }
.ap-nav:disabled { opacity: 0.2; cursor: not-allowed; }
.ap-nav-prev { left: 1rem; }
.ap-nav-next { right: 1rem; }

/* Lightbox: Schließen-Button */
.ap-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    background: rgb(0 0 0 / 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    transition: background 0.15s;
    cursor: pointer;
}
.ap-close:hover { background: rgb(0 0 0 / 0.8); }

/* Lightbox: Zähler-Badge (1 / N) */
.ap-counter {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
    background: rgb(0 0 0 / 0.6);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

/* Lightbox: Info-Leiste unten */
.ap-info {
    padding: 1rem;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.ap-info-left {
    min-width: 0;
    flex: 1 1 0%;
}
.ap-info-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ap-info-filename {
    font-size: 0.75rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ap-info-right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Lightbox: Aktions-Buttons (Google Maps, Fotos öffnen, Vollauflösung) */
.ap-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background 0.15s;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
    color: white;
    cursor: pointer;
}
.ap-action-btn-green { background: #16a34a; }
.ap-action-btn-green:hover { background: #15803d; }
.ap-action-btn-blue  { background: #2563eb; }
.ap-action-btn-blue:hover  { background: #1d4ed8; }

/* ==========================================================================
   Mobile UI Verbesserungen (max-width: 767px = unter md-Breakpoint)
   ========================================================================== */

/* 1. Timeline-Gutter: 136px → 72px auf Mobile */
@media (max-width: 767px) {
    #v2-timeline { padding-left: 72px !important; }
    #v2-timeline::before { left: 57px !important; }
    .v2-tl-date {
        left: -72px !important;
        width: 50px !important;
        font-size: 11px !important;
    }
}

/* 4. Secondary-KPI-Strip auf Mobile ausblenden (spart ~120px above-the-fold) */
@media (max-width: 639px) {
    .secondary-kpi-strip { display: none !important; }
}
