/* Cyanotype palette: Prussian blue ink on pale paper. In dark mode the
   paper becomes the deep blue of the print itself. */
:root {
  --paper: #f4f6f4;
  --card: #ffffff;
  --ink: #0f1b26;
  --mute: #566676;
  --line: #d3dbe2;
  --wash: #dce8f2;
  --accent: #0d3b66;
  --on-accent: #ffffff;
  --accent-soft: #e3edf7;
  --danger: #b3261e;
  --shadow: 0 1px 0 rgba(13, 59, 102, .08), 0 14px 28px -16px rgba(13, 59, 102, .45);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --text: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a1e33;
    --card: #0f2d4b;
    --ink: #e9eff5;
    --mute: #9db1c4;
    --line: #1f4468;
    --wash: #153a5e;
    --accent: #8ec1f2;
    --on-accent: #08233d;
    --accent-soft: #123456;
    --danger: #ff8a80;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 28px -16px rgba(0, 0, 0, .7);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--text);
}
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: .18em; }
[hidden] { display: none !important; }

h1, h2 { font-family: var(--display); margin: 0; letter-spacing: -.02em; line-height: 1.08; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.5rem); font-weight: 700; font-variation-settings: "opsz" 96; }
h2 { font-size: 1.35rem; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--mute); }
.lede { font-size: 1.15rem; max-width: 60ch; margin-top: .6rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- Header ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}
.mark {
  font: 700 1.25rem/1 var(--display); letter-spacing: -.02em;
  color: var(--ink); text-decoration: none;
}
.bar-nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; justify-content: flex-end; }
.bar-nav a { color: var(--ink); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.bar-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.bar-nav form { margin: 0; }

.page { padding: clamp(1.25rem, 4vw, 2.75rem) clamp(1rem, 4vw, 2.5rem) 5rem; max-width: 1500px; margin: 0 auto; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.album-head { align-items: flex-start; }
.album-head .muted { margin-top: .6rem; }
.back { display: inline-block; margin-bottom: 1.25rem; color: var(--mute); }

/* ---------- Buttons and form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .95rem/1 var(--text);
  padding: .75rem 1.1rem; min-height: 44px;
  border-radius: 999px; border: 1.5px solid var(--accent);
  background: transparent; color: var(--accent);
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.wide { width: 100%; margin-top: .5rem; }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.link { background: none; border: 0; padding: .25rem 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: .18em; }
.danger-text { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; }

.field { display: block; margin: 0 0 1.1rem; font-weight: 500; border: 0; padding: 0; }
.field legend { padding: 0; margin-bottom: .4rem; font-weight: 500; }
.field input:not([type="checkbox"]), .field textarea, .inline-form input {
  display: block; width: 100%; margin-top: .35rem;
  font: 400 1rem/1.4 var(--text); color: var(--ink);
  padding: .7rem .8rem; min-height: 44px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 8px;
}
.field input:focus, .field textarea:focus, .inline-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.hint { display: block; margin-top: .3rem; font-size: .88rem; font-weight: 400; color: var(--mute); }

.checks { list-style: none; margin: 0; padding: 0; max-height: 14rem; overflow: auto; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); }
.checks li + li { border-top: 1px solid var(--line); }
.checks label, .check-line { display: flex; gap: .7rem; align-items: center; padding: .65rem .8rem; font-weight: 400; cursor: pointer; }
.check-line { padding-left: 0; margin-bottom: 1rem; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); flex: none; }

.flashes { margin-bottom: 1.5rem; display: grid; gap: .5rem; }
.flash { padding: .75rem 1rem; border-radius: 8px; border: 1.5px solid var(--line); background: var(--card); }
.flash-ok { border-color: var(--accent); background: var(--accent-soft); }
.flash-error { border-color: var(--danger); color: var(--danger); }

/* ---------- Sign in / setup ---------- */
.entry-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.exposure {
  position: relative; overflow: hidden; display: flex; align-items: flex-end;
  padding: clamp(1.5rem, 5vw, 4rem);
  background:
    radial-gradient(60% 50% at 78% 18%, rgba(255, 255, 255, .55), transparent 62%),
    radial-gradient(90% 70% at 15% 90%, #05223f, transparent 70%),
    linear-gradient(160deg, #1a5a98 0%, #0d3b66 55%, #082a4a 100%);
  color: #f1f7fc;
}
.exposure::after {
  content: ""; position: absolute; inset: 7%;
  border: 1.5px solid rgba(255, 255, 255, .35); border-radius: 4px; pointer-events: none;
}
.exposure-name { position: relative; z-index: 1; font: 700 clamp(3rem, 8vw, 6.5rem)/.92 var(--display); letter-spacing: -.035em; max-width: 8ch; }
.entry-form { align-self: center; width: 100%; max-width: 30rem; padding: 2rem clamp(1.25rem, 5vw, 3.5rem); margin: 0 auto; }
.entry-form h1 { font-size: clamp(2rem, 4vw, 2.6rem); margin-bottom: .6rem; }
.entry-form .muted { margin-bottom: 1.75rem; }

/* ---------- Album index: a stack of prints ---------- */
.albums { list-style: none; margin: 0; padding: 0; display: grid; gap: 3rem 2.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.album { display: block; color: inherit; text-decoration: none; }
.album h2 { margin-top: 1.1rem; }
.album .muted { font-size: .95rem; }
.stack { position: relative; aspect-ratio: 4 / 3; margin: .5rem .4rem 0; }
.stack::before, .stack::after {
  content: ""; position: absolute; inset: 0; background: var(--wash);
  border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow);
}
.stack::before { transform: rotate(-3.2deg); }
.stack::after { transform: rotate(2.4deg); background: var(--accent-soft); }
.print {
  position: absolute; inset: 0; z-index: 1; padding: 8px 8px 8px;
  background: #fff; border-radius: 3px; box-shadow: var(--shadow);
}
.print img, .print .blank { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 1px; }
.print .blank { background: linear-gradient(160deg, #1a5a98, #0d3b66 60%, #082a4a); }

.empty { max-width: 34rem; padding: 3rem 0; display: grid; gap: .8rem; justify-items: start; }
.empty p { color: var(--mute); }
.empty .btn { margin-top: .6rem; }

/* ---------- Gallery: justified rows, chronological ---------- */
.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery::after { content: ""; flex-grow: 1000000; }
.shot {
  position: relative; margin: 0;
  flex: calc(var(--ar) * 100) 1 calc(var(--ar) * 230px);
  min-width: 0; max-width: calc(var(--ar) * 420px);
}
.shot-open { display: block; width: 100%; padding: 0; border: 0; background: var(--wash); cursor: zoom-in; border-radius: 4px; overflow: hidden; }
.shot-open img { display: block; width: 100%; height: auto; aspect-ratio: var(--ar); object-fit: cover; }
.shot-check { position: absolute; top: 8px; left: 8px; display: none; width: 30px; height: 30px; align-items: center; justify-content: center; background: rgba(255, 255, 255, .92); border-radius: 50%; cursor: pointer; }
.shot-check input { margin: 0; width: 18px; height: 18px; }
.selecting .shot-check { display: flex; }
.selecting .shot-open { cursor: pointer; }
.selecting .shot:has(input:checked) .shot-open { outline: 3px solid var(--accent); outline-offset: -3px; }

/* ---------- Dialogs ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(5, 25, 45, .62); }
.sheet {
  width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto;
  padding: 1.75rem; border: 1px solid var(--line); border-radius: 14px; background: var(--paper);
}
.sheet h2 { margin-bottom: 1.25rem; font-size: 1.6rem; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }
.danger-zone { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

.lightbox {
  width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0;
  border: 0; background: #06182a; color: #e9eff5;
}
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 1rem 3.5rem 0; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 2px; }
.lb-nav {
  position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 64px;
  border: 0; border-radius: 8px; background: rgba(255, 255, 255, .1); color: #fff;
  font-size: 2.2rem; line-height: 1; cursor: pointer;
}
.lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-prev { left: .5rem; }
.lb-next { right: .5rem; }
.lb-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.25rem 1.1rem; }
.lb-meta { display: grid; min-width: 0; }
.lb-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-meta .muted { color: #9db1c4; font-size: .92rem; }
.lb-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.lightbox .btn { border-color: #8ec1f2; color: #8ec1f2; }
.lightbox .btn:hover { background: rgba(142, 193, 242, .16); }
.lightbox .btn.danger { border-color: #ff8a80; color: #ff8a80; }
.lightbox :focus-visible { outline-color: #8ec1f2; }
form.inline { display: inline; margin: 0; }

/* ---------- Uploads ---------- */
.uploads { margin-bottom: 1.5rem; padding: 1rem 1.1rem; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--card); }
.uploads-head { display: flex; justify-content: space-between; margin-bottom: .6rem; }
#uploads-list { list-style: none; margin: 0; padding: 0; max-height: 15rem; overflow: auto; display: grid; gap: .55rem; }
#uploads-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .8rem; font-size: .93rem; }
#uploads-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#uploads-list .state { color: var(--mute); }
#uploads-list .failed .state { color: var(--danger); }
#uploads-list progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--accent); }
.dragging::after { content: "Drop pictures to add them to this album"; position: fixed; inset: 1rem; z-index: 50; display: grid; place-items: center; font: 650 1.6rem var(--display); color: var(--accent); background: color-mix(in srgb, var(--paper) 88%, transparent); border: 3px dashed var(--accent); border-radius: 18px; pointer-events: none; }

/* ---------- People ---------- */
.people-grid { display: grid; gap: 2.5rem; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.card { padding: 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.card h2 { margin-bottom: 1.1rem; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--mute); font-size: .92rem; padding: 0 .75rem .6rem 0; border-bottom: 1.5px solid var(--line); }
.table td { padding: .85rem .75rem .85rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.row-actions { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.row-actions form { margin: 0; }
.row-actions summary { cursor: pointer; color: var(--accent); }
.inline-form { display: flex; gap: .5rem; margin-top: .6rem; }
.inline-form input { margin-top: 0; min-width: 11rem; }
.tag { margin-left: .4rem; padding: .1rem .5rem; font-size: .8rem; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); }
.note { margin-top: 1rem; font-size: .95rem; max-width: 55ch; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .entry-grid { grid-template-columns: 1fr; min-height: 0; }
  .exposure { min-height: 11rem; }
  .exposure-name { font-size: 3rem; max-width: none; }
  .people-grid { grid-template-columns: 1fr; }
  .lb-stage { padding: .75rem .5rem 0; }
  .lb-nav { width: 38px; height: 56px; background: rgba(6, 24, 42, .6); }
}
@media (max-width: 640px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table tr { display: grid; gap: .15rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
  .table td { display: block; padding: 0; border: 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--mute); }
  .toolbar .btn { flex: 1 1 auto; }
  .shot { max-width: none; }
}

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