/* Deima's Album — warm paper & terracotta */
:root {
  --bg: #f5efe4;
  --surface: #fffaf2;
  --surface-2: #efe6d7;
  --ink: #2a211d;
  --muted: #7a6a60;
  --line: #e3d7c4;
  --accent: #b8523a;
  --accent-ink: #fffaf2;
  --accent-soft: #f3dcd2;
  --sage: #6f8468;
  --tile: #e8dccb;
  --shadow: 0 1px 2px rgb(60 30 10 / .08), 0 8px 24px rgb(60 30 10 / .08);
  --row-h: 140px;
  --gap: 4px;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120f;
    --surface: #211b17;
    --surface-2: #2b231e;
    --ink: #f2e9dc;
    --muted: #a8998b;
    --line: #3a302a;
    --accent: #e07a5f;
    --accent-ink: #1b1411;
    --accent-soft: #3d2620;
    --sage: #9bb193;
    --tile: #2a221d;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
@media (min-width: 640px) { :root { --row-h: 200px; --gap: 6px; } }
@media (min-width: 1200px) { :root { --row-h: 240px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg circle[r="1.8"] { fill: currentColor; stroke: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.spacer { flex: 1; }

.brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  letter-spacing: -.01em;
  font-size: 2.2rem;
  margin: 0;
  line-height: 1.1;
}
.brand.small { font-size: 1.55rem; }

/* ---------- buttons & inputs */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: .55rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform .1s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--accent); padding: .35rem .9rem; font-size: .9rem; }
.btn.wide { width: 100%; padding: .8rem; font-size: 1.05rem; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgb(255 255 255 / .12); }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="tel"], input:not([type]), select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .75rem;
  outline: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .tag-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ---------- login */
.login {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--sage) 22%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 28px 24px;
  text-align: center;
  display: grid; gap: 14px;
}
.login-icon { margin: 0 auto 4px; border-radius: 20px; transform: rotate(-4deg); }
.login-sub { margin: -6px 0 6px; color: var(--muted); }
.login-error { color: var(--accent); min-height: 1.5em; margin: 0; font-size: .95rem; }
.login-card.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 1600px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); display: grid; gap: 10px; }
.brand-row { display: flex; align-items: center; gap: 10px; position: relative; }
.count { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.filters { display: flex; gap: 8px; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search input { padding-left: 36px; border-radius: 999px; }
.filters select { width: auto; border-radius: 999px; padding-right: 2rem; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: .25rem .8rem;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip small { color: var(--muted); margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip[aria-pressed="true"] small { color: inherit; opacity: .8; }
.chip.special { border-style: dashed; }

.menu {
  position: absolute; right: 0; top: 46px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px; min-width: 220px;
  display: grid; z-index: 20;
}
.menu button { text-align: left; background: none; border: 0; padding: .6rem .8rem; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }

.scan-bar { position: relative; font-size: .85rem; color: var(--muted); text-align: center; padding: 4px 16px 6px; }
.scan-bar i { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--accent); transition: width .5s; }

/* ---------- gallery: justified rows with pure CSS flex */
.gallery { max-width: 1600px; margin: 0 auto; padding: 8px max(8px, env(safe-area-inset-right)) 40px max(8px, env(safe-area-inset-left)); }
.group { margin-top: 18px; }
.group h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 8px 10px;
  display: flex; align-items: baseline; gap: 10px;
}
.group h2 small { font-family: var(--sans); font-size: .85rem; font-weight: 400; color: var(--muted); }
.rows { display: flex; flex-wrap: wrap; gap: var(--gap); }
.rows::after { content: ""; flex-grow: 1e9; }
.tile {
  --r: 1;
  position: relative;
  flex-grow: calc(var(--r) * 100);
  width: calc(var(--r) * var(--row-h));
  max-width: 100%;
  aspect-ratio: var(--r);
  max-height: calc(var(--row-h) * 1.6);
  background: var(--tile);
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  padding: 0; border: 0;
}
.tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .35s ease, transform .5s ease;
}
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.025); }
.tile .cap {
  position: absolute; inset: auto 0 0 0;
  padding: 26px 10px 8px;
  color: #fff; font-size: .82rem; line-height: 1.3; text-align: left;
  background: linear-gradient(transparent, rgb(0 0 0 / .6));
  opacity: 0; transition: opacity .2s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile:hover .cap, .tile:focus-visible .cap { opacity: 1; }
@media (hover: none) { .tile .cap { display: none; } }

.sentinel { height: 1px; }
.empty { text-align: center; color: var(--muted); padding: 80px 24px; max-width: 520px; margin: 0 auto; }
.empty h2 { font-family: var(--serif); color: var(--ink); font-weight: 600; }
.empty code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- viewer */
.viewer {
  position: fixed; inset: 0; z-index: 50;
  background: #0d0b0a;
  display: grid;
  grid-template-columns: 1fr auto;
  color: #fff;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.stage { position: relative; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.v-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 58px 12px 12px;
  transition: transform .25s ease, opacity .25s;
}
.v-img.low { filter: blur(6px); transform: scale(1.01); }
.v-img.dragging { transition: none; }
.v-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(rgb(0 0 0 / .55), transparent);
}
.v-pos { font-size: .9rem; opacity: .75; margin-left: 4px; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: rgb(255 255 255 / .1); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  transition: background .2s;
}
.nav:hover { background: rgb(255 255 255 / .22); }
.nav.prev { left: 14px; } .nav.next { right: 14px; }
.nav[disabled] { opacity: 0; pointer-events: none; }
@media (hover: none) { .nav { display: none; } }
.v-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 40px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgb(0 0 0 / .65));
  font-size: .95rem; pointer-events: none;
}
.v-caption:empty { display: none; }
.v-caption b { font-family: var(--serif); font-size: 1.05rem; }

.panel {
  width: 360px;
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
  border-left: 1px solid var(--line);
}
.viewer.no-panel .panel { display: none; }
.viewer:not(.no-panel) .v-caption { display: none; }
.panel-grip { display: none; }
.meta { padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.meta h2 { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; margin: 0 0 8px; }
.meta label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 10px; }
.meta textarea { resize: vertical; min-height: 90px; }
.hint { font-size: .85rem; color: var(--muted); margin: 2px 0 0; }
.hint a { color: var(--accent); font-weight: 600; }
.date-row { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 6px; }
.tag-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; cursor: text;
}
.tag-input input { flex: 1; min-width: 120px; border: 0; padding: .3rem .4rem; box-shadow: none !important; background: transparent; }
.tag {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--accent-soft); color: var(--ink);
  border-radius: 999px; padding: .15rem .3rem .15rem .7rem; font-size: .92rem;
}
.tag button { border: 0; background: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.tag button:hover { background: rgb(0 0 0 / .08); color: var(--ink); }
.tag svg { width: 14px; height: 14px; }
.meta-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.m-status { color: var(--muted); font-size: .9rem; }
.m-status.ok { color: var(--sage); }
.m-status.err { color: var(--accent); }
.facts { margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- faces */
.faces { display: flex; flex-wrap: wrap; gap: 6px; }
.face {
  display: grid; justify-items: center; gap: 5px;
  width: 72px; padding: 6px 2px 4px;
  background: none; border: 0; border-radius: 12px; cursor: pointer;
}
.face:hover, .face[aria-expanded="true"] { background: var(--surface-2); }
.face-crop {
  width: 52px; height: 52px; border-radius: 50%;
  background-color: var(--tile); background-repeat: no-repeat;
  outline: 2px solid transparent; outline-offset: 2px;
}
.face.named .face-crop { outline-color: var(--sage); }
.face.suggested .face-crop { outline: 2px dashed var(--accent); }
.face.unknown .face-crop { outline: 2px dashed var(--line); }
.face.hidden { opacity: .55; }
.face-name { font-size: .78rem; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face.unknown .face-name, .face.hidden .face-name { color: var(--muted); }
.face.suggested .face-name { color: var(--accent); font-weight: 600; }
.face-edit { background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; gap: 10px; margin-top: 4px; }
.face-edit p { margin: 0; font-size: .92rem; }
.face-edit .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.face-edit input { flex: 1; min-width: 0; width: auto; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: .85rem; cursor: pointer; }
.tag.auto { background: transparent; outline: 1.5px dashed var(--accent); outline-offset: -1.5px; }
.v-boxes { position: absolute; inset: 0; pointer-events: none; transition: transform .25s ease; }
.v-boxes.dragging { transition: none; }
.box {
  position: absolute; border: 2px solid #fff; border-radius: 8px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .45); opacity: 0; transition: opacity .15s;
}
.box.on { opacity: 1; }
.box span {
  position: absolute; left: -2px; top: 100%; margin-top: 5px;
  background: rgb(0 0 0 / .72); color: #fff; font-size: .8rem;
  padding: 1px 7px; border-radius: 6px; white-space: nowrap;
}
.menu-note { margin: 4px 0 0; padding: .55rem .8rem .3rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); max-width: 250px; }

@media (max-width: 820px) {
  .viewer { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .panel {
    width: auto; max-height: 62dvh;
    border-left: 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgb(0 0 0 / .35);
  }
  .panel-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; }
  .meta { padding-top: 10px; }
  .v-img { padding: 56px 0 0; }
}

/* ---------- dialog & toast */
.dialog {
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink);
  padding: 0; width: min(440px, calc(100% - 32px));
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(20 10 5 / .45); }
.dialog-inner { padding: 22px; }
.dialog h2 { font-family: var(--serif); margin: 0 0 4px; }
.people-manage { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; max-height: 55dvh; overflow-y: auto; }
.people-manage li { display: flex; gap: 8px; align-items: center; }
.people-manage small { color: var(--muted); white-space: nowrap; min-width: 4.5em; text-align: right; }
.people-manage .empty-note { color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: .6rem 1.1rem; border-radius: 999px; z-index: 100;
  box-shadow: var(--shadow); font-size: .95rem;
  animation: fade .2s;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- tabs: in the top bar on wide screens, a bottom bar on phones */
:root { --tabbar-h: 0px; }
.tabs { display: flex; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.tabs a {
  display: flex; align-items: center; gap: 6px;
  padding: .35rem .85rem; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 600;
}
.tabs a svg { width: 18px; height: 18px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
body:not(.tab-photos) .photos-only { display: none; }
@media (max-width: 640px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }
  body { padding-bottom: var(--tabbar-h); }
  /* A backdrop filter would trap the fixed tab bar inside the top bar. */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    border-radius: 0; padding: 4px 8px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    justify-content: space-around;
  }
  .tabs a { flex-direction: column; gap: 2px; font-size: .72rem; padding: .35rem 1.2rem; }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs a[aria-current="page"] { background: none; box-shadow: none; color: var(--accent); }
  .toast { bottom: calc(var(--tabbar-h) + 14px); }
}

/* ---------- explore */
.explore { max-width: 1200px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); }
.ex-section { margin-top: 22px; }
.ex-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.ex-head h2 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 0; flex: 1; }
.ex-head a.linkish { text-decoration: none; }
.ex-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 8px; }
.person {
  display: grid; justify-items: center; gap: 6px; padding: 8px 4px;
  background: none; border: 0; border-radius: 14px; cursor: pointer; text-align: center;
}
.person:hover { background: var(--surface-2); }
.avatar {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover;
  background: var(--tile); display: grid; place-items: center;
  font-family: var(--serif); font-size: 2rem; color: var(--muted);
}
.person b { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person small { color: var(--muted); margin-top: -6px; }
.ex-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.fgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; align-content: start; }
.fgroup-faces { display: flex; flex-wrap: wrap; gap: 6px; }
.fgroup-faces button { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; position: relative; }
.fgroup-faces img { width: 52px; height: 52px; border-radius: 50%; display: block; background: var(--tile); transition: opacity .15s, filter .15s; }
.fgroup-faces button[aria-pressed="false"] img { opacity: .3; filter: grayscale(1); }
.fgroup-faces button[aria-pressed="false"]::after {
  content: "×"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 1.6rem; color: var(--ink);
}
.fgroup-more { align-self: center; color: var(--muted); font-size: .85rem; }
.fgroup .row { display: flex; gap: 6px; }
.fgroup input { flex: 1; min-width: 0; width: auto; }
.ex-places { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.placecard {
  position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  border: 0; padding: 0; cursor: pointer; background: var(--tile); text-align: left;
}
.placecard img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.placecard:hover img { transform: scale(1.04); }
.placecard span {
  position: absolute; inset: auto 0 0 0; padding: 30px 12px 10px; color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / .65)); line-height: 1.25;
}
.placecard b { display: block; font-family: var(--serif); font-size: 1.1rem; }
.placecard small { opacity: .85; }

/* ---------- map */
.map-view { position: fixed; left: 0; right: 0; top: var(--top-h, 60px); bottom: var(--tabbar-h); z-index: 0; isolation: isolate; }
.map { position: absolute; inset: 0; background: var(--surface-2); }
.map-note {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1000;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: .45rem 1rem; box-shadow: var(--shadow); font-size: .9rem; white-space: nowrap;
}
.map-note button { margin-left: 4px; }
.photo-pin, .photo-cluster { background: none; border: 0; }
.photo-pin img, .photo-cluster img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 10px; border: 2px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .35); background: var(--tile);
}
.photo-cluster b {
  position: absolute; top: -8px; right: -8px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font: 700 .78rem/24px var(--sans); text-align: center; box-shadow: 0 1px 4px rgb(0 0 0 / .3);
}
.leaflet-container { font-family: var(--sans); }
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .4);
}

/* ---------- place field and picker */
.place-row { display: flex; align-items: center; gap: 10px; }
.place-name { flex: 1; min-width: 0; }
.place-name.none { color: var(--muted); }
.dialog.wide { width: min(640px, calc(100% - 24px)); }
.loc-search { display: flex; gap: 6px; margin-top: 12px; }
.loc-search input { flex: 1; width: auto; }
.loc-results { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 10px; max-height: 180px; overflow-y: auto; }
.loc-results button { width: 100%; text-align: left; background: none; border: 0; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; font-size: .92rem; }
.loc-results button:hover { background: var(--surface-2); }
.loc-results .note { padding: .5rem .6rem; color: var(--muted); font-size: .92rem; }
.loc-map { height: min(46dvh, 380px); margin-top: 10px; border-radius: 12px; overflow: hidden; background: var(--surface-2); isolation: isolate; }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9) saturate(.6); }
}

/* ---------- selecting photos */
.tick {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; background: rgb(0 0 0 / .25);
  box-shadow: 0 1px 4px rgb(0 0 0 / .35);
  display: grid; place-items: center;
  opacity: 0; transition: opacity .15s, background .15s;
}
.tick svg { width: 15px; height: 15px; stroke-width: 3; color: #fff; opacity: 0; }
@media (hover: hover) { .tile:hover .tick { opacity: 1; } }
body.selecting .tick { opacity: 1; }
body.selecting .tile { cursor: pointer; }
.tile.selected { background: var(--accent-soft); }
.tile.selected .tick { background: var(--accent); }
.tile.selected .tick svg { opacity: 1; }
.tile.selected img, .tile.selected:hover img { transform: scale(.9); border-radius: 6px; }
.tile img { -webkit-touch-callout: none; }
.selbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--tabbar-h) + 14px);
  width: min(820px, calc(100% - 24px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 8px 10px;
  animation: fade .15s;
}
.sel-count { font-weight: 700; }
.selbar .btn { padding: .4rem .9rem; }
@media (max-width: 480px) { .selbar .spacer { flex-basis: 100%; height: 0; } .selbar .btn { flex: 1; } }
.bp-add { display: flex; gap: 6px; margin-top: 12px; }
.bp-add input { flex: 1; width: auto; }
.people-manage button.linkish { white-space: nowrap; }
body.selecting .toast { bottom: calc(var(--tabbar-h) + 84px); }
@media (max-width: 480px) { body.selecting .toast { bottom: calc(var(--tabbar-h) + 124px); } }

/* ---------- uploads */
.uploads {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px); z-index: 45;
  width: min(360px, calc(100% - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 12px 14px 14px; display: grid; gap: 8px;
  animation: fade .15s;
}
.up-head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.up-head b { flex: 1; }
.up-head .icon-btn { width: 30px; height: 30px; }
.up-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s; }
.uploads.finished .up-bar i { background: var(--sage); }
.uploads .hint { margin: 0; }
.up-errors { margin: 0; padding-left: 1.1rem; font-size: .85rem; color: var(--accent); max-height: 110px; overflow-y: auto; }
body.selecting .uploads { bottom: calc(var(--tabbar-h) + 84px); }
body.dropping::after {
  content: "Drop photos to add them to the album";
  position: fixed; inset: 12px; z-index: 60; pointer-events: none;
  display: grid; place-items: center;
  border: 3px dashed var(--accent); border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  font: italic 600 1.6rem var(--serif); color: var(--ink);
}

/* ---------- sign-in and users */
.login-card > div { display: grid; gap: 14px; }
.code-input { text-align: center; font-size: 1.5rem; letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.login-links { margin: -4px 0 0; font-size: .9rem; color: var(--muted); }
.menu .me-line { margin: 0 0 4px; border-top: 0; border-bottom: 1px solid var(--line); padding: .3rem .8rem .55rem; }
.users-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; max-height: 46dvh; overflow-y: auto; }
.users-list li { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }
.users-list input { padding: .45rem .6rem; }
.users-list small { grid-column: 1 / -1; color: var(--muted); margin-top: -4px; font-size: .8rem; }
.users-list .owner { color: var(--sage); font-weight: 700; }
.user-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.user-add h3 { grid-column: 1 / -1; margin: 0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
@media (max-width: 480px) { .users-list li, .user-add { grid-template-columns: 1fr auto; } .users-list li input[type="tel"], .user-add input[type="tel"] { grid-column: 1; } }

/* ---------- albums */
.albums-top { margin-top: 22px; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px 12px; }
.albumcard { display: grid; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: inherit; text-decoration: none; }
.albumcard .cover { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--tile); display: grid; place-items: center; color: var(--muted); }
.albumcard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.albumcard:hover .cover img { transform: scale(1.04); }
.albumcard b { font-family: var(--serif); font-size: 1.1rem; line-height: 1.2; overflow-wrap: anywhere; }
.albumcard small { color: var(--muted); margin-top: -4px; }
.album-head { max-width: 1600px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.album-head .back { text-decoration: none; }
.ah-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-top: 6px; }
.ah-text { flex: 1; min-width: 240px; }
.ah-text h2 { font-family: var(--serif); font-weight: 600; font-size: 2rem; margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
.ah-desc { margin: 6px 0 0; white-space: pre-line; }
.ah-desc:empty { display: none; }
.ah-text .hint { margin-top: 4px; }
.ah-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ah-actions .btn { padding: .45rem 1rem; }
body.picking .album-head { display: none; }
.tile.in-album { cursor: default; }
.tile.in-album img { opacity: .35; }
.tile.in-album .tick { opacity: 1; background: var(--sage); }
.tile.in-album .tick svg { opacity: 1; }
body.picking .tick { opacity: 1; }
.ap-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; max-height: 44dvh; overflow-y: auto; }
.ap-list button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: 0; border-radius: 10px; padding: 6px; cursor: pointer;
}
.ap-list button:hover { background: var(--surface-2); }
.ap-list img, .ap-list .ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--tile); flex: none; }
.ap-list span { flex: 1; min-width: 0; }
.ap-list small { display: block; color: var(--muted); }
.form-grid { display: grid; gap: 6px; }
.form-grid label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 10px; }
.form-grid h2 { margin-bottom: 4px; }
.chips-label { flex: none; align-self: center; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-right: 2px; }

/* ---------- sharing */
.form-grid label.check { display: flex; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-size: .95rem; font-weight: 400; color: var(--ink); margin-top: 12px; cursor: pointer; }
.form-grid label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
#sh-url { flex: 1; width: auto; font-size: .9rem; }
.shares-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; max-height: 60dvh; overflow-y: auto; }
.shares-list li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; }
.shares-list li.dead { opacity: .65; }
.shares-list b { font-family: var(--serif); font-size: 1.05rem; }
.shares-list .sl-meta { font-size: .85rem; color: var(--muted); }
.shares-list .state-live { color: var(--sage); font-weight: 700; }
.shares-list .state-dead { color: var(--accent); font-weight: 700; }
.shares-list .acts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; }
.shares-list .empty-note { border: 0; color: var(--muted); padding: 0; }
/* the guest page */
body.guest .guest-head { max-width: 1600px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left)); }
.guest-brand { margin: 0; font-family: var(--serif); font-style: italic; color: var(--accent); font-weight: 600; }
.guest-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 4px 0 0; line-height: 1.1; overflow-wrap: anywhere; }
.guest-head .hint { margin-top: 6px; }
body.guest .tile { cursor: zoom-in; }

/* ---------- delete, trash and duplicates */
.btn.danger { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn.danger:hover { background: var(--accent-soft); }
.dupmark {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  display: flex; align-items: center; gap: 3px;
  background: rgb(0 0 0 / .55); color: #fff; border-radius: 999px;
  padding: 2px 7px 2px 5px; font-size: .72rem; font-weight: 700; pointer-events: none;
}
.dupmark svg { width: 13px; height: 13px; }
.filter-note {
  max-width: 1600px; margin: 12px auto 0; padding: 10px 14px;
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  width: calc(100% - 2 * max(16px, env(safe-area-inset-left)));
}
.filter-note span { color: var(--muted); font-size: .92rem; }
.dups-list { display: grid; gap: 14px; margin-top: 12px; max-height: 64dvh; overflow-y: auto; }
.dupset { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.dupset .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dupcard { display: grid; gap: 4px; cursor: pointer; border-radius: 10px; padding: 6px; border: 2px solid transparent; font-size: .8rem; color: var(--muted); }
.dupcard:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.dupcard img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--tile); }
.dupcard input { position: absolute; opacity: 0; pointer-events: none; }
.dupcard b { color: var(--ink); font-size: .85rem; }
.dupcard .best { color: var(--sage); font-weight: 700; }
.dupcard .keep { color: var(--accent); font-weight: 700; display: none; }
.dupcard:has(input:checked) .keep { display: inline; }
.dupcard .file { overflow-wrap: anywhere; }
.dupset .row { display: flex; flex-wrap: wrap; gap: 8px; }
.trash-top { margin-top: 10px; }
.trash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; max-height: 56dvh; overflow-y: auto; }
.trash-item { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
.trash-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--tile); }
.trash-item .row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- checking suggestions */
.rv-head { display: flex; gap: 16px; align-items: center; }
.rv-avatar { width: 72px; height: 72px; flex: none; font-size: 1.6rem; }
.rv-head h2 { margin: 0; }
.rv-grid { margin-top: 16px; max-height: 56dvh; overflow-y: auto; padding: 2px; gap: 8px; }
.rv-grid img { width: 72px; height: 72px; }
.rv-grid .rv-divider { flex-basis: 100%; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }
.person-wrap { display: grid; justify-items: center; align-content: start; }
.person-wrap .linkish { font-size: .8rem; margin-top: -4px; }

/* ---------- date headings with select ticks */
.group h2, .subhead { position: relative; }
.subhead { display: flex; align-items: baseline; gap: 8px; margin: 14px 8px 8px; font-size: 1rem; font-weight: 600; }
.subhead:first-of-type { margin-top: 4px; }
.subhead small, .group h2 small { font-weight: 400; }
.subhead small { font-size: .82rem; color: var(--muted); }
.gtick {
  align-self: center; width: 22px; height: 22px; padding: 0; flex: none;
  border-radius: 50%; border: 2px solid var(--muted); background: transparent; cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s, background .15s;
}
.gtick svg { width: 13px; height: 13px; stroke-width: 3; color: #fff; opacity: 0; }
.group h2:hover .gtick, .subhead:hover .gtick, .gtick:focus-visible, body.selecting .gtick { opacity: 1; }
@media (hover: none) { .gtick { opacity: .7; } }
.gtick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); opacity: 1; }
.gtick[aria-pressed="true"] svg { opacity: 1; }

/* Photos in the app aren't draggable: dragging one would offer it to the page's own "drop to upload". */
#app img, #viewer img, dialog img { -webkit-user-drag: none; user-select: none; }

/* ---------- Explore: tidy up */
.tidy-list { display: grid; gap: 8px; }
.tidy-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.tidy-row > div { flex: 1; min-width: 220px; display: grid; }
.tidy-row b { font-weight: 700; }
.tidy-row span { color: var(--muted); font-size: .92rem; }
