:root {
    --gallery-bg: #f7ecc0;
    --gallery-ink: #2b2b2b;
    --gallery-accent: #5aa0c6;
    --gallery-border: rgba(90, 70, 40, 0.2);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body.gallery-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100%;
    overflow: hidden;
    background: var(--gallery-bg);
    color: var(--gallery-ink);
    font-family: "Noto Sans KR", sans-serif;
}

.gallery-header {
    flex-shrink: 0;
    z-index: 10;
    padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 4vw, 3rem) 1rem;
    border-bottom: 1px solid var(--gallery-border);
    background: rgba(247, 236, 192, 0.96);
    backdrop-filter: blur(6px);
}

.gallery-header-inner {
    position: relative;
    width: 100%;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.gallery-header-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.gallery-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--gallery-accent);
    text-decoration: none;
    line-height: 0;
    opacity: 0.9;
    transition: opacity 0.15s ease;
}

.gallery-nav-link:hover {
    opacity: 1;
}

.gallery-nav-icon {
    width: 1.6rem;
    height: 1.6rem;
}

.gallery-tabs-wrap {
    max-width: 1100px;
    margin: 0 auto;
}

.gallery-title {
    margin: 0 0 0.75rem;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gallery-ink);
}

.gallery-header-nav-start,
.gallery-header-nav-end {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gallery-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.gallery-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--gallery-border);
    background: #fffdf6;
    color: var(--gallery-ink);
    text-decoration: none;
    font-size: 0.92rem;
}

.gallery-tab.is-active {
    background: var(--gallery-accent);
    border-color: var(--gallery-accent);
    color: #fff;
}

.gallery-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem clamp(1.25rem, 4vw, 3rem) 2.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(90, 160, 198, 0.55) transparent;
}

.gallery-main::-webkit-scrollbar {
    width: 8px;
}

.gallery-main::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

.gallery-main::-webkit-scrollbar-thumb {
    background: linear-gradient(
        180deg,
        rgba(90, 160, 198, 0.35) 0%,
        rgba(90, 160, 198, 0.65) 100%
    );
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.gallery-main::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
        180deg,
        rgba(90, 160, 198, 0.55) 0%,
        rgba(61, 133, 168, 0.85) 100%
    );
    background-clip: padding-box;
}

.gallery-empty {
    text-align: center;
    color: rgba(43, 43, 43, 0.7);
    padding: 3rem 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.gallery-item {
    display: flex;
    flex-direction: column;
    margin: 0;
    min-width: 0;
}

.gallery-item-media {
    position: relative;
    overflow: hidden;
    border: 0;
    padding: 0;
    width: 100%;
    border-radius: 12px;
    cursor: pointer;
    aspect-ratio: 1;
    background: #fffdf6;
}

.gallery-item-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.gallery-item-media:hover img {
    transform: scale(1.06);
}

.gallery-item-caption {
    margin: 0.45rem 0 0;
    padding: 0 0.2rem;
    font-size: 1.2rem;
    line-height: 1.4;
    text-align: center;
    color: rgba(43, 43, 43, 0.82);
    word-break: keep-all;
}

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    color: #fff;
    font-size: 2rem;
    padding: 1rem;
    cursor: pointer;
    z-index: 2001;
    border: 0;
    background: transparent;
}

.lightbox-close {
    top: 20px;
    right: 20px;
    font-size: 3rem;
    line-height: 1;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

@media (max-width: 767px) {
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        font-size: 1.5rem;
        padding: 0.5rem;
    }
}
