:root {
    --ink: #17171b;
    --muted: #6f7078;
    --paper: #f7f7f5;
    --surface: #fff;
    --accent: #6155e7;
    --line: #deded9;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: 'DM Sans', sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(97,85,231,.35); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header { padding: 0 clamp(20px, 4vw, 64px) 42px; color: #fff; background: #201f28; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 68px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand, .instagram-link { color: inherit; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand__mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.6); border-radius: 50%; font-weight: 500; }
.instagram-link { color: rgba(255,255,255,.75); font-size: .84rem; font-weight: 600; }

.header-grid { display: grid; grid-template-columns: minmax(280px,.8fr) minmax(460px,1.2fr); align-items: end; gap: clamp(40px,7vw,110px); max-width: 1500px; margin: 36px auto 0; }
.eyebrow { margin: 0 0 10px; color: #a9a3ff; font-size: .69rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.headline h1 { margin: 0; font-size: clamp(2.6rem,5vw,5.1rem); line-height: .96; letter-spacing: -.055em; }
.headline > p:last-child { max-width: 500px; margin: 16px 0 0; color: rgba(255,255,255,.62); line-height: 1.5; }

.search-tools { display: grid; grid-template-columns: 1fr 185px; gap: 10px; }
.search-box, .sort-box { min-width: 0; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; background: rgba(255,255,255,.08); }
.search-box { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 14px; }
.search-box svg { flex: 0 0 auto; width: 19px; fill: none; stroke: rgba(255,255,255,.7); stroke-linecap: round; stroke-width: 1.8; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; color: #fff; background: transparent; }
.search-box input::placeholder { color: rgba(255,255,255,.48); }
.search-box input::-webkit-search-cancel-button { filter: invert(1); }
kbd { padding: 5px 7px; border: 1px solid rgba(255,255,255,.16); border-radius: 5px; color: rgba(255,255,255,.5); background: transparent; font: 500 .68rem 'DM Sans', sans-serif; }
.sort-box { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 0 12px; }
.sort-box span { color: rgba(255,255,255,.42); font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; }
.sort-box select { width: 100%; padding: 3px 0 0; border: 0; outline: 0; color: #fff; background: transparent; cursor: pointer; }

.library { max-width: 1600px; margin: 0 auto; padding: 38px clamp(16px,4vw,64px) 90px; }
.filter-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.filter-row h2 { margin: 0 0 14px; font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; }
.result-count { margin: 0 0 9px; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.category-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.category-chip { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--surface); cursor: pointer; transition: .18s ease; }
.category-chip:hover { border-color: #aaa9a3; }
.category-chip[aria-pressed='true'] { color: #fff; border-color: var(--ink); background: var(--ink); }
.category-chip strong { font-size: .78rem; }
.category-chip small { opacity: .52; font-size: .68rem; }

.gallery { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: clamp(12px,1.5vw,22px); }
.art-card { min-width: 0; margin: 0; animation: reveal .35s both; animation-delay: var(--delay); }
.art-card__button { display: flex; flex-direction: column; width: 100%; height: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 10px; color: var(--ink); background: var(--surface); cursor: pointer; text-align: left; box-shadow: 0 1px 0 rgba(0,0,0,.05); }
.art-card__button::after { display: none; }
.art-card img { display: block; width: 100%; aspect-ratio: 4/5; object-fit: cover; background: #e6e5e1; transition: transform .35s ease; }
.art-card__button:hover img { transform: scale(1.02); }
.art-card__overlay { position: static; display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; width: 100%; padding: 14px 15px 16px; }
.card-category { grid-column: 1; margin: 0; color: var(--accent); font-size: .63rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.art-card__overlay strong { grid-column: 1 / -1; overflow: hidden; font-size: .93rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.art-card__meta { grid-column: 2; grid-row: 1; color: var(--muted); font-size: .65rem; }

.loading-state, .error-state, .empty-state { grid-column: 1/-1; display: grid; place-items: center; min-height: 310px; padding: 40px; text-align: center; }
.loading-orbit { width: 38px; height: 38px; border: 2px solid #ddd; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.empty-state[hidden] { display: none; }
.empty-state > span, .error-state > span { color: var(--muted); font-size: 2.5rem; }
.empty-state h2, .error-state h2 { margin: 14px 0 0; font-size: 1.4rem; }
.empty-state p, .error-state p { margin: 7px 0 20px; color: var(--muted); }
.text-button { padding: 10px 15px; border: 1px solid var(--ink); border-radius: 7px; color: var(--ink); background: transparent; cursor: pointer; }

.art-dialog { width: min(1040px,calc(100% - 28px)); max-height: min(780px,calc(100vh - 28px)); padding: 0; overflow: hidden; border: 0; border-radius: 12px; color: var(--ink); background: var(--surface); box-shadow: 0 30px 100px rgba(0,0,0,.4); }
.art-dialog::backdrop { background: rgba(10,10,14,.76); backdrop-filter: blur(6px); }
.dialog-layout { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(320px,.85fr); min-height: 600px; }
.dialog-image-wrap { min-height: 440px; background: #17171b; }
.dialog-image-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.dialog-copy { align-self: center; padding: clamp(28px,5vw,58px); }
.dialog-copy h2 { margin: 12px 0 20px; font-size: clamp(1.7rem,3vw,2.7rem); line-height: 1.05; letter-spacing: -.035em; }
.dialog-copy > p:not(.card-category) { max-height: 220px; overflow: auto; color: var(--muted); line-height: 1.6; }
.dialog-close { position: absolute; z-index: 2; top: 12px; right: 12px; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; color: var(--ink); background: rgba(255,255,255,.9); cursor: pointer; font-size: 1.5rem; }
.dialog-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.dialog-tags span { padding: 5px 8px; border-radius: 5px; color: #5149bc; background: #efedff; font-size: .68rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.primary-button,.secondary-button { padding: 11px 14px; border-radius: 7px; text-decoration: none; font-size: .78rem; font-weight: 700; }
.primary-button { color: #fff; background: var(--ink); }
.secondary-button { color: var(--ink); border: 1px solid var(--line); }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(20px,4vw,64px); color: #aaa; background: #201f28; font-size: .76rem; }
footer p { margin: 0; }
footer a { color: #fff; }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
    .header-grid { grid-template-columns: 1fr; gap: 28px; }
    .headline h1 { font-size: 3.5rem; }
    .gallery { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 680px) {
    .site-header { padding-bottom: 24px; }
    .topbar { min-height: 58px; }
    .header-grid { margin-top: 24px; gap: 22px; }
    .headline h1 { font-size: 2.65rem; }
    .headline > p:last-child { margin-top: 10px; font-size: .9rem; }
    .search-tools { grid-template-columns: 1fr; }
    .search-box { height: 52px; }
    .sort-box { min-height: 52px; }
    kbd { display: none; }
    .library { padding-top: 25px; }
    .filter-row { align-items: start; flex-direction: column; gap: 10px; }
    .result-count { margin: 0; }
    .category-filters { flex-wrap: nowrap; max-width: calc(100vw - 32px); overflow-x: auto; padding-bottom: 5px; }
    .category-chip { flex: 0 0 auto; }
    .gallery { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
    .art-card__overlay { display: flex; flex-direction: column; gap: 5px; padding: 10px 11px 12px; }
    .art-card__overlay strong { font-size: .78rem; }
    .art-card__meta { font-size: .61rem; }
    .dialog-layout { grid-template-columns: 1fr; min-height: 0; }
    .art-dialog { overflow-y: auto; }
    .dialog-image-wrap { height: 50vh; min-height: 330px; }
    .dialog-copy { padding: 24px; }
    footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *,*::before,*::after { scroll-behavior: auto!important; animation-duration: .01ms!important; animation-iteration-count: 1!important; transition-duration: .01ms!important; }
}
