.hp-photo-manager,
.hp-photo-upload,
.hp-photo-recent {
    max-width: 960px;
    margin: 2rem auto;
}

.hp-photo-upload {
    padding: 1.4rem;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .07);
}

.hp-photo-upload p {
    margin: 0 0 1.15rem;
}

.hp-photo-upload label {
    display: block;
    margin-bottom: .4rem;
}

.hp-photo-upload input[type="text"] {
    box-sizing: border-box;
    width: 100%;
    min-height: 52px;
    padding: .7rem;
    border: 1px solid #aaa;
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.hp-photo-choice {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.hp-photo-choice__option {
    position: relative;
}

.hp-photo-choice__input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.hp-photo-choice__button {
    display: flex !important;
    box-sizing: border-box;
    min-height: 150px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin: 0 !important;
    padding: 1rem;
    border: 2px solid #222;
    border-radius: 14px;
    background: #fff;
    color: #222;
    text-align: center;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.hp-photo-choice__button:hover,
.hp-photo-choice__input:focus-visible + .hp-photo-choice__button {
    transform: translateY(-2px);
    background: #fff4d5;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
}

.hp-photo-choice__button strong,
.hp-photo-choice__button span {
    display: block;
}

.hp-photo-choice__button > span:last-child {
    font-size: .9rem;
    font-weight: 400;
    opacity: .75;
}

.hp-photo-choice__icon {
    font-size: 2.5rem;
    line-height: 1;
}

.hp-photo-selected {
    padding: .75rem .9rem;
    border-radius: 8px;
    background: #f2f2f2;
    font-size: .95rem;
}

.hp-photo-upload__hint {
    font-size: .92rem;
    opacity: .8;
}

.hp-photo-button {
    min-height: 52px;
    padding: .75rem 1.25rem;
    border: 0;
    border-radius: 9px;
    background: #222;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.hp-photo-button:disabled {
    cursor: wait;
    opacity: .65;
}

.hp-photo-notice {
    margin: 1rem 0;
    padding: 1rem;
    border-left: 5px solid #d99400;
    background: #fff4d5;
}

.hp-photo-notice--success {
    border-left-color: #2c883c;
    background: #e7f8e9;
}

.hp-photo-notice--error {
    border-left-color: #c52a2a;
    background: #ffe7e7;
}

.hp-gallery {
    display: grid;
    grid-template-columns: repeat(var(--hp-gallery-columns, 3), minmax(0, 1fr));
    align-items: start;
    gap: 1rem;
}

.hp-gallery__item {
    align-self: start;
    overflow: hidden;
    margin: 0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
}

.hp-gallery__link {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #eee;
    cursor: zoom-in;
}

.hp-gallery__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}

.hp-gallery__link:hover .hp-gallery__image,
.hp-gallery__link:focus-visible .hp-gallery__image {
    transform: scale(1.025);
}

.hp-gallery__item figcaption {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: .65rem .8rem;
    background: #fff;
    font-size: .95rem;
}

.hp-gallery-pagination {
    margin: 2rem 0 0;
}

.hp-gallery-pagination ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .45rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hp-gallery-pagination a,
.hp-gallery-pagination .current,
.hp-gallery-pagination .dots {
    display: inline-flex;
    min-width: 42px;
    min-height: 42px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: .45rem .7rem;
    border-radius: 8px;
    background: #fff;
    color: #222;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.hp-gallery-pagination .current {
    background: #222;
    color: #fff;
    font-weight: 700;
}

.hp-gallery-pagination a:hover,
.hp-gallery-pagination a:focus-visible {
    background: #fff4d5;
}

.hp-lightbox-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.hp-lightbox-open {
    position: fixed;
    left: 0;
    width: 100%;
}

.hp-lightbox {
    position: fixed;
    z-index: 2147483646;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #080808;
    color: #fff;
    isolation: isolate;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

.hp-lightbox:fullscreen {
    width: 100vw;
    height: 100vh;
    background: #080808;
}

.hp-lightbox[hidden] {
    display: none;
}

.hp-lightbox__topbar {
    position: absolute;
    z-index: 4;
    top: 0;
    right: 0;
    display: flex;
    gap: .45rem;
    padding: max(.75rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) .75rem .75rem;
}

.hp-lightbox button.hp-lightbox__close,
.hp-lightbox button.hp-lightbox__fullscreen,
.hp-lightbox button.hp-lightbox__previous,
.hp-lightbox button.hp-lightbox__next {
    appearance: none !important;
    -webkit-appearance: none !important;
    display: inline-flex !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, .22) !important;
    border-radius: 999px !important;
    background: rgba(18, 18, 18, .62) !important;
    color: #fff !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .3) !important;
    text-decoration: none !important;
    cursor: pointer;
    opacity: .88;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity .16s ease, background-color .16s ease, transform .16s ease;
}

.hp-lightbox button.hp-lightbox__close:hover,
.hp-lightbox button.hp-lightbox__fullscreen:hover,
.hp-lightbox button.hp-lightbox__previous:hover,
.hp-lightbox button.hp-lightbox__next:hover,
.hp-lightbox button.hp-lightbox__close:focus-visible,
.hp-lightbox button.hp-lightbox__fullscreen:focus-visible,
.hp-lightbox button.hp-lightbox__previous:focus-visible,
.hp-lightbox button.hp-lightbox__next:focus-visible {
    background: rgba(40, 40, 40, .9) !important;
    opacity: 1;
    outline: 2px solid rgba(255, 255, 255, .92) !important;
    outline-offset: 2px;
}

.hp-lightbox button.hp-lightbox__close:active,
.hp-lightbox button.hp-lightbox__fullscreen:active,
.hp-lightbox button.hp-lightbox__previous:active,
.hp-lightbox button.hp-lightbox__next:active {
    transform: scale(.94);
}

.hp-lightbox__close,
.hp-lightbox__fullscreen {
    width: 46px !important;
    height: 46px !important;
}

.hp-lightbox__fullscreen.is-active {
    background: rgba(255, 255, 255, .2) !important;
}

.hp-lightbox button svg {
    display: block;
    width: 23px;
    height: 23px;
    overflow: visible;
    pointer-events: none;
}

.hp-lightbox button svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hp-lightbox__previous,
.hp-lightbox__next {
    position: absolute;
    z-index: 3;
    top: 50%;
    width: 54px !important;
    height: 54px !important;
    transform: translateY(-50%);
}

.hp-lightbox__previous:active,
.hp-lightbox__next:active {
    transform: translateY(-50%) scale(.94) !important;
}

.hp-lightbox__previous {
    left: max(1rem, env(safe-area-inset-left));
}

.hp-lightbox__next {
    right: max(1rem, env(safe-area-inset-right));
}

.hp-lightbox__stage {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: flex;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: max(4rem, env(safe-area-inset-top)) max(5.5rem, env(safe-area-inset-right)) max(5.5rem, env(safe-area-inset-bottom)) max(5.5rem, env(safe-area-inset-left));
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.hp-lightbox--dragging .hp-lightbox__stage {
    cursor: grabbing;
}

.hp-lightbox__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    transform: translate3d(var(--hp-lightbox-drag-x, 0), 0, 0);
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .42));
    transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease;
    will-change: transform, opacity;
    pointer-events: none;
}

.hp-lightbox--dragging .hp-lightbox__image {
    transition: none;
}

.hp-lightbox__image--from-left {
    transform: translate3d(-28px, 0, 0);
    opacity: .55;
}

.hp-lightbox__image--from-right {
    transform: translate3d(28px, 0, 0);
    opacity: .55;
}

.hp-lightbox__footer {
    position: absolute;
    z-index: 4;
    right: 0;
    bottom: 0;
    left: 0;
    box-sizing: border-box;
    padding: .8rem max(1rem, env(safe-area-inset-right)) max(.8rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: rgba(0, 0, 0, .58);
    color: #fff;
    text-align: center;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.hp-lightbox__footer[hidden] {
    display: none;
}

.hp-lightbox__caption {
    display: block;
    font-size: clamp(.95rem, 2vw, 1.08rem);
    font-weight: 650;
    line-height: 1.3;
    text-shadow: 0 1px 7px rgba(0, 0, 0, .95);
}

.hp-photo-recent__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 1rem;
}

.hp-photo-recent__item {
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 12px;
    background: #fff;
}

.hp-photo-recent__item img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.hp-photo-delete {
    display: block;
    padding: .65rem;
    color: #a21b1b !important;
    text-align: center;
    font-weight: 700;
}


@media (prefers-reduced-motion: reduce) {
    .hp-lightbox__image,
    .hp-lightbox button,
    .hp-gallery__image {
        transition: none !important;
    }
}

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

@media (max-width: 600px) {
    .hp-photo-choice {
        grid-template-columns: 1fr;
    }

    .hp-photo-choice__button {
        min-height: 120px;
    }

    .hp-lightbox__stage {
        inset: 0;
        padding: 0;
        touch-action: pan-y;
    }

    .hp-lightbox__image {
        width: 100vw;
        width: 100dvw;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        max-height: none;
        object-fit: contain;
        object-position: center;
        filter: none;
    }

    .hp-lightbox__footer {
        padding-top: .7rem;
        padding-bottom: max(.7rem, env(safe-area-inset-bottom));
        background: rgba(0, 0, 0, .62);
    }

    .hp-lightbox button.hp-lightbox__previous,
    .hp-lightbox button.hp-lightbox__next {
        top: 15%;
        width: 68px !important;
        height: 70% !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        opacity: .72;
        transform: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .hp-lightbox button.hp-lightbox__previous:hover,
    .hp-lightbox button.hp-lightbox__next:hover,
    .hp-lightbox button.hp-lightbox__previous:focus-visible,
    .hp-lightbox button.hp-lightbox__next:focus-visible {
        background: transparent !important;
        outline: 0 !important;
        opacity: 1;
    }

    .hp-lightbox button.hp-lightbox__previous:active,
    .hp-lightbox button.hp-lightbox__next:active {
        transform: none !important;
    }

    .hp-lightbox__previous {
        left: 0;
        justify-content: flex-start !important;
        padding-left: max(.45rem, env(safe-area-inset-left)) !important;
    }

    .hp-lightbox__next {
        right: 0;
        justify-content: flex-end !important;
        padding-right: max(.45rem, env(safe-area-inset-right)) !important;
    }

    .hp-lightbox__previous svg,
    .hp-lightbox__next svg {
        width: 31px;
        height: 31px;
        filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .9));
    }

    .hp-lightbox__topbar {
        gap: .35rem;
    }

    .hp-lightbox__close,
    .hp-lightbox__fullscreen {
        width: 44px !important;
        height: 44px !important;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .hp-lightbox__stage {
        inset: 0;
        padding: 0;
    }

    .hp-lightbox__image {
        width: 100vw;
        width: 100dvw;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        max-height: none;
        object-fit: contain;
        object-position: center;
        filter: none;
    }

    .hp-lightbox__topbar {
        padding-top: max(.45rem, env(safe-area-inset-top));
        padding-right: max(.45rem, env(safe-area-inset-right));
    }

    .hp-lightbox__close,
    .hp-lightbox__fullscreen {
        width: 42px !important;
        height: 42px !important;
        background: rgba(8, 8, 8, .72) !important;
        border-color: rgba(255, 255, 255, .35) !important;
    }

    .hp-lightbox button.hp-lightbox__previous,
    .hp-lightbox button.hp-lightbox__next {
        top: 50% !important;
        width: 52px !important;
        height: 52px !important;
        border: 1px solid rgba(255, 255, 255, .32) !important;
        border-radius: 999px !important;
        background: rgba(8, 8, 8, .68) !important;
        box-shadow: 0 4px 18px rgba(0, 0, 0, .42) !important;
        opacity: .94;
        transform: translateY(-50%) !important;
        backdrop-filter: blur(7px);
        -webkit-backdrop-filter: blur(7px);
    }

    .hp-lightbox button.hp-lightbox__previous:hover,
    .hp-lightbox button.hp-lightbox__next:hover,
    .hp-lightbox button.hp-lightbox__previous:focus-visible,
    .hp-lightbox button.hp-lightbox__next:focus-visible {
        background: rgba(28, 28, 28, .9) !important;
        outline: 2px solid rgba(255, 255, 255, .92) !important;
        outline-offset: 2px;
    }

    .hp-lightbox button.hp-lightbox__previous:active,
    .hp-lightbox button.hp-lightbox__next:active {
        transform: translateY(-50%) scale(.94) !important;
    }

    .hp-lightbox__previous {
        left: max(.65rem, env(safe-area-inset-left));
        justify-content: center !important;
        padding: 0 !important;
    }

    .hp-lightbox__next {
        right: max(.65rem, env(safe-area-inset-right));
        justify-content: center !important;
        padding: 0 !important;
    }

    .hp-lightbox__previous svg,
    .hp-lightbox__next svg {
        width: 28px;
        height: 28px;
        filter: drop-shadow(0 2px 6px #000) drop-shadow(0 0 2px #000);
    }

    .hp-lightbox__footer {
        padding: .55rem max(4.8rem, env(safe-area-inset-right)) max(.55rem, env(safe-area-inset-bottom)) max(4.8rem, env(safe-area-inset-left));
        background: rgba(0, 0, 0, .62);
    }

    .hp-lightbox__caption {
        font-size: .9rem;
    }
}

@media (max-width: 520px) {
    .hp-gallery,
    .hp-photo-recent__grid {
        grid-template-columns: 1fr;
    }
}
