.page-viewport {
    overflow: hidden;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

.page-track {
    display: flex;
    width: 200%;
    height: 100%;
    transition: transform 0.35s ease;
}

.page-track.show-gallery {
    transform: translateX(-50%);
}

.page-panel {
    width: 50%;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
}

.gallery-panel {
    background-color: #f5f5f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
}

.gallery-panel-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.gallery-panel-header h1 {
    font-size: 1.5rem;
    font-weight: normal;
    font-style: normal;
    font-family: 'Times New Roman', Times, serif;
    color: #000;
    padding: 0;
    border: none;
}

.gallery-back,
.gallery-open {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #0000EE;
    font-family: Georgia, 'Times New Roman', serif;
    text-decoration: underline;
}

.gallery-back:hover,
.gallery-open:hover .label {
    color: #EE0000;
}

.gallery-open {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.3;
    max-width: 72px;
    text-align: center;
}

.gallery-open .arrow {
    font-size: 1.25rem;
    line-height: 1;
    color: #000;
}

.gallery-open .label {
    font-size: 0.75rem;
    color: #0000EE;
    text-decoration: underline;
}

body.showing-gallery .gallery-open {
    display: none;
}

.gallery-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.gallery-media {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-media img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    border: 1px solid #ddd;
    background-color: #fff;
}

.gallery-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background-color: #000;
}

.gallery-story {
    flex: 0 0 300px;
    max-height: 100%;
    overflow-y: auto;
    text-align: left;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.9rem;
    line-height: 1.65;
    color: #333;
    white-space: pre-wrap;
    padding-right: 4px;
}

.gallery-caption {
    font-size: 0.8rem;
    font-style: italic;
    color: #555;
    text-align: center;
    margin-top: 10px;
}

.gallery-strip {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 0 2px;
    margin-top: 6px;
    flex-shrink: 0;
}

.gallery-strip::-webkit-scrollbar {
    display: none;
}

.gallery-thumb {
    flex: 0 0 auto;
    width: 68px;
    height: 48px;
    padding: 0;
    border: 1px solid #ddd;
    background-color: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: width 0.25s ease, height 0.25s ease;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-thumb.is-video {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1rem;
    color: #000;
}

.gallery-thumb.is-active {
    border-color: #000;
}

@media (max-width: 900px) {
    .gallery-stage {
        flex-direction: column;
        gap: 12px;
    }

    .gallery-media {
        flex: 1;
        min-height: 0;
        width: 100%;
    }

    .gallery-story {
        flex: 0 0 auto;
        max-height: 30%;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .gallery-open {
        right: 10px;
        max-width: 56px;
    }

    .gallery-panel-header h1 {
        font-size: 1.25rem;
    }
}
