:root {
  --paper: #f4efe8;
  --ink: #2a241f;
  --muted: #6f655c;
  --line: #e2d8cc;
  --gold: #9a7b4f;
  --gold-soft: #c4a574;
  --card: #fffcf8;
  --shadow: 0 18px 50px rgba(42, 36, 31, 0.12);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
}
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
.eyebrow {
  margin: 0 0 0.35rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
}
.lede { color: var(--muted); margin: 0 0 0.75rem; line-height: 1.5; }
.meta { color: var(--muted); margin: 0; font-size: 0.92rem; }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }

.lookup {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.2rem;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(196, 165, 116, 0.18), transparent 60%),
    var(--paper);
}
.lookup-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 2.4rem 2rem;
  box-shadow: var(--shadow);
}
.lookup-form { display: grid; gap: 0.65rem; margin-top: 1.4rem; }
label { font-size: 0.82rem; color: var(--muted); }
input, select, button, .btn {
  font: inherit;
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
}
button, .btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.92rem;
}
button:hover, .btn:hover { background: #171411; }
.btn, .toolbar .btn {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn:hover, .toolbar .btn:hover { background: #fff; color: var(--ink); }
.lookup-form button { background: var(--ink); color: #fff; }
.text-link { color: var(--gold); }
.flash {
  background: #eef6ea;
  border: 1px solid #cfe3c6;
  color: #315528;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
}
.flash-error { background: #fbeeee; border-color: #efc9c9; color: #7a2e2e; }
.hint { color: var(--muted); font-size: 0.8rem; margin: -0.2rem 0 0.8rem; }

.gallery-top, .admin-top, .toolbar, .admin {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
}
.gallery-top, .admin-top {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  padding: 2.2rem 0 1.2rem;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0 1.2rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
}
.toolbar-primary, .toolbar-tools, .row-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.view-select {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.view-select select { width: auto; padding: 0.45rem 0.7rem; min-width: 10.5rem; }
.photo-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.photo-search input {
  width: 11.5rem;
  padding: 0.45rem 0.7rem;
}
.tile.is-off { display: none !important; }
.wall-empty { padding: 2.5rem 1rem 4rem; }
.toolbar-status {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0 0.25rem;
  white-space: nowrap;
}
.speed {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.speed select { width: auto; padding: 0.45rem 0.6rem; }
#play-btn[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

.stage { width: min(1280px, calc(100% - 2rem)); margin: 0 auto 3rem; position: relative; }
html.photolab-booting,
html.photolab-booting body {
  overflow: hidden;
  height: 100%;
}
.stage.is-loading .wall,
.stage.is-loading .viewer {
  visibility: hidden;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}
.gallery-loader {
  min-height: 52vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.65rem;
  text-align: center;
  padding: 4rem 1rem;
}
.stage.is-ready .gallery-loader { display: none; }
.loader-mark {
  width: 36px;
  height: 36px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: photolab-spin 0.8s linear infinite;
}
.gallery-loader p { margin: 0; font-family: var(--serif); font-size: 1.5rem; }
.loader-sub { color: var(--muted); font-family: var(--sans) !important; font-size: 0.92rem !important; }
@keyframes photolab-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loader-mark { animation: none; border-top-color: var(--gold); }
}
.wall { column-count: 3; column-gap: 0.7rem; }
@media (max-width: 900px) { .wall { column-count: 2; } }
@media (max-width: 560px) { .wall { column-count: 1; } }
.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 14px;
  overflow: hidden;
  margin: 0 0 0.7rem;
  break-inside: avoid;
  cursor: zoom-in;
}
.tile img {
  width: 100%;
  display: block;
  vertical-align: top;
  background: #ddd4c8;
  transition: transform 0.45s ease;
}
.tile img:not([src]) {
  min-height: 220px;
}
.tile:hover img { transform: scale(1.03); }

.stage .wall { display: block; }
.stage .viewer { display: none; gap: 0.9rem; }
.layout-grid .wall {
  column-count: unset;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.65rem;
}
.layout-grid .tile { margin: 0; aspect-ratio: 1; }
.layout-grid .tile img { height: 100%; object-fit: cover; }
.layout-single .wall,
.layout-coverflow .wall,
.layout-present .wall { display: none !important; }
.layout-single .viewer,
.layout-coverflow .viewer,
.layout-present .viewer {
  display: grid !important;
}

.viewer {
  position: relative;
  min-height: 62vh;
}
.viewer-frame {
  margin: 0;
  min-height: 58vh;
  display: grid;
  place-items: center;
  position: relative;
}
#hero {
  max-width: min(1080px, 100%);
  max-height: 72vh;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: #ddd4c8;
}
.layout-coverflow #hero { display: none; }
.layout-single .coverflow,
.layout-present .coverflow { display: none; }
.viewer figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  width: min(1080px, 100%);
  margin-top: 0.7rem;
}
.lb-nav {
  position: absolute;
  top: 38%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,252,248,0.9);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 1.8rem;
  z-index: 3;
}
.lb-nav.prev { left: 0; }
.lb-nav.next { right: 0; }

.coverflow {
  width: 100%;
  height: min(68vh, 640px);
  perspective: 1400px;
  display: grid;
  place-items: center;
}
.coverflow-track {
  position: relative;
  width: min(920px, 100%);
  height: 100%;
  transform-style: preserve-3d;
}
.cover-card {
  position: absolute;
  inset: 8% auto 12%;
  width: min(420px, 58vw);
  left: 50%;
  margin-left: calc(min(420px, 58vw) / -2);
  border: 0;
  padding: 0;
  background: none;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.22);
  transition: transform 0.7s cubic-bezier(.22,1,.36,1), opacity 0.7s ease;
}
.cover-card.is-center { box-shadow: 0 28px 70px rgba(42, 36, 31, 0.38); }
.cover-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.filmstrip {
  --thumb: 76px;
  --gap: 8px;
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0 0.6rem;
  height: calc(var(--thumb) + 14px);
  scrollbar-width: thin;
}
.filmstrip-rail {
  position: relative;
  height: var(--thumb);
}
.filmstrip button {
  position: absolute;
  top: 0;
  width: var(--thumb);
  height: var(--thumb);
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #ddd4c8;
}
.filmstrip button.is-on { border-color: var(--gold); }
.filmstrip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.layout-present {
  width: 100%;
  max-width: none;
  margin: 0;
  background: #120f0d;
  color: #f6f1ea;
  min-height: calc(100vh - 7rem);
  padding: 0 0 2rem;
}
.layout-present .viewer-frame { min-height: 78vh; }
.layout-present #hero {
  max-height: 82vh;
  border-radius: 0;
  box-shadow: none;
  max-width: 100%;
  background: #1b1612;
}
.layout-present figcaption {
  color: #f3eadf;
  width: min(1100px, calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}
.layout-present .lb-nav { background: rgba(18,15,13,0.55); color: #fff; border-color: transparent; }
.layout-present .filmstrip button { background: #2a241f; border-color: #3a3129; }
.layout-present .filmstrip button.is-on { border-color: var(--gold-soft); }
body:has(.layout-present) { background: #120f0d; }
body:has(.layout-present) .gallery-top,
body:has(.layout-present) .toolbar,
body:has(.layout-present) h1 { color: #f6f1ea; }
body:has(.layout-present) .gallery-top { padding-top: 1.1rem; padding-bottom: 0.4rem; }
body:has(.layout-present) .view-select,
body:has(.layout-present) .photo-search,
body:has(.layout-present) .toolbar-status,
body:has(.layout-present) .lede,
body:has(.layout-present) .meta,
body:has(.layout-present) .speed,
body:has(.layout-present) .eyebrow { color: #d4c4b0; }
body:has(.layout-present) .toolbar { background: rgba(18,15,13,0.92); }
body:has(.layout-present) .btn,
body:has(.layout-present) .toolbar .btn {
  color: #f6f1ea;
  border-color: #5a4c3e;
  background: transparent;
}
body:has(.layout-present) .btn:hover,
body:has(.layout-present) .toolbar .btn:hover {
  background: #2a241f;
  color: #f6f1ea;
}
body:has(.layout-present) .speed select,
body:has(.layout-present) .photo-search input,
body:has(.layout-present) .view-select select {
  background: #1b1612;
  color: #f6f1ea;
  border-color: #5a4c3e;
}
body:has(.layout-present) #play-btn[aria-pressed="true"] {
  background: var(--gold-soft);
  border-color: var(--gold-soft);
  color: #120f0d;
}

@media (max-width: 720px) {
  .gallery-top { padding: 1.2rem 0 0.7rem; align-items: start; }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding-bottom: 0.8rem;
  }
  .toolbar-primary, .toolbar-tools { width: 100%; }
  .view-select, .photo-search { width: 100%; }
  .view-select select, .photo-search input { min-width: 0; flex: 1; width: auto; }
  .toolbar-tools { justify-content: space-between; }
  .speed { font-size: 0.75rem; }
  .lb-nav { width: 40px; height: 40px; top: 30%; font-size: 1.5rem; }
  .lb-nav.prev { left: 0.2rem; }
  .lb-nav.next { right: 0.2rem; }
  #hero { max-height: 58vh; }
  .coverflow { height: min(56vh, 420px); }
  .cover-card { width: min(260px, 70vw); margin-left: calc(min(260px, 70vw) / -2); }
}

@media (prefers-reduced-motion: reduce) {
  .cover-card, .tile img { transition: none; }
}

.admin { padding-bottom: 4rem; }
.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1.1fr);
  gap: 1.5rem;
}
@media (max-width: 860px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-form, .admin-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.3rem;
}
.admin-form { display: grid; gap: 0.45rem; align-content: start; }
.admin-list ul { list-style: none; padding: 0; margin: 0; }
.admin-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}
.admin-list span { display: block; color: var(--muted); font-size: 0.85rem; }
.row-actions form { display: inline; }
.row-actions button {
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 0;
  border-radius: 0;
  text-decoration: underline;
}
.row-actions .danger { color: #9a3030; }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  z-index: 50;
}
