.slideshow-root {
    position: fixed; inset: 0; z-index: 80;
    display: none;
    background: radial-gradient(circle at center, #241a10 0%, #120d07 80%);
    color: var(--paper);
    overflow: hidden;
}
.slideshow-root[aria-hidden="false"] {
    display: grid;
    place-items: center;
}

.slideshow-stage {
    position: relative;
    width: min(92vw, 38rem);
    max-height: 88vh;
}

.slideshow-card {
    background: var(--paper);
    color: var(--ink);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-serif);
    font-size: 1.3rem;
    line-height: 1.6;
    animation: ssFade .6s ease;
    max-height: 82vh;
    overflow-y: auto;
}
.slideshow-card .salutation { font-style: italic; font-size: 1.55rem; margin: 0 0 1rem; }
.slideshow-card .body { white-space: pre-wrap; margin: 0 0 1.25rem; }
.slideshow-card .signoff { font-style: italic; text-align: right; margin: 0; }
.slideshow-attachments {
    margin-top: 1rem;
    display: grid;
    gap: .5rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: start;
}
.slideshow-attachments.single {
    display: flex;
    justify-content: center;
}
.slideshow-attachments.single .att {
    flex: 0 0 auto;
    max-width: 100%;
    max-height: 55vh;
}
.slideshow-attachments .att {
    aspect-ratio: 4 / 3; /* JS overrides via style.aspectRatio when known */
    background: var(--envelope);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 0;
}
.slideshow-attachments .att.portrait {
    max-height: 50vh;
}
.slideshow-attachments .att img,
.slideshow-attachments .att video {
    width: 100%; height: 100%;
    /* `contain` so portrait content isn't center-cropped when the cell's
       aspect ratio doesn't match (e.g., when DB width/height were missing
       and we fell back to the default 4:3). The envelope color shows as
       a soft letterbox in that case. */
    object-fit: contain;
    display: block;
}

@keyframes ssFade {
    from { opacity: 0; transform: translateY(8px) scale(.995); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Gallery slideshow — bare media item per slide, full-screen-ish. */
.gallery-slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .9rem;
    max-width: 92vw;
    max-height: 90vh;
    animation: ssFade .5s ease;
}
.gallery-slide-media {
    max-width: 92vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, .35);
    box-shadow: var(--shadow-lg);
}
.gallery-slide-caption {
    color: var(--paper);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.1rem;
    text-align: center;
    max-width: 36rem;
    padding: .5rem 1rem;
    background: rgba(0, 0, 0, .35);
    border-radius: var(--radius);
}

.slideshow-controls {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex; gap: .5rem;
    background: rgba(20, 14, 8, .6);
    padding: .5rem .75rem;
    border-radius: 999px;
    color: var(--paper);
    font-size: .9rem;
}
.slideshow-controls button {
    background: transparent;
    color: var(--paper);
    border: 0;
    font: inherit;
    cursor: pointer;
    opacity: .85;
    padding: .25rem .5rem;
    border-radius: var(--radius);
}
.slideshow-controls button:hover { opacity: 1; background: rgba(255, 255, 255, .1); }

.slideshow-progress {
    position: fixed; left: 0; right: 0; top: 0;
    height: 2px; background: rgba(255, 255, 255, .08);
    z-index: 81;
}
.slideshow-progress .bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width .15s linear;
}

.slideshow-close {
    position: fixed; top: 1rem; right: 1rem;
    background: rgba(255, 255, 255, .15);
    color: var(--paper);
    border: 0;
    font: inherit;
    padding: .4rem .75rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.slideshow-close:hover { background: rgba(255, 255, 255, .25); }
