:root {
  color-scheme: light;
  --paper: #f6f7f3;
  --surface: #ffffff;
  --ink: #1f2623;
  --muted: #64716b;
  --line: #d9ded7;
  --accent: #2f7f79;
  --accent-strong: #1d5f5b;
  --warm: #b65b38;
  --gold: #bc8b2b;
  --shadow: 0 18px 50px rgba(31, 38, 35, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 760px);
  gap: 24px;
  align-items: end;
  padding: 24px clamp(18px, 4vw, 44px) 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper), white 62%);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--warm);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4.8vw, 4.4rem);
  line-height: 0.98;
  font-weight: 820;
}

.archive-status,
.result-count {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.topbar__tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px);
  gap: 12px;
  align-items: end;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 136px);
}

.filters {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  gap: 14px;
  max-height: 100vh;
  padding: 20px clamp(16px, 2.4vw, 28px);
  overflow: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper), white 48%);
}

.filters__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filters h2 {
  margin: 0;
  font-size: 1.1rem;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
}

.field input:focus,
.field select:focus,
.colour-swatch:focus-visible,
.art-card:focus-visible,
.text-button:focus-visible,
.primary-button:focus-visible,
.modal-close:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), white 58%);
  outline-offset: 2px;
}

.colour-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 7px;
  margin-top: -6px;
}

.colour-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface);
  cursor: pointer;
}

.colour-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  background: var(--swatch);
}

.colour-swatch.is-active {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent), white 72%);
}

.colour-swatch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.colour-swatch:disabled span {
  filter: grayscale(0.75) saturate(0.35);
  opacity: 0.55;
}

.colour-swatch:disabled::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    transparent calc(50% - 1px),
    rgba(31, 38, 35, 0.72) calc(50% - 1px),
    rgba(31, 38, 35, 0.72) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: none;
}

.text-button,
.modal-close {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 760;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  color: white;
  background: var(--accent-strong);
  font-weight: 780;
  text-decoration: none;
  cursor: pointer;
}

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

.gallery {
  min-width: 0;
  padding: 20px clamp(16px, 3.2vw, 40px) 42px;
}

.result-strip {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  margin-bottom: 18px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.filter-chip,
.card-chip,
.related-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--gold), white 78%);
  color: #4a3610;
  font-size: 0.76rem;
  font-weight: 720;
}

.tag-link {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.tag-link:hover {
  background: color-mix(in srgb, var(--accent), white 80%);
  color: var(--accent-strong);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 14px;
  align-items: start;
}

.art-card {
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: inherit;
  background: var(--surface);
  text-align: left;
  box-shadow: 0 1px 0 rgba(31, 38, 35, 0.04);
  cursor: pointer;
}

.art-card:hover {
  border-color: color-mix(in srgb, var(--accent), var(--line) 44%);
  transform: translateY(-1px);
}

.skeleton-card {
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface);
}

.skeleton-image,
.skeleton-line,
.skeleton-chip-row span {
  display: block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    #e7ebe4 0%,
    #f4f6f1 50%,
    #e7ebe4 100%
  );
  background-size: 220% 100%;
  animation: loading-sheen 1.35s ease-in-out infinite;
}

.skeleton-image {
  aspect-ratio: 1 / 1;
}

.skeleton-line {
  width: 78%;
  height: 17px;
}

.skeleton-line--title {
  width: 62%;
  height: 20px;
}

.skeleton-chip-row {
  display: flex;
  gap: 6px;
}

.skeleton-chip-row span {
  width: 68px;
  height: 24px;
  border-radius: 999px;
}

.card-image {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: #eef0ec;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.swatch {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: var(--swatch, #d8d8d8);
}

.card-title {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.card-title strong {
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.18;
}

.card-meta {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.28;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.related-badge {
  background: color-mix(in srgb, var(--accent), white 80%);
  color: var(--accent-strong);
}

.load-row {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.load-row[hidden],
.related-section[hidden],
.art-modal:not([open]),
.detail-modal:not([open]) {
  display: none;
}

.art-modal,
.detail-modal {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1120px, calc(100vw - 28px));
  max-height: min(900px, calc(100vh - 28px));
  margin: 0;
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.art-modal {
  height: min(900px, calc(100vh - 32px));
}

.art-modal::backdrop,
.detail-modal::backdrop {
  background: rgba(24, 29, 27, 0.58);
}

.modal-shell {
  display: grid;
  grid-template-columns: minmax(300px, 1.2fr) minmax(300px, 0.9fr);
  gap: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  min-height: 36px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(31, 38, 35, 0.16);
  backdrop-filter: blur(10px);
}

.modal-media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  height: 100%;
  padding: 28px;
  background: #eef0ec;
}

.modal-media-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.modal-media-button:disabled {
  cursor: default;
}

.modal-media-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), white 58%);
  outline-offset: 4px;
}

.modal-media.is-loading::after,
.detail-stage.is-loading::after {
  content: "";
  position: absolute;
  top: calc(50% - 19px);
  left: calc(50% - 19px);
  z-index: 4;
  width: 38px;
  height: 38px;
  border: 4px solid rgba(47, 127, 121, 0.2);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.modal-media.is-loading img,
.detail-stage.is-loading img {
  opacity: 0.18;
}

.modal-media.is-error img,
.detail-stage.is-error img {
  opacity: 0;
}

.modal-media.is-error::after,
.detail-stage.is-error::after {
  content: "Preview unavailable";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 720;
  backdrop-filter: blur(10px);
}

.modal-media img,
.modal-media-button img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-modal {
  top: 12px;
  width: calc(100vw - 24px);
  max-width: none;
  height: calc(100vh - 24px);
  max-height: none;
  background: #111513;
}

.detail-modal::backdrop {
  background: rgba(12, 14, 13, 0.82);
}

.detail-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

.detail-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
  color: white;
  background: transparent;
  pointer-events: none;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.detail-actions .text-button,
.detail-actions .modal-close {
  position: static;
  min-height: 38px;
  color: white;
  background: rgba(17, 21, 19, 0.52);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.detail-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 18px;
}

.detail-stage img {
  display: block;
  width: calc(100vw - 60px);
  height: calc(100vh - 60px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.detail-modal.is-zoomed .detail-stage {
  display: block;
  overflow: auto;
}

.detail-modal.is-zoomed .detail-stage img {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
}

.modal-detail {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 34px 30px 28px;
}

.modal-detail h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  line-height: 1.02;
}

.modal-description {
  margin: 14px 0 0;
  color: #38413d;
  line-height: 1.5;
}

.palette {
  display: flex;
  gap: 7px;
  margin: 18px 0 0;
}

.palette span {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: var(--swatch, #d8d8d8);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 22px 0 0;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
  text-transform: uppercase;
}

.meta-grid dd {
  margin: 3px 0 0;
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.tag-block {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.tag-block h3,
.related-section h3 {
  margin: 0;
  font-size: 0.95rem;
}

.modal-actions {
  margin-top: 22px;
}

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

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.related-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}

.related-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent), white 74%);
}

.related-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 5px;
  background: #eef0ec;
}

.related-item span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.18;
}

.empty-state {
  padding: 44px 0;
  color: var(--muted);
  font-size: 1rem;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loading-sheen {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-image,
  .skeleton-line,
  .skeleton-chip-row span,
  .modal-media.is-loading::after,
  .detail-stage.is-loading::after {
    animation: none;
  }
}

@media (max-width: 940px) {
  .topbar {
    grid-template-columns: 1fr;
  }

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

  .filters {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filters__header {
    grid-column: 1 / -1;
  }

  .modal-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 48%) minmax(0, 1fr);
  }

  .modal-media {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .topbar__tools,
  .filters {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  }

  .gallery {
    padding-inline: 12px;
  }

  .modal-detail {
    padding: 24px 18px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }
}
