:root {
  color-scheme: light;
  --ink: #191716;
  --muted: #6f6761;
  --paper: #fbfaf8;
  --panel: #ffffff;
  --line: #ded8d0;
  --accent: #b4233a;
  --teal: #007f7a;
  --gold: #c7932b;
  --shadow: 0 18px 44px rgba(25, 23, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(0, 127, 122, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(180, 35, 58, 0.06), transparent 360px),
    var(--paper);
  background-size: 72px 72px, auto, auto;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(222, 216, 208, 0.82);
  background: rgba(251, 250, 248, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 760;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: Georgia, serif;
  font-size: 20px;
  line-height: 1;
}

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

.icon-button,
.load-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.icon-button:hover,
.load-button:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
  box-shadow: 0 10px 24px rgba(25, 23, 22, 0.09);
}

.icon-button {
  width: 42px;
  height: 42px;
}

.load-button {
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  font-weight: 720;
}

.icon-button svg,
.load-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

main {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 30px clamp(14px, 3vw, 38px) 80px;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 10px 0 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 6vw, 74px);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.96;
}

.stats {
  display: grid;
  min-width: 112px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.72);
}

.stats span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  font-weight: 800;
}

.stats small {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}

.status-row p {
  margin: 0;
}

.status-row a {
  color: var(--accent);
  font-weight: 720;
  text-decoration: none;
  white-space: nowrap;
}

.gallery {
  column-count: var(--columns, 4);
  column-gap: clamp(12px, 2vw, 22px);
}

.photo-card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 clamp(12px, 2vw, 22px);
  overflow: hidden;
  break-inside: avoid;
  border: 1px solid rgba(25, 23, 22, 0.1);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.photo-card:focus-visible {
  outline: 3px solid rgba(0, 127, 122, 0.5);
  outline-offset: 4px;
}

.photo-card.is-favorite {
  border-color: rgba(199, 147, 43, 0.72);
}

.photo-card.is-favorite::after {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(25, 23, 22, 0.22);
  content: "";
}

.photo-card img {
  display: block;
  width: 100%;
  min-height: 180px;
  object-fit: cover;
  opacity: 1;
  transition: opacity 260ms ease;
}

.photo-card.is-loading img {
  opacity: 0;
}

.skeleton {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 280px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.58), transparent),
    linear-gradient(135deg, rgba(0, 127, 122, 0.16), rgba(180, 35, 58, 0.14));
  background-size: 180px 100%, auto;
  animation: shimmer 1.2s infinite linear;
}

.photo-card.is-loading .skeleton {
  display: block;
}

.card-meta {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.photo-card:hover .card-meta,
.photo-card:focus-visible .card-meta,
.photo-card.has-error .card-meta {
  opacity: 1;
  transform: translateY(0);
}

.card-meta span,
.card-meta button {
  border: 1px solid rgba(255, 255, 255, 0.54);
  background: rgba(25, 23, 22, 0.72);
  color: #fff;
  font: 700 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  backdrop-filter: blur(8px);
}

.card-meta span {
  padding: 7px 9px;
}

.card-meta div {
  display: inline-flex;
  gap: 6px;
}

.card-meta button {
  display: inline-flex;
  padding: 7px 10px;
  cursor: pointer;
}

.card-meta button:not(.favorite-chip) {
  display: none;
}

.photo-card.is-favorite .favorite-chip {
  background: rgba(199, 147, 43, 0.88);
  color: var(--ink);
}

.photo-card.has-error {
  min-height: 240px;
  border-color: rgba(180, 35, 58, 0.45);
  background:
    linear-gradient(135deg, rgba(180, 35, 58, 0.2), rgba(199, 147, 43, 0.18)),
    var(--panel);
}

.photo-card.has-error img {
  opacity: 0;
}

.photo-card.has-error .card-meta button:not(.favorite-chip) {
  display: inline-flex;
}

body.preview-open {
  overflow: hidden;
}

.preview {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  color: #fff;
}

.preview.is-open {
  display: block;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(0, 127, 122, 0.22), transparent 32%),
    radial-gradient(circle at 82% 20%, rgba(180, 35, 58, 0.22), transparent 30%),
    rgba(15, 14, 13, 0.9);
  cursor: zoom-out;
}

.preview-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  padding: 18px clamp(14px, 3vw, 34px) 14px;
  pointer-events: none;
}

.preview-topbar,
.preview-controls,
.preview-nav,
.preview-figure {
  pointer-events: auto;
}

.preview-topbar {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.preview-topbar p {
  margin: 0 0 3px;
  color: rgba(255, 255, 255, 0.62);
  font: 700 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
}

.preview-topbar strong {
  font: 760 22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.preview-actions,
.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.preview-actions button,
.zoom-controls button,
.preview-nav {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition:
    background 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}

.preview-actions button:hover,
.zoom-controls button:hover,
.preview-nav:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.18);
}

.preview-actions button.is-active {
  border-color: rgba(199, 147, 43, 0.8);
  background: rgba(199, 147, 43, 0.24);
  color: #ffd889;
}

.preview svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.preview-actions [data-preview-favorite] svg {
  fill: transparent;
}

.preview-actions [data-preview-favorite].is-active svg {
  fill: currentColor;
}

.preview-figure {
  display: grid;
  min-height: 0;
  margin: 0;
  padding: 18px 62px;
  place-items: center;
  overflow: auto;
}

.preview-figure img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  transition: transform 160ms ease;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.preview-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 48px;
  height: 64px;
  transform: translateY(-50%);
}

.preview-nav:hover {
  transform: translateY(calc(-50% - 1px));
}

.preview-nav-prev {
  left: clamp(12px, 2vw, 28px);
}

.preview-nav-next {
  right: clamp(12px, 2vw, 28px);
}

.preview-controls {
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.zoom-controls {
  min-width: 242px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.zoom-controls output {
  min-width: 54px;
  color: rgba(255, 255, 255, 0.82);
  font: 760 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
}

.filmstrip {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  scrollbar-color: rgba(255, 255, 255, 0.42) transparent;
}

.thumb {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

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

.thumb span {
  position: absolute;
  right: 4px;
  bottom: 3px;
  padding: 2px 4px;
  background: rgba(25, 23, 22, 0.72);
  color: #fff;
  font: 800 9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.thumb.is-active {
  border-color: #fff;
}

.thumb.is-favorite::before {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 1;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.sentinel {
  height: 1px;
}

@keyframes shimmer {
  from {
    background-position: -180px 0, 0 0;
  }
  to {
    background-position: calc(100% + 180px) 0, 0 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
  }

  .brand span:last-child {
    max-width: 110px;
    line-height: 1.05;
  }

  main {
    padding-top: 22px;
  }

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

  .stats {
    width: 100%;
  }

  .status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-stage {
    padding: 12px;
  }

  .preview-topbar {
    align-items: flex-start;
  }

  .preview-actions button,
  .zoom-controls button {
    width: 38px;
    height: 38px;
  }

  .preview-figure {
    padding: 12px 0 16px;
  }

  .preview-nav {
    top: auto;
    bottom: 106px;
    width: 44px;
    height: 44px;
    transform: none;
  }

  .preview-nav:hover {
    transform: translateY(-1px);
  }

  .preview-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .zoom-controls {
    justify-content: center;
    min-width: 0;
  }

  .thumb {
    width: 52px;
    height: 52px;
  }
}
