.mg-wrap { display: grid; grid-template-columns: repeat(var(--mg-cols, 4), 1fr); grid-auto-rows: var(--mg-row, 180px); gap: var(--mg-gap, 10px); margin: 1.5rem 0; }
.mg-item { position: relative; overflow: hidden; border-radius: 5px; background: #e8e8e8; }
.mg-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.mg-item:hover img { transform: scale(1.05); }
.mg-item a { display: block; width: 100%; height: 100%; }
.mg-item.wide { grid-column: span 2; }
.mg-item.tall { grid-row: span 2; }
.mg-item.big  { grid-column: span 2; grid-row: span 2; }
.mg-caption { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px 12px; background: linear-gradient(transparent, rgba(0,0,0,0.55)); color: #fff; font-size: 13px; opacity: 0; transition: opacity 0.3s; }
.mg-item:hover .mg-caption { opacity: 1; }

/* Lightbox – vollflächig, unabhängig vom Theme-Wrapper */
.mg-lightbox {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: rgba(0,0,0,0.92);
    z-index: 999999 !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.mg-lightbox.active { display: flex; }
.mg-lb-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
    box-sizing: border-box;
}
.mg-lb-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}
.mg-lb-caption { color: rgba(255,255,255,0.75); font-size: 13px; margin-top: 12px; flex-shrink: 0; }
.mg-lb-close, .mg-lb-prev, .mg-lb-next {
    position: fixed;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 12px;
    z-index: 1000000;
    line-height: 1;
}
.mg-lb-close:hover, .mg-lb-prev:hover, .mg-lb-next:hover { opacity: 1; }
.mg-lb-close { top: 16px; right: 20px; font-size: 2.4rem; }
.mg-lb-prev  { left: 16px; top: 50%; transform: translateY(-50%); font-size: 3.5rem; }
.mg-lb-next  { right: 16px; top: 50%; transform: translateY(-50%); font-size: 3.5rem; }

@media (max-width: 768px) {
    .mg-wrap { grid-template-columns: repeat(2, 1fr) !important; grid-auto-rows: 130px !important; }
    .mg-lb-inner { padding: 50px 50px; }
}
@media (max-width: 480px) {
    .mg-wrap { grid-template-columns: 1fr 1fr !important; grid-auto-rows: 100px !important; }
    .mg-lb-inner { padding: 40px 16px; }
}
