/* ==========================================================================
   Face Gallery
   Quiet, neutral chrome so the photos carry the colour. One accent, marigold
   (from the haldi and the garlands), and it only ever means "selected" or
   "the main action". Contrast (WCAG): text 16.3:1, secondary 5.3–5.8:1,
   text on marigold 8.6:1; rings use a darker marigold (4.1:1) in light mode.
   ========================================================================== */
:root {
  --bg: #fbfbfa;
  --sidebar: #f1f1ef;
  --fill: #e7e7e4;            /* photo placeholder */
  --text: #1d1d1f;
  --text-2: #636366;
  --sep: rgba(0, 0, 0, .09);
  --hover: rgba(0, 0, 0, .05);
  --chip: #ffffff;
  --accent: #f0a500;          /* marigold */
  --on-accent: #1f1600;
  --ring: #a86f00;            /* focus + selection outline, 4.1:1 on --bg */
  --tint: rgba(240, 165, 0, .16);
  --bar: rgba(251, 251, 250, .78);
  --shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .08);
  --sb-w: 300px;
  --row-h: 190px;
  --gap: 3px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0f;
    --sidebar: #1a1a1c;
    --fill: #232326;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --sep: rgba(255, 255, 255, .1);
    --hover: rgba(255, 255, 255, .07);
    --chip: #2c2c2f;
    --accent: #f5b52e;
    --on-accent: #1f1600;
    --ring: #f5b52e;
    --tint: rgba(245, 181, 46, .2);
    --bar: rgba(14, 14, 15, .72);
    --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  }
}
@media (prefers-contrast: more) {
  :root { --sep: rgba(127, 127, 127, .6); --text-2: var(--text); --bar: var(--bg); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sub { color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------- controls */
button, select, input { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 14px; border-radius: 999px; border: 0;
  background: var(--hover); color: var(--text); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 100ms ease-out, background-color 120ms;
}
.btn:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.btn:active, .icon-btn:active, .person:active, .chip:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.small { min-height: 28px; padding: 0 11px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: none; color: var(--text); cursor: pointer; transition: transform 100ms ease-out, background-color 120ms;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.text-btn { border: 0; background: none; color: var(--text-2); font-size: 13px; cursor: pointer; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--text); }
select, input[type=search] {
  min-height: 32px; border: 1px solid var(--sep); background: var(--chip); border-radius: 9px; padding: 0 10px; font-size: 14px;
}
input[type=search] { width: 100%; }
.badge { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100dvh; }
.app.sb-hidden { grid-template-columns: minmax(0, 1fr); }
.app.sb-hidden .sidebar { display: none; }
.main { min-width: 0; }

/* ----------------------------------------------------------------- sidebar */
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--sep); min-width: 0;
}
.sb-head { display: flex; align-items: flex-start; gap: 8px; padding: 18px 16px 10px; }
.sb-title { flex: 1; min-width: 0; }
.sb-title h1 { font-size: 19px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
.grabber, .sheet-only { display: none; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 4px 16px 20px; overscroll-behavior: contain; }
.sb-section { padding: 12px 0; border-top: 1px solid var(--sep); }
.sb-section:first-child { border-top: 0; }
.sb-label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.sb-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.sb-count { font-size: 12px; color: var(--text-2); }
.sb-foot { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--sep); font-size: 13px; color: var(--text-2); }

/* current filter */
.filter { padding-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 3px; border-radius: 999px; border: 0;
  background: var(--chip); box-shadow: 0 0 0 1px var(--sep); font-size: 13px; cursor: pointer; transition: transform 100ms ease-out;
}
.chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--fill); }
.chip .x { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--text-2); }
.chip .x svg { width: 12px; height: 12px; }
.chip:hover .x { background: var(--hover); color: var(--text); }
.seg { display: flex; padding: 2px; border-radius: 9px; background: var(--hover); }
.seg button {
  flex: 1; min-height: 28px; border: 0; background: none; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--text); transition: background-color 150ms;
}
.seg button[aria-pressed=true] { background: var(--chip); box-shadow: 0 1px 3px rgba(0,0,0,.15), 0 0 0 .5px var(--sep); font-weight: 600; }
.filter-actions { margin-top: 4px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--sep); }
.admin-actions .sb-label { width: 100%; margin: 0; }

/* folders: a disclosure row, so people stay near the top */
.folders-wrap > summary {
  display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; list-style: none; border-radius: 8px;
}
.folders-wrap > summary::-webkit-details-marker { display: none; }
.folders-wrap > summary .sb-label { margin: 0; }
.folders-wrap > summary .current { flex: 1; text-align: right; font-size: 13px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folders-wrap > summary .chev { width: 14px; height: 14px; color: var(--text-2); transition: transform 160ms var(--ease-out); }
.folders-wrap[open] > summary .chev { transform: rotate(90deg); }
.folders-wrap[open] > summary { margin-bottom: 6px; }
.folders { list-style: none; margin: 0; padding: 0; }
.folders li {
  display: flex; justify-content: space-between; gap: 8px; align-items: center; min-height: 30px;
  padding: 0 8px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.folders li.sub-folder { padding-left: 24px; }
.folders li:hover { background: var(--hover); }
.folders li[aria-selected=true] { background: var(--tint); font-weight: 600; }
.folders .n { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 400; }

/* people */
#peopleSearch { margin-bottom: 12px; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 12px 4px; }
.person {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  cursor: pointer; min-width: 0; transition: transform 100ms ease-out;
}
.person .av { position: relative; width: 60px; height: 60px; border-radius: 50%; }
.person img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: var(--fill);
  box-shadow: 0 0 0 1px var(--sep);
}
.person[aria-selected=true] img { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 5px var(--ring); }
.person[aria-selected=true] .av::after {
  content: ""; position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%231f1600' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
  box-shadow: 0 0 0 2px var(--sidebar);
}
.person.is-hidden img { opacity: .35; }
.person .lbl { font-size: 12px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .cnt { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.check-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--ring); }
.empty-note { grid-column: 1 / -1; font-size: 13px; color: var(--text-2); }

/* ----------------------------------------------------------------- toolbar */
.toolbar { position: sticky; top: 0; z-index: 10; isolation: isolate; }
/* the material lives on a pseudo-element: a backdrop-filter on the toolbar itself would
   trap position:fixed children (the phone selection bar) inside it */
.toolbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--bar); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
}
/* scroll-edge effect instead of a hard divider */
.toolbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; pointer-events: none;
  background: linear-gradient(var(--bar), transparent);
}
.tb-row { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 12px; }
.tb-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.tb-title strong { font-size: 17px; font-weight: 650; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-title span { color: var(--text-2); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-actions { display: flex; gap: 6px; align-items: center; }
.zoom { display: flex; }
.sel-info { flex: 1; min-width: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-transparency: reduce) {
  .toolbar::before, .tb-select:not([hidden]), .fab { background: var(--bg) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
}

/* ------------------------------------------------------- justified photos */
/* Each tile grows in proportion to its aspect ratio, so every photo in a row
   ends up the same height and is shown uncropped. */
.grid { display: flex; flex-wrap: wrap; gap: var(--gap); padding: 2px 12px 40px; }
.grid::after { content: ""; flex-grow: 1000000; }      /* keeps the last row from stretching */
.tile {
  --ar: 1.5;
  position: relative; flex: var(--ar) 1 calc(var(--ar) * var(--row-h)); aspect-ratio: var(--ar);
  max-height: calc(var(--row-h) * 1.6);
  background: var(--fill); overflow: hidden; cursor: pointer; border-radius: 2px;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 160ms var(--ease-out), border-radius 160ms; }
.tile:active img { transform: scale(.97); }
.tile .check {
  position: absolute; top: 0; left: 0; width: 40px; height: 40px; display: grid; place-items: center; opacity: 0;
  transition: opacity 120ms;
}
.tile .check i {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, .28); box-shadow: 0 1px 3px rgba(0,0,0,.35); color: transparent;
}
.tile .check svg { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) { .tile:hover .check { opacity: .9; } }
body.selecting .tile .check { opacity: .9; }
.tile.sel { background: var(--tint); }
.tile.sel img { transform: scale(.9); border-radius: 6px; }
.tile.sel .check { opacity: 1; }
.tile.sel .check i { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tile:focus-visible { outline-offset: -3px; }
#sentinel { height: 1px; }
.empty { text-align: center; padding: 72px 20px; display: grid; gap: 6px; }

/* ------------------------------------------------------------------ lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; color: #fff; overflow: hidden; touch-action: none; }
.lb-scrim { position: absolute; inset: 0; background: #000; opacity: 0; }
.lb-stage { position: absolute; inset: 0; }
.lb-track { position: absolute; inset: 0; will-change: transform; }
.lb-slide { position: absolute; inset: 0; }
.lb-slide[data-k="-1"] { transform: translateX(calc(-100% - 24px)); }
.lb-slide[data-k="1"]  { transform: translateX(calc(100% + 24px)); }
.lb-photo { position: absolute; transform-origin: 50% 50%; }
.lb-photo img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.lb-photo .hi { opacity: 0; transition: opacity 180ms ease-out; }
.lb-photo .hi.loaded { opacity: 1; }
.lb-chrome { position: absolute; left: 0; right: 0; transition: opacity 200ms ease-out; }
.lightbox.chrome-off .lb-chrome, .lightbox.chrome-off .nav { opacity: 0; pointer-events: none; }
.lb-top {
  top: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) 14px 28px;
  background: linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,0));
}
.lb-title { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.lb-title strong { font-size: 15px; font-weight: 600; }
.lb-title span { font-size: 13px; color: rgba(255,255,255,.78); }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.on-dark { background: rgba(255,255,255,.16); color: #fff; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.btn.on-dark:hover { background: rgba(255,255,255,.26); }
.btn.on-dark[aria-pressed=true] { background: var(--accent); color: var(--on-accent); }
.icon-btn.on-dark { color: #fff; background: rgba(255,255,255,.16); border-radius: 50%; }
.icon-btn.on-dark:hover { background: rgba(255,255,255,.26); }
.nav {
  position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.14); cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: opacity 200ms, background-color 120ms;
}
.nav:hover { background: rgba(255,255,255,.26); }
.nav.prev { left: 16px; } .nav.next { right: 16px; }
.nav:disabled { opacity: 0; pointer-events: none; }
.lb-bottom {
  bottom: 0; display: flex; gap: 14px; align-items: flex-end; overflow-x: auto;
  padding: 36px 16px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.6));
}
.lb-bottom .lbl-in { font-size: 12px; color: rgba(255,255,255,.78); align-self: center; white-space: nowrap; }
.lb-bottom .person { color: #fff; flex: none; width: 64px; }
.lb-bottom .person .av { width: 48px; height: 48px; }
.lb-bottom .person img { box-shadow: 0 0 0 1.5px rgba(255,255,255,.5); }
.lb-bottom .person[aria-selected=true] img { box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--accent); }
.lb-bottom .person[aria-selected=true] .av::after { box-shadow: 0 0 0 2px #000; }
.lb-bottom .who { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lb-bottom .rm { font-size: 11px; color: #ffb4a6; background: none; border: 0; cursor: pointer; padding: 2px; }
@media (hover: none) { .pointer-only { display: none; } }

/* --------------------------------------------------------------- misc */
.fab { display: none; }
.scrim { display: none; }
.toast {
  position: fixed; top: 14px; left: 50%; translate: -50% 0; z-index: 80; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow);
}
img:not([src]) { visibility: hidden; }

/* ------------------------------------------------- compact: phones / narrow */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .app, .app.sb-hidden { display: block; }
  .app.sb-hidden .sidebar { display: flex; }
  /* the sidebar becomes a bottom sheet (driven by JS so it can follow the finger) */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40; height: min(88dvh, 760px);
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
    transform: translateY(105%); visibility: hidden; will-change: transform;
  }
  .sidebar.sheet-live { visibility: visible; }
  .sb-head { position: relative; padding: 22px 16px 10px; touch-action: none; cursor: grab; }
  .grabber { display: block; position: absolute; top: 7px; left: 50%; translate: -50% 0; width: 38px; height: 5px; border-radius: 3px; background: var(--sep); }
  .sheet-only { display: inline-grid; }
  .sb-scroll { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .sb-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: #000; opacity: 0; }
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 40px; font-size: 15px; }
  .people { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .person .av { width: 58px; height: 58px; }
  .folders li { min-height: 40px; font-size: 15px; }
  input[type=search], select { font-size: 16px; min-height: 40px; }
  .seg button { min-height: 34px; font-size: 14px; }
  .zoom { display: none; }
  .tb-row { padding: 6px 8px; min-height: 52px; }
  .grid { padding: 2px 2px 120px; --gap: 2px; }
  /* selection actions move to a bottom toolbar, within thumb reach */
  .tb-select:not([hidden]) {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex-wrap: wrap; justify-content: space-between;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bar);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); box-shadow: 0 -1px 0 var(--sep);
  }
  .tb-select .sel-info { order: -1; flex-basis: 100%; text-align: center; font-size: 15px; padding-bottom: 4px; }
  .tb-select .tb-actions { flex: 1; justify-content: flex-end; }
  .tb-select #selectAll { display: none; }
  body.selecting .tb-browse .tb-actions { display: none; }
  .fab {
    position: fixed; z-index: 20; left: 50%; translate: -50% 0; bottom: calc(18px + env(safe-area-inset-bottom));
    display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px 0 16px; border: 0; border-radius: 999px;
    background: var(--bar); color: var(--text); font-size: 16px; font-weight: 600; box-shadow: var(--shadow);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); cursor: pointer;
    transition: transform 100ms ease-out;
  }
  .fab:active { transform: scale(.96); }
  .fab .faces { display: flex; }
  .fab .faces img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--bg); margin-left: -8px; }
  .fab .faces img:first-child { margin-left: 0; }
  body.selecting .fab { display: none; }
  .lb-top { padding-left: 10px; padding-right: 10px; }
  .lb-title { order: 2; flex-basis: 100%; }
  .lb-actions { margin-left: auto; }
  .lb-actions .btn { min-height: 36px; font-size: 14px; padding: 0 12px; }
}

/* ------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; }
  .tile.sel img { transform: none; }
}

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 28px;
  background: var(--sidebar); border-radius: 18px; box-shadow: 0 0 0 1px var(--sep);
}
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.015em; }
.login-card .muted { color: var(--text-2); font-size: 14px; }
.login-card input[type=password] {
  min-height: 44px; border: 1px solid var(--sep); background: var(--chip); border-radius: 10px; padding: 0 12px; font-size: 16px;
}
.login-card .btn { min-height: 44px; font-size: 16px; }
.error { color: #d70015; font-size: 14px; }
@media (prefers-color-scheme: dark) { .error { color: #ff6961; } }

/* ======================================================= naming, zoom, faces */
.people-hint { margin: -2px 0 10px; }
.faces-btn { padding: 0 12px 0 10px; }
.faces-btn svg { width: 19px; height: 19px; }
.name-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; min-height: 32px; }
.name-row .nm { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-row .nm.none { font-weight: 400; color: var(--text-2); }
.name-form { display: flex; gap: 6px; width: 100%; }
.name-form input {
  flex: 1; min-width: 0; min-height: 32px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--ring);
  background: var(--chip); font-size: 14px;
}
.lb-bottom .name-form input { border-color: rgba(255,255,255,.5); background: rgba(0,0,0,.5); color: #fff; width: 140px; }
.lb-bottom .add-name { font-size: 11px; color: #fff; background: rgba(255,255,255,.16); border: 0; border-radius: 999px; padding: 3px 8px; cursor: pointer; }
.lb-bottom .add-name:hover { background: rgba(255,255,255,.28); }
.lb-zoom { display: flex; gap: 6px; margin-right: 4px; }
.lightbox.zoomed .lb-stage { cursor: grab; }
.lightbox.zoomed .lb-stage:active { cursor: grabbing; }
.lb-photo .zm { opacity: 0; transition: opacity 200ms ease-out; }
.lb-photo .zm.loaded { opacity: 1; }
.face-rail { display: none; }
.fab .lead { display: inline-grid; place-items: center; }

@media (max-width: 860px) {
  #sbToggle { display: none; }
  .face-rail { display: block; padding: 6px 0 10px; }
  .rail-hint { padding: 0 12px 6px; font-size: 13px; color: var(--text-2); }
  .rail {
    display: flex; gap: 6px; overflow-x: auto; padding: 2px 10px 4px; scroll-snap-type: x proximity;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail .person { flex: none; width: 70px; scroll-snap-align: start; }
  .rail .person .av { width: 56px; height: 56px; }
  .rail .see-all {
    flex: none; width: 70px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none;
    cursor: pointer; font-size: 12px; color: var(--text);
  }
  .rail .see-all .av { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--hover); }
  .lb-zoom { display: none; }      /* pinch and double-tap on touch screens */
  .name-form input { font-size: 16px; min-height: 40px; }
}
.fab span, .lb-bottom .add-name, .rail .person .lbl { white-space: nowrap; }
@media (max-width: 860px) { .fab { max-width: calc(100vw - 32px); } .fab > span:last-child { overflow: hidden; text-overflow: ellipsis; } }

/* ======================================================== find me by selfie */
.selfie-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 12px; padding: 10px 12px; border: 0; border-radius: 12px;
  background: var(--tint); color: var(--text); text-align: left; cursor: pointer; transition: transform 100ms ease-out, background-color 120ms;
}
.selfie-btn:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.selfie-btn:active { transform: scale(.98); }
.selfie-btn svg { width: 26px; height: 26px; color: var(--ring); }
.selfie-btn span { display: flex; flex-direction: column; }
.selfie-btn strong { font-size: 15px; font-weight: 600; }
.selfie-btn small { font-size: 12px; color: var(--text-2); }
.rail .find-me .av { background: var(--tint); display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px var(--ring); }
.rail .find-me .av svg { width: 26px; height: 26px; color: var(--ring); }
.rail .find-me .lbl { font-weight: 600; }

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity 200ms ease-out; }
.modal-card {
  position: relative; width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--bg); color: var(--text); border-radius: 18px; box-shadow: var(--shadow); padding: 22px 22px 20px;
  opacity: 0; transform: scale(.96); transition: opacity 200ms ease-out, transform 260ms var(--ease-out);
}
.modal.open .modal-scrim { opacity: 1; }
.modal.open .modal-card { opacity: 1; transform: none; }
.modal-card h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 0 36px 6px 0; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal-card p { margin: 0 0 10px; }
.modal-card .privacy { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.modal-actions .btn { min-height: 44px; font-size: 16px; width: 100%; }
.selfie-stage { display: grid; place-items: center; gap: 12px; padding: 12px 0 4px; text-align: center; }
.selfie-preview { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 4px var(--tint); }
.selfie-video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; background: #000; transform: scaleX(-1); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--ring); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.match-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.match {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; border: 0; width: 100%; text-align: left;
  background: var(--sidebar); color: var(--text); cursor: pointer; transition: transform 100ms ease-out, box-shadow 120ms;
}
.match:hover { box-shadow: 0 0 0 2px var(--ring); }
.match:active { transform: scale(.98); }
.match img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--fill); flex: none; }
.match .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.match .who strong { font-size: 16px; }
.match .who span { font-size: 13px; color: var(--text-2); }
.match .tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--hover); white-space: nowrap; }
.match.strong .tag { background: var(--accent); color: var(--on-accent); }
@media (max-width: 860px) {
  .modal { place-items: end stretch; padding: 0; }
  .modal-card { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateY(30px); }
}
@media (prefers-reduced-motion: reduce) { .modal-card { transform: none !important; } .spinner { animation-duration: 2.4s; } }

/* ============================================ sign-in page with the couple's photo */
.login-page.has-bg { position: relative; overflow: hidden; background: #111; place-items: center start; padding: clamp(20px, 4vw, 64px); }
.login-bg, .login-bg img { position: fixed; inset: 0; width: 100%; height: 100%; }
.login-bg img {
  object-fit: cover; object-position: 40% 35%;
  /* nudge the couple to the right so the sign-in card sits beside them, not over them */
  transform: scale(1.12); transform-origin: 0% 40%;
  opacity: 0; transition: opacity 700ms ease-out;
}
.login-bg img.ready { opacity: 1; }
.login-bg::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.42), rgba(0,0,0,0) 45%);
}
.has-bg .login-card {
  position: relative; max-width: 340px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 20px 60px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.18);
}
.has-bg .login-card .muted { color: var(--text); opacity: .78; }
/* narrower landscape screens: the card moves to the bottom, below the couple's faces */
@media (orientation: landscape) and (max-aspect-ratio: 7/5), (orientation: landscape) and (max-width: 1000px) {
  .login-page.has-bg { place-items: end center; }
  .login-bg img { transform: none; object-position: 50% 25%; }
  .login-bg::after { background: linear-gradient(0deg, rgba(0,0,0,.5), rgba(0,0,0,0) 50%); }
}
/* phones and tall screens: portrait photo, card at the bottom within thumb reach */
@media (orientation: portrait) {
  .login-page.has-bg { place-items: end center; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .login-bg img { transform: none; object-position: 55% 20%; }
  .login-bg::after { background: linear-gradient(0deg, rgba(0,0,0,.55), rgba(0,0,0,0) 55%); }
  .has-bg .login-card { max-width: 420px; }
}
@media (prefers-reduced-transparency: reduce) {
  .has-bg .login-card { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ================================================================ events */
.grid .section {
  flex-basis: 100%; display: flex; align-items: baseline; gap: 10px; margin: 22px 2px 6px; scroll-margin-top: 64px;
  font-size: 22px; font-weight: 700; letter-spacing: -.015em;
}
.grid .section:first-child { margin-top: 6px; }
.grid .section span { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--text-2); }
.grid .row-end { flex: 1000000 1 0; height: 0; }
@media (max-width: 860px) {
  .grid .section { font-size: 19px; margin: 18px 6px 6px; scroll-margin-top: 64px; }
}

/* ============================================ names right under each face */
.person-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.name-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; max-width: 100%; min-height: 26px;
  padding: 2px 7px; white-space: nowrap; border: 0; border-radius: 999px; background: none; color: var(--text); cursor: pointer;
  font-size: 12px; font-weight: 600; transition: background-color 120ms;
}
.name-btn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-btn svg { width: 12px; height: 12px; flex: none; color: var(--text-2); }
.name-btn:hover { background: var(--hover); }
.name-btn.empty { background: var(--hover); color: var(--text-2); font-weight: 500; flex-direction: row-reverse; }
.name-btn.empty svg { color: var(--ring); }
.name-btn.empty:hover { background: var(--tint); color: var(--text); }
.cell-name-form { display: flex; align-items: center; gap: 2px; width: 100%; }
.cell-name-form input {
  flex: 1; min-width: 0; min-height: 28px; padding: 0 6px; border: 1.5px solid var(--ring); border-radius: 8px;
  background: var(--chip); font-size: 13px; text-align: center;
}
.cell-name-form .ok { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--on-accent); flex: none; }
.cell-name-form .ok svg { width: 14px; height: 14px; }
@media (max-width: 860px) {
  /* phones: 3 big faces per row, easy to recognise and to name */
  .people { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 8px; }
  .people .person .av { width: 92px; height: 92px; }
  .people .person .cnt { font-size: 12px; }
  .name-btn { font-size: 14px; min-height: 32px; padding: 4px 10px; }
  .name-btn svg { width: 14px; height: 14px; }
  .cell-name-form input { font-size: 16px; min-height: 36px; }
  .cell-name-form .ok { width: 36px; height: 36px; }
  .cell-name-form .ok svg { width: 16px; height: 16px; }
}
