.photo-gallery {
    --gallery-ink: #203452;
    --gallery-muted: #52657e;
    --gallery-blue: #2655c8;
    --gallery-line: #dce5f1;
    width: min(1376px, calc(100% - 3rem));
    margin: 2rem auto 3.5rem;
    color: var(--gallery-ink);
}

.gallery-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem 2rem;
    padding: 1.6rem 1.8rem;
    border: 1px solid var(--gallery-line);
    border-radius: 20px;
    background: linear-gradient(110deg, #f8fbff, #ecf3ff 70%, #f8faff);
}

.gallery-heading h1 {
    margin: 0;
    color: inherit;
    font-size: clamp(1.45rem, 3vw, 2.15rem);
    font-weight: 850;
}

.gallery-search {
    display: flex;
    width: min(100%, 28rem);
    padding: .3rem;
    border: 1px solid #c8d6ea;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(30, 65, 110, .05);
}

.gallery-search:focus-within {
    border-color: var(--gallery-blue);
    box-shadow: 0 0 0 3px rgba(38, 85, 200, .15);
}

.gallery-search-input {
    flex: 1;
    min-width: 0;
    padding: .55rem .8rem;
    border: 0;
    outline: 0;
    color: var(--gallery-ink);
    background: transparent;
}

.gallery-search-input::placeholder {
    color: #64758c;
}

.gallery-search-submit {
    padding: .55rem 1.1rem;
    border: 0;
    border-radius: 8px;
    background: var(--gallery-blue);
    color: #fff;
    font-weight: 750;
}

.gallery-search-submit:hover {
    background: #1d46ae;
}

.gallery-results {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin: 1.35rem 0 .85rem;
}

.gallery-result-count,
.gallery-status {
    margin: 0;
    color: var(--gallery-muted);
    font-size: .9rem;
    font-weight: 700;
}

.gallery-clear {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: #324d81;
    font-size: .86rem;
}

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

.gallery-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--gallery-line);
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(34, 57, 91, .055);
    transition: box-shadow .18s ease, border-color .18s ease;
}

.gallery-card:hover,
.gallery-card:focus-within {
    border-color: #9cb4e7;
    box-shadow: 0 9px 22px rgba(34, 57, 91, .12);
}

.gallery-photo {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #f4f6fa, #e1e9f4);
    cursor: zoom-in;
}

.gallery-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform .2s ease;
}

.gallery-photo:hover img {
    transform: scale(1.025);
}

.gallery-photo-icon {
    position: absolute;
    inset-inline-end: .55rem;
    inset-block-end: .55rem;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(26, 43, 69, .85);
    color: #fff;
    font-size: 1.12rem;
}

.gallery-photo-name {
    display: block;
    padding: .8rem .85rem;
    color: var(--gallery-ink);
    font-size: .95rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.gallery-photo-name:hover,
.gallery-clear:hover {
    color: var(--gallery-blue);
    text-decoration: underline;
}

.gallery-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .65rem;
    margin-top: 1.65rem;
}

.gallery-more {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .65rem 1.15rem;
    border: 1px solid #b5c8ec;
    border-radius: 11px;
    background: #fff;
    color: var(--gallery-blue);
    font-weight: 750;
}

.gallery-more:hover {
    background: #edf3ff;
    color: #1d46ae;
}

.gallery-more[hidden] {
    display: none;
}

.gallery-more[aria-disabled="true"] {
    opacity: .65;
    cursor: wait;
}

.photo-gallery :focus-visible {
    outline: 2px solid #3566d6;
    outline-offset: -2px;
}

.gallery-search-input:focus-visible {
    outline: 0;
}

.gallery-status {
    text-align: center;
}

.gallery-status:not(:empty) {
    margin-top: .65rem;
}

.gallery-empty {
    display: grid;
    justify-items: center;
    gap: .65rem;
    padding: 2.5rem 1rem;
    border: 1px dashed #c5d3e6;
    border-radius: 15px;
    background: #f9fbff;
    color: var(--gallery-muted);
}

.gallery-empty i {
    font-size: 2rem;
    color: #476ba9;
}

.gallery-empty p {
    margin: 0;
}

.gallery-viewer {
    width: min(960px, calc(100% - 1.5rem));
    max-height: calc(100dvh - 1.5rem);
    padding: 0;
    margin: auto;
    overflow: auto;
    border: 1px solid #293447;
    border-radius: 16px;
    background: #172335;
    color: #e7eefb;
}

.gallery-viewer::backdrop {
    background: rgba(12, 21, 33, .77);
}

.gallery-viewer-heading,
.gallery-viewer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .7rem .95rem;
}

.gallery-viewer-heading h2 {
    margin: 0;
    color: inherit;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    font-weight: 750;
}

.gallery-viewer-stage {
    display: grid;
    grid-template-columns: 2.7rem minmax(0, 1fr) 2.7rem;
    align-items: center;
    justify-items: center;
    min-height: min(52vw, 50vh);
    padding: .55rem .25rem;
    background: #0e1726;
    touch-action: pan-y pinch-zoom;
}

.gallery-viewer-stage img,
.gallery-viewer-stage p {
    grid-area: 1 / 2;
}

.gallery-viewer-stage img {
    display: block;
    max-width: 100%;
    max-height: min(66dvh, 680px);
    object-fit: contain;
    border-radius: 4px;
}

.gallery-viewer-stage img[hidden] {
    display: none;
}

.gallery-viewer-stage p {
    margin: 0;
    padding: .3rem;
    text-align: center;
}

.gallery-viewer-prev {
    grid-area: 1 / 1;
}

.gallery-viewer-next {
    grid-area: 1 / 3;
}

.gallery-viewer-button {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #3c516f;
    border-radius: 10px;
    background: #253854;
    color: #fff;
    font-size: 1.35rem;
}

.gallery-viewer-button:hover:not(:disabled) {
    background: #344f79;
}

.gallery-viewer-button:disabled {
    opacity: .35;
}

.gallery-viewer-footer a {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: #b6d2ff;
}

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

@media (max-width: 700px) {
    .photo-gallery { width: calc(100% - 1.3rem); margin-top: 1rem; }
    .gallery-heading { padding: 1rem; gap: .85rem; border-radius: 14px; }
    .gallery-search { width: 100%; }
    .gallery-search-submit { padding-inline: .75rem; }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .gallery-card { border-radius: 11px; }
    .gallery-photo-name { padding: .65rem .6rem; font-size: .85rem; }
    .gallery-photo-icon { width: 27px; height: 27px; font-size: .95rem; }
    .gallery-viewer-stage { grid-template-columns: 2.3rem minmax(0, 1fr) 2.3rem; padding-inline: 0; }
    .gallery-viewer-stage .gallery-viewer-button { width: 32px; }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-card, .gallery-photo img { transition: none; }
}
