/* =========================================================
   우리 단지 사진관
   기존 style.css / community.css 디자인 토큰을 그대로 사용
========================================================= */

.gallery-sub-header {
    margin-bottom: 0;
}

.gallery-shell,
.gallery-detail-shell {
    width: min(1200px, calc(100% - 48px));
    margin: 22px auto 70px;
}

.gallery-intro-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 27px 30px;
    margin-bottom: 26px;
    overflow: hidden;
    position: relative;
    background:
        radial-gradient(circle at 92% 5%, rgba(232, 224, 255, .85), transparent 150px),
        radial-gradient(circle at 8% 110%, rgba(220, 242, 255, .95), transparent 175px),
        rgba(255,255,255,.94);
    border: 1px solid rgba(211, 221, 239, .78);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
}

.gallery-intro-card > * {
    position: relative;
    z-index: 1;
}

.gallery-intro-label {
    display: inline-flex;
    padding: 5px 9px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: #eef4ff;
    color: #6687bd;
    font-size: 11px;
    font-weight: 900;
}

.gallery-intro-card h2 {
    color: #4f5d74;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -.6px;
    margin-bottom: 6px;
}

.gallery-intro-card p {
    color: #7c879a;
    font-size: 13px;
    line-height: 1.75;
}

.gallery-write-btn {
    min-width: 118px;
    flex-shrink: 0;
}

.gallery-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 4px 14px;
    color: #768297;
    font-size: 13px;
    font-weight: 800;
}

.gallery-list-head strong {
    margin-left: 5px;
    color: #5f82bd;
}

.gallery-list-note {
    color: #9aa4b5;
    font-size: 11px;
    font-weight: 700;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.gallery-grid-all {
    grid-column: 1 / -1;
}

.gallery-card {
    display: block;
    overflow: hidden;
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(216, 224, 238, .86);
    border-radius: 21px;
    box-shadow: var(--shadow-md);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.gallery-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: #c7d8f3;
}

.gallery-card-cover {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background:
        linear-gradient(145deg, #edf3fb, #f5f1ff);
}

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

.gallery-card:hover .gallery-card-cover img {
    transform: scale(1.035);
}

.gallery-card-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #9aabc5;
    font-size: 38px;
}

.gallery-photo-count {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(26, 37, 55, .72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
}

.gallery-card-body {
    padding: 17px 18px 18px;
}

.gallery-card-title {
    color: #4b5870;
    font-size: 16px;
    font-weight: 900;
    line-height: 1.45;
    margin-bottom: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    color: #929dac;
    font-size: 11px;
    font-weight: 650;
}

.gallery-card-meta strong {
    color: #69758a;
    font-weight: 800;
}

.gallery-guide-box {
    margin-top: 24px;
}

/* ---------- 작성 / 수정 ---------- */
.gallery-form-card {
    padding-top: 26px;
}

.gallery-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.gallery-upload-card {
    margin: 24px 0;
    padding: 21px;
    border: 1px dashed #cdd8e8;
    border-radius: 20px;
    background: linear-gradient(145deg, #fbfcff, #f7f5ff);
}

.gallery-upload-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
}

.gallery-upload-head strong {
    color: #526078;
    font-size: 15px;
    font-weight: 900;
}

.gallery-upload-head strong em,
.community-field label em {
    color: #e27777;
    font-style: normal;
    font-size: 11px;
}

.gallery-upload-head p {
    margin-top: 4px;
    color: #929dad;
    font-size: 11px;
}

.gallery-upload-head > span {
    padding: 5px 8px;
    border-radius: 8px;
    background: #edf3ff;
    color: #6e8fca;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}

.gallery-upload-button {
    min-height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    border: 1px solid #dce4f0;
    border-radius: 16px;
    background: #fff;
    color: #728097;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.gallery-upload-button:hover {
    border-color: #aac4ec;
    background: #fafdff;
    transform: translateY(-1px);
}

.gallery-upload-icon {
    color: #81a5dd;
    font-size: 26px;
    font-weight: 400;
    line-height: 1;
}

.gallery-file-input {
    display: none;
}

.gallery-preview-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 13px;
}

.gallery-preview-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    border-radius: 13px;
    background: #edf1f6;
    border: 1px solid #e1e7ef;
}

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

.gallery-preview-item.marked-delete img {
    opacity: .28;
    filter: grayscale(.8);
}

.gallery-preview-item.marked-delete::after {
    content: "삭제 예정";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #b45353;
    font-size: 10px;
    font-weight: 900;
    pointer-events: none;
}

.gallery-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(27,38,57,.78);
    color: #fff;
    font-size: 17px;
    line-height: 1;
    box-shadow: 0 3px 9px rgba(0,0,0,.14);
}

.gallery-existing-wrap {
    margin-top: 16px;
}

.gallery-existing-wrap h3 {
    color: #758096;
    font-size: 12px;
    font-weight: 900;
}

.gallery-sort-guide {
    margin-top: 12px;
    color: #9aa5b5;
    font-size: 10.5px;
    line-height: 1.65;
}

/* ---------- 상세 ---------- */
.gallery-detail-shell {
    max-width: 1040px;
}

.gallery-detail-card {
    overflow: hidden;
    border: 1px solid rgba(216,224,238,.88);
    border-radius: 24px;
    background: rgba(255,255,255,.97);
    box-shadow: var(--shadow);
}

.gallery-viewer {
    padding: 18px;
    background:
        radial-gradient(circle at 0 0, rgba(115, 146, 200, .14), transparent 34%),
        radial-gradient(circle at 100% 100%, rgba(163, 143, 211, .14), transparent 36%),
        #18202c;
}

.gallery-main-stage {
    position: relative;
    min-height: 360px;
    height: min(70vh, 720px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 16px;
    background: #111821;
}

.gallery-main-stage img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
}

.gallery-stage-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255,255,255,.82);
    color: #465268;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 5px 18px rgba(0,0,0,.18);
    backdrop-filter: blur(6px);
}

.gallery-stage-nav.prev { left: 13px; }
.gallery-stage-nav.next { right: 13px; }
.gallery-stage-nav[hidden] { display: none; }

.gallery-stage-count {
    position: absolute;
    right: 13px;
    bottom: 13px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(12,18,27,.66);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-top: 12px;
    padding: 1px 1px 4px;
    scrollbar-width: none;
}

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

.gallery-thumb {
    flex: 0 0 72px;
    width: 72px;
    height: 58px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 10px;
    background: #242e3c;
    opacity: .62;
    transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
}

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

.gallery-thumb.active {
    border-color: #9fc0f2;
    opacity: 1;
    transform: translateY(-1px);
}

.gallery-info {
    padding: 28px 30px 30px;
}

.gallery-info-title {
    color: #45536a;
    font-size: 26px;
    font-weight: 900;
    letter-spacing: -.8px;
    line-height: 1.35;
    word-break: keep-all;
}

.gallery-info-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 15px;
    margin-top: 11px;
    padding-bottom: 20px;
    border-bottom: 1px solid #edf1f6;
    color: #8e99aa;
    font-size: 11.5px;
    font-weight: 700;
}

.gallery-info-meta strong {
    color: #68758b;
}

.gallery-description {
    min-height: 90px;
    padding: 24px 0 3px;
    color: #465164;
    font-size: 14px;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-word;
}

.gallery-description.empty {
    color: #a0a9b8;
}

.gallery-detail-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 26px;
}

/* ---------- 라이트박스 ---------- */
.gallery-lightbox {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    padding: 36px 58px;
    border: 0;
    background: rgba(8, 12, 19, .96);
}

.gallery-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox::backdrop {
    background: rgba(0,0,0,.88);
}

.gallery-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gallery-lightbox-close {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 2;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: rgba(255,255,255,.13);
    color: #fff;
    font-size: 29px;
}

.gallery-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 34px;
}

.gallery-lightbox-nav.prev { left: 15px; }
.gallery-lightbox-nav.next { right: 15px; }

.gallery-lightbox-count {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.13);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
}

@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .gallery-preview-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .gallery-shell,
    .gallery-detail-shell {
        width: calc(100% - 32px);
        margin-top: 4px;
        margin-bottom: 50px;
    }

    .gallery-intro-card {
        flex-direction: column;
        align-items: stretch;
        padding: 21px 18px;
        gap: 18px;
    }

    .gallery-intro-card h2 {
        font-size: 19px;
    }

    .gallery-write-btn {
        width: 100%;
        text-align: center;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }

    .gallery-card {
        border-radius: 17px;
    }

    .gallery-card-body {
        padding: 13px 13px 14px;
    }

    .gallery-card-title {
        font-size: 14px;
        margin-bottom: 7px;
    }

    .gallery-card-meta {
        gap: 4px 8px;
        font-size: 10px;
    }

    .gallery-form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .gallery-upload-card {
        padding: 16px;
    }

    .gallery-preview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .gallery-viewer {
        padding: 9px;
    }

    .gallery-main-stage {
        min-height: 260px;
        height: 58vh;
        border-radius: 13px;
    }

    .gallery-stage-nav {
        width: 37px;
        height: 37px;
        font-size: 24px;
    }

    .gallery-thumb {
        flex-basis: 60px;
        width: 60px;
        height: 48px;
    }

    .gallery-info {
        padding: 22px 18px 24px;
    }

    .gallery-info-title {
        font-size: 21px;
    }

    .gallery-lightbox {
        padding: 54px 10px 50px;
    }
}

@media (max-width: 430px) {
    .gallery-grid {
        grid-template-columns: 1fr 1fr;
    }

    .gallery-preview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .gallery-photo-count {
        right: 8px;
        bottom: 8px;
    }
}


/* =========================================================
   iOS Safari date input width / native appearance fix
========================================================= */
#gallery-taken-at {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 46px;
    box-sizing: border-box;
    padding: 0 14px;
    line-height: normal;
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
}

/* iOS Safari가 날짜 텍스트를 위쪽에 붙이는 현상 보정 */
#gallery-taken-at::-webkit-date-and-time-value {
    width: 100%;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    text-align: left;
    line-height: 1.2;
}

#gallery-taken-at::-webkit-datetime-edit {
    height: 44px;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

#gallery-taken-at::-webkit-datetime-edit-fields-wrapper {
    margin: 0;
    padding: 0;
}

#gallery-taken-at::-webkit-calendar-picker-indicator {
    margin: 0 0 0 auto;
    padding: 0;
    flex: 0 0 auto;
}

@media (max-width: 760px) {
    .gallery-form-grid,
    .gallery-form-grid > .community-field {
        min-width: 0;
        width: 100%;
    }

    #gallery-taken-at {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        font-size: 16px;
    }
}
