* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    font-family: Verdana, Arial, sans-serif;
}

.wrapper {
    background: #381f33;
    display: flex;
    flex-direction: row;
    /* Nebeneinander */
    height: calc(100dvh - 45px);
    /* Fallback */
    height: calc(100dvh - 45px);
    gap: 4px;
    z-index: 0;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    /* Verteilt Home, Titel und Platzhalter */
    background: #2a1726;
    /* Dein dunkler Lila-Ton */
    height: 35px;
    width: 100%;
    color: white;
    position: sticky;
    top: 0;
    z-index: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.home-link {
    text-decoration: none;
    font-size: 24px;
    padding: 5px 10px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s;
}

.home-link:active {
    transform: scale(0.9);
    /* Kleiner "Drück-Effekt" am Tablet */
}

.projektname {
    font-family: Verdana, sans-serif;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 1px;
    color: #ffcc00;
    /* Dein Gold-Ton */
    text-transform: uppercase;

    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Auf mobilen Geräten (iPhone/iPad) etwas kleiner */
@media (max-width: 767px) {
    .projektname {
        padding: 10px;
    }

    .projektname {
        font-size: 0.8rem;
    }

}

@media (max-width: 480px) {
    .project-title {
        max-width: 200px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        /* Macht "..." wenn der Text zu lang ist */
        font-size: 0.75rem;
    }
}

/* .projektname h1 {
         margin: 0;
         font-size: 1.0rem;
         letter-spacing: 2px;
         text-transform: uppercase;
     } */

.left {
    width: 360px;
    padding: 8px;
    overflow-y: auto;
    /* macht vertikales Scrollen möglich */
    background: #f5f5f5;
    border-right: 1px solid #ccc;
    border: 4px solid #3c7a41;
    font-family: Verdana, Arial, sans-serif;
    /* damit der Bereich exakt die Höhe nimmt und scrollt */
    display: flex;
    flex-direction: column;
}

.caption {
    margin-top: 4px;
    font-size: 0.7rem;
    word-break: break-word;
}

/* optional: für immer sichtbaren Scrollbalken (bei manchen Browsern braucht es nichts extra) */
.left {
    scrollbar-gutter: stable;
    /* reserviert Platz für Scrollbar, vermeidet Layout-Sprung */
}

.left img {
    transition: transform 0.2s, border 0.2s;
    border: 2px solid transparent;
    border-radius: 8px;
    /* Schön abgerundete Ecken */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    /* Sanfter Schatten */
}

.left img.active-thumb {
    border: 2px solid #ffcc00;
    /* Goldener Rahmen */
    transform: scale(0.95);
    /* Drückt das Bild leicht ein (Click-Effekt) */
    filter: brightness(1.2);
    /* Macht es ein wenig heller */
}


.arrow-icon {
    display: inline-block;
    font-size: 14px;
    line-height: 1;
    /* Verhindert das Verzerren: */
    width: 14px;
    text-align: center;
}

.arrow-text {
    font-family: Verdana, sans-serif;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
}

@keyframes bounceIndicator {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    40% {
        transform: translateX(-50%) translateY(-5px);
    }

    60% {
        transform: translateX(-50%) translateY(-3px);
    }
}

.right {
    position: relative;
    width: 80%;
    /* Beispielbreite */
    /* max-width: 900px; */

    background-color: #9f9e9e;
    border: 4px solid #3c7a41;
    padding: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    /* Umbruch bei kleineren Geräten */
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: calc(100dvh - 40px);
    max-height: 100dvh;
    /* 100vh minus dem Padding von 20px oben und 20px unten */
    /* Scrollleiste anzeigen, wenn der Inhalt zu groß wird */
    /* overflow-y: auto;  */
    overflow: hidden;
    /* Verhindert, dass die ganze Seite scrollt */
    display: flex;
    flex-direction: column;
}

#mediaContainer {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Zentriert das Bild vertikal im Container */
    background-color: #a1a1a1;

    /* WICHTIG: Erlaubt dem Container zu schrumpfen, statt den Inhalt rauszuschieben */
    flex: 1;
    width: 100%;
    min-height: 0;
    /* Verhindert, dass Flexbox den Container aufbläht */

    padding-bottom: 10px;

    /*Platz für dein Overlay */
    box-sizing: border-box;
    overflow: hidden;
}

#mediaDisplay {
    display: block;
    /* Nutzt soviel Platz wie da ist, aber nie mehr als 100% */
    max-width: 100%;
    max-height: 100%;

    width: auto;
    height: auto;

    object-fit: contain;
    /* Erhält die Proportionen ohne Beschneiden */
    border: 3px solid white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease-in-out;
    cursor: zoom-in;
}

#videoDisplay {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 70px - 14px);
    /* 70px Overlay + 2x7px Border */
    border: 7px solid white;
    object-fit: contain;
    transition: opacity 0.3s ease-in-out;
    cursor: zoom-in;
}

.fade-in {
    opacity: 0;
}


#mediaDisplay.landscape {
    width: 100%;
    height: auto;
}

#mediaDisplay.portrait {
    width: auto;
    height: 100%;
    max-height: 90dvh;
    /* etwas Reserve für Caption */
}


/* Die active-Klasse zeigt das Element an */
#mediaDisplay.active,
#videoDisplay.active {
    opacity: 1;
}

#mediaDisplay.dragging,
#videoDisplay.dragging {
    cursor: grabbing;
}

.thumb-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.thumb-cell {
    padding: 6px;
    vertical-align: top;
    text-align: center;
    width: 50%;
}

.thumb-cell button {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    width: 100%;
}

.thumb-cell img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border: 1px solid #999;
}

.left::-webkit-scrollbar {
    width: 12px;
}


.left::-webkit-scrollbar-track {
    background: #e0e0e0;
}

.left::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 6px;
}

.left::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.playPauseBtn-control-btn {
    position: relative;
    width: 40px;
    height: 40px;

    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    border: 1px solid white;
    font-size: 20px;
    /* Größe des Emojis */
    cursor: pointer;

    /* WICHTIG: Das hier zentriert den Inhalt (das ::after) */
    display: flex;
    align-items: center;
    /* Vertikal mittig */
    justify-content: center;
    /* Horizontal mittig */

    /* Falls der Button über dem Video schwebt: */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}

.play-icon::before {
    content: '▶️';
}

.pause-icon::before {
    content: '⏸️';
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
    transition: all 0.2s ease;
}


#progressBarContainer {
    /* Klebt am Browserfenster (Viewport) */
    position: fixed;

    /* Position am unteren Rand */
    bottom: env(safe-area-inset-bottom, 0);
    /* Rückt die Leiste über den Home-Indikator */

    /* Zieht sich über die gesamte Breite */
    left: 0%;
    width: 100%;

    /* Sicherstellen, dass die Leiste über anderen Inhalten liegt */
    z-index: 99999;

    /* Beibehalten der visuellen Eigenschaften */
    height: 5px;
    background-color: #d12121ff;
    display: block;
}

#myProgressBar {
    height: 100%;
    background-color: #4CAF50;
}

/* .controls {
         position: absolute;
         bottom: calc(84px + env(safe-area-inset-bottom));
         left: 50%;
         transform: translateX(-50%);
         display: flex;
         gap: 12px;
         transition: opacity 0.3s;
         z-index: 99999;
         touch-action: manipulation;
     } */

#closeMain {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    /* Verhindert Konflikt mit der Statusleiste */
    right: 10px;
    padding: 5px 10px;
    background: rgba(215, 191, 13, 0.6);
    color: rgb(255, 255, 255);
    border: none;
    cursor: pointer;
    border-radius: 5px;
    z-index: 9999;
}


.fullscreenBt {
    position: fixed;
    /* Klebt am Viewport */
    top: 5px;
    /* 10px vom oberen Rand */
    right: 10px;
    /* 10px vom rechten Rand */
    z-index: 1000;
    /* Über allem */
    border-radius: 10px;
    color: rgb(10, 10, 10);
    background-color: rgb(255, 187, 0);
    color: rgb(8, 8, 8);
}

#homebutton {
    width: 40px;
    height: 40px;

    background: rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 25px;
    left: 250px;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.loading {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    z-index: 1;
}

@media (orientation: portrait) {

    /* Untereinander stapeln */
    .wrapper {
        flex-direction: column-reverse;
        height: calc(100dvh - 40px);
        overflow: hidden;
        /* Verhindert, dass die ganze Seite wackelt */
    }

    .left {
        width: 100%;
        height: 50dvh;
        /* Etwas Platz für die Thumbs */

        /* WICHTIG: Weg von Flex, hin zu Block für vertikales Scrollen */
        display: block;
        overflow-y: auto;
        /* Vertikales Scrollen erlauben */
        overflow-x: hidden;
        /* Horizontales Scrollen verbieten */

        background: #f4f4f4;
        border-top: 2px solid #ccc;
        -webkit-overflow-scrolling: touch;
        padding: 5px;
        box-sizing: border-box;
    }

    .right {
        width: 100%;
        height: 50dvh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .left tbody {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        /* Hier die 4 erzwingen */
        gap: 8px;
        width: 100%;
    }

    /* Die Tabellenzeile (tr) darf jetzt kein Grid mehr sein */
    /* Wir setzen sie auf 'contents', damit sie für das Layout "unsichtbar" wird */
    .left tr {
        display: contents !important;
    }

    .left td {
        display: block;
        width: 100%;
        padding: 0 !important;
    }

    .left img {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        object-fit: cover;
        display: block;
    }

    .left h2 {
        display: none;
    }

    /* Scrollbar-Optik für Tablets */
    .left::-webkit-scrollbar {
        width: 8px;
        display: block;
    }

    .left::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.4);
        border-radius: 4px;
    }
}

/* --- Gemeinsame Basis-Stile (für alle Geräte) --- */
.nav-button,
#playPauseBtn,
#closeZoom,
#buttonios,
#btn-unmute-video {
    position: absolute;
    z-index: 2000;
    /* Sicherstellen, dass sie über dem Bild/Video liegen */
    border: none;
    background: rgba(0, 0, 0, 0.4);
    /* Dezenter Hintergrund */
    color: #ffcc00;
    /* Dein Gold-Ton */
    padding: 15px;
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(4px);
    /* Schicker Glas-Effekt für iPad/Handy */
    -webkit-backdrop-filter: blur(4px);
    transition: transform 0.2s;
}

/* 2. Play/Pause genau in der Mitte */
#playPauseBtn {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    font-size: 24px;
}

/* 3. Schließen-Button OBEN RECHTS */
#closeZoom {
    top: 20px;
    right: 20px;
    border-radius: 5px;
    /* Eher rechteckig oder leicht rund */
    padding: 10px 15px;
    background: rgba(200, 0, 0, 0.6);
    /* Ein leichter Rot-Ton signalisiert "Schließen" */
    color: white;
}

/* 4. Audio-Buttons UNTEN */
#buttonios,
#btn-unmute-video {
    bottom: 20px;
    right: 20px;
}

#buttonios {
    right: 80px;
}

/* Etwas links vom Unmute-Button */

/* Wenn das Handy HOCHKANT (Portrait) ist: Buttons etwas größer für Finger */
@media only screen and (max-width: 767px) and (orientation: portrait) {
    #closeZoom {
        top: 10px;
        right: 10px;
    }
}

/* Wenn das Gerät im QUERFORMAT (Landscape) ist (z.B. Video schauen) */
@media only screen and (orientation: landscape) {

    /* Close-Button bei Landscape oft besser in der Ecke aufgehoben */
    #closeZoom {
        top: 15px;
    }
}

.left {
    -webkit-overflow-scrolling: touch;
    /* Erlaubt das weiche "Nachschwingen" beim Wischen */
    scrollbar-width: none;
    /* Versteckt Scrollbar auf Firefox Mobile */
}

/* Versteckt die Scrollbar auf iOS/Chrome oft ganz, um Platz zu sparen */
.left::-webkit-scrollbar {
    display: none;
}

#buttonios {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Exakt mittig */

    background: rgba(233, 233, 50, 0.6);
    /* Halbtransparenter schwarzer Kreis */
    color: white;
    border: 2px solid white;
    border-radius: 50px;
    /* Abgerundete Ecken */
    padding: 15px 25px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 12;
    /* backdrop-filter: blur(5px);  Schicker Milchglas-Effekt (iOS Style) */
    transition: all 0.3s ease;
}

#buttonios:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%) scale(1.1);
    /*Wird beim Drücken leicht größer */
}

.unmute-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Exakt mittig */
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    z-index: 101;
    font-size: 0.9rem;
    content: '🔉';
}

/* Spezifische Korrekturen für iOS */
.is-ios .slideVideo {
    /* Zwingt Safari, das Video ohne Tiefenebene (Z-Achse) zu rendern */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;

    /* Verhindert Geisterbilder durch Backface-Rendering */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;

    /* Entfernt alle Filter, die Safari oft zum Verdoppeln zwingen */
    filter: none !important;
    -webkit-filter: none !important;
}

/* Deinen Play-Button auf iOS absolut unsichtbar und nicht klickbar machen */
.is-ios #playPauseBtn {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Falls dein Video in einem Container mit Rundungen liegt */
.is-ios .video-container {
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    overflow: hidden;
}

.is-ios #playPauseBtn,
.is-ios #progressBarContainer,
.is-ios .loading {
    pointer-events: none !important;
    /* Klicks gehen einfach "hindurch" zum Video */
    display: none !important;
}

/* Das Video selbst muss alle Klicks empfangen */
.is-ios #videoDisplay {
    pointer-events: auto !important;
    z-index: 100;
}

/* Wenn wir im iOS-Simulationsmodus sind */
.is-ios #videoDisplay {
    position: relative !important;
    z-index: 1000 !important;
    /* Absolut im Vordergrund */
    pointer-events: auto !important;
    display: block;
}

/* Alles andere MUSS unterwürfig sein */
.is-ios #playPauseBtn,
.is-ios #progressBarContainer,
.is-ios .loading,
.is-ios .progress-bar {
    display: none !important;
    pointer-events: none !important;
    z-index: 0 !important;
}

#scrollPfeil.scroll-indicator {
    position: sticky;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);

    background: rgba(201, 231, 82, 0.95);
    /* Dein Gold-Ton */
    color: #2a1726;
    padding: 6px 15px;
    border-radius: 20px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    width: fit-content;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);

    /* Animation für Aufmerksamkeit */
    animation: bounceIndicator 2s infinite;
    transition: opacity 0.3s ease;

    /* --- Klick-Optimierung für PC --- */
    cursor: pointer !important;
    /* Erzwingt die Klick-Hand statt des | Balkens */
    user-select: none;
    /* Verhindert Text-Markierung beim Klicken */
    -webkit-user-select: none;
    /* Für Safari/Chrome */

    /* --- Z-Index & Interaktion --- */
    pointer-events: auto !important;
    /* Nimmt Klicks aktiv an */
    z-index: 1001 !important;
    /* Liegt sicher über den Thumbs */
}

/* Optional: Verhindert, dass das Icon im Inneren den Cursor beeinflusst */
#scrollPfeil.scroll-indicator .arrow-icon {
    pointer-events: none;
}

/* * {
         outline: 1px solid rgba(255, 0, 0, 0.3) !important;
     } */