body.single-memorial .communio-memory-gallery {
    display: grid;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: inherit;
    background: color-mix(in srgb, currentColor 5%, transparent);
}
body.single-memorial .communio-memory-gallery__item {
    position: relative;
    display: block;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}
body.single-memorial .communio-memory-gallery__item img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
}
body.single-memorial .communio-memory-gallery--1 { aspect-ratio: 4 / 3; }
body.single-memorial .communio-memory-gallery--2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; gap: 3px; }
body.single-memorial .communio-memory-gallery--3,
body.single-memorial .communio-memory-gallery--4 { grid-template-columns: 1.45fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 10; gap: 3px; }
body.single-memorial .communio-memory-gallery--3 .communio-memory-gallery__item:first-child,
body.single-memorial .communio-memory-gallery--4 .communio-memory-gallery__item:first-child { grid-row: 1 / 3; }
body.single-memorial .communio-memory-gallery--3 .communio-memory-gallery__item:nth-child(n+4),
body.single-memorial .communio-memory-gallery--4 .communio-memory-gallery__item:nth-child(n+4) { display: none; }
body.single-memorial .communio-memory-gallery__more {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(24, 35, 38, .55);
    font: 700 clamp(18px, 5vw, 28px)/1 system-ui, sans-serif;
}
body.single-memorial .communio-memory-no-images .communio-recuerdo-imagen { display: none !important; }
body.single-memorial .communio-memory-no-images > .e-con-inner { grid-template-columns: minmax(0, 1fr) !important; }

/* Presentación única y adaptativa, independiente de selecciones históricas. */
body.single-memorial .communio-recuerdo-card.communio-memory-card,
body.single-memorial .communio-recuerdo-card.communio-memory-card > .e-con-inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    min-width: 0 !important;
}
body.single-memorial .communio-memory-card .communio-recuerdo-imagen {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    transform: none !important;
    overflow: hidden !important;
}
body.single-memorial .communio-memory-card .communio-memory-gallery--1 { aspect-ratio: 4 / 3; }
body.single-memorial .communio-memory-card.communio-memory-no-images .communio-recuerdo-imagen { display: none !important; }
body.single-memorial .communio-memory-card.communio-memory-no-images :is(.communio-recuerdo-identidad,.communio-recuerdo-contenido) {
    grid-column: 1 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}

.communio-memory-viewer[hidden] { display: none !important; }
.communio-memory-viewer { position: fixed; inset: 0; z-index: 1000005; }
.communio-memory-viewer__backdrop { position: absolute; inset: 0; background: rgba(8, 12, 14, .92); backdrop-filter: blur(8px); }
.communio-memory-viewer__dialog { position: absolute; inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; grid-template-rows: minmax(0, 1fr) auto; align-items: center; }
.communio-memory-viewer figure { grid-column: 2; display: grid; place-items: center; max-width: 100%; max-height: 100%; margin: 0; overflow: hidden; }
.communio-memory-viewer figure img { display: block; max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; touch-action: pinch-zoom; }
.communio-memory-viewer figcaption { margin-top: 10px; color: #fff; font: 400 14px/1.4 system-ui, sans-serif; text-align: center; }
.communio-memory-viewer button { position: relative; z-index: 2; width: 44px; height: 44px; padding: 0; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; color: #fff; background: rgba(20,28,31,.72); font-size: 34px; line-height: 1; cursor: pointer; }
.communio-memory-viewer__close { position: absolute !important; top: 0; right: 0; }
.communio-memory-viewer__previous { grid-column: 1; grid-row: 1; }
.communio-memory-viewer__next { grid-column: 3; grid-row: 1; }
.communio-memory-viewer__counter { grid-column: 2; grid-row: 2; margin: 8px 0 0; color: #fff; font: 600 13px/1 system-ui, sans-serif; text-align: center; }
body.communio-memory-viewer-open { overflow: hidden; }

@media (max-width: 600px) {
    .communio-memory-viewer__dialog { grid-template-columns: 42px minmax(0, 1fr) 42px; }
    .communio-memory-viewer button { width: 38px; height: 38px; font-size: 29px; }
}
