:root {
  --bg: #090b0d;
  --panel: #11151a;
  --panel-raised: #171c22;
  --line: #2b323a;
  --line-bright: #49525d;
  --text: #eef1f3;
  --muted: #9ca6af;
  --copper: #d49554;
  --gold: #f0c36f;
  --violet: #a78bfa;
  --shadow: 0 22px 60px rgb(0 0 0 / 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgb(167 139 250 / 0.12), transparent 30rem),
    radial-gradient(circle at 95% 0%, rgb(212 149 84 / 0.12), transparent 34rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  color: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: 3.5rem clamp(1.25rem, 4vw, 4rem) 2.5rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--copper);
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 0.65rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.3rem, 6vw, 5.6rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

h1 span {
  color: var(--gold);
  font-style: italic;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.lede,
.result-count,
.empty-state p,
.viewer-figure figcaption {
  color: var(--muted);
}

.lede {
  max-width: 680px;
  margin-bottom: 0;
  font-size: 1.05rem;
}

.archive-total {
  min-width: 150px;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--line-bright);
  background: rgb(17 21 26 / 0.78);
  box-shadow: var(--shadow);
}

.archive-total strong,
.archive-total span {
  display: block;
}

.archive-total strong {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  font-weight: 500;
}

.archive-total span {
  color: var(--muted);
  font-size: 0.9rem;
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 3.5rem);
  max-width: 1600px;
  margin: 0 auto;
  padding: 2.5rem clamp(1.25rem, 4vw, 4rem) 5rem;
}

.era-panel {
  position: sticky;
  top: 1.25rem;
  align-self: start;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding: 1.35rem;
  border: 1px solid var(--line);
  background: rgb(17 21 26 / 0.9);
}

.panel-heading {
  padding: 0.3rem 0.45rem 1rem;
  border-bottom: 1px solid var(--line);
}

.category-list {
  display: grid;
  gap: 0.45rem;
  padding-top: 1rem;
}

.category-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem 0.9rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.category-button:hover {
  border-color: var(--line-bright);
  color: var(--text);
}

.category-button[aria-current="true"] {
  border-color: var(--copper);
  background: rgb(212 149 84 / 0.1);
  color: var(--text);
}

.category-button span:first-child {
  line-height: 1.25;
}

.category-button span:last-child {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.result-count {
  margin-bottom: 0;
}

.toolbar-controls {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.search-field,
.sort-field {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.search-field input,
.sort-field select {
  min-height: 44px;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  outline: none;
  background-color: var(--panel-raised);
}

.search-field input {
  width: min(42vw, 320px);
  padding: 0.7rem 0.85rem;
}

.sort-field select {
  min-width: 170px;
  padding: 0.7rem 2.2rem 0.7rem 0.85rem;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 52%,
    calc(100% - 10px) 52%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.search-field input:focus,
.sort-field select:focus,
button:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.image-card {
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.18);
  transition: border-color 140ms ease, transform 140ms ease;
}

.image-card:hover {
  transform: translateY(-2px);
  border-color: var(--copper);
}

.thumb-wrap {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background:
    linear-gradient(135deg, #191e24 25%, #11151a 25% 50%, #191e24 50% 75%, #11151a 75%);
  background-size: 24px 24px;
}

.thumb-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-wrap img.is-broken {
  visibility: hidden;
}

.card-copy {
  display: grid;
  gap: 0.3rem;
  padding: 0.8rem 0.9rem 0.9rem;
}

.card-title,
.card-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 650;
}

.card-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  padding: 5rem 1rem;
  border: 1px dashed var(--line-bright);
  text-align: center;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding-top: 2rem;
}

.load-more,
.viewer-footer button,
.icon-button {
  min-height: 44px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line-bright);
  background: var(--panel-raised);
}

.load-more:hover,
.viewer-footer button:hover,
.icon-button:hover {
  border-color: var(--gold);
}

.image-viewer {
  width: min(96vw, 1400px);
  height: min(94vh, 1000px);
  padding: 0;
  border: 1px solid var(--line-bright);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.image-viewer::backdrop {
  background: rgb(2 3 4 / 0.86);
  backdrop-filter: blur(6px);
}

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

.viewer-header,
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.viewer-header {
  border-bottom: 1px solid var(--line);
}

.viewer-header h2,
.viewer-header .eyebrow {
  overflow: hidden;
  max-width: min(70vw, 1000px);
  margin-bottom: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-figure {
  display: grid;
  min-height: 0;
  margin: 0;
  padding: 1rem;
  place-items: center;
}

.viewer-figure img {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 190px);
  object-fit: contain;
  box-shadow: 0 12px 35px rgb(0 0 0 / 0.45);
}

.viewer-figure figcaption {
  align-self: end;
  width: 100%;
  margin-top: 0.75rem;
  overflow: hidden;
  font-size: 0.85rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-footer {
  border-top: 1px solid var(--line);
}

#viewer-position {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .site-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .archive-total {
    align-self: start;
  }

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

  .era-panel {
    position: static;
    max-height: none;
  }

  .category-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.35rem;
  }

  .category-button {
    flex: 0 0 min(280px, 80vw);
  }

  .toolbar-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field input,
  .sort-field select {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .site-header {
    padding-top: 2.25rem;
  }

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

  .card-copy {
    padding: 0.65rem;
  }

  .viewer-header h2 {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
