/* ------------------------------------------------------------------ tokens
   Photographs read best on a dark wall, so dark is the considered default; a light wall is
   offered for viewers who ask for it. The accent is a warm brass used sparingly — the photos
   carry the colour. */
:root {
  --ground:    #F3F2EF;
  --surface:   #FFFFFF;
  --surface-2: #ECEAE5;
  --ink:       #17181B;
  --muted:     #66635C;
  --faint:     #9A968D;
  --rule:      #DEDBD4;
  --accent:    #8A6424;
  --accent-ink:#FFFFFF;
  --good:      #2F6F5E;
  --bad:       #A33A2A;
  --shadow:    0 1px 2px rgba(20,18,14,.06), 0 10px 30px rgba(20,18,14,.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:    #0E0F11;
    --surface:   #17191C;
    --surface-2: #1F2125;
    --ink:       #ECEAE6;
    --muted:     #A29E96;
    --faint:     #6F6C66;
    --rule:      #2A2C31;
    --accent:    #D1AA62;
    --accent-ink:#121212;
    --good:      #6CB39C;
    --bad:       #E0796A;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --ground:    #0E0F11;
  --surface:   #17191C;
  --surface-2: #1F2125;
  --ink:       #ECEAE6;
  --muted:     #A29E96;
  --faint:     #6F6C66;
  --rule:      #2A2C31;
  --accent:    #D1AA62;
  --accent-ink:#121212;
  --good:      #6CB39C;
  --bad:       #E0796A;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground); color: var(--ink);
  font: 400 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.serif { font-family: "Iowan Old Style", Georgia, "Times New Roman", serif; }
.mono  { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* Any class that sets `display` outranks the browser's own [hidden] rule, so an element given
   `hidden` would stay on screen. This restores the attribute's meaning everywhere. */
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 6px; font-size: 14px; line-height: 1.2;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ============================================================ GALLERY */
.site-head { padding: 56px 24px 22px; max-width: 1480px; margin: 0 auto; }
.site-head .eyebrow {
  font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 14px;
}
.site-head h1 {
  font-family: "Iowan Old Style", Georgia, serif; font-weight: 400; margin: 0;
  font-size: clamp(2.1rem, 5.2vw, 3.8rem); line-height: 1.02; letter-spacing: -.02em; text-wrap: balance;
}
.site-head p.sub { margin: 14px 0 0; color: var(--muted); max-width: 62ch; font-size: 1.02rem; }

.albums-bar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.albums-inner {
  max-width: 1480px; margin: 0 auto; padding: 10px 24px; display: flex; gap: 8px; align-items: center;
  overflow-x: auto; scrollbar-width: none;
}
.albums-inner::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--rule); background: transparent; color: var(--muted);
  padding: 6px 13px; border-radius: 999px; cursor: pointer; font-size: 13.5px; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--ink); border-color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.chip .n { font-family: ui-monospace, Menlo, monospace; font-size: 11px; opacity: .7; margin-left: 6px; }
.albums-bar .count { margin-left: auto; flex: none; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--faint); }

.grid-wrap { max-width: 1480px; margin: 0 auto; padding: 16px 24px 80px; }
@media (max-width: 640px) {
  .site-head { padding: 34px 16px 16px; }
  .albums-inner { padding: 10px 16px; }
  .grid-wrap { padding: 10px 8px 60px; }
}
.jrow { display: flex; gap: 6px; margin-bottom: 6px; }
.tile {
  position: relative; display: block; flex: none; overflow: hidden; border-radius: 3px;
  background: var(--surface-2); cursor: zoom-in; border: 0; padding: 0;
}
.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .35s ease, transform .5s ease;
}
.tile img.in { opacity: 1; }
.tile:hover img { transform: scale(1.025); }
.empty { text-align: center; color: var(--muted); padding: 90px 16px; }
.empty .serif { font-size: 1.6rem; color: var(--ink); margin-bottom: 6px; }
.loader { text-align: center; padding: 26px; color: var(--faint); font-size: 13px; }

/* ----------------------------------------------------------- lightbox */
.lb {
  position: fixed; inset: 0; z-index: 100; background: #050506; color: #EDEBE7;
  display: none; grid-template-rows: auto 1fr auto; user-select: none;
}
.lb.open { display: grid; }
.lb-top, .lb-bottom { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.lb-top .count { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #9A968F; }
.lb-top .spacer { flex: 1; }
.lb .ico {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: #EDEBE7;
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; cursor: pointer;
}
.lb .ico:hover { background: rgba(255,255,255,.14); }
.lb .ico svg { width: 18px; height: 18px; }
.lb .pill {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: #EDEBE7;
  padding: 9px 15px; border-radius: 999px; cursor: pointer; font-size: 13.5px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.lb .pill:hover { background: rgba(255,255,255,.16); }
.lb .pill svg { width: 16px; height: 16px; }
.lb-stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; }
/* The image fills the stage box and `contain` fits it inside both dimensions. A percentage
   max-height does not resolve inside a grid cell, which let portrait photos overflow and crop. */
.lb-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.lb-stage img.low { filter: blur(6px); transform: scale(1.01); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
}
.lb-nav.prev { left: 14px; } .lb-nav.next { right: 14px; }
.lb-bottom { justify-content: center; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
@media (max-width: 640px) { .lb-nav { display: none; } }

/* ============================================================== ADMIN */
.admin-top {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--rule);
  background: var(--surface); position: sticky; top: 0; z-index: 30;
}
.admin-top .brand { font-family: "Iowan Old Style", Georgia, serif; font-size: 20px; }
.admin-top .brand small {
  font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint); margin-left: 10px;
}
.admin-top .spacer { flex: 1; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 22px 0; }
.stat { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 11px 15px; min-width: 150px; }
.stat b { display: block; font-family: "Iowan Old Style", Georgia, serif; font-size: 1.45rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.stat span { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.stat.good b { color: var(--good); }

.admin-body { display: grid; grid-template-columns: 270px minmax(0,1fr); gap: 20px; padding: 18px 22px 60px; align-items: start; }
@media (max-width: 900px) { .admin-body { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.panel-h h2 { margin: 0; font-size: 14.5px; font-weight: 650; }
.panel-h .spacer { flex: 1; }
.panel-b { padding: 14px 16px; }

.alist { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.alist li { display: flex; align-items: center; gap: 6px; border-radius: 6px; }
.alist li > button.pick {
  flex: 1; text-align: left; background: transparent; border: 0; padding: 8px 10px; border-radius: 6px;
  cursor: pointer; display: flex; justify-content: space-between; gap: 10px; min-width: 0;
}
.alist li > button.pick span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alist li > button.pick .n { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--faint); }
.alist li.on > button.pick { background: var(--surface-2); font-weight: 600; }
.alist li:hover > button.pick { background: var(--surface-2); }
.alist .tools { display: none; gap: 2px; padding-right: 4px; }
.alist li:hover .tools, .alist li.on .tools { display: flex; }
.alist .tools button { background: transparent; border: 0; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 4px; }
.alist .tools button:hover { color: var(--ink); background: var(--surface); }
.alist .tools svg { width: 14px; height: 14px; }
.alist .sep { height: 1px; background: var(--rule); margin: 6px 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); }
.input, select.input {
  border: 1px solid var(--rule); background: var(--ground); border-radius: 6px; padding: 8px 10px; width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* upload */
.drop {
  border: 1.5px dashed var(--rule); border-radius: 10px; padding: 30px 18px; text-align: center;
  background: var(--ground); transition: border-color .15s, background .15s; cursor: pointer;
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--ground)); }
.drop .big { font-family: "Iowan Old Style", Georgia, serif; font-size: 1.35rem; margin-bottom: 4px; }
.drop p { margin: 0; color: var(--muted); font-size: 14px; }
.drop .picks { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset {
  border: 1px solid var(--rule); background: var(--ground); border-radius: 6px; padding: 6px 10px; cursor: pointer;
  font-size: 13px; text-align: left;
}
.preset small { display: block; font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--faint); }
.preset[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-row output { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; min-width: 42px; text-align: right; }

.progress { margin-top: 16px; display: none; }
.progress.show { display: block; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.pline { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.pline b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pline .ok b { color: var(--good); }
.pline .err b { color: var(--bad); }
.log { margin-top: 10px; max-height: 190px; overflow: auto; border: 1px solid var(--rule); border-radius: 6px; font-size: 12.5px; }
.log div { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 5px 10px; border-bottom: 1px solid var(--rule); }
.log div:last-child { border-bottom: 0; }
.log .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .st { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }
.log .st.ok { color: var(--good); } .log .st.skip { color: var(--faint); } .log .st.err { color: var(--bad); }

/* manage grid */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--rule); }
.toolbar .spacer { flex: 1; }
.toolbar .sel { font-size: 13px; color: var(--muted); }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; padding: 14px 16px; }
.mcell {
  position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--surface-2);
  cursor: pointer; border: 0; padding: 0;
}
.mcell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mcell .tick {
  position: absolute; top: 7px; left: 7px; width: 22px; height: 22px; border-radius: 999px;
  border: 2px solid rgba(255,255,255,.9); background: rgba(0,0,0,.25); display: grid; place-items: center;
}
.mcell.on { outline: 3px solid var(--accent); outline-offset: -3px; }
.mcell.on .tick { background: var(--accent); border-color: var(--accent); }
.mcell.on .tick::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px,-1px); }
.mcell .cov {
  position: absolute; bottom: 6px; left: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 9.5px;
  letter-spacing: .08em; text-transform: uppercase; background: var(--accent); color: var(--accent-ink);
  padding: 2px 6px; border-radius: 3px;
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { font-family: "Iowan Old Style", Georgia, serif; font-weight: 400; font-size: 1.9rem; margin: 0 0 4px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.err-msg { color: var(--bad); font-size: 13.5px; min-height: 20px; margin-top: 8px; }

dialog.modal {
  border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); color: var(--ink);
  padding: 22px; width: min(440px, 92vw); box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(10,10,12,.55); }
dialog.modal h3 { margin: 0 0 8px; font-size: 1.05rem; }
dialog.modal p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
dialog.modal .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ============================================================== FINDER */
.btn.big { padding: 12px 20px; font-size: 15.5px; border-radius: 8px; }
.btn.big svg { width: 20px; height: 20px; }
.eyebrow.accent { color: var(--accent) !important; }
.sub.small { font-size: .95rem; margin-top: 8px; }

.finder-wrap { max-width: 1480px; margin: 0 auto; padding: 4px 24px 26px; }
.finder {
  display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 28px; align-items: center;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; padding: 28px 32px;
  box-shadow: var(--shadow);
}
.finder .eyebrow {
  font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; margin: 0 0 10px;
}
.finder-h { font-family: "Iowan Old Style", Georgia, serif; font-weight: 400; font-size: clamp(1.55rem, 3vw, 2.1rem); line-height: 1.12; margin: 0 0 8px; text-wrap: balance; }
.finder-p { margin: 0 0 20px; color: var(--muted); max-width: 56ch; }
.finder-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.finder-note { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: var(--faint); }
.finder-note svg { width: 15px; height: 15px; flex: none; }
.finder-art svg { width: 100%; height: auto; display: block; }
.fa-corner { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.fa-oval { fill: none; stroke: var(--faint); stroke-width: 2.5; stroke-dasharray: 5 7; }
.fa-scan { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; animation: fa-scan 2.6s ease-in-out infinite; }
@keyframes fa-scan { 0%, 100% { transform: translateY(-50px); opacity: .25; } 50% { transform: translateY(50px); opacity: 1; } }
@media (max-width: 700px) {
  .finder-wrap { padding: 0 12px 18px; }
  .finder { grid-template-columns: 1fr; padding: 22px 20px; }
  .finder-art { display: none; }
  .finder-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ============================================================= RESULTS */
.results { max-width: 1480px; margin: 0 auto; padding: 6px 24px 0; }
.results-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 1px solid var(--rule);
}
.results .eyebrow { font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; margin: 0 0 8px; }
.results-h { font-family: "Iowan Old Style", Georgia, serif; font-weight: 400; font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0; }
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-wrap.inner { padding: 16px 0 70px; max-width: none; }
@media (max-width: 640px) { .results { padding: 0 12px; } }

/* ============================================================= SCANNER */
.scanner { position: fixed; inset: 0; z-index: 150; background: #050506; color: #EDEBE7; overflow: hidden; }
.scanner video, .scanner #frozen {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.scanner video, .scanner #frozen.mirror { transform: scaleX(-1); }
.scanner #frozen:not(.mirror) { object-fit: contain; }
.oval {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(66vw, 44vh); aspect-ratio: 3 / 4; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 200vmax rgba(5, 5, 6, .62);     /* darken everything outside the oval */
  overflow: hidden; pointer-events: none; transition: border-color .3s;
}
.oval .sweep {
  position: absolute; left: 0; right: 0; height: 22%; top: -22%; opacity: 0;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, #D1AA62 55%, transparent), transparent);
}
.scanner.busy .oval { border-color: #D1AA62; }
.scanner.busy .oval .sweep { opacity: 1; animation: sweep 1.3s ease-in-out infinite; }
@keyframes sweep { 0% { top: -22%; } 100% { top: 100%; } }
.scanner .close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 3;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); color: #fff;
  width: 42px; height: 42px; border-radius: 999px; display: grid; place-items: center; cursor: pointer; }
.scanner .close svg { width: 18px; height: 18px; }
.scan-ui {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 18px 20px max(26px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: linear-gradient(to top, rgba(5,5,6,.85), rgba(5,5,6,0));
}
.scan-hint { margin: 0; text-align: center; font-size: 15.5px; max-width: 34ch; text-wrap: balance; min-height: 1.5em; }
.shutter {
  width: 76px; height: 76px; border-radius: 999px; border: 4px solid #fff; background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.shutter span { width: 58px; height: 58px; border-radius: 999px; background: #fff; transition: transform .12s; }
.shutter:active span { transform: scale(.9); }
.shutter:disabled { opacity: .35; cursor: default; }
.scanner.busy .shutter { visibility: hidden; }
.linkish { background: none; border: 0; color: #CFCBC4; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; }
.linkish:hover { color: #fff; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; cursor: pointer; font-size: 13.5px; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.maybe-head { padding: 26px 0 0; border-top: 1px dashed var(--rule); margin-top: 6px; }
.maybe-head h3 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.maybe-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
#maybe .tile img { filter: saturate(.9); }
