/* ══════════════════════════════════════════════════════════════════════════
   Photoshare — contact sheet
   A contact sheet is the artifact for "look at everything, mark what you keep",
   which is exactly this app's job. Warm near-black ground, thin-ruled frames,
   monospace edge markings, one safelight accent, and a colour per person.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --ground:    #12100E;   /* the sheet's backing */
  --sheet:     #1B1815;   /* lifted panels, frame wells */
  --rule:      #3A3430;   /* hairlines */
  --ink:       #EDE6DC;
  --ink-dim:   #8C8279;
  --safelight: #E8622B;   /* the ONLY loud colour in the app */
  --danger:    #E05252;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --pad: 12px;
  --person: var(--ink-dim);   /* overridden per tile/chip */

  color-scheme: dark;
}

/* ── reset + the small-screen guards ──────────────────────────────────────
   The spike scrolled sideways on an iPhone mini. No framework prevents that;
   these four rules do. Anything that can hold an unbroken string gets
   `overflow-wrap: anywhere`, and every flex/grid child gets `min-width: 0` —
   without it items refuse to shrink below their content's intrinsic width,
   which is the usual cause. */

*, *::before, *::after { box-sizing: border-box; }

/* Any `display` declaration outranks the UA's `[hidden] { display: none }`,
   so every flex/grid/block element the app hides would render anyway. This is
   easy to reintroduce one component at a time; make it structural instead. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;    /* belt; the rules above are the braces */
}

body {
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

img { max-width: 100%; }
h1, h2, p { margin: 0; }

button, input, textarea {
  font: inherit;
  color: inherit;
  min-width: 0;
}

:focus-visible {
  outline: 2px solid var(--safelight);
  outline-offset: 2px;
}

code, .err, textarea, .upname {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ── screens ──────────────────────────────────────────────────────────── */

.screen { display: none; }
body[data-screen="boot"]     #scr-boot,
body[data-screen="link"]     #scr-link,
body[data-screen="identity"] #scr-identity,
body[data-screen="gallery"]  #scr-gallery { display: block; }

.centered {
  max-width: 32rem;
  margin: 0 auto;
  padding: max(2.5rem, env(safe-area-inset-top)) var(--pad) 3rem;
}

.wordmark {
  font: 11px/1 var(--mono);
  letter-spacing: .34em;
  color: var(--ink-dim);
  margin-bottom: 2.2rem;
}

.eyebrow {
  font: 11px/1 var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--safelight);
  margin-bottom: .9rem;
}

.centered h1 {
  font: 400 20px/1.3 var(--mono);
  letter-spacing: .01em;
  margin-bottom: .6rem;
}

.lede {
  color: var(--ink-dim);
  font-size: 13px;
  margin-bottom: 1.5rem;
}

.loading {
  color: var(--ink-dim);
  font: 13px/1 var(--mono);
}

.fineprint {
  color: var(--ink-dim);
  font-size: 11px;
  margin-top: .9rem;
}

.err {
  color: var(--danger);
  font: 12px/1.5 var(--mono);
  margin: .8rem 0 0;
}

textarea {
  width: 100%;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .7rem;
  font: 12px/1.5 var(--mono);
  resize: vertical;
}

/* ── buttons ──────────────────────────────────────────────────────────── */

.btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .62rem 1rem;
  min-height: 44px;             /* tap target floor */
  font: 12px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-dim); }
.btn:disabled { opacity: .4; cursor: default; }

.btn.primary {
  background: var(--safelight);
  border-color: var(--safelight);
  color: #1A0C05;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn.danger { color: var(--danger); border-color: #4A2A2A; }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); }

.btn.ghost { border-color: transparent; color: var(--ink-dim); }
.btn.ghost:hover { color: var(--ink); }

.btn.wide { width: 100%; margin-top: 1.1rem; }

/* ── identity ─────────────────────────────────────────────────────────── */

.swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--person);
}

.namerow {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 .8rem;
}
.namerow input {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: 0;
  padding: .8rem 0;
  font-size: 16px;              /* < 16px makes iOS zoom the viewport */
}
.namerow input:focus { outline: none; }
.namerow:focus-within { border-color: var(--ink-dim); }

.known { margin-top: 2.4rem; }

.rule-label {
  display: flex;
  align-items: center;
  gap: .8rem;
  font: 10px/1 var(--mono);
  letter-spacing: .2em;
  color: var(--ink-dim);
  margin-bottom: .9rem;
}
.rule-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--rule);
}

.knownlist { display: flex; flex-wrap: wrap; gap: 6px; }

.knownbtn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
  min-height: 44px;
  max-width: 100%;
  padding: .5rem .85rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--person);
  border-radius: 3px;
  font-size: 14px;
  cursor: pointer;
}
.knownbtn:hover { border-color: var(--ink-dim); border-left-color: var(--person); }
.knownbtn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── gallery header ───────────────────────────────────────────────────── */

.sheethead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ground);
  border-bottom: 1px solid var(--rule);
  padding: max(.75rem, env(safe-area-inset-top)) var(--pad) .6rem;
}

.headtop {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.albumtitle {
  flex: 1 1 auto;
  min-width: 0;
  font: 400 15px/1.3 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .45rem;
  max-width: 44%;
  min-height: 36px;
  padding: .3rem .6rem;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.who:hover { border-color: var(--ink-dim); }
.whoname {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .3rem;
  font: 10px/1.4 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.meta > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta b { color: var(--safelight); font-weight: 400; }

/* Long-press already selects, but nobody discovers a long-press — so this is
   the discoverable route and has to look like a control, not a footnote. */
.metabtn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  appearance: none;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
  min-height: 30px;
  padding: .3rem .6rem;
  font: 10px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
}
.metabtn::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: .75;
}
.metabtn:hover { border-color: var(--ink-dim); }

/* While selecting it becomes Select all / Clear, and says so in the accent. */
.metabtn.on {
  color: var(--safelight);
  border-color: #5A3020;
}
.metabtn.on::before {
  background: var(--safelight);
  border-color: var(--safelight);
  opacity: 1;
}

/* ── sort: a segment, not a button ────────────────────────────────────────
   Sorting is a mode, not an action, so both modes stay legible and the lit one
   states the current order without being tapped. It deliberately shares none of
   .metabtn's chrome: next to Select, a second bordered box with a square glyph
   read as a second checkbox. */
.seg {
  flex: 0 0 auto;
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.segbtn {
  appearance: none;
  background: none;
  border: 0;
  min-height: 30px;
  padding: .3rem .6rem;
  font: 10px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  cursor: pointer;
}
.segbtn + .segbtn { border-left: 1px solid var(--rule); }
.segbtn:hover { color: var(--ink); }
.segbtn.on {
  background: var(--sheet);
  color: var(--safelight);
  cursor: default;
}

/* ── filters: scrolls inside itself, never the page ───────────────────── */

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: .7rem var(--pad);
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  appearance: none;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--person);
  border-radius: 3px;
  min-height: 32px;
  padding: .35rem .6rem;
  font: 10px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .45rem;
  white-space: nowrap;
}
/* One long name shouldn't push every other person off the row. */
.chip > span:first-child {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip .n { color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink-dim); }
.chip[aria-pressed="true"] { border-left-color: var(--person); }

/* ── the sheet itself ─────────────────────────────────────────────────── */

.grid {
  display: grid;
  /* 92px keeps three columns down to a 320px phone — a contact sheet wants
     density. min() is what stops it overflowing at the very bottom end. */
  grid-template-columns: repeat(auto-fill, minmax(min(92px, 100%), 1fr));
  gap: 8px;
  /* The dock clearance that used to live here is on .colophon now, so the
     stamp sits directly under the last row instead of after a dead gap. */
  padding: 0 var(--pad) 1.4rem;
}

/* Deploy stamp: a diagnostic for "did this phone pick up the push", not
   something guests need in their face — so it lives past the last frame and
   carries the scroll clearance for the fixed dock. */
.colophon {
  padding: 0 var(--pad) 6.5rem;
  text-align: center;
  font: 9px/1 var(--mono);
  letter-spacing: .18em;
  color: var(--ink-dim);
  opacity: .5;
}

.tile {
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.shot {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--sheet);
  border: 1px solid var(--rule);
}
.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .3s ease-out;
}
.shot img.loaded { opacity: 1; }

/* Frame numbering, in the uploader's colour. The number is assigned from the
   full oldest-first list, so it stays put when you filter. */
.frame {
  display: flex;
  justify-content: space-between;
  gap: .4rem;
  border-top: 3px solid var(--person);
  padding: 3px 2px 0;
  font: 9px/1.4 var(--mono);
  letter-spacing: .08em;
  color: var(--person);
}
.frame .fname {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-dim);
}

/* ── the grease-pencil mark ───────────────────────────────────────────────
   The signature element. Uneven border widths and a slight rotation so it
   reads as something drawn on the sheet rather than a UI dot. Only the two
   states that need action get one; the ordinary middle state stays clean. */

.mark {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2px solid var(--safelight);
  border-width: 2px 2.5px 1.5px 2px;
  transform: rotate(-8deg);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .85));
  display: none;
}
.tile[data-state="new"] .mark,
.tile[data-state="saved"] .mark { display: block; }

.tile[data-state="saved"] .mark {
  border-color: var(--ink);
  border-width: 1.5px 2px 2.5px 2px;
  transform: rotate(6deg);
}
.tile[data-state="saved"] .mark::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: 2px solid var(--ink);
  border-top: 0;
  border-left: 0;
  transform: rotate(38deg);
}

/* ── selection ────────────────────────────────────────────────────────────
   Thumbnails must not offer the OS long-press menu, or it fires instead of
   entering selection. The full-size image in the lightbox keeps it, because
   "Add to Photos" from a long-press is the fallback when Web Share isn't
   available. */

.tile {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* A long-press here means "start selecting", so nothing may hijack it: no OS
   callout, no text selection, and no native image drag. */
.tile img {
  -webkit-user-drag: none;
  user-drag: none;
}

.selbox {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2px solid #fffc;
  background: #0006;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .85));
  display: none;
}
.grid.selecting .selbox { display: block; }

.grid.selecting .tile[data-sel="on"] .selbox {
  background: var(--safelight);
  border-color: var(--safelight);
}
.grid.selecting .tile[data-sel="on"] .selbox::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  width: 4px;
  height: 8px;
  border: 2px solid #1A0C05;
  border-top: 0;
  border-left: 0;
  transform: rotate(40deg);
}
.grid.selecting .tile[data-sel="on"] .shot {
  border-color: var(--safelight);
}
.grid.selecting .tile[data-sel="on"] img { opacity: .55; }

.selacts {
  display: flex;
  gap: 6px;
  width: 100%;
  min-width: 0;
}
.selacts .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: .4rem;
  background: var(--sheet);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── legend ───────────────────────────────────────────────────────────────
   A legend, not an introduction: a term/description list keyed by the literal
   glyphs on the controls below it, so it's read as a caption for the screen
   rather than as documentation. Three rows is the budget — a fourth turns it
   into something to skip. */

.intro {
  position: relative;
  margin: 0 var(--pad) .9rem;
  padding: .8rem .9rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--sheet);
}
.introhead {
  margin: 0 0 .7rem;
  padding-right: 1.6rem;         /* clear of the ✕ */
  font: 10px/1.4 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--safelight);
}
.introkeys {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .45rem .7rem;
  align-items: baseline;
}
/* The row wrapper exists only so a whole row can be hidden at once; it must not
   introduce a box between the grid and its dt/dd. */
.introkeys > div { display: contents; }
.introkeys dt {
  min-width: 0;
  font: 10px/1.5 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}
.introkeys dd {
  margin: 0;
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-dim);
}
.introx {
  position: absolute;
  top: .2rem;
  right: .2rem;
  appearance: none;
  background: none;
  border: 0;
  padding: .45rem .55rem;
  font: 12px/1 var(--mono);
  color: var(--ink-dim);
  cursor: pointer;
}
.introx:hover { color: var(--ink); }

.empty {
  padding: 3.5rem var(--pad);
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
}
.empty-big {
  display: block;
  font: 15px/1.4 var(--mono);
  color: var(--ink);
  margin-bottom: .4rem;
}
.empty b { color: var(--safelight); }

/* Same sentence, right verb — and the drop shortcut only exists where there is
   something to drag from. `(pointer: fine)` is the same test `isHandheld()`
   makes in JS, so the two copies never disagree. */
.mouse-only { display: none; }
@media (pointer: fine) {
  .touch-only { display: none; }
  .mouse-only { display: inline; }
}

/* ── dock ─────────────────────────────────────────────────────────────── */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--ground) 62%, transparent);
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

.btn.save {
  background: var(--sheet);
  border-color: var(--rule);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fab {
  appearance: none;
  margin-left: auto;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--safelight);
  color: #1A0C05;
  font: 300 30px/1 var(--sans);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.fab:hover { filter: brightness(1.1); }
.fab:active { transform: scale(.94); }

/* ── lightbox ─────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0A0908;
  animation: fade .14s ease-out;
}
.lightbox[hidden] { display: none; }

/* Paging is a native scroll-snap carousel. Doing it by hand gave no movement
   at all — the image just cut to the next one — and it lost the axis fight
   with the page, so a swipe scrolled vertically first. `touch-action: pan-x`
   settles that outright: this element owns horizontal gestures and refuses
   vertical ones. */
.lbtrack {
  position: absolute;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  touch-action: pan-x;
  scrollbar-width: none;
}
.lbtrack::-webkit-scrollbar { display: none; }

.lbslide {
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;     /* one photo per flick, not four */
  display: grid;
  place-items: center;
}

.lbslide img {
  /* A fixed box rather than a shrink-to-fit one. The slide paints the cached
     thumbnail first and swaps in the mid-size copy a moment later; sized to
     their natural widths those two would land in different geometry and the
     photo would jump under your thumb. object-fit does the letterboxing. */
  width: 100%;
  height: 100dvh;               /* dvh: iOS Safari's toolbar makes vh wrong */
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: default;   /* keep long-press → Add to Photos */
}

.lbclose {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: 8px;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, .5);
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
}

.lbnav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  background: rgba(0, 0, 0, .4);
  border: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
}
.lbnav:hover { opacity: 1; }
.lbnav.prev { left: 0; border-radius: 0 4px 4px 0; }
.lbnav.next { right: 0; border-radius: 4px 0 0 4px; }
.lbnav[hidden] { display: none; }

.lbbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .75rem var(--pad) calc(.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, .92), transparent);
}

.lbmeta {
  flex: 1 1 8rem;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  font: 11px/1.4 var(--mono);
  letter-spacing: .06em;
  color: var(--ink-dim);
  overflow: hidden;
}
.lbmeta > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbWho { color: var(--ink); }
.lbframe { color: var(--person); flex: 0 0 auto; }
.lbdate { flex: 0 0 auto; }

.lbacts { flex: 0 0 auto; display: flex; gap: 6px; }
.lbacts .btn { background: rgba(0, 0, 0, .55); }
/* Needed explicitly: the rule above and `.btn.primary` have equal specificity,
   and this one comes later — so the armed Save button would otherwise keep its
   translucent black fill and render near-black text on it. */
.lbacts .btn.primary { background: var(--safelight); }

/* ── upload sheet ─────────────────────────────────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, .6);
  animation: fade .14s ease-out;
}
.sheet[hidden] { display: none; }

.sheetbox {
  width: 100%;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  border-top: 1px solid var(--rule);
  border-radius: 10px 10px 0 0;
  padding: 1rem var(--pad) calc(1rem + env(safe-area-inset-bottom));
  animation: slideup .2s ease-out;
}

.sheettop {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .3rem;
}
.sheettop h2 {
  flex: 1 1 auto;
  min-width: 0;
  font: 400 13px/1.3 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.upsummary {
  font: 11px/1.5 var(--mono);
  color: var(--ink-dim);
  margin-bottom: .7rem;
}

.uplist {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--rule);
}

.uprow {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
}
.upname {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-dim);
}
.upstat {
  flex: 0 0 auto;
  font: 10px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.uprow[data-s="done"]  .upstat { color: #5FBF77; }
.uprow[data-s="dupe"]  .upstat { color: var(--ink-dim); }
.uprow[data-s="fail"]  .upstat { color: var(--danger); }
.uprow[data-s="work"]  .upstat { color: var(--safelight); }

/* Confirm — the same bottom sheet, since a permanent delete deserves the same
   weight as a long-running job rather than a browser dialog. */

.confirmbox { max-height: none; }

.confirmtitle {
  font: 400 15px/1.35 var(--mono);
  margin-bottom: .5rem;
}

.confirmacts {
  display: flex;
  gap: 8px;
  margin-top: 1.2rem;
}
.confirmacts .btn { flex: 1 1 0; min-width: 0; }

/* A photo whose thumbnail never arrived still gets a frame — the tile is a
   real record, and hiding it would misrepresent the album. */
.tile.nothumb .shot::after {
  content: "no preview";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 9px/1 var(--mono);
  letter-spacing: .1em;
  color: var(--ink-dim);
}

/* ── drop target ──────────────────────────────────────────────────────────
   Above the upload sheet (70) but under the toasts (90), because a drop can
   land while a finished sheet is still open — and the toast that explains a
   refused drop has to be readable over it. Dashed hairline instead of a solid
   one: the frame is a target, not a panel, and it is the one moment the
   safelight gets to outline something. */

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: rgba(10, 9, 8, .82);
  animation: fade .12s ease-out;
  pointer-events: none;      /* the listeners live on window */
}
.dropzone[hidden] { display: none; }

.dropbox {
  width: min(460px, 100%);
  padding: 2.2rem 1.25rem;
  text-align: center;
  border: 1px dashed var(--safelight);
  border-radius: 4px;
  background: rgba(232, 98, 43, .05);
}

.dropmark {
  font: 300 34px/1 var(--sans);
  color: var(--safelight);
}

.drophead {
  margin-top: .7rem;
  font: 400 15px/1.3 var(--mono);
}

.dropsub {
  margin-top: .4rem;
  font: 10px/1.5 var(--mono);
  letter-spacing: .08em;
  color: var(--ink-dim);
  overflow-wrap: anywhere;
}

/* ── toasts ───────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100vw - 2 * var(--pad));
  pointer-events: none;
}

.toast {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .55rem .85rem;
  font: 11px/1.4 var(--mono);
  max-width: 100%;
  overflow-wrap: anywhere;
  animation: fade .16s ease-out;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.toast.bad { border-color: #4A2A2A; color: #F0A0A0; }

/* ── motion ───────────────────────────────────────────────────────────── */

@keyframes fade    { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(14px); } }
@keyframes rise    { from { opacity: 0; transform: translateY(6px); } }

/* First paint only — never on filtering, where a restagger reads as thrash. */
.tile.enter { animation: rise .34s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
  }
}
