.ig-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 1080px;
    margin: 0 auto 16px;
    padding: 0 4px;
}

.ig-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ig-header-avatar {
    flex-shrink: 0;
    display: block;
    width: 56px;
    height: 56px;
    box-sizing: border-box;
    border-radius: 50%;
    padding: 2.5px;
    /* Instagram-typischer Story-Ring - rein dekorativ, permanent sichtbar */
    background: linear-gradient(45deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.15);
}

.ig-header-avatar img {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    object-fit: cover;
    display: block;
    border: 2px solid #fff;
    border-radius: 50%;
    color: transparent; /* falls Bild nicht laedt: Alt-Text nicht anzeigen statt ueberlaufen lassen */
}

.ig-header-info {
    flex: 0 1 auto;
    max-width: 260px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ig-header-name,
.ig-header-username {
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ig-header-name {
    font-weight: 600;
    font-size: 16px;
}

.ig-header-username {
    font-size: 14px;
    opacity: 0.65;
}

.ig-header .ig-follow-btn {
    margin-left: 8px;
}

.ig-follow-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    min-height: 36px;
    border: 1.5px solid #b09159;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    background: #b09159;
    color: #fff;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.15);
    touch-action: manipulation;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ig-follow-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.ig-follow-btn:hover,
.ig-follow-btn:focus-visible {
    background: #fff;
    color: #b09159;
    border-color: #b09159;
}

.ig-feed-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 1080px;
    margin: 0 auto;
}

.ig-tile {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: #eee;
    /* Ganze Kachel ist Tap-Ziel -> auf Mobile bequem antippbar, keine kleinen Buttons noetig */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.15);
    touch-action: manipulation;
}

.ig-tile-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    color: transparent; /* falls Bild nicht laedt: Alt-Text nicht anzeigen statt ueberlaufen lassen */
}

.ig-tile-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    fill: #fff;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.6));
}

/* Caption als dunkles Overlay - auf Desktop bei Hover/Focus, auf Mobile per
   Long-Press (JS togglet .ig-tile-caption-visible), da es dort kein Hover gibt. */
.ig-tile-caption {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.7) 100%);
    color: #fff;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ig-tile:hover .ig-tile-caption,
.ig-tile:focus-visible .ig-tile-caption,
.ig-tile-caption.ig-tile-caption-visible {
    opacity: 1;
}

.ig-tile-likes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ig-tile-text {
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ig-load-more {
    display: block;
    margin: 16px auto 0;
    padding: 10px 28px;
    min-height: 44px; /* ausreichend grosses Tap-Ziel */
    border: 1.5px solid #b09159;
    border-radius: 6px;
    background: #b09159;
    color: #fff;
    font-weight: 500;
    cursor: pointer;
    font-size: 15px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ig-load-more:hover,
.ig-load-more:focus-visible {
    background: #fff;
    color: #b09159;
    border-color: #b09159;
}

/* Tablet: 2 Spalten */
@media (max-width: 768px) {
    .ig-feed-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}

/* Mobile: Kopfzeile bricht auf 2 Zeilen um (Logo+Name oben, Folgen-Button darunter,
   zentriert, mit eigener max-width statt voller Bildschirmbreite). Caption/Herz-Zaehler
   auf den Kacheln werden komplett ausgeblendet (wie im echten Instagram-Grid) - ein Tap
   oeffnet ohnehin das Popup mit allen Details, ein dauerhaftes Overlay ist dort ueberfluessig. */
@media (max-width: 480px) {
    .ig-header {
        gap: 8px;
        margin-bottom: 12px;
    }

    .ig-header-avatar {
        width: 44px;
        height: 44px;
    }

    .ig-header-name,
    .ig-header-username {
        font-size: 14px;
    }

    .ig-header .ig-follow-btn {
        margin-left: 0;
    }

    .ig-follow-btn {
        max-width: 200px;
        justify-content: center;
        padding: 8px 12px;
        font-size: 13px;
    }

    .ig-feed-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* ---- Popup mit Bild-/Video-Slider ---- */

body.ig-modal-locked {
    overflow: hidden;
}

.ig-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}

.ig-modal.ig-modal-open {
    display: block;
}

.ig-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.ig-modal-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    max-width: 520px;
    height: 92vh;
    max-height: 92vh;
    margin: 4vh auto;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.ig-modal-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.ig-modal-media {
    position: relative;
    background: #000;
    flex: 1 1 auto;
    min-height: 120px;
}

.ig-modal-slide {
    position: relative;
    width: 100%;
    height: 100%;
}

.ig-modal-slide-item {
    display: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    background: #000;
}

.ig-modal-slide-item-active {
    display: block;
}

.ig-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    z-index: 1;
}

.ig-modal-nav-prev {
    left: 12px;
}

.ig-modal-nav-next {
    right: 12px;
}

.ig-modal-dots {
    position: absolute;
    bottom: 12px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ig-modal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.ig-modal-dot-active {
    background: #fff;
}

.ig-modal-info {
    flex: 0 1 auto;
    max-height: 40vh;
    padding: 14px 16px;
    overflow-y: auto;
    color: #000;
}

.ig-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: #000;
}

.ig-modal-avatar {
    flex-shrink: 0;
    display: block;
    width: 36px;
    height: 36px;
    box-sizing: border-box;
    border-radius: 50%;
    padding: 2px;
    /* Instagram-typischer Story-Ring - rein dekorativ, permanent sichtbar */
    background: linear-gradient(45deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5);
}

.ig-modal-avatar img {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    object-fit: cover;
    display: block;
    border: 1.5px solid #fff;
    border-radius: 50%;
    color: transparent;
}

.ig-modal-username {
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    color: #000;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-modal-header .ig-follow-btn {
    padding: 6px 14px;
    min-height: 30px;
    font-size: 13px;
}

.ig-modal-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.ig-modal-likes {
    font-weight: 600;
    font-size: 15px;
}

.ig-modal-caption {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
    margin-bottom: 8px;
}

.ig-modal-caption-username {
    font-weight: 600;
    color: #000;
    text-decoration: none;
    margin-right: 4px;
}

.ig-modal-link {
    color: #0095f6;
    text-decoration: none;
}

.ig-modal-date {
    display: block;
    font-size: 11px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #8e8e8e;
}

.ig-modal-viewpost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: #000;
}

.ig-modal-viewpost svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

@media (max-width: 600px) {
    .ig-modal-dialog {
        max-width: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        height: 100%;
    }

    .ig-modal-info {
        max-height: 50vh;
    }
}
