:root {
    color-scheme: light;
    --paper: #f7f3ea;
    --surface: #fffdf8;
    --ink: #191816;
    --muted: #746f66;
    --line: #ded5c7;
    --accent: #8e2f3d;
    --accent-dark: #5e1f2b;
    --moss: #2f5d50;
    --gold: #c58b32;
    --shadow: 0 18px 45px rgba(25, 24, 22, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: "Manrope", Arial, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(18px, 4vw, 48px);
    background: rgba(247, 243, 234, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

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

.brand-mark {
    width: 34px;
    height: 34px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background:
        linear-gradient(135deg, transparent 0 40%, var(--gold) 41% 58%, transparent 59%),
        linear-gradient(45deg, var(--accent) 0 48%, var(--moss) 49%);
}

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

.brand strong {
    font-size: 18px;
    font-weight: 800;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-nav a,
.clear-link,
.admin-edit,
.empty-state a,
.back-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    background: rgba(255, 253, 248, 0.64);
}

.top-nav a:hover,
.clear-link:hover,
.admin-edit:hover,
.empty-state a:hover,
.back-link:hover {
    border-color: var(--ink);
}

.catalog-shell,
.detail-shell {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: clamp(28px, 5vw, 62px) 0 72px;
}

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

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

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

.catalog-heading h1,
.detail-content h1 {
    max-width: 820px;
    margin-bottom: 0;
    font-size: clamp(36px, 6vw, 76px);
    line-height: 0.98;
    letter-spacing: 0;
}

.catalog-count {
    min-width: 118px;
    padding: 14px 16px;
    border-left: 3px solid var(--accent);
    background: rgba(255, 253, 248, 0.62);
}

.catalog-count strong,
.catalog-count span {
    display: block;
}

.catalog-count strong {
    font-size: 30px;
    line-height: 1;
}

.catalog-count span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.catalog-tools {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(160px, 0.8fr) minmax(150px, 0.7fr) auto auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 26px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.catalog-tools label {
    display: grid;
    gap: 7px;
}

.catalog-tools span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

input,
select,
button {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

input,
select {
    padding: 0 13px;
    background: #fff;
    color: var(--ink);
}

button {
    padding: 0 18px;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
}

button:hover {
    background: var(--accent-dark);
}

.painting-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.painting-card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.painting-image {
    display: block;
    aspect-ratio: 4 / 5;
    background: #e7dccb;
}

.painting-image img,
.detail-image img,
.related-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(142, 47, 61, 0.88), rgba(47, 93, 80, 0.86)),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.18) 0 10px, transparent 10px 28px);
    color: #fff;
}

.image-fallback span {
    width: 86px;
    height: 86px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.76);
    border-radius: 50%;
    font-size: 44px;
    font-weight: 800;
}

.painting-body {
    padding: 16px;
}

.painting-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.painting-meta span {
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(47, 93, 80, 0.1);
    color: var(--moss);
    font-size: 12px;
    font-weight: 800;
}

.painting-card h2 {
    margin-bottom: 6px;
    font-size: 21px;
    line-height: 1.16;
}

.artist {
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 700;
}

.artist.big {
    margin: 12px 0 24px;
    font-size: 22px;
}

.facts,
.detail-facts {
    display: grid;
    gap: 8px;
    margin: 0;
}

.facts div,
.detail-facts div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

dd {
    margin: 0;
    text-align: right;
    font-weight: 700;
}

.empty-state {
    padding: 44px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

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

.detail-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(300px, 0.72fr);
    gap: clamp(24px, 5vw, 56px);
    align-items: start;
    margin-top: 22px;
}

.detail-image {
    min-height: 420px;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: #e7dccb;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.image-fallback.large span {
    width: 118px;
    height: 118px;
    font-size: 58px;
}

.detail-content {
    position: sticky;
    top: 98px;
    padding: 24px 0;
}

.detail-facts {
    margin-bottom: 26px;
}

.description {
    color: #302d27;
    font-size: 17px;
    line-height: 1.75;
}

.admin-edit {
    margin-top: 18px;
    border-color: var(--accent);
    color: var(--accent-dark);
}

.related-section {
    margin-top: 54px;
}

.related-section h2 {
    font-size: 28px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.related-item {
    min-height: 150px;
    display: grid;
    grid-template-rows: 1fr auto;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.related-item span {
    min-height: 130px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--moss));
    color: #fff;
    font-size: 42px;
    font-weight: 800;
}

.related-item strong {
    padding: 12px;
    font-size: 14px;
}

.about-hero {
    display: grid;
    grid-template-columns: minmax(320px, 1.15fr) minmax(300px, 0.85fr);
    min-height: min(620px, calc(100vh - 70px));
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.about-hero__image {
    min-height: 380px;
    overflow: hidden;
}

.about-hero__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.about-hero__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(30px, 5vw, 72px);
}

.about-hero__content h1 {
    margin-bottom: 20px;
    font-size: clamp(40px, 6vw, 74px);
    line-height: 0.98;
    letter-spacing: 0;
}

.about-hero__content p {
    max-width: 620px;
    color: #302d27;
    font-size: 18px;
    line-height: 1.75;
}

.about-shell {
    width: min(1080px, calc(100% - 36px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: clamp(24px, 5vw, 58px);
    margin: 0 auto;
    padding: clamp(38px, 6vw, 78px) 0 26px;
}

.about-copy h2 {
    margin-bottom: 18px;
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.08;
}

.about-copy p {
    color: #302d27;
    font-size: 17px;
    line-height: 1.78;
}

.about-facts {
    display: grid;
    align-content: start;
    gap: 12px;
}

.about-facts div {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.about-facts span {
    display: block;
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.about-facts p,
.source-note p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.55;
}

.source-note {
    width: min(1080px, calc(100% - 36px));
    margin: 0 auto 70px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

@media (max-width: 920px) {
    .catalog-tools {
        grid-template-columns: 1fr 1fr;
    }

    .search-field {
        grid-column: 1 / -1;
    }

    .painting-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }

    .about-hero,
    .about-shell {
        grid-template-columns: 1fr;
    }

    .about-hero {
        min-height: 0;
    }

    .detail-content {
        position: static;
        padding-top: 0;
    }
}

@media (max-width: 640px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .top-nav,
    .top-nav a,
    .catalog-tools,
    .catalog-tools button,
    .clear-link {
        width: 100%;
    }

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

    .catalog-tools,
    .painting-grid,
    .related-grid {
        grid-template-columns: 1fr;
    }

    .catalog-heading h1,
    .detail-content h1 {
        font-size: 42px;
    }

    .detail-image {
        min-height: 320px;
    }
}
