/* Ghost Biographer — Memory Lens styles
   Page-specific layout and overrides only.
   Shared tokens and components live in design.css. */

/* ── Body / shell ────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Memory Lens sub-header ──────────────────────── */
#ml-subheader {
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ml-brand { display: flex; align-items: center; gap: 8px; }
.ml-logo { height: 38px; width: 38px; object-fit: contain; }
.ml-brand-title { font-size: 16px; font-weight: 700; color: var(--plum); }
.ml-subheader-sep { flex: 1; }
.ml-neo-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: 99px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  text-decoration: none;
  transition: border-color 150ms, background 150ms, color 150ms;
  white-space: nowrap;
  flex-shrink: 0;
}
.ml-neo-link:hover { border-color: var(--plum-3); background: oklch(0.95 0.04 295); color: var(--plum); }

/* Companion Mode entry — same shape as ml-neo-link but warmer + slightly
   larger so it draws the eye on the Memory Lens header. Mom + Dad
   2026-05-24/25: Skip couldn't find the buried Settings entry while
   onboarding Dad — this is the primary discoverable entry. */
.ml-companion-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, oklch(0.92 0.08 295), oklch(0.95 0.06 220));
  border: 1px solid var(--plum-3);
  border-radius: 99px;
  color: var(--plum);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  text-decoration: none;
  transition: filter 150ms, transform 100ms;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(120, 90, 200, .15);
}
.ml-companion-link:hover { filter: brightness(1.05); }
.ml-companion-link:active { transform: translateY(1px); }

/* ── Studio recording indicator ──────────────────── */
#studio-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  background: oklch(0.97 0.02 25);
  border: 1px solid oklch(0.7 0.12 25);
  border-radius: 99px;
  padding: 4px 12px;
  flex-shrink: 0;
}
#studio-indicator.active { display: flex; }
.studio-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 6px 2px oklch(0.5 0.2 25 / 0.4);
  animation: studio-glow 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.studio-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--rose);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
@keyframes studio-glow {
  0%,100% { box-shadow: 0 0 6px 2px oklch(0.5 0.2 25 / 0.4); opacity: 1; }
  50%      { box-shadow: 0 0 3px 1px oklch(0.5 0.2 25 / 0.15); opacity: 0.7; }
}

/* ── Upload drop zone ────────────────────────────── */
#ml-upload-btn {
  position: relative;
  overflow: hidden;
  min-width: 200px;
  height: 52px;
  border: 2px dashed var(--plum-3);
  border-radius: 10px;
  background: oklch(0.97 0.02 295);
  color: var(--plum);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
  padding: 5px 14px;
}
#ml-upload-btn:hover { background: oklch(0.94 0.04 295); border-color: var(--plum); box-shadow: 0 0 0 3px oklch(0.7 0.12 295 / 0.2); }
#ml-upload-btn.drag-active { background: oklch(0.91 0.05 295); border-color: var(--plum); box-shadow: inset 0 0 0 3px oklch(0.7 0.12 295 / 0.25); }
.zone-main { font-size: 14px; font-weight: 700; color: var(--plum); line-height: 1.2; }
.zone-sub  { font-size: 11px; color: var(--ink-4); }

/* Upload progress bar */
#ml-upload-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
  height: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms;
}
#ml-upload-progress.visible { opacity: 1; }
#ml-upload-bar { height: 100%; width: 0%; background: var(--sage); transition: width 200ms; }
#ml-upload-status {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity 150ms;
  pointer-events: none;
  white-space: nowrap;
}
#ml-upload-status.visible { opacity: 1; }

/* ── Lens tab bar ────────────────────────────────── */
#lens-tabs {
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  overflow-x: auto;
  padding: 0 12px;
}
.lens-tab {
  display: flex;
  align-items: center;
  padding: 0 18px;
  height: 44px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 150ms, border-color 150ms;
}
.lens-tab:hover { color: var(--ink); }
.lens-tab.active { color: var(--plum); border-bottom-color: var(--plum); }

/* ── Main lens area ──────────────────────────────── */
#lens-area { flex: 1; overflow-y: auto; min-height: 0; background: var(--paper-2); }

/* ── Shared lens utilities ───────────────────────── */
.pill-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; }
.pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink-3);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
  user-select: none;
}
.pill:hover { background: oklch(0.95 0.04 295); color: var(--plum); border-color: var(--plum-3); }
.pill.active { background: var(--plum); color: #fff; border-color: var(--plum); }
.pill .count { display: inline-block; background: rgba(255,255,255,.2); border-radius: 10px; padding: 0 6px; margin-left: 4px; font-size: 11px; }

.entity-mic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 120ms, color 120ms, border-color 120ms;
  flex-shrink: 0;
}
.entity-mic:hover { background: var(--plum); color: #fff; border-color: var(--plum); }

.lens-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 16px;
  color: var(--ink-4);
  gap: 16px;
  text-align: center;
}
.lens-empty .empty-icon { font-size: 3rem; opacity: .4; }

/* ── What's Next modal ───────────────────────────── */
#wn-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150; display: none; align-items: center; justify-content: center; padding: 16px; }
#wn-overlay.open { display: flex; }
#wn-modal { background: var(--paper); border-radius: var(--radius); padding: 24px; max-width: 540px; width: 100%; max-height: 85vh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-lg); position: relative; }
#wn-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#wn-modal-header h2 { color: var(--ink); font-size: 18px; font-weight: 600; margin: 0; }
#wn-close { position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 5px; border-radius: 4px; transition: color 150ms, background 150ms; }
#wn-close:hover { color: var(--ink); background: var(--paper-2); }
.wn-guidance { font-size: 14px; line-height: 1.65; color: var(--ink-2); background: var(--paper-2); border-radius: 8px; padding: 12px 16px; }
.wn-arc-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.wn-arc-chip { background: var(--paper-2); border: 1px solid var(--hairline); border-radius: 99px; padding: 3px 12px; font-size: 12px; color: var(--ink-3); }
.wn-arc-chip span { color: var(--plum); font-weight: 600; }
.wn-tip { font-size: 13px; line-height: 1.55; color: var(--ink-3); border-left: 2px solid var(--hairline); padding: 5px 12px; font-style: italic; }
.wn-phases { display: flex; flex-direction: column; gap: 6px; }
.wn-phase { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.wn-phase.complete    { color: var(--sage); }
.wn-phase.in_progress { color: var(--terra); background: oklch(0.97 0.04 60 / 0.5); }
.wn-phase.not_started { color: var(--ink-4); }
.wn-phase.clickable   { cursor: pointer; transition: background 120ms; }
.wn-phase.clickable:hover { background: oklch(0.95 0.04 295); }
.wn-phase .wn-ph-icon { flex-shrink: 0; width: 18px; text-align: center; }
.wn-phase .wn-phase-name { font-weight: 600; min-width: 9rem; }
.wn-steps { display: flex; flex-direction: column; gap: 6px; }
.wn-step { font-size: 13px; color: var(--ink); display: flex; gap: 8px; border-radius: 6px; padding: 5px 8px; }
.wn-step::before { content: "\2192"; color: var(--plum); flex-shrink: 0; }
.wn-step.clickable { cursor: pointer; transition: background 120ms, color 120ms; }
.wn-step.clickable:hover { background: var(--paper-2); color: var(--plum); }
#wn-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 0; }
#wn-loading span { font-size: 13px; color: var(--ink-3); }
.wn-progress-track { width: 100%; height: 5px; background: var(--hairline); border-radius: 99px; overflow: hidden; }
.wn-progress-bar { height: 100%; width: 30%; background: linear-gradient(90deg, var(--plum), oklch(0.6 0.17 295), var(--plum)); background-size: 200% 100%; border-radius: 99px; animation: wn-sweep 1.6s ease-in-out infinite; }
@keyframes wn-sweep { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.wn-steps-label { font-size: 10px; font-weight: 600; color: var(--ink-4); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }

/* ── Photo lightbox ──────────────────────────────── */
#photo-lightbox { display: none; position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#lightbox-card { pointer-events: all; position: absolute; top: 0; left: 0; background: var(--paper); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(72vw, 640px); min-width: 240px; min-height: 180px; display: flex; flex-direction: column; overflow: hidden; resize: both; }
/* "Make bigger" toggle — geometry is set inline by _lbApplyPaneGeometry() and
   stays bounded to (and centered in) the grid pane, so it never covers the
   biographer bar or top controls. This rule is just a state marker + disables
   the corner resize handle while in the bigger state. (The old version forced
   92vw×92vh, which buried the biographer panel — Skip 2026-06-05.) */
#lightbox-card.lb-fullscreen { resize: none; }
#lightbox-titlebar { display: flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 7px 9px 6px; border-bottom: 1px solid var(--hairline); cursor: move; user-select: none; background: var(--paper-2); }
#lightbox-label { flex: 1; color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Icon buttons (44×44 minimum touch target per iOS HIG — Mom + Dad 2026-05-24
   feedback: prior 28×28 was too small for elderly fingers). */
.lb-icon-btn { background: transparent; border: none; color: var(--ink-3); width: 44px; height: 44px; flex-shrink: 0; font-size: 20px; cursor: pointer; line-height: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: background 120ms, color 120ms; }
.lb-icon-btn:hover { background: var(--hairline); color: var(--ink); }
#lightbox-mic-btn { background: var(--plum); border: none; color: #fff; border-radius: 50%; width: 44px; height: 44px; flex-shrink: 0; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 120ms; }
#lightbox-mic-btn:hover { background: oklch(0.4 0.2 295); }
/* Close button — larger, more visually distinct, and visibly labeled
   "Done" so Mom doesn't mistake it for the app-level logout x (which
   she hit several times by accident during her 2026-05-24 session). */
#lightbox-close-btn { background: var(--paper-2); border: 1px solid var(--ink-4); color: var(--ink); border-radius: 8px; width: auto; min-width: 64px; height: 44px; padding: 0 14px; flex-shrink: 0; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 120ms; }
#lightbox-close-btn:hover { background: var(--hairline); }
#lightbox-img-wrap { flex: 1; padding: 4px 8px 10px; min-height: 0; overflow: hidden; position: relative; }

/* ── Listening "Vegas-lights" frame ─────────────────────────────────────
   When the biographer is actively listening to the user (mic open),
   add .lb-listening to #lightbox-card to make it VISUALLY UNMISTAKABLE
   that the biographer is paying attention. Skip's mom 2026-05-24:
   "she often assumed something was wrong" during quiet periods. */
#lightbox-card.lb-listening {
  box-shadow:
    var(--shadow-lg),
    0 0 0 4px rgba(255,255,255,.6),
    0 0 0 8px transparent;
  animation: lb-vegas-frame 1.4s linear infinite;
}
@keyframes lb-vegas-frame {
  0%   { box-shadow: var(--shadow-lg), 0 0 0 4px oklch(0.62 0.22 25),  0 0 18px 8px oklch(0.62 0.22 25  / .35); }
  20%  { box-shadow: var(--shadow-lg), 0 0 0 4px oklch(0.78 0.18 80),  0 0 18px 8px oklch(0.78 0.18 80  / .35); }
  40%  { box-shadow: var(--shadow-lg), 0 0 0 4px oklch(0.74 0.20 145), 0 0 18px 8px oklch(0.74 0.20 145 / .35); }
  60%  { box-shadow: var(--shadow-lg), 0 0 0 4px oklch(0.66 0.20 220), 0 0 18px 8px oklch(0.66 0.20 220 / .35); }
  80%  { box-shadow: var(--shadow-lg), 0 0 0 4px oklch(0.58 0.22 295), 0 0 18px 8px oklch(0.58 0.22 295 / .35); }
  100% { box-shadow: var(--shadow-lg), 0 0 0 4px oklch(0.62 0.22 25),  0 0 18px 8px oklch(0.62 0.22 25  / .35); }
}
#lightbox-img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; display: block; }
/* Loading + retry states for the lightbox image (mirror grid-thumb pattern).
   Skip Sr. 2026-05-09 21:05 reported "Photos still don't open" — the lightbox
   opened but the image silently failed to load with no user feedback. Now
   shows shimmer while loading and a tap-to-retry overlay on failure. */
#lightbox-img.thumb-pending {
  background: linear-gradient(110deg, #2a1a4a 8%, #3d2868 18%, #2a1a4a 33%);
  background-size: 200% 100%;
  animation: ml-thumb-shimmer 1.4s linear infinite;
}
#lightbox-img.thumb-failed { background: #2a1a4a; cursor: pointer; }
#lightbox-img-wrap:has(img.thumb-failed)::after {
  content: '↻ Tap to retry';
  position: absolute; inset: 4px 8px 10px; display: flex;
  align-items: center; justify-content: center;
  color: #c4b5fd; font-size: .95rem; font-weight: 600;
  background: rgba(42,26,74,.85); pointer-events: none;
  border-radius: 8px;
}

/* Lightbox options menu */
#lightbox-menu { display: none; position: fixed; z-index: 200; background: var(--paper); border: 1px solid var(--hairline); border-radius: 8px; box-shadow: var(--shadow-lg); min-width: 180px; padding: 4px 0; flex-direction: column; }
#lightbox-menu.open { display: flex; }
.lb-menu-item { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--ink); padding: 8px 14px; font-size: 13px; cursor: pointer; font-family: var(--font-ui); transition: background 100ms; }
.lb-menu-item:hover { background: var(--paper-2); }
.lb-menu-sep { border-top: 1px solid var(--hairline); margin: 4px 0; }
.lb-menu-item.danger { color: var(--rose); }

/* ── Face context lightbox ───────────────────────── */
#face-ctx-lb { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.6); align-items: center; justify-content: center; }
#face-ctx-lb.open { display: flex; }
.face-ctx-card { background: var(--paper); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-width: min(94vw, 920px); max-height: 92vh; overflow: hidden; }
.face-ctx-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--hairline); flex-shrink: 0; }
#face-ctx-title { flex: 1; font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.face-ctx-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 8px; min-height: 0; }
.face-ctx-inner { position: relative; display: inline-block; line-height: 0; }
#face-ctx-img { display: block; max-width: min(85vw, 800px); max-height: 65vh; width: auto; height: auto; }
#face-ctx-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.face-ctx-hint { font-size: 11px; color: var(--ink-4); text-align: center; padding: 5px 8px; border-top: 1px solid var(--hairline); flex-shrink: 0; }

/* ── Ring disambiguation modal ───────────────────── */
#identify-ring-modal { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); align-items: center; justify-content: center; }
#identify-ring-modal.open { display: flex; }
.ring-modal-card { background: var(--paper); border: 1px solid var(--hairline); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; width: min(94vw, 420px); max-height: 92vh; overflow-y: auto; }
.ring-modal-header { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.ring-modal-title { font-size: 15px; font-weight: 700; color: var(--plum); }
.ring-modal-hint { font-size: 12px; color: var(--ink-4); text-align: center; padding: 0 8px; }
#ring-stage { position: relative; width: 500px; height: 500px; flex-shrink: 0; }
#ring-hints { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 8px; }
.ring-name-row { display: flex; gap: 8px; width: 100%; }
#ring-name-input { flex: 1; background: var(--paper-2); border: 1px solid var(--hairline); color: var(--ink); border-radius: var(--radius); padding: 8px 12px; font-size: 14px; outline: none; min-width: 0; font-family: var(--font-ui); }
#ring-name-input:focus { border-color: var(--plum); }
.ring-irrelevant-btn { background: transparent; border: 1px solid var(--hairline); color: var(--ink-3); border-radius: var(--radius); padding: 5px 12px; font-size: 12px; cursor: pointer; transition: background 150ms, color 150ms, border-color 150ms; font-family: var(--font-ui); }
.ring-irrelevant-btn:hover { background: oklch(0.96 0.03 25); color: var(--rose); border-color: var(--rose); }
.ring-secondary-row { display: flex; gap: 8px; width: 100%; justify-content: space-between; flex-wrap: wrap; }
.ring-family-btn { background: transparent; border: 1px solid var(--sage); color: var(--sage); border-radius: var(--radius); padding: 5px 12px; font-size: 12px; cursor: pointer; transition: background 150ms, color 150ms; font-family: var(--font-ui); font-weight: 600; }
.ring-family-btn:hover { background: var(--sage); color: #fff; }

/* Ring candidate circles */
.ring-candidate { position: absolute; width: 110px; height: 110px; border-radius: 50%; overflow: hidden; border: 3px solid var(--hairline); cursor: grab; background: var(--paper-2); touch-action: none; user-select: none; transition: box-shadow 120ms, border-color 120ms, opacity 120ms; }
.ring-candidate:active { cursor: grabbing; }
.ring-candidate img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ring-name { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); font-size: 9px; color: #fff; text-align: center; padding: 2px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
#ring-center-face { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 160px; height: 160px; border-radius: 50%; overflow: hidden; border: 4px solid var(--terra); background: var(--paper-2); transition: box-shadow 100ms; z-index: 2; }
#ring-center-face.ring-match { box-shadow: 0 0 0 5px var(--sage); }
#ring-center-face img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Auth overlay (401 expiry only) ──────────────── */
#auth-overlay { position: fixed; inset: 0; background: oklch(0.98 0.01 270 / 0.95); z-index: 300; display: none; align-items: center; justify-content: center; }
#auth-overlay.visible { display: flex; }
.auth-box { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px; width: min(380px, 90vw); display: flex; flex-direction: column; gap: 16px; }
.auth-box h2 { font-size: 17px; color: var(--ink); font-weight: 700; }
.auth-box p  { font-size: 13px; color: var(--ink-3); }
.auth-box a  { color: var(--plum); text-decoration: none; font-weight: 600; }
.auth-box a:hover { text-decoration: underline; }

/* ── Spinner ─────────────────────────────────────── */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--hairline); border-top-color: var(--plum); border-radius: 50%; animation: ml-spin 0.8s linear infinite; vertical-align: middle; margin-right: 5px; }
@keyframes ml-spin { to { transform: rotate(360deg); } }

/* ── Lens body partial styles ─── */
/* ── memory_lens_photos ── */
.photo-card {
  position: relative; border-radius: 6px; overflow: hidden;
  background: var(--paper-2); cursor: pointer; aspect-ratio: 1;
  border: 2px solid transparent; transition: border-color .15s, transform .1s;
}
.photo-card:hover { border-color: var(--plum); transform: scale(1.02); }
.photo-card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* Pending state — soft shimmer while the lazy-fetch is in flight, so users
   see "something is loading" instead of a blank tile. (Skip's father
   2026-05-09: "None of the pictures are showing in memory Lens" — 21
   thumbnails existed; cards just rendered blank because img.src was unset
   until the lazy fetch resolved.) */
.photo-card img.thumb-pending {
  background: linear-gradient(110deg, #2a1a4a 8%, #3d2868 18%, #2a1a4a 33%);
  background-size: 200% 100%;
  animation: ml-thumb-shimmer 1.4s linear infinite;
}
.photo-card img.thumb-failed {
  background: #2a1a4a; cursor: pointer;
}
/* ::before/::after don't render on <img>; use the parent .photo-card
   when an inner img has the thumb-failed class. :has() is supported on
   iPad Safari 16.4+ which all our beta hardware exceeds. */
.photo-card:has(img.thumb-failed)::after {
  content: '↻ Retry';
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  color: #c4b5fd; font-size: .7rem; font-weight: 600;
  background: rgba(42,26,74,.85); pointer-events: none;
}
@keyframes ml-thumb-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.photo-card .photo-mic {
  position: absolute; bottom: 4px; right: 4px;
  opacity: 0; transition: opacity .15s;
}
.photo-card:hover .photo-mic { opacity: 1; }
.photo-card .photo-date {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #e2e8f0; font-size: .65rem; padding: 12px 4px 3px;
  text-align: center;
}

/* ── memory_lens_faces ── */
@keyframes spin { to { transform: rotate(360deg); } }
.face-card {
  background: var(--paper); border-radius: 8px; overflow: hidden;
  border: 2px solid var(--hairline); cursor: pointer; position: relative;
  transition: border-color .15s, transform .1s;
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: .4rem;
  box-shadow: var(--shadow-sm);
}
.face-card:hover { border-color: var(--plum); transform: scale(1.03); }
.face-card.known { border-color: var(--sage); }
/* Tap-to-select merge UX (replaces HTML5 drag, which never fires on iOS Safari). */
.face-card.selected {
  border-color: var(--terra); transform: scale(1.04);
  box-shadow: 0 0 0 3px oklch(0.85 0.12 35 / .45);
}
.face-select-dot {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.55); border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8rem; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.face-card.selected .face-select-dot {
  background: var(--terra); border-color: #fff;
}
#faces-merge-bar {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: .6rem; z-index: 9998;
  background: var(--paper); border: 1px solid var(--hairline);
  border-radius: 28px; padding: .45rem .55rem .45rem 1rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: .85rem; color: var(--ink-1);
}
#faces-merge-bar button {
  border: none; border-radius: 20px; padding: .5rem 1rem;
  font-size: .85rem; font-weight: 600; cursor: pointer;
}
#faces-merge-bar .merge-go { background: var(--plum); color: #fff; }
#faces-merge-bar .merge-cancel { background: transparent; color: var(--ink-3); padding: .5rem .6rem; }
.face-card img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
.face-card .face-name {
  font-size: .7rem; color: var(--ink-3); margin-top: .25rem;
  text-align: center; padding: 0 .25rem; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.face-card .face-name.named { color: var(--plum); font-weight: 600; }
.face-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0 .3rem;
}
.cd-chip {
  position: relative;
  display: inline-flex; flex-direction: column; align-items: center;
  border-radius: 6px; padding: 4px;
  border: 2px solid transparent; transition: border-color .15s, opacity .15s;
  background: #1e293b;
}
.cd-chip:hover { border-color: #7c3aed; }
/* Per-chip remove button — replaces the HTML5 drag-to-drop-zone, which never
   fires on iOS Safari, so removing a misgrouped face was impossible on iPad. */
.cd-chip-remove {
  position: absolute; top: 2px; right: 2px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.65); border: 1.5px solid #fff;
  color: #fff; font-size: .7rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.cd-chip-remove:hover { background: #ef4444; }

/* ── memory_lens_moments ── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── memory_lens_places ── */
.place-group { margin-bottom: 1.25rem; }
.place-heading {
  font-size: .9rem; font-weight: 700; color: var(--plum);
  padding: .3rem 0 .4rem; border-bottom: 1px solid var(--hairline);
  margin-bottom: .5rem; display: flex; align-items: center; gap: .5rem;
}
.place-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 5px;
}

/* Biographer bar styles moved to design.css (shared across all pages) */

/* ── Memory Sparks carousel ──────────────────────── */
#sparks-carousel::-webkit-scrollbar { display: none; }

.sc-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: opacity 200ms, background 150ms;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sc-arrow:hover { background: var(--paper-2); }
.sc-arrow-left  { left: 2px; }
.sc-arrow-right { right: 2px; }

.sc-card {
  flex-shrink: 0;
  width: 200px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--paper);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 150ms, border-color 150ms, transform 120ms;
  display: flex;
  flex-direction: column;
}
.sc-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--plum-3);
  transform: translateY(-2px);
}
.sc-card.sc-sparked {
  border-color: var(--sage);
  background: oklch(0.98 0.02 145);
}

.sc-card-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--paper-2);
}
.sc-card-img-placeholder {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--ink-3);
  background: var(--paper-2);
}

.sc-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sc-card-era {
  font-size: .72rem;
  font-weight: 700;
  color: var(--plum);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.sc-card-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.sc-sparked-badge {
  font-size: .7rem;
  font-weight: 700;
  color: var(--sage);
  margin-top: 4px;
}

/* ── Memora hand-off highlight (?highlight=<uuid>,...) ─────────────────────── */
.photo-card-highlight {
  outline: 3px solid #0d9488;
  outline-offset: 2px;
  position: relative;
  z-index: 1;
}
.photo-card-highlight::before {
  content: "Just sent from Memora";
  position: absolute;
  top: 6px;
  left: 6px;
  background: #0d9488;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  z-index: 2;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ── Dialoged-photo checkmark badge (top-right corner of card) ─────────────── */
.photo-dialog-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 2px 4px rgba(21, 128, 61, 0.4);
  pointer-events: none;
}
.photo-card-dialoged {
  position: relative;
}
