.image-viewer {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: #f5f5f5;
    overflow-y: auto;
    scroll-behavior: smooth;
    touch-action: pan-y;
}

body.dark-mode .image-viewer {
    background-color: var(--page-bg);
}

.image-viewer.active {
    display: block;
}

.image-viewer-header {
    position: sticky;
    top: 0;
    z-index: 1001;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    min-height: 74px;
    padding: 16px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    touch-action: manipulation;
}

body.dark-mode .image-viewer-header {
    background: var(--page-bg);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.image-viewer-back {
    color: #333;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    padding: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-family: 'IvyEpic', 'Arial', sans-serif;
    transition: opacity 0.2s ease;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.2;
    white-space: nowrap;
}

body.dark-mode .image-viewer-back {
    color: var(--text-color);
}

.image-viewer-back:hover {
    opacity: 0.65;
}

.image-viewer-title {
    color: #333;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    margin: 0;
    padding: 0 12px;
}

body.dark-mode .image-viewer-title {
    color: var(--text-color);
}

.image-viewer-header::after {
    content: '';
    width: 44px;
}

.image-viewer-content {
    padding: 20px 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    will-change: transform;
    background: #f5f5f5;
    touch-action: pan-y;
}

body.dark-mode .image-viewer-content {
    background: var(--page-bg);
}

.image-viewer-page {
    margin-bottom: 20px;
    width: 800px;
    max-width: 90%;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    touch-action: auto;
}

body.dark-mode .image-viewer-page {
    background: var(--surface-bg);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.image-viewer-page img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.image-viewer-page-fallback {
    text-align: center;
    padding: 40px;
    color: #dc3545;
    background-color: #fff;
}

.back-to-top-button {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: #333;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    z-index: 1002;
    touch-action: manipulation;
}

body.dark-mode .back-to-top-button {
    background: rgba(45, 55, 64, 0.96);
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.12);
}

.back-to-top-button.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top-button:hover {
    background: #fff;
}

body.dark-mode .back-to-top-button:hover {
    background: #34404a;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.no-images-message {
    text-align: center;
    color: #333;
    padding: 40px;
    font-size: 18px;
}

body.dark-mode .no-images-message {
    color: var(--text-color);
}

.error-message {
    text-align: center;
    color: #ff6b6b;
    padding: 40px;
    font-size: 16px;
}

.nav-button {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

.nav-button:nth-child(1) {
    animation-delay: 0.1s;
}

.nav-button:nth-child(2) {
    animation-delay: 0.2s;
}

.nav-button:nth-child(3) {
    animation-delay: 0.3s;
}

.nav-button:nth-child(4) {
    animation-delay: 0.4s;
}

.nav-button:nth-child(5) {
    animation-delay: 0.5s;
}

.nav-button:nth-child(6) {
    animation-delay: 0.6s;
}

.nav-button:nth-child(7) {
    animation-delay: 0.7s;
}

.nav-button:nth-child(8) {
    animation-delay: 0.8s;
}

.nav-button:nth-child(9) {
    animation-delay: 0.9s;
}

.nav-button:nth-child(10) {
    animation-delay: 1s;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .image-viewer-header {
        min-height: 66px;
        padding: 14px 16px;
    }

    .image-viewer-title {
        font-size: 0.88rem;
        padding: 0 10px;
    }

    .image-viewer-content {
        padding: 16px 0 24px;
    }

    .image-viewer-page {
        max-width: 94%;
        margin-bottom: 16px;
    }

    .back-to-top-button {
        right: 16px;
        bottom: 16px;
        width: 42px;
        height: 42px;
    }
}
