:root {
    --ink: #25312d;
    --muted: #69736e;
    --paper: #f6f2e9;
    --card: #fffdf8;
    --sage: #73897b;
    --sage-dark: #4d6758;
    --peach: #e7a47d;
    --line: #ded8cc;
    --shadow: 0 18px 50px rgba(52, 62, 57, .09);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 4%, rgba(231, 164, 125, .16), transparent 25rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    line-height: 1.12;
}

h1,
.hero h2 {
    font-family: Georgia, "Times New Roman", serif;
}

.skip-link {
    position: fixed;
    z-index: 20;
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: white;
    background: var(--ink);
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header,
main,
footer {
    width: min(1180px, calc(100% - 40px));
    margin-inline: auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 94px;
    gap: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--sage);
    border-radius: 50% 50% 45% 55%;
    color: white;
    background: var(--sage-dark);
    font: 700 23px/1 Georgia, serif;
    transform: rotate(-4deg);
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .13);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font: 700 18px/1.2 Georgia, serif;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.site-header nav {
    display: flex;
    gap: 8px;
}

.site-header nav a {
    padding: 10px 14px;
    border-radius: 99px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a:focus-visible,
.site-header nav a.active {
    color: var(--ink);
    background: rgba(255, 255, 255, .67);
}

.hero,
.browse-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(270px, .8fr);
    align-items: end;
    gap: 60px;
    padding: 76px 0 58px;
}

.hero-copy {
    max-width: 760px;
}

.eyebrow {
    margin-bottom: 12px;
    color: var(--sage-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.hero h1,
.browse-hero h1,
.detail-copy > h1 {
    margin-bottom: 22px;
    font-size: clamp(42px, 6vw, 76px);
    letter-spacing: -.045em;
}

.hero-copy > p:last-child,
.browse-hero p,
.detail-copy > p {
    max-width: 650px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 18px;
}

.collection-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0;
    padding: 26px;
    border: 1px solid rgba(115, 137, 123, .25);
    border-radius: var(--radius);
    background: rgba(255, 253, 248, .62);
}

.collection-stats div {
    text-align: center;
}

.collection-stats div + div {
    border-left: 1px solid var(--line);
}

.collection-stats dt {
    font: 700 29px/1 Georgia, serif;
}

.collection-stats dd {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.search-panel {
    display: grid;
    grid-template-columns: minmax(190px, .55fr) minmax(0, 1.45fr);
    align-items: end;
    gap: 40px;
    padding: 34px;
    border-radius: var(--radius);
    color: white;
    background: var(--sage-dark);
    box-shadow: var(--shadow);
}

.search-panel .eyebrow {
    color: #d4e1d8;
}

.search-panel h2 {
    margin-bottom: 0;
    font-size: 26px;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(150px, .7fr) minmax(230px, 1.3fr) auto;
    align-items: end;
    gap: 14px;
}

.search-form label span {
    display: block;
    margin: 0 0 7px 3px;
    color: #e6eee8;
    font-size: 12px;
    font-weight: 700;
}

select,
input,
button {
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    font: inherit;
}

select,
input {
    width: 100%;
    padding: 0 14px;
    color: var(--ink);
    background: white;
}

button {
    padding: 0 22px;
    color: var(--ink);
    background: #f3c2a5;
    font-weight: 800;
    cursor: pointer;
}

button:hover,
button:focus-visible {
    background: white;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid #f1b48f;
    outline-offset: 3px;
}

.reset-link {
    grid-column: 1 / -1;
    justify-self: end;
    color: white;
    font-size: 13px;
}

.results-section {
    padding: 64px 0 84px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 28px;
}

.section-heading h2 {
    margin-bottom: 0;
    font: 700 clamp(30px, 4vw, 44px)/1.1 Georgia, serif;
}

.text-link {
    color: var(--sage-dark);
    font-size: 14px;
    font-weight: 800;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.stamp-list {
    display: grid;
    gap: 18px;
}

.stamp-card {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    overflow: hidden;
    min-height: 225px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 7px 25px rgba(46, 55, 51, .04);
}

.stamp-image-wrap {
    display: grid;
    min-height: 220px;
    padding: 22px;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(115, 137, 123, .11), rgba(231, 164, 125, .10)),
        #ece8df;
}

.stamp-image-wrap img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.stamp-info {
    min-width: 0;
    padding: 27px 30px 25px;
}

.tag {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 99px;
    color: var(--sage-dark);
    background: #e7eee9;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.stamp-info h3 {
    max-width: 820px;
    margin: 13px 0 8px;
    font: 700 clamp(21px, 2.5vw, 29px)/1.18 Georgia, serif;
}

.meta {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 13px;
}

.creation-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-color: var(--sage) transparent;
}

.creation-strip a {
    flex: 0 0 84px;
    overflow: hidden;
    height: 72px;
    border: 2px solid white;
    border-radius: 10px;
    background: #eee;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}

.creation-strip a:hover,
.creation-strip a:focus-visible {
    border-color: var(--peach);
}

.creation-strip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.viewer-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    margin-top: 10px;
    padding: 0 15px;
    border: 1px solid var(--sage);
    color: var(--sage-dark);
    background: transparent;
    font-size: 13px;
}

.viewer-open:hover,
.viewer-open:focus-visible {
    color: white;
    background: var(--sage-dark);
}

.viewer-open span {
    font-size: 18px;
    line-height: 1;
}

.viewer-is-open {
    overflow: hidden;
}

.creation-viewer {
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    color: white;
    background: #15201b;
}

.creation-viewer::backdrop {
    background: rgba(12, 18, 15, .94);
}

.creation-viewer[open] {
    display: block;
}

.viewer-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 22px clamp(16px, 3vw, 42px) 14px;
    background:
        radial-gradient(circle at 50% 45%, rgba(115, 137, 123, .22), transparent 48%),
        #15201b;
}

.viewer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 14px;
}

.viewer-kicker {
    margin-bottom: 4px;
    color: #aebbb4;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.viewer-header h2 {
    max-width: min(760px, 75vw);
    margin: 0;
    overflow: hidden;
    font: 700 clamp(18px, 2.4vw, 28px)/1.2 Georgia, serif;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-close,
.viewer-nav {
    display: grid;
    flex: 0 0 auto;
    min-height: 0;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    color: white;
    background: rgba(255, 255, 255, .09);
}

.viewer-close {
    width: 46px;
    height: 46px;
    font-size: 32px;
    font-weight: 300;
}

.viewer-close:hover,
.viewer-close:focus-visible,
.viewer-nav:hover,
.viewer-nav:focus-visible {
    color: var(--ink);
    background: white;
}

.viewer-stage {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    min-height: 0;
    gap: clamp(10px, 2.2vw, 30px);
    touch-action: none;
    user-select: none;
}

.viewer-nav {
    width: clamp(44px, 5vw, 62px);
    height: clamp(44px, 5vw, 62px);
    font-size: clamp(23px, 3vw, 34px);
}

.viewer-figure {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-width: 0;
    height: 100%;
    min-height: 0;
    margin: 0;
}

.viewer-figure img {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
}

.viewer-figure figcaption {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding-top: 12px;
    color: #dfe5e1;
    font-size: 13px;
}

.viewer-caption-text {
    display: inline-flex;
    gap: 14px;
}

.viewer-count {
    color: #aebbb4;
}

.viewer-detail-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 99px;
    color: white;
    background: rgba(255, 255, 255, .09);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.viewer-detail-link:hover,
.viewer-detail-link:focus-visible {
    color: var(--ink);
    background: white;
}

.viewer-help {
    margin: 9px 0 0;
    color: #87978e;
    font-size: 11px;
    text-align: center;
}

.empty-state {
    padding: 70px 30px;
    border: 1px dashed #bfc5bf;
    border-radius: var(--radius);
    text-align: center;
    background: rgba(255, 255, 255, .42);
}

.empty-state > span {
    color: var(--peach);
    font-size: 35px;
}

.empty-state h3 {
    margin: 15px 0 8px;
    font: 700 27px/1.2 Georgia, serif;
}

.empty-state p {
    color: var(--muted);
}

.button-secondary {
    display: inline-block;
    padding: 11px 16px;
    border-radius: 10px;
    color: white;
    background: var(--sage-dark);
    font-weight: 700;
    text-decoration: none;
}

.browse-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    padding-bottom: 42px;
}

.browse-hero h1 {
    margin-bottom: 16px;
}

.browse-count {
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 99px;
    color: var(--muted);
    background: rgba(255, 255, 255, .55);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.creation-gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    padding-bottom: 44px;
}

.creation-card {
    position: relative;
    overflow: hidden;
    min-height: 290px;
    border-radius: 18px;
    color: white;
    background: #ddd;
    box-shadow: 0 8px 26px rgba(41, 49, 46, .08);
}

.creation-card img {
    width: 100%;
    height: 100%;
    min-height: 290px;
    object-fit: cover;
    transition: transform .35s ease;
}

.creation-card:hover img,
.creation-card:focus-visible img {
    transform: scale(1.035);
}

.creation-overlay {
    position: absolute;
    inset: auto 0 0;
    display: block;
    padding: 45px 16px 15px;
    background: linear-gradient(transparent, rgba(22, 29, 26, .88));
}

.creation-overlay strong,
.creation-overlay small {
    display: block;
}

.creation-overlay small {
    margin-top: 2px;
    color: #e7ece9;
}

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding-bottom: 70px;
    color: var(--muted);
    font-size: 14px;
}

.pagination a {
    color: var(--sage-dark);
    font-weight: 800;
    text-underline-offset: 4px;
}

.pagination a:last-child {
    justify-self: end;
}

.detail-hero {
    padding: 46px 0 82px;
}

.back-link {
    display: inline-block;
    margin-bottom: 28px;
    color: var(--sage-dark);
    font-size: 14px;
    font-weight: 800;
    text-underline-offset: 4px;
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(300px, .9fr) minmax(0, 1.1fr);
    align-items: start;
    gap: clamp(35px, 6vw, 78px);
}

.featured-creation {
    position: sticky;
    top: 24px;
    overflow: hidden;
    margin: 0;
    border: 10px solid white;
    border-radius: var(--radius);
    background: #ddd;
    box-shadow: var(--shadow);
}

.featured-creation img {
    width: 100%;
    max-height: 720px;
    object-fit: contain;
}

.detail-copy {
    padding-top: 22px;
}

.detail-copy > h1 {
    margin-bottom: 15px;
    font-size: clamp(38px, 5vw, 64px);
}

.related-stamps {
    display: grid;
    gap: 14px;
    margin-top: 35px;
}

.related-stamp {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center;
    gap: 20px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
}

.related-stamp > img {
    width: 120px;
    height: 115px;
    padding: 8px;
    border-radius: 10px;
    object-fit: contain;
    background: #eeebe4;
    mix-blend-mode: multiply;
}

.related-stamp h2 {
    margin: 10px 0 9px;
    font: 700 20px/1.2 Georgia, serif;
}

.related-stamp a {
    color: var(--sage-dark);
    font-size: 12px;
    font-weight: 800;
}

.notice {
    margin: 70px 0;
    padding: 25px;
    border-radius: 15px;
}

.notice.error {
    color: #6f2b27;
    background: #f7dfda;
}

.notice p {
    margin: 5px 0 0;
}

footer {
    display: flex;
    gap: 22px;
    align-items: center;
    min-height: 110px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

footer p {
    margin: 0 auto 0 0;
}

@media (max-width: 900px) {
    .hero,
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .hero {
        gap: 30px;
        padding-top: 45px;
    }

    .search-panel {
        grid-template-columns: 1fr;
        gap: 24px;
    }

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

    .featured-creation {
        position: static;
        max-width: 680px;
    }
}

@media (max-width: 680px) {
    .site-header,
    main,
    footer {
        width: min(100% - 26px, 1180px);
    }

    .site-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px 0 13px;
        gap: 15px;
    }

    .site-header nav {
        width: 100%;
    }

    .site-header nav a {
        flex: 1;
        padding-inline: 8px;
        text-align: center;
    }

    .brand small {
        display: none;
    }

    .hero {
        padding-top: 38px;
    }

    .hero h1,
    .browse-hero h1 {
        font-size: 43px;
    }

    .collection-stats {
        padding: 20px 12px;
    }

    .search-panel {
        padding: 26px 20px;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .reset-link {
        justify-self: center;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .stamp-card {
        grid-template-columns: 1fr;
    }

    .stamp-image-wrap {
        min-height: 180px;
    }

    .stamp-image-wrap img {
        height: 145px;
    }

    .stamp-info {
        padding: 24px 20px 20px;
    }

    .viewer-shell {
        padding: 14px 10px 10px;
    }

    .viewer-stage {
        grid-template-columns: 48px minmax(0, 1fr) 48px;
        gap: 7px;
    }

    .viewer-header h2 {
        max-width: calc(100vw - 90px);
    }

    .viewer-nav {
        width: 44px;
        height: 44px;
    }

    .viewer-help {
        display: none;
    }

    .viewer-figure figcaption {
        flex-direction: column;
        gap: 8px;
    }

    .browse-hero {
        align-items: flex-start;
        grid-template-columns: 1fr;
        gap: 20px;
        padding-top: 42px;
    }

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

    .creation-card,
    .creation-card img {
        min-height: 235px;
    }

    .detail-hero {
        padding-top: 30px;
    }

    .related-stamp {
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 13px;
    }

    .related-stamp > img {
        width: 88px;
        height: 90px;
    }

    footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        padding: 27px 0;
    }

    footer p {
        margin: 0 0 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .creation-card img {
        transition: none;
    }
}
