:root {
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    --page-bg: #fbf3e7;
    --card-bg: rgba(255, 255, 255, 0.96);
    --line: rgba(190, 140, 34, 0.18);
    --text: #23180f;
    --muted: #6c5b42;
    --accent: #8a5a10;
    --hero-start: #7d4a10;
    --hero-end: #d7a137;
    --hero-glow: rgba(255, 255, 255, 0.16);
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(223, 164, 88, 0.18), transparent 30%),
        radial-gradient(circle at top right, rgba(255, 243, 217, 0.84), transparent 24%),
        linear-gradient(180deg, #fffdf9 0%, var(--page-bg) 100%);
}

body.age-gate-pending {
    overflow: hidden;
}

body.age-gate-pending .shell {
    visibility: hidden;
}

body[data-gallery-mode="test"] {
    --page-bg: #f6efe7;
    --line: rgba(159, 97, 37, 0.16);
    --accent: #9f6125;
    --hero-start: #6d3a0f;
    --hero-end: #d28d3b;
    --hero-glow: rgba(255, 255, 255, 0.14);
    background:
        radial-gradient(circle at top left, rgba(212, 141, 59, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(248, 220, 178, 0.28), transparent 24%),
        linear-gradient(180deg, #fffaf3 0%, var(--page-bg) 100%);
}

body[data-gallery-mode="router"] {
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top, rgba(190, 140, 34, 0.2), transparent 40%),
        linear-gradient(180deg, #fff9ef 0%, #ffffff 100%);
}

.age-gate[hidden] {
    display: none;
}

.age-gate {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(10, 7, 4, 0.76);
    backdrop-filter: blur(20px) saturate(1.04);
}

.age-gate-card {
    width: min(100%, 34rem);
    padding: 1.6rem;
    border-radius: 1.8rem;
    background: rgba(255, 252, 247, 0.95);
    border: 1px solid rgba(35, 24, 15, 0.08);
    text-align: center;
    box-shadow: 0 44px 90px -50px rgba(0, 0, 0, 0.52);
}

.age-gate-kicker {
    margin: 0 0 0.75rem;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.age-gate-card h1 {
    margin: 0;
    font-family: "Fraunces", serif;
    font-size: clamp(2rem, 4.5vw, 3rem);
    letter-spacing: -0.04em;
}

.age-gate-copy {
    margin: 1rem 0 0;
    color: var(--text);
    line-height: 1.72;
}

.age-gate-copy-secondary {
    color: var(--muted);
}

.age-gate-human-check {
    display: grid;
    gap: 0.7rem;
    margin-top: 1.2rem;
    text-align: left;
}

.age-gate-human-check-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

.age-gate-human-check-input {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 0.95rem;
    padding: 0.9rem 0.95rem;
    font: inherit;
    background: rgba(255, 255, 255, 0.98);
    color: var(--text);
}

.age-gate-human-check-feedback {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
}

.age-gate-human-check-feedback.is-valid {
    color: var(--text);
}

.age-gate-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.4rem;
}

.shell {
    width: min(1160px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-family: "Fraunces", serif;
    font-size: clamp(1.8rem, 3.4vw, 2.5rem);
    letter-spacing: -0.02em;
}

.top-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 0.85rem 1.2rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: #2f2416;
    color: white;
    box-shadow: 0 18px 34px -24px rgba(15, 23, 42, 0.5);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid rgba(15, 23, 42, 0.1);
}

.hero {
    position: relative;
    overflow: hidden;
    margin-top: 0.75rem;
    padding: clamp(1.6rem, 4vw, 2.5rem);
    border-radius: 2rem;
    background: linear-gradient(135deg, var(--hero-start) 0%, var(--hero-end) 100%);
    color: white;
    box-shadow: 0 32px 64px -44px rgba(15, 23, 42, 0.55);
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -3rem -3.5rem auto;
    width: 14rem;
    height: 14rem;
    border-radius: 999px;
    background: var(--hero-glow);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    margin: 1rem 0 0.75rem;
    font-family: "Fraunces", serif;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 1.04;
    letter-spacing: -0.03em;
}

.hero p {
    margin: 0;
    max-width: 46rem;
    color: rgba(255, 255, 255, 0.94);
    line-height: 1.75;
    font-size: 1rem;
}

.meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.4rem;
}

.meta-pill {
    padding: 0.68rem 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.14);
    font-size: 0.9rem;
}

.gallery-card {
    margin-top: 1.5rem;
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 1.8rem;
    background: var(--card-bg);
    border: 1px solid var(--line);
    box-shadow: 0 28px 60px -38px rgba(15, 23, 42, 0.24);
}

.gallery-status {
    margin: 0 0 1rem;
    color: var(--muted);
    line-height: 1.65;
}

.gallery-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.72rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.filter-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px -22px rgba(15, 23, 42, 0.4);
}

.filter-chip.is-active {
    border-color: rgba(138, 90, 16, 0.28);
    background: rgba(138, 90, 16, 0.12);
    color: var(--accent);
}

.filter-count {
    display: inline-grid;
    place-items: center;
    min-width: 1.7rem;
    height: 1.7rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
    font-size: 0.78rem;
}

.loading-state,
.empty-state {
    padding: 2rem 1rem;
    border-radius: 1.25rem;
    border: 1px dashed var(--line);
    background: rgba(255, 255, 255, 0.76);
    color: var(--muted);
    text-align: center;
    line-height: 1.7;
}

.months-stack {
    display: grid;
    gap: 1rem;
}

.month-panel {
    display: grid;
    gap: 1rem;
    padding: 1.1rem;
    border-radius: 1.4rem;
    background: white;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.month-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    padding-bottom: 0.85rem;
}

.month-kicker {
    display: inline-block;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.month-title {
    margin: 0.35rem 0 0;
    font-family: "Fraunces", serif;
    font-size: clamp(1.45rem, 2.6vw, 1.9rem);
}

.month-note,
.month-count {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.photo-card {
    position: relative;
    overflow: hidden;
    border-radius: 0;
    background: white;
    border: none;
    box-shadow: 0 24px 44px -34px rgba(15, 23, 42, 0.24);
}

.photo-link {
    display: block;
    position: relative;
    color: inherit;
    text-decoration: none;
}

.media-shell {
    position: relative;
    overflow: hidden;
    min-height: 20rem;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.55), transparent 55%),
        linear-gradient(180deg, rgba(255, 244, 221, 0.95) 0%, rgba(247, 228, 188, 0.8) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-shell img,
.media-shell video {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(84vh, 68rem);
    padding: 0;
    object-fit: contain;
    object-position: center;
    background: transparent;
}

.media-shell-video {
    background:
        radial-gradient(circle at top, rgba(230, 165, 54, 0.22), transparent 58%),
        linear-gradient(180deg, rgba(33, 23, 14, 0.98) 0%, rgba(60, 39, 22, 0.92) 100%);
}

.photo-play {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 1;
    width: 2.8rem;
    height: 2.8rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: white;
    font-size: 1.05rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 36px -24px rgba(15, 23, 42, 0.6);
}

.photo-meta {
    padding: 0.95rem 1rem 1rem;
}

.photo-label {
    margin: 0;
    font-size: 0.96rem;
    font-weight: 700;
}

.photo-caption {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--muted);
    word-break: break-word;
}

.test-collage {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: 180px;
    grid-auto-flow: dense;
    gap: 1rem;
}

.test-card {
    grid-column: span var(--col-span, 4);
    grid-row: span var(--row-span, 1);
    position: relative;
    overflow: hidden;
    border-radius: 1.6rem;
    background: white;
    border: 1px solid rgba(159, 97, 37, 0.14);
    box-shadow: 0 24px 42px -34px rgba(93, 49, 15, 0.44);
    transform: rotate(var(--tilt, 0deg));
}

.test-card::before {
    content: "";
    position: absolute;
    inset: auto auto -30% -10%;
    width: 60%;
    height: 60%;
    border-radius: 999px;
    background: var(--accent-wash, rgba(190, 140, 34, 0.18));
    filter: blur(16px);
    pointer-events: none;
}

.test-card .photo-link {
    height: 100%;
}

.test-card .media-shell {
    height: 100%;
    aspect-ratio: auto;
}

.test-card img,
.test-card video {
    background: #fbf0df;
}

.viewer[hidden] {
    display: none;
}

.viewer {
    position: fixed;
    inset: 0;
    z-index: 300;
    padding: 0;
    display: grid;
    place-items: center;
}

.viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(10px);
}

.viewer-card {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.viewer-frame {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.viewer-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #120c07;
    --viewer-backdrop-image: none;
}

.viewer-stage::before {
    content: "";
    position: absolute;
    inset: -8%;
    background-image: var(--viewer-backdrop-image);
    background-position: center;
    background-size: cover;
    filter: blur(40px) saturate(1.08);
    opacity: 0.45;
    transform: scale(1.08);
}

.viewer-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(2, 6, 23, 0.08) 0%, rgba(2, 6, 23, 0.42) 100%);
}

.viewer-media {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    padding:
        max(1rem, env(safe-area-inset-top, 0px))
        max(1rem, env(safe-area-inset-right, 0px))
        max(1rem, env(safe-area-inset-bottom, 0px))
        max(1rem, env(safe-area-inset-left, 0px));
}

.viewer-media img,
.viewer-media video {
    display: block;
    width: auto;
    height: auto;
    max-width: min(96vw, 1440px);
    max-height: min(94svh, 1000px);
    object-fit: contain;
    background: transparent;
    touch-action: pan-y;
}

.viewer-media img[hidden],
.viewer-media video[hidden] {
    display: none !important;
}

.viewer-media video {
    background: rgba(2, 6, 23, 0.24);
}

.viewer-close {
    position: absolute;
    top: calc(0.85rem + env(safe-area-inset-top, 0px));
    right: calc(0.85rem + env(safe-area-inset-right, 0px));
    z-index: 3;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: white;
    font: inherit;
    font-size: 1.3rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.viewer-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    transform: translateY(-50%);
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.16);
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.viewer-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.viewer-nav-prev {
    left: 1rem;
}

.viewer-nav-next {
    right: 1rem;
}

.router-card {
    width: min(92vw, 32rem);
    padding: 2rem;
    border-radius: 1.6rem;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(190, 140, 34, 0.16);
    box-shadow: 0 28px 60px -36px rgba(15, 23, 42, 0.32);
    text-align: center;
}

.router-badge {
    width: 4.4rem;
    height: 4.4rem;
    border-radius: 999px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #8a5a10 0%, #d7a137 100%);
    color: white;
    font-size: 1.8rem;
}

.router-title {
    margin: 0 0 0.55rem;
    font-family: "Fraunces", serif;
    font-size: clamp(1.9rem, 4vw, 2.4rem);
}

.router-copy,
.router-status {
    margin: 0;
    line-height: 1.7;
    color: var(--muted);
}

.router-status {
    margin-top: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    background: #fff4dd;
    color: #8a5a10;
}

.router-status.error {
    background: #fef2f2;
    color: #991b1b;
}

.router-link {
    display: inline-block;
    margin-top: 1.2rem;
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

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

@media (max-width: 720px) {
    .shell {
        width: min(100%, calc(100% - 1rem));
    }

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

    .topbar,
    .gallery-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .top-actions,
    .filter-strip {
        width: 100%;
    }

    .filter-chip {
        justify-content: space-between;
        width: 100%;
    }

    .media-shell {
        min-height: min(78svh, 48rem);
    }

    .media-shell img,
    .media-shell video {
        width: 100%;
        max-height: min(78svh, 48rem);
        background: rgba(255, 255, 255, 0.9);
    }

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

    .viewer-close {
        top: 0.65rem;
        right: 0.65rem;
    }

    .viewer-nav {
        display: none;
    }

    .age-gate-actions {
        flex-direction: column;
    }

    .month-header {
        align-items: start;
        flex-direction: column;
    }

    .test-collage {
        grid-template-columns: 1fr;
    }

    .test-card {
        grid-column: auto;
        grid-row: auto;
        transform: none;
    }
}

@media (max-width: 540px) {
    .media-shell {
        min-height: min(82svh, 52rem);
        max-height: none;
    }

    .media-shell img,
    .media-shell video {
        width: 100%;
        max-height: min(82svh, 52rem);
    }
}
