@layer components {
    .gallery-page {
        padding: 154px 0 0;
        background: var(--page-background);
        color: var(--foreground);
        font-size: 16px;
        line-height: 1.6;
    }
    .gallery-shell {
        width: min(var(--container-max-width), calc(100% - 2 * var(--container-gutter)));
        margin-inline: auto;
    }
    .gallery-intro {
        display: grid;
        grid-template-columns: 1.65fr 1fr;
        align-items: end;
        gap: 64px;
        padding-bottom: 48px;
    }
    .gallery-eyebrow {
        margin: 0 0 20px;
        color: var(--primary);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .15em;
        text-transform: uppercase;
    }
    .gallery-intro h1 {
        margin: 0;
        color: var(--foreground);
        font-family: var(--font-accent);
        font-size: clamp(40px, 4.7vw, 68px);
        font-weight: 400;
        line-height: 1.12;
        letter-spacing: -.035em;
    }
    .gallery-intro__text {
        max-width: 420px;
        margin: 0 0 4px;
        color: var(--muted-foreground);
        font-size: 18px;
        line-height: 1.75;
    }
    .gallery-toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
        padding: 20px 0;
        border-block: 1px solid var(--border);
    }
    .gallery-filters { display: flex; flex-wrap: wrap; gap: 8px; }
    .gallery-filters[hidden] { display: none; }
    .gallery-filters button {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 44px;
        padding: 9px 18px;
        border: 1px solid transparent;
        border-radius: 4px;
        background: transparent;
        color: var(--foreground);
        font-size: 14px;
        line-height: 24px;
        transition: background-color .18s, color .18s;
    }
    .gallery-filters button:hover { background: var(--section-muted); }
    .gallery-filters button.is-selected { background: var(--primary); color: #fff; font-weight: 500; }
    .gallery-filters button span { font-size: 11px; }
    .gallery-filters .gallery-filter-mark { display: none; }
    .gallery-filters .is-selected .gallery-filter-mark { display: inline; font-size: 13px; }
    .gallery-count { margin: 0; color: var(--muted-foreground); font-size: 12px; white-space: nowrap; }
    .gallery-context { max-width: 820px; margin: 20px 0 28px; color: var(--muted-foreground); font-size: 14px; }
    .gallery-photos { display: grid; gap: 48px; padding-bottom: 88px; }
    .gallery-row { display: flex; gap: 32px; align-items: start; }
    .gallery-photo { flex: var(--photo-ratio) 1 0; min-width: 0; margin: 0; }
    .gallery-row--portrait { justify-content: center; }
    .gallery-row--portrait .gallery-photo { flex: 0 1 560px; }
    .gallery-photo__link {
        position: relative;
        display: block;
        overflow: hidden;
        aspect-ratio: var(--photo-ratio);
        border-radius: 8px;
        background: var(--section-muted);
        color: var(--foreground);
    }
    .gallery-photo__link picture,
    .gallery-photo__link img { display: block; width: 100%; }
    .gallery-photo__link img { height: auto; }
    .gallery-photo__expand {
        position: absolute;
        right: 20px;
        bottom: 20px;
        display: grid;
        width: 44px;
        height: 44px;
        place-items: center;
        border-radius: 4px;
        background: rgba(255, 255, 255, .92);
        color: var(--foreground);
        font-size: 24px;
        transition: background-color .18s, transform .18s;
    }
    .gallery-photo__link:hover .gallery-photo__expand { background: #fff; transform: translate(2px, -2px); }
    .gallery-photo__link:focus-visible { outline: 3px solid var(--primary); outline-offset: 5px; }
    .gallery-photo__error { display: none; }
    .gallery-photo[data-image-state="error"] .gallery-photo__error {
        position: absolute;
        inset: 0;
        display: grid;
        place-content: center;
        padding: 32px;
        text-align: center;
        font-size: 14px;
    }
    .gallery-photo figcaption { display: flex; align-items: baseline; gap: 16px; margin-top: 16px; }
    .gallery-photo__collection {
        flex-shrink: 0;
        color: var(--primary);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .12em;
        text-transform: uppercase;
    }
    .gallery-photo__title { font-family: var(--font-body); font-size: 16px; line-height: 1.35; }
    body.gallery-viewer-open { overflow: hidden; }
    .gallery-viewer {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0;
        padding: 0;
        border: 0;
        background: #151815;
        color: #f8f8f3;
        font-size: 14px;
        line-height: 1.5;
    }
    .gallery-viewer[open] { display: flex; flex-direction: column; }
    .gallery-viewer::backdrop { background: #151815; }
    .gallery-viewer__bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex: 0 0 auto;
        min-height: 76px;
        padding: max(12px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) 12px max(28px, env(safe-area-inset-left));
    }
    .gallery-viewer__bar p { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
    .gallery-viewer__collection { margin-left: 24px; color: #c0c6b9; }
    .gallery-viewer button { display: grid; width: 48px; height: 48px; padding: 0; place-items: center; border: 0; border-radius: 4px; background: transparent; color: #fff; line-height: 1; }
    .gallery-viewer button:focus-visible { outline: 2px solid #e9ece6; outline-offset: 4px; }
    .gallery-viewer__close:hover { color: #c0c6b9; }
    .gallery-viewer__stage { position: relative; flex: 1 1 0; min-height: 0; padding: 0 92px; touch-action: pan-y pinch-zoom; }
    .gallery-viewer__picture { display: block; width: 100%; height: 100%; }
    .gallery-viewer__image { display: block; width: 100%; height: 100%; object-fit: contain; }
    .gallery-viewer__stage.is-loading .gallery-viewer__picture { opacity: 0; }
    .gallery-viewer__loading,
    .gallery-viewer__error { position: absolute; top: 50%; left: 50%; width: min(420px, 75%); margin: 0; transform: translate(-50%, -50%); color: #c0c6b9; text-align: center; }
    .gallery-viewer__error a { color: #e9ece6; text-decoration: underline; }
    .gallery-viewer__loading[hidden], .gallery-viewer__error[hidden], .gallery-viewer__credit[hidden] { display: none; }
    .gallery-viewer__arrow { position: absolute; top: 50%; transform: translateY(-50%); }
    .gallery-viewer__arrow::before { content: ''; width: 18px; height: 18px; border: solid currentColor; border-width: 2px 2px 0 0; filter: drop-shadow(0 1px 3px rgba(20,30,23,.8)); }
    .gallery-viewer__arrow:hover::before { border-width: 3px 3px 0 0; }
    .gallery-viewer__prev::before { transform: rotate(-135deg); }
    .gallery-viewer__next::before { transform: rotate(45deg); }
    .gallery-viewer__prev { left: max(24px, env(safe-area-inset-left)); }
    .gallery-viewer__next { right: max(24px, env(safe-area-inset-right)); }
    .gallery-viewer__caption { flex: 0 0 auto; padding: 24px 32px max(24px, env(safe-area-inset-bottom)); text-align: center; }
    .gallery-viewer__caption h2 { margin: 0 0 8px; color: #f8f8f3; font-family: var(--font-accent); font-size: 23px; font-weight: 400; }
    .gallery-viewer__caption p { max-width: 760px; margin: 0 auto; color: #c0c6b9; font-size: 14px; }
    .gallery-viewer__caption .gallery-viewer__credit { margin-top: 8px; font-size: 12px; }
    .gallery-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

    @media (max-width: 991px) {
        .gallery-intro { grid-template-columns: 1fr; gap: 24px; padding-bottom: 32px; }
        .gallery-intro__text { max-width: 620px; font-size: 18px; }
        .gallery-toolbar { align-items: start; flex-direction: column; gap: 12px; }
        .gallery-row { flex-direction: column; gap: 36px; }
        .gallery-photo, .gallery-row--portrait .gallery-photo { flex: none; width: 100%; }
        .gallery-row--portrait .gallery-photo { max-width: 560px; margin-inline: auto; }
        .gallery-photo figcaption { margin-top: 12px; }
    }
    @media (max-width: 767px) {
        .gallery-page { padding-top: 120px; }
        .gallery-eyebrow { margin-bottom: 18px; font-size: 11px; }
        .gallery-intro h1 { font-size: clamp(36px, 9vw, 44px); }
        .gallery-intro { gap: 20px; }
        .gallery-intro__text { font-size: 16px; line-height: 1.75; }
        .gallery-toolbar { padding: 16px 0; }
        .gallery-filters { gap: 6px; }
        .gallery-filters button { gap: 8px; padding: 8px 13px; font-size: 13px; }
        .gallery-context { margin: 16px 0 24px; font-size: 13px; }
        .gallery-photos { gap: 36px; padding-bottom: 52px; }
        .gallery-photo figcaption { flex-direction: column; gap: 4px; }
        .gallery-photo__title { font-size: 16px; }
        .gallery-photo__expand { right: 12px; bottom: 12px; width: 44px; height: 44px; font-size: 22px; }
        .gallery-viewer__bar { min-height: 68px; padding-inline: max(16px, env(safe-area-inset-left)); }
        .gallery-viewer__stage { padding: 0 12px; }
        .gallery-viewer__prev { left: max(20px, env(safe-area-inset-left)); }
        .gallery-viewer__next { right: max(20px, env(safe-area-inset-right)); }
        .gallery-viewer__caption { padding: 20px 20px max(24px, env(safe-area-inset-bottom)); }
        .gallery-viewer__caption h2 { font-size: 20px; }
        .gallery-viewer__caption p { font-size: 13px; }
    }
    @media (max-height: 500px) {
        .gallery-viewer__bar { min-height: 52px; padding-block: 4px; }
        .gallery-viewer button { width: 44px; height: 44px; }
        .gallery-viewer__caption { padding: 8px 24px max(8px, env(safe-area-inset-bottom)); }
        .gallery-viewer__caption h2 { margin-bottom: 4px; font-size: 18px; }
        .gallery-viewer__caption p { font-size: 12px; }
    }
    @media (prefers-reduced-motion: reduce) {
        .gallery-filters button, .gallery-photo__expand { transition: none; }
    }
}
