/* Our Storybook app styles.
   Camera, preview and viewer are always dark (like Snapchat); Memories and sheets follow
   the system light/dark setting. */

:root {
  --bg: #ffffff; --fg: #121214; --muted: #6e6e76; --line: #ececf0;
  --chip: #f2f2f5; --chip-on: #121214; --chip-on-fg: #ffffff; --tile: #ececf0;
  --accent: #ffcf24; --accent-fg: #121214; --heart: #ff375f; --heart-text: #c8102e; --send: #0eadff; --ok: #1fbf6a;
  --cols: 3; --gap: 2px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0f; --fg: #f4f4f6; --muted: #9b9ba4; --line: #222227;
    --chip: #1c1c20; --chip-on: #f4f4f6; --chip-on-fg: #0d0d0f; --tile: #1a1a1e; --heart-text: var(--heart);
    color-scheme: dark;
  }
}
@media (min-width: 600px) { :root { --cols: 4; } }
@media (min-width: 900px) { :root { --cols: 5; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; background: #000; color: #fff; overflow: hidden;
  overscroll-behavior: none;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.screen { position: fixed; inset: 0; overflow: hidden; }
.icon { width: 26px; height: 26px; display: block; }
.icon svg, .ibtn svg { width: 100%; height: 100%; display: block; }

/* icon button over the camera and the preview (like Snapchat's): a thin white outline icon right on
   the picture, a soft shadow to read on bright scenes, no circle behind it. The 44px box is the tap
   target; the icon is 28px. On = the brand yellow. */
.ibtn {
  position: relative; width: 44px; height: 44px; border: 0; border-radius: 50%; padding: 8px;
  background: transparent; color: #fff; display: grid; place-items: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)) drop-shadow(0 0 6px rgba(0,0,0,.18));
}
.ibtn svg :is(path, circle, rect, line, polyline) { stroke-width: 2px; }
.ibtn:active { transform: scale(.88); }
.ibtn.on { background: transparent; color: var(--accent); }

/* ------------------------------------------------------------- camera */
#camera {
  background: #000; touch-action: none; user-select: none; -webkit-user-select: none;
  --cam-nav: calc(50px + max(var(--safe-b), 6px));   /* the five screens' bar, over the home indicator */
}
#viewfinder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#viewfinder.mirror { transform: scaleX(-1); }
/* top: a whisper of shade so the status bar and the icons read on a bright sky */
#camera::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: calc(var(--safe-t) + 120px); z-index: 1; pointer-events: none;
  background: linear-gradient(rgba(0,0,0,.28), rgba(0,0,0,0));
}
.cam-top {
  position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 6px) 8px 0;
  display: flex; justify-content: space-between; align-items: flex-start; z-index: 2; pointer-events: none;
}
.cam-top > * { pointer-events: auto; }
/* you: the yellow initial (a 36px circle in a 44px tap target) */
.avatar {
  width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 4px; background: var(--accent); background-clip: content-box;
  color: #111; font-weight: 800; font-size: 16px; display: grid; place-items: center;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.35));
}
.avatar:active { transform: scale(.92); }
.cam-left { display: flex; gap: 4px; align-items: center; }
.cam-right { display: flex; flex-direction: column; align-items: flex-end; }
.cam-row { display: flex; gap: 4px; }
/* the tools under flip: flash, timer, (HD), and ⌄ for the rest, Snapchat's names beside them when it's open */
.cam-rail { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.cam-right .cam-rail { margin-top: 6px; }
.cam-rail .ibtn[data-label]::before {
  content: attr(data-label); position: absolute; right: 100%; top: 50%; transform: translateY(-50%); margin-right: 2px;
  white-space: nowrap; font: 700 13.5px/1 system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.cam-rail.open .ibtn[data-label]::before { opacity: 1; }
.cam-rail:not(.open) #hqBtn:not(.on) { display: none; }     /* HD lives under ⌄ (shown while it's on) */
.ibtn.more svg { transition: transform .2s ease; }
.ibtn.more[aria-expanded="true"] svg { transform: rotate(180deg); }
.badge-dot {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: #ff3b30; color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center;
  border: 2px solid #000;
}
.code-box { font-size: 34px; font-weight: 800; letter-spacing: .18em; text-align: center; padding: 14px; border-radius: 16px; background: var(--chip); margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
/* bottom: shade for legibility, the shutter row with its looks & lenses beside it, their tabs, the five screens */
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; pointer-events: none; }
.cam-bottom > * { pointer-events: auto; }
.cam-bottom::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; top: -48px; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.42) 70%, rgba(0,0,0,.55));
}
.cam-controls { position: relative; height: 122px; pointer-events: none; }   /* shutter row (84) + tabs */
.cam-controls > :not(.filter-strip, .rec-lock) { pointer-events: auto; }
.cam-controls .shutter { position: absolute; left: 50%; top: 0; margin-left: -42px; z-index: 1; }
#memoriesBtn { position: absolute; top: 20px; left: calc(50% - 154px); }
.cam-nav {
  display: flex; justify-content: space-around; align-items: stretch; padding: 0 4px max(var(--safe-b), 6px);
}
.nav-tab {
  position: relative; flex: 1 1 0; min-width: 0; min-height: 50px; border: 0; padding: 4px 0 2px; background: transparent;
  color: rgba(255,255,255,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
}
.nav-tab svg { width: 26px; height: 26px; display: block; flex: none; }
.nav-label { font: 700 10.5px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .01em; white-space: nowrap; }
.nav-tab[aria-current="page"] { color: var(--accent); }
.nav-tab:active svg { transform: scale(.9); }
.nav-tab .badge-dot { top: 0; right: auto; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; border-width: 2px; border-color: rgba(0,0,0,.6); }
.shutter {
  position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0; padding: 0; background: transparent;
  transition: transform .15s ease; filter: drop-shadow(0 1px 4px rgba(0,0,0,.3));
}
.shutter svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.shutter .ring { fill: rgba(255,255,255,.08); stroke: #fff; stroke-width: 6; }
.shutter .prog { fill: none; stroke: #ff3b30; stroke-width: 6; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; opacity: 0; }
.shutter.pressed { transform: scale(1.12); }
.shutter.recording { transform: scale(1.3); }
.shutter.recording .ring { fill: rgba(255,59,48,.18); stroke: rgba(255,255,255,.5); }
.shutter.recording .prog { opacity: 1; }
.rec-timer {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 18px); transform: translateX(-50%); z-index: 3;
  background: #ff3b30; color: #fff; font-weight: 800; font-size: 14px; padding: 4px 12px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.cam-msg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 32px; z-index: 1;
  color: #ddd;
}
.cam-msg .card { max-width: 340px; }
.cam-msg h2 { color: #fff; margin: 0 0 8px; font-size: 20px; }
.cam-msg p { margin: 0 0 18px; color: #b9b9c0; }
.front-flash { position: absolute; inset: 0; background: #fff8e8; z-index: 5; opacity: 0; pointer-events: none; transition: opacity .12s; }
.front-flash.on { opacity: 1; }
.shot-flash { position: absolute; inset: 0; background: #000; z-index: 4; opacity: 0; pointer-events: none; transition: opacity .18s; }
.shot-flash.on { opacity: .6; transition: none; }
.zoom-pill {
  position: absolute; left: 50%; bottom: calc(var(--cam-nav, 0px) + 132px); transform: translateX(-50%); z-index: 2;
  background: rgba(0,0,0,.32); color: #fff; font-weight: 800; font-size: 12.5px; padding: 5px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* filter carousel (camera + preview) */
.filter-strip {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 128px); z-index: 2;
  display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; justify-content: safe center;
}
.filter-strip::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; border: 0; border-radius: 999px; padding: 8px 13px; font-weight: 800; font-size: 13px;
  background: rgba(0,0,0,.42); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.filter-chip[aria-pressed="true"] { background: #fff; color: #000; }
.filter-name {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 3; pointer-events: none;
  font-size: 30px; font-weight: 800; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.55); opacity: 0; transition: opacity .3s;
}
.filter-name.show { opacity: 1; transition: none; }

/* ------------------------------------------------------------- preview */
#preview { background: #000; z-index: 20; touch-action: none; }
.pv-stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); overflow: hidden; border-radius: 0; }
.pv-stage > img, .pv-stage > video, .pv-stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.pv-stage .mirror { transform: scaleX(-1); }
.pv-stage canvas { pointer-events: none; }
.pv-top {
  position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 6px) 8px 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-start;
}
.pv-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 16px calc(var(--safe-b) + 22px); z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
/* "✨ Caption ideas" (AI helper, photos only): under the close button, clear of the side buttons */
#pvIdeas { position: absolute; left: 14px; top: calc(var(--safe-t) + 70px); max-width: min(68%, 320px); z-index: 3; color: #fff; }
#pvIdeas .fh-caption-btn { background: rgba(0,0,0,.45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#pvIdeas .fh-caption-chip { background: rgba(0,0,0,.5); border-color: rgba(255,255,255,.25); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pv-save {
  height: 48px; padding: 0 18px 0 14px; border-radius: 24px; border: 0; background: rgba(0,0,0,.45); color: #fff;
  font-weight: 800; display: flex; align-items: center; gap: 8px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.pv-save svg { width: 22px; height: 22px; }
.pv-send {
  height: 48px; padding: 0 16px 0 20px; border-radius: 24px; border: 0; background: var(--send); color: #fff;
  font-weight: 800; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 16px rgba(14,173,255,.35);
}
.pv-send svg { width: 20px; height: 20px; }
.caption-input {
  position: absolute; left: 0; right: 0; z-index: 4; border: 0; outline: 0; text-align: center;
  background: rgba(0,0,0,.58); color: #fff; font-weight: 600; padding: 10px 14px; font-size: 18px;
}

/* ------------------------------------------------------------- bottom sheets */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 85; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg); color: var(--fg); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(var(--safe-b) + 18px); max-height: 88vh; overflow-y: auto; animation: rise .22s cubic-bezier(.2,.8,.2,1);
}
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 2px 0 4px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.sheet .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.book-list { display: grid; gap: 8px; margin: 6px 0 16px; }
.book {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 2px solid transparent; background: var(--chip);
  border-radius: 16px; padding: 12px 14px; text-align: left;
}
.book .dot { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #111; flex: none; }
.book .nm { font-weight: 800; font-size: 16px; }
.book .sub { color: var(--muted); font-size: 12.5px; }
.book .tick {
  margin-left: auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: transparent;
}
.book .tick svg { width: 16px; height: 16px; }
.book[aria-pressed="true"] { border-color: var(--fg); }
.book[aria-pressed="true"] .tick { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.book.add { background: transparent; border: 2px dashed var(--line); color: var(--muted); }
.book.add .dot { background: var(--chip); color: var(--fg); }
.book.add .dot svg { width: 18px; height: 18px; }
.btn {
  width: 100%; height: 52px; border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-fg);
  font-weight: 800; font-size: 16.5px;
}
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--chip); color: var(--fg); }
.btn + .btn { margin-top: 8px; }
.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 5px; }
.field input, .field select {
  width: 100%; height: 48px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--bg); color: var(--fg);
  padding: 0 14px; font-size: 16px;
}
.row-check { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.row-check input { width: 20px; height: 20px; accent-color: var(--fg); }
.list { border-radius: 16px; background: var(--chip); overflow: hidden; margin: 0 0 16px; }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line); font-size: 14.5px; }
.list .item:first-child { border-top: 0; }
.list .item b { font-weight: 700; }
.list .item .v { color: var(--muted); text-align: right; }
.steps { margin: 4px 0 18px; padding-left: 22px; line-height: 1.6; font-size: 15px; }
.steps li { margin-bottom: 6px; }
.share-glyph { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--chip); font-size: 13px; }
.section-label { font-size: 12.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 4px 8px; }

/* ------------------------------------------------------------- memories */
#memories {
  background: var(--bg); color: var(--fg); z-index: 30; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; animation: rise .26s cubic-bezier(.2,.8,.2,1);
}
.m-head {
  position: sticky; top: 0; z-index: 5; padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.m-title { display: flex; align-items: center; gap: 10px; padding: 10px 14px 4px; }
.m-title h1 { margin: 0; font-size: 21px; font-weight: 800; flex: 1; text-align: center; letter-spacing: -.015em; }
.m-title .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; }
.cbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--chip); color: var(--fg); display: grid; place-items: center; padding: 9px; flex: none; }
.cbtn svg { width: 100%; height: 100%; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 14px 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: var(--chip); color: var(--fg); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.tab[aria-pressed="true"] { background: var(--chip-on); color: var(--chip-on-fg); }
.tab .n { opacity: .6; font-weight: 600; margin-left: 4px; }
.flash { padding: 14px 0 4px; }
.flash h2, .month h2 { font-size: 17px; font-weight: 800; margin: 0; padding: 18px 14px 9px; letter-spacing: -.01em; display: flex; gap: 8px; align-items: baseline; }
.flash h2 { padding-top: 4px; }
.month h2 span, .flash h2 span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.flash-row { display: flex; gap: 10px; overflow-x: auto; padding: 0 14px 6px; scrollbar-width: none; }
.flash-row::-webkit-scrollbar { display: none; }
.flash-card { flex: none; width: 124px; aspect-ratio: 3/4.6; border-radius: 16px; overflow: hidden; position: relative; border: 0; padding: 0; background: var(--tile); }
.flash-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flash-card .lbl { position: absolute; inset: auto 0 0 0; padding: 26px 10px 10px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.flash-card .lbl b { display: block; font-size: 14px; } .flash-card .lbl span { font-size: 11.5px; opacity: .85; }
.grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: var(--gap); padding: 0 var(--gap); }
.tile { position: relative; aspect-ratio: 3/4; background: var(--tile); overflow: hidden; border: 0; padding: 0; border-radius: 3px; display: block; width: 100%; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile .badge { position: absolute; left: 6px; bottom: 5px; color: #fff; font-size: 11.5px; font-weight: 800; display: flex; gap: 3px; align-items: center; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.tile .badge svg { width: 12px; height: 12px; }
.tile .fav { position: absolute; right: 6px; top: 6px; width: 17px; height: 17px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); display: none; }
.tile.is-fav .fav { display: block; }
.tile .sync { position: absolute; right: 5px; bottom: 4px; width: 16px; height: 16px; color: #fff; opacity: .9; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.tile .ph svg { width: 24px; height: 24px; opacity: .5; }
.empty { padding: 70px 24px; text-align: center; color: var(--muted); max-width: 460px; margin: 0 auto; }
.empty h2 { color: var(--fg); font-size: 20px; margin: 0 0 8px; }
.m-foot { height: calc(var(--safe-b) + 60px); }

.backup-row { padding: 0 14px 12px; display: flex; }
.backup-pill {
  border: 0; border-radius: 999px; padding: 7px 13px 7px 10px; font-weight: 700; font-size: 13px;
  background: var(--chip); color: var(--fg); display: inline-flex; align-items: center; gap: 7px;
}
.backup-pill svg { width: 17px; height: 17px; }
.backup-pill.ok { color: var(--ok); }
.backup-pill.todo { background: var(--accent); color: var(--accent-fg); }

/* ------------------------------------------------------------- special dates */
#dates { background: var(--bg); color: var(--fg); z-index: 40; overflow-y: auto; }
.dates-body { padding: 8px 14px calc(var(--safe-b) + 40px); max-width: 640px; margin: 0 auto; }
.date-card { background: var(--chip); border-radius: 18px; padding: 14px; margin: 10px 0; }
.date-top { display: flex; gap: 12px; align-items: center; }
.date-badge { width: 52px; height: 56px; border-radius: 14px; background: var(--accent); color: #111; display: grid; place-content: center; text-align: center; flex: none; line-height: 1.05; }
.date-badge b { font-size: 21px; font-weight: 800; } .date-badge span { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.date-badge.small { width: 42px; height: 46px; } .date-badge.small b { font-size: 17px; }
.date-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.date-txt b { font-size: 16.5px; font-weight: 800; }
.date-txt span { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; margin: 10px 2px 0; }
.date-strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 12px; scrollbar-width: none; }
.date-strip::-webkit-scrollbar { display: none; }
.mini { flex: none; width: 64px; height: 84px; border-radius: 10px; overflow: hidden; border: 0; padding: 0; position: relative; background: var(--tile); color: #fff; }
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; font-weight: 800; padding: 10px 0 4px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.mini.more { color: var(--fg); font-weight: 800; }
.ideas { margin-top: 18px; }
.idea { display: flex; gap: 12px; align-items: center; padding: 10px 2px; border-top: 1px solid var(--line); }
.coming { padding: 14px 14px 0; }
.coming h2 { font-size: 17px; font-weight: 800; margin: 0 0 10px; }
.coming-card { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; border-radius: 18px; padding: 12px 14px; margin-bottom: 8px; background: linear-gradient(135deg, #ffcf24, #ff9f6e); color: #1a1405; }
.coming-card .big { width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,.55); display: grid; place-content: center; text-align: center; font-size: 22px; font-weight: 800; line-height: 1; flex: none; }
.coming-card .big small { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; margin-top: 2px; }
.coming-card .txt { display: flex; flex-direction: column; min-width: 0; }
.coming-card .txt b { font-size: 16px; }
.coming-card .txt span { font-size: 13px; opacity: .85; }
.coming-card .hint2 { font-weight: 700; }
.field select { appearance: auto; }

/* ------------------------------------------------------------- family */
#family { background: var(--bg); color: var(--fg); z-index: 40; overflow-y: auto; }
.fam-body { padding: 10px 14px calc(var(--safe-b) + 40px); max-width: 680px; margin: 0 auto; }
.fam-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.fam-big { border: 0; border-radius: 18px; padding: 16px 14px; text-align: left; background: var(--accent); color: #111; display: flex; flex-direction: column; gap: 3px; }
.fam-big.alt { background: var(--chip); color: var(--fg); }
.fam-big .ico { width: 30px; height: 30px; margin-bottom: 6px; }
.fam-big .ico svg { width: 100%; height: 100%; }
.fam-big b { font-size: 16px; }
.fam-big span { font-size: 12.5px; opacity: .75; }
.doc-list { display: grid; gap: 8px; }
.doc-card { display: flex; gap: 12px; align-items: center; border: 0; border-radius: 16px; padding: 10px; background: var(--chip); text-align: left; color: var(--fg); }
.doc-card img { width: 56px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--tile); flex: none; }
.doc-txt { display: flex; flex-direction: column; min-width: 0; }
.doc-txt b { font-size: 15.5px; }
.doc-txt span { font-size: 13px; color: var(--muted); }
.doc-view { background: #0d0d0f; color: #fff; z-index: 60; overflow-y: auto; }
.doc-top { position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; align-items: center; padding: calc(var(--safe-t) + 12px) 14px 12px; background: rgba(13,13,15,.92); backdrop-filter: blur(10px); }
.doc-pages { display: grid; gap: 14px; padding: 6px 14px; max-width: 760px; margin: 0 auto; }
.doc-pages figure { margin: 0; }
.doc-pages img { width: 100%; display: block; border-radius: 6px; background: #fff; }
.doc-pages figcaption { font-size: 12px; opacity: .6; text-align: center; padding-top: 6px; }
.doc-foot { padding: 10px 14px calc(var(--safe-b) + 30px); max-width: 760px; margin: 0 auto; }
.scanner { background: #000; color: #fff; z-index: 80; display: flex; flex-direction: column; }
.scan-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 12px) 16px 10px; font-size: 15px; }
.scan-stage { position: relative; flex: 1; min-height: 0; margin: 0 12px; touch-action: none; }
.scan-stage.result { display: block; }
.scan-photo, .scan-poly { position: absolute; }
.scan-poly { overflow: visible; pointer-events: none; }
.scan-poly polygon { fill: rgba(255,207,36,.16); stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.scan-handle { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 3px solid var(--accent); background: rgba(0,0,0,.35); touch-action: none; cursor: grab; }
.scan-result { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; box-shadow: 0 6px 30px rgba(0,0,0,.5); background: #fff; }
.scan-looks { display: flex; gap: 8px; justify-content: center; padding: 12px; }
.scan-bottom { display: flex; gap: 8px; padding: 6px 12px calc(var(--safe-b) + 16px); }
.scan-bottom .btn { margin: 0; flex: 1; height: 48px; font-size: 15px; }
.scan-busy { flex: 1; display: grid; place-content: center; text-align: center; gap: 14px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent); margin: 0 auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- family tree */
#tree { background: var(--bg); color: var(--fg); z-index: 45; display: flex; flex-direction: column; }
.tree-head { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 14px 10px; border-bottom: 1px solid var(--line); }
.tree-title { flex: 1; min-width: 0; text-align: center; }
.tree-title b { display: block; font-size: 18px; font-weight: 800; }
.tree-title span { font-size: 12px; color: var(--muted); }
.tree-svg { flex: 1; width: 100%; min-height: 0; touch-action: none; cursor: grab; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent) 8%, var(--bg)), var(--bg) 70%); }
.tlinks { fill: none; stroke: var(--muted); stroke-width: 2; opacity: .55; }
.tcard { cursor: pointer; }
.tcard rect { fill: var(--chip); stroke: var(--line); stroke-width: 1.5; }
.tcard.m rect { fill: color-mix(in srgb, #5ea8ff 16%, var(--bg)); }
.tcard.f rect { fill: color-mix(in srgb, #ff7aa8 16%, var(--bg)); }
.tcard.focus rect { stroke: var(--accent); stroke-width: 4; }
.tcard:focus-visible rect, .tcard:hover rect { stroke: var(--fg); }
.tcard text { fill: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.tcard .t1 { font-size: 15px; font-weight: 800; }
.tcard .t2 { font-size: 13px; font-weight: 600; }
.tcard .t3 { font-size: 11.5px; fill: var(--muted); }
.tree-start { display: grid; gap: 8px; }
.tree-start .btn + .btn { margin-top: 0; }
.fam-big.tree-open { width: 100%; margin-bottom: 10px; }
.people-search { width: 100%; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); color: var(--fg); padding: 0 14px; font-size: 15px; margin-bottom: 8px; }
.people-list { display: grid; gap: 4px; max-height: 340px; overflow-y: auto; margin-bottom: 12px; }
.person-row { display: flex; justify-content: space-between; gap: 10px; border: 0; background: var(--chip); color: var(--fg); border-radius: 12px; padding: 11px 13px; text-align: left; }
.person-row span { color: var(--muted); font-size: 13px; }
.tree-tools { display: grid; gap: 8px; }
.tree-tools .btn + .btn { margin-top: 0; }
.pchips { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { border: 0; border-radius: 14px; background: var(--chip); color: var(--fg); padding: 9px 12px; text-align: left; display: flex; flex-direction: column; }
.pchip b { font-size: 14px; } .pchip span { font-size: 12px; color: var(--muted); }
.person-notes { white-space: pre-wrap; background: var(--chip); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; line-height: 1.5; }
.person-actions { display: grid; gap: 8px; margin-top: 18px; }
.person-actions .btn + .btn { margin-top: 0; }
.rel-buttons { display: flex; gap: 8px; justify-content: center; }

/* ------------------------------------------------------------- tags & stories */
.tag-list .person-row.on { background: var(--chip-on); color: var(--chip-on-fg); }
.tag-list .person-row.on span { color: inherit; opacity: .8; }
#vPeople.toggled { background: #fff; color: #000; }
.story-modes { display: flex; gap: 8px; justify-content: center; margin: 4px 0 12px; }
.story-preview { min-height: 120px; border-radius: 16px; background: var(--chip); display: grid; place-items: center; overflow: hidden; margin-bottom: 12px; }
.story-preview video { width: 100%; max-height: 50vh; display: block; background: #000; }
.story-preview audio { width: calc(100% - 24px); }
.story-wave { font-size: 18px; font-weight: 700; color: var(--muted); padding: 30px; }
.story-controls { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
.story-rec { width: 72px; height: 72px; border-radius: 50%; border: 5px solid var(--fg); background: #ff3b30; box-shadow: inset 0 0 0 5px var(--bg); }
.story-rec.on { border-radius: 22px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); } }
.story-time { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 64px; }
.story-card .story-ico { font-size: 26px; width: 44px; text-align: center; flex: none; }
.story-player { width: 100%; margin: 6px 0 14px; border-radius: 12px; }
.v-when .with { opacity: .95; font-weight: 700; }

/* ------------------------------------------------------------- date scrubber */
#memScrubber { position: fixed; right: 0; top: calc(var(--safe-t) + 150px); bottom: calc(var(--safe-b) + 20px); width: 36px; z-index: 31; touch-action: none; }
.scrub-handle { position: absolute; right: 5px; width: 6px; height: 40px; border-radius: 3px; background: var(--muted); transform: translateY(-50%); opacity: 0; transition: opacity .25s; }
.scrub-pill {
  position: absolute; right: 22px; transform: translateY(-50%); background: var(--chip-on); color: var(--chip-on-fg);
  font-size: 13px; font-weight: 800; padding: 7px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .25s; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
#memScrubber.scrolling .scrub-handle { opacity: .6; }
#memScrubber.scrolling .scrub-pill, #memScrubber.dragging .scrub-pill { opacity: 1; }
.scrubber.dragging .scrub-handle { opacity: 1; background: var(--fg); }

/* month "Play" */
.month h2 { align-items: center; }
.month-play {
  margin-left: auto; border: 0; border-radius: 999px; background: var(--chip); color: var(--fg);
  font-weight: 800; font-size: 12.5px; padding: 5px 11px 5px 8px; display: inline-flex; align-items: center; gap: 4px;
}
.month-play svg { width: 13px; height: 13px; }

/* ------------------------------------------------------------- story mode */
.story { background: #000; color: #fff; z-index: 90; user-select: none; -webkit-user-select: none; touch-action: none; }
.st-bars { position: absolute; top: calc(var(--safe-t) + 8px); left: 8px; right: 8px; display: flex; gap: 3px; z-index: 3; }
.st-bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.3); overflow: hidden; }
.st-bars b { display: block; height: 100%; width: 0; background: #fff; }
.st-head { position: absolute; top: calc(var(--safe-t) + 18px); left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 6px 14px; z-index: 3; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.st-head b { display: block; font-size: 15px; }
.st-when { font-size: 12.5px; opacity: .85; }
.st-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.st-stage img, .st-stage video { max-width: 100%; max-height: 100%; object-fit: contain; grid-area: 1 / 1; }
.st-stage .layer { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.st-stage .mirror { transform: scaleX(-1); }
.st-missing { opacity: .8; padding: 30px; text-align: center; }

/* ------------------------------------------------------------- places (map) */
#places { background: var(--bg); color: var(--fg); z-index: 40; display: flex; flex-direction: column; }
.places-head { position: relative; }
.places-head .m-title { padding-bottom: 10px; }
.cbtn.ghost { visibility: hidden; }
.map-el { flex: 1; min-height: 0; background: var(--tile); }
.place-pin { display: grid !important; place-items: center; }
.place-pin span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent); color: #111; font-weight: 800; font-size: 12px;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.marker-cluster div { background: var(--accent) !important; color: #111; font-weight: 800; }
.marker-cluster { background: rgba(255,207,36,.35) !important; }

/* ------------------------------------------------------------- viewer */
#viewer { background: #000; z-index: 50; user-select: none; -webkit-user-select: none; touch-action: none; }
.v-stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; }
.v-stage img, .v-stage video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.v-stage .layer { pointer-events: none; }
.v-stage .mirror { transform: scaleX(-1); }
.v-top, .v-bottom { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 14px 16px; z-index: 3; transition: opacity .2s; }
.v-top { top: 0; padding-top: calc(var(--safe-t) + 14px); background: linear-gradient(rgba(0,0,0,.55), transparent); padding-bottom: 36px; }
.v-bottom { bottom: 0; padding-bottom: calc(var(--safe-b) + 16px); justify-content: center; flex-wrap: wrap; row-gap: 8px; background: linear-gradient(transparent, rgba(0,0,0,.55)); padding-top: 36px; }
.v-when { flex: 1; min-width: 0; }
.v-when b { display: block; font-size: 15.5px; font-weight: 800; }
.v-when span { font-size: 12.5px; opacity: .85; }
.v-when a { color: #fff; }
.v-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; padding: 11px; flex: none; }
.v-btn svg { width: 100%; height: 100%; }
.v-btn.on { color: var(--heart); background: #fff; }
.v-btn.pill { width: auto; border-radius: 22px; padding: 0 16px; font-weight: 700; font-size: 13.5px; }
.v-btn.toggled { background: #fff; color: #000; }
.v-nav { position: absolute; top: 0; bottom: 0; width: 24%; z-index: 2; }
.v-nav.prev { left: 0; } .v-nav.next { right: 0; }
.v-progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,.22); z-index: 4; margin-top: var(--safe-t); }
.v-progress i { display: block; height: 100%; width: 0; background: #fff; }
.viewer-idle .v-top, .viewer-idle .v-bottom { opacity: 0; }
.v-count { position: absolute; top: calc(var(--safe-t) + 6px); left: 0; right: 0; text-align: center; font-size: 11px; opacity: .55; z-index: 4; pointer-events: none; }
.v-need { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; text-align: center; padding: 24px; color: #ddd; }
.v-need p { margin: 0; }
.v-need .btn { max-width: 260px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------- onboarding */
#onboarding { background: radial-gradient(120% 80% at 50% 0%, #2a2410 0%, #0d0d0f 60%); z-index: 70; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.ob { width: 100%; max-width: 380px; color: #fff; }
.ob .logo { width: 72px; height: 72px; border-radius: 22px; background: var(--accent); display: grid; place-items: center; margin: 0 0 22px; }
.ob .logo svg { width: 40px; height: 40px; }
.ob h1 { font-size: 32px; line-height: 1.1; margin: 0 0 8px; letter-spacing: -.02em; }
.ob p { color: #b9b9c0; margin: 0 0 24px; font-size: 16px; }
.ob .field span { color: #b9b9c0; }
.ob .field input { background: #1a1a1e; border-color: #2a2a30; color: #fff; }
.ob .btn { margin-top: 8px; }
.ob .fine { font-size: 12.5px; color: #8b8b93; margin-top: 14px; }

/* ------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 16px); transform: translate(-50%, -12px); z-index: 100;
  background: rgba(20,20,22,.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- location filters & making your own ---------- */
.filter-chip.geo { background: rgba(255, 207, 36, .22); color: #fff; }
.filter-chip.geo[aria-pressed="true"] { background: var(--accent); color: #111; }
.filter-chip.make { background: rgba(255,255,255,.12); border: 1px dashed rgba(255,255,255,.6); }
.cf-layout { display: grid; grid-template-columns: 132px 1fr; gap: 14px; align-items: start; }
.cf-preview { width: 132px; height: auto; aspect-ratio: 9 / 16; border-radius: 14px; background: #333; box-shadow: 0 4px 18px rgba(0,0,0,.35); }
.cf-fields { min-width: 0; }
.cf-fields .btn.secondary { margin-bottom: 14px; }
.cf-styles { display: flex; flex-wrap: wrap; gap: 6px; }
.cf-styles .filter-chip { background: var(--tile); color: var(--fg); }
.cf-styles .filter-chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.cf-color input { width: 56px; height: 36px; padding: 0; border: 0; background: none; }
.cf-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); font-size: 14px; }
.cf-row small { color: var(--muted); }
.cf-del { border: 0; background: none; color: var(--heart-text); font-weight: 700; font-size: 13px; padding: 6px; }
@media (max-width: 380px) { .cf-layout { grid-template-columns: 1fr; } .cf-preview { width: 150px; justify-self: center; } }

/* ---------- AI helper: reading documents, the family historian, research ---------- */
.fam-big.ask { width: 100%; margin: 0 0 12px; background: linear-gradient(135deg, #6a5cff, #b84dff); color: #fff; }
.fam-big.ask .ico { font-size: 22px; }
.reading { padding: 0 14px 10px; display: flex; flex-direction: column; gap: 18px; }
.rd-page { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) { .rd-page { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.rd-page figure { margin: 0; }
.rd-page img { width: 100%; border-radius: 10px; display: block; background: #fff; }
.rd-page figcaption { font-size: 12px; opacity: .6; margin-top: 4px; text-align: center; }
.rd-text { background: #1b1b20; border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.5; }
.rd-text p { margin: 4px 0 10px; white-space: pre-wrap; }
.rd-orig { font-family: Georgia, "Times New Roman", serif; opacity: .85; }
.rd-label { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #ffcf24; cursor: pointer; }
.rd-summary { background: linear-gradient(135deg, rgba(106,92,255,.25), rgba(184,77,255,.18)); border-radius: 14px; padding: 12px 14px; }
.rd-summary p { margin: 6px 0; line-height: 1.45; }
.rd-facts { font-size: 13.5px; opacity: .9; }
.rd-action { display: flex; flex-direction: column; gap: 6px; }
.ai-view { background: #0d0d0f; color: #f4f4f6; z-index: 65; display: flex; flex-direction: column; }
.chat-thread { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 88%; border-radius: 16px; padding: 10px 13px; line-height: 1.45; font-size: 15px; }
.chat-msg p { margin: 0 0 6px; } .chat-msg p:last-child { margin: 0; }
.chat-msg.user { align-self: flex-end; background: #0eadff; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: #1d1d23; border-bottom-left-radius: 4px; }
.chat-msg.thinking::after { content: "…"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.chat-starters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 10px; }
.chat-starters .tab { background: #1d1d23; color: #fff; text-align: left; }
.chat-bar { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(var(--safe-b) + 10px); border-top: 1px solid #222227; background: #0d0d0f; }
.chat-bar textarea { flex: 1; resize: none; border-radius: 18px; border: 1px solid #2a2a31; background: #16161a; color: #fff; padding: 10px 14px; font: inherit; font-size: 15px; }
.chat-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #0eadff; color: #fff; display: grid; place-items: center; flex: none; }
.chat-send svg { width: 20px; height: 20px; }
.chat-send:disabled { opacity: .4; }
.chat-clear { border: 0; background: none; color: #9b9ba4; font-weight: 700; padding: 10px 4px; }
.rich h3 { font-size: 15px; margin: 12px 0 4px; }
.rich ul { margin: 4px 0 8px; padding-left: 20px; }
.rich li { margin: 3px 0; }
.rich a, .sources a { color: #6fc8ff; word-break: break-word; }
.research-body { padding: 4px 16px calc(var(--safe-b) + 30px); overflow-y: auto; flex: 1; }
.research-status { min-height: 1.4em; }
.research-report { line-height: 1.5; font-size: 15px; }
.research-past { background: #16161a; border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.research-past summary { cursor: pointer; font-weight: 700; }
.sources ol { padding-left: 20px; font-size: 13.5px; }

/* ---------- chat with your person (like Snapchat's, but nothing disappears) ---------- */
.talk-view { background: var(--bg); color: var(--fg); z-index: 48; display: flex; flex-direction: column; }
.talk-view .doc-top { background: var(--bg); color: var(--fg); border-bottom: 1px solid var(--line); }
.talk-view .v-btn { color: var(--fg); background: var(--chip); }
.talk-thread { flex: 1; overflow-y: auto; padding: 6px 16px 14px; }
.talk-day { text-align: center; color: var(--muted); font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 6px; }
.talk-msg { border-left: 3px solid #0eadff; padding: 1px 0 1px 10px; margin: 2px 0; }
.talk-msg.me { border-color: #f23c57; }
.talk-who { font-size: 11.5px; font-weight: 800; text-transform: uppercase; color: #0eadff; margin-top: 8px; }
.talk-msg.me .talk-who { color: #f23c57; }
.talk-time { color: var(--muted); font-weight: 600; margin-left: 6px; text-transform: none; }
.talk-text { white-space: pre-wrap; word-wrap: break-word; font-size: 15.5px; line-height: 1.4; }
.talk-memory { display: block; width: 120px; height: 200px; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: var(--tile); margin: 4px 0; }
.talk-memory img { width: 100%; height: 100%; object-fit: cover; display: block; }
.talk-memory.missing { background: repeating-linear-gradient(45deg, var(--tile), var(--tile) 8px, var(--chip) 8px, var(--chip) 16px); }
.talk-status { font-size: 12px; color: var(--muted); } .talk-status.bad { color: var(--heart-text); }
.talk-empty { color: var(--muted); text-align: center; margin: 40px 20px; }
.talk-more { display: block; margin: 8px auto; border: 0; background: var(--chip); color: var(--fg); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.talk-view .chat-bar { background: var(--bg); border-top: 1px solid var(--line); }
.talk-view .chat-bar textarea { background: var(--chip); color: var(--fg); border-color: var(--line); }
.talk-cam { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--chip); color: var(--fg); display: grid; place-items: center; flex: none; }
.talk-cam svg { width: 22px; height: 22px; }

.talk-banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 16px; background: rgba(255, 207, 36, .14); font-size: 14px; }
.talk-banner[hidden] { display: none; }
.talk-banner .tab { flex: none; }
.talk-source { margin: 20px auto 4px; width: max-content; padding: 4px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.talk-source.snapchat { background: #fffc00; color: #111; }
.talk-source.storybook { background: var(--accent); color: var(--accent-fg); }
.talk-memory.video { display: grid; place-items: center; background: #1b1b22; }
.talk-play { font-size: 34px; color: #fff; }
.talk-lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.92); display: grid; place-items: center; }
.talk-lightbox img, .talk-lightbox video { max-width: 100vw; max-height: 100vh; }
.cf-row.pick { width: 100%; border: 0; background: none; color: inherit; text-align: left; font: inherit; }
.ideas-btn { flex: none; align-self: center; }
.ideas-out { margin-top: 12px; line-height: 1.45; }
.ideas-out .rich h3 { font-size: 15px; }

/* ---------- pen & stickers on the preview ---------- */
#pvDraw.on { background: transparent; color: var(--accent); }
.pv-colors { position: absolute; right: 17px; top: calc(var(--safe-t) + 262px); z-index: 4; display: flex; flex-direction: column; gap: 8px; }
.pv-colors[hidden] { display: none; }
.pv-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pv-color.on { transform: scale(1.3); border-color: #fff; }
.pv-undo { position: absolute; left: 14px; top: calc(var(--safe-t) + 66px); z-index: 4; }
.pv-undo[hidden] { display: none; }
.pv-trash { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 110px); transform: translateX(-50%); z-index: 4; width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; transition: transform .12s, background .12s; }
.pv-trash[hidden] { display: none; }
.pv-trash svg { width: 26px; height: 26px; }
.pv-trash.hot { transform: translateX(-50%) scale(1.25); background: #ff3b30; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 4px; max-height: 50vh; overflow-y: auto; }
.emoji { font-size: 32px; border: 0; background: none; padding: 6px 0; border-radius: 12px; }
.emoji:active { background: var(--chip); }
#pvStage img, #pvStage video { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: none; }

/* ---------- "Finish setting up" ---------- */
.setup-card { margin: 12px 14px 4px; padding: 12px; border-radius: 18px; background: var(--chip); }
.setup-head { display: flex; align-items: baseline; gap: 8px; margin: 2px 4px 8px; }
.setup-head b { font-size: 16px; } .setup-head span { color: var(--muted); font-size: 13px; flex: 1; }
.setup-x { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 2px 6px; }
.setup-step { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: var(--bg); color: var(--fg); border-radius: 14px; padding: 10px 12px; margin-top: 6px; font: inherit; }
.setup-step:disabled { opacity: .6; }
.setup-step.done { opacity: .55; }
.setup-tick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 900; color: #fff; }
.setup-step.done .setup-tick { background: var(--ok); border-color: var(--ok); }
.setup-txt { display: flex; flex-direction: column; min-width: 0; } .setup-txt b { font-size: 14.5px; } .setup-txt span { font-size: 12.5px; color: var(--muted); }
.setup-help { padding-left: 20px; line-height: 1.5; } .setup-help li { margin: 6px 0; }

/* ---------- search ---------- */
.m-actions { display: flex; gap: 8px; }
.search-view { background: var(--bg); color: var(--fg); z-index: 45; overflow-y: auto; }
.search-top { position: sticky; top: 0; z-index: 2; display: flex; gap: 10px; align-items: center; padding: calc(var(--safe-t) + 10px) 14px 10px; background: var(--bg); }
.search-top input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--chip); color: var(--fg); font: inherit; font-size: 16px; }
.search-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 14px 10px; }
.search-chips[hidden] { display: none; }
.search-chips .tab { background: var(--chip); color: var(--fg); }
.search-status { padding: 2px 16px 8px; color: var(--muted); font-size: 13px; }
.search-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding-bottom: calc(var(--safe-b) + 30px); }
.search-grid .tile { position: relative; aspect-ratio: 9 / 16; border: 0; padding: 0; background: var(--tile); overflow: hidden; }
.search-grid .tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-date { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); }

/* ---------- lenses ---------- */
.lens-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; z-index: 1; }
.lens-canvas.mirror { transform: scaleX(-1); }

/* ---------- photo book ---------- */
.pb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.pb-grid .field { min-width: 0; }
.pb-summary { font-size: 14px; font-weight: 600; margin: 4px 0 14px; }
.pb-bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; margin: 0 0 12px; }
.pb-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.pb-previews { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scroll-snap-type: x mandatory; }
.pb-previews img { height: 150px; width: auto; flex: none; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.18); scroll-snap-align: start; background: #fff; }

/* ---------- time capsules ---------- */
.cap-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; }
.cap-icon { font-size: 26px; flex: none; }
.cap-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cap-text b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap-text small { color: var(--muted); font-size: 12.5px; }
.cap-go { background: var(--accent); color: var(--accent-fg); font-weight: 800; font-size: 13px; padding: 7px 14px; border-radius: 999px; }
.cap-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.cap-presets .filter-chip { background: var(--tile); color: var(--fg); }
.cap-presets .filter-chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.cap-letter-input { width: 100%; font: inherit; font-size: 15px; line-height: 1.5; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--chip); color: var(--fg); resize: vertical; }
.cap-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 4px; max-height: 220px; overflow-y: auto; border-radius: 10px; }
.cap-tile { position: relative; aspect-ratio: 3 / 4; border: 0; padding: 0; border-radius: 6px; overflow: hidden; background: var(--tile); }
.cap-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cap-tile.on { outline: 3px solid var(--accent); outline-offset: -3px; }
.cap-tile.on::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #111; font-size: 13px; font-weight: 800; display: grid; place-items: center; }
.cap-banner { display: flex; align-items: center; gap: 12px; width: calc(100% - 20px); margin: 10px; padding: 14px; border: 0; border-radius: 16px; text-align: left; font: inherit; color: #3a1d2b; background: linear-gradient(135deg, #ffe1ec, #ffd2a8); }
.cap-banner b { display: block; font-size: 15px; }
.cap-banner small { display: block; font-size: 12.5px; opacity: .8; }
.cap-center { text-align: center; }
.cap-title { text-align: center; font-family: Georgia, "Iowan Old Style", "Noto Serif", serif; font-size: 24px; }
.cap-opens { font-size: 17px; font-weight: 700; margin: 8px 0 18px; }
.cap-opens small { font-weight: 500; color: var(--muted); font-size: 14px; }
.cap-letter { white-space: pre-wrap; font-family: Georgia, "Iowan Old Style", "Noto Serif", serif; font-size: 17px; line-height: 1.6; background: #fbf7ee; color: #2b2620; padding: 20px 18px; border-radius: 6px; box-shadow: 0 2px 14px rgba(0,0,0,.12); margin: 6px 0 14px; }
.cap-photos { display: grid; gap: 8px; margin: 0 0 14px; }
.cap-photos img { width: 100%; border-radius: 10px; display: block; }
.cap-envelope { position: relative; width: 180px; height: 120px; margin: 10px auto 14px; background: #f3d9a4; border-radius: 6px; box-shadow: 0 6px 22px rgba(0,0,0,.18); perspective: 600px; }
.cap-envelope::before { content: ""; position: absolute; inset: 0; border-radius: 6px; background: linear-gradient(to top right, transparent 49.5%, #e9c98a 50%) left / 50% 100% no-repeat, linear-gradient(to top left, transparent 49.5%, #e9c98a 50%) right / 50% 100% no-repeat; }
.cap-flap { position: absolute; left: 0; right: 0; top: 0; height: 64px; background: #e2bd77; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; border-radius: 6px 6px 0 0; }
.cap-seal { position: absolute; left: 50%; top: 44px; width: 34px; height: 34px; margin-left: -17px; border-radius: 50%; background: #c8324f; color: #ffe6ec; display: grid; place-items: center; font-size: 16px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.cap-envelope.opening .cap-flap { animation: cap-flap 0.9s ease-in-out 0.2s forwards; }
.cap-envelope.opening .cap-seal { animation: cap-seal 0.4s ease-in 0.1s forwards; }
.cap-envelope.opening { animation: cap-away 0.6s ease-in 1.2s forwards; }
.cap-content.reveal { opacity: 0; animation: cap-in 0.7s ease-out 1.5s forwards; }
@keyframes cap-flap { to { transform: rotateX(180deg); } }
@keyframes cap-seal { to { transform: scale(0); opacity: 0; } }
@keyframes cap-away { to { height: 0; margin: 0 auto; opacity: 0; } }
@keyframes cap-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .cap-envelope.opening, .cap-envelope.opening .cap-flap, .cap-envelope.opening .cap-seal { animation: none; display: none; }
  .cap-content.reveal { animation: none; opacity: 1; }
}

.talk-status.opened { color: var(--send); font-weight: 700; }

a.btn { display: grid; place-items: center; text-decoration: none; }
a.btn + .btn { margin-top: 8px; }

/* ---------- baby books ---------- */
.cap-banner.baby { background: linear-gradient(135deg, #dff3ff, #e6ffe9); color: #183447; }
.baby-head { display: flex; align-items: center; gap: 8px; margin: 10px; padding: 14px; border-radius: 16px; background: var(--tile); }
.baby-head > div { flex: 1; min-width: 0; }
.baby-head b { display: block; font-size: 17px; }
.baby-head small { color: var(--muted); font-size: 13px; }
.ms-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.ms-pick .filter-chip { background: var(--tile); color: var(--fg); }
.ms-pick .filter-chip.on { background: var(--accent); color: var(--accent-fg); }
.ms-pick.todo .filter-chip { opacity: .55; }
.ms-list { display: grid; gap: 8px; margin: 6px 0 10px; }
.ms-row { display: flex; align-items: center; gap: 12px; padding: 6px; border: 0; border-radius: 14px; background: var(--tile); color: inherit; font: inherit; text-align: left; }
.ms-row img { width: 54px; height: 72px; object-fit: cover; border-radius: 10px; background: var(--chip); flex: none; }
.ms-row b { display: block; font-size: 15px; }
.ms-row small { color: var(--muted); font-size: 12.5px; }
#vMilestone.toggled { color: var(--accent); }

.cap-text small.cap-warn { color: var(--heart-text); }

.baby-shared { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.baby-share-row { display: flex; justify-content: flex-end; margin: -4px 10px 6px; }

/* ---------- private ---------- */
.sheet input.pin { width: 100%; height: 52px; font-size: 24px; letter-spacing: .4em; text-align: center; border-radius: 14px; border: 1px solid var(--line); background: var(--chip); color: var(--fg); margin: 0 0 10px; }
#vPrivate.toggled { color: var(--accent); }

/* hands-free recording: slide left onto the lock */
.rec-lock { position: absolute; left: calc(50% - 88px); top: 42px; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.35); border: 2px dashed rgba(255,255,255,.7); pointer-events: none; }
.rec-lock svg { width: 20px; height: 20px; }
.rec-lock.locked { background: #ff3b30; border: 2px solid #fff; }

/* self-timer */
#timerBtn { position: relative; }
#timerBtn .timer-n { position: absolute; right: 1px; bottom: 1px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: #111; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; padding: 0 3px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; color: #fff; font-size: 160px; font-weight: 800; text-shadow: 0 6px 30px rgba(0,0,0,.45); }
.countdown.tick { animation: count-pop .9s ease-out; }
@keyframes count-pop { from { transform: scale(1.4); opacity: 0; } 25% { opacity: 1; } to { transform: scale(1); opacity: .85; } }
@media (prefers-reduced-motion: reduce) { .countdown.tick { animation: none; } }

/* selfie video light: around the edges, under the controls */
.front-flash.on.ring { z-index: 1; background: transparent; box-shadow: inset 0 0 0 34px #fff6ea, inset 0 0 90px 70px rgba(255,246,234,.85); }

.talk-memory.locked { display: grid; place-items: center; color: var(--muted); }
.talk-memory.locked svg { width: 28px; height: 28px; }

/* ---------- Family History: its own look (warm paper, serif), the second half of the app ---------- */
:root {
  --fh-paper: #f6efe2; --fh-card: #fffaf1; --fh-ink: #2b2219; --fh-muted: #786752; --fh-line: #e5d8c3;
  --fh-accent: #966638; --fh-accent-fg: #fffaf1;
  --fh-serif: Georgia, "Iowan Old Style", "Noto Serif", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root { --fh-paper: #17130e; --fh-card: #221c15; --fh-ink: #f2e8d8; --fh-muted: #b5a48d; --fh-line: #3a3025; --fh-accent: #d9a86f; --fh-accent-fg: #17130e; }
}
#family.fh { background: var(--fh-paper); color: var(--fh-ink); }
.fh h1, .fh h2, .fh .fh-serif { font-family: var(--fh-serif); }
.fh-head { position: sticky; top: 0; z-index: 3; background: color-mix(in srgb, var(--fh-paper) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--fh-line); padding-top: var(--safe-t); }
.fh-title { display: flex; align-items: center; gap: 10px; padding: 10px 14px 6px; }
.fh-title h1 { flex: 1; margin: 0; font-size: 24px; font-weight: 600; line-height: 1.1; }
.fh-title h1 .sub { display: block; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 12.5px; font-weight: 500; color: var(--fh-muted); }
.fh-title .cbtn { color: var(--fh-ink); background: var(--fh-card); }
.fh-switch { border: 1px solid var(--fh-line); background: var(--fh-card); color: var(--fh-ink); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 700; }
.fh-tabs { padding: 4px 14px 10px; }
.fh .tab { background: var(--fh-card); color: var(--fh-ink); border: 1px solid var(--fh-line); }
.fh .tab[aria-pressed="true"] { background: var(--fh-ink); color: var(--fh-paper); border-color: var(--fh-ink); }
.fh-welcome { font-family: var(--fh-serif); font-size: 17px; line-height: 1.5; color: var(--fh-ink); margin: 14px 2px 16px; }
.fh .fam-big { background: var(--fh-accent); color: var(--fh-accent-fg); }
.fh .fam-big.alt, .fh .fam-big.ask { background: var(--fh-card); color: var(--fh-ink); border: 1px solid var(--fh-line); }
.fh .fam-big .ico span { font-size: 24px; }
.fh .doc-card, .fh .person-row { background: var(--fh-card); color: var(--fh-ink); border: 1px solid var(--fh-line); }
.fh .doc-txt span, .fh .hint, .fh .muted { color: var(--fh-muted); }
.fh .section-label { color: var(--fh-muted); }
.fh .btn.secondary { background: var(--fh-card); color: var(--fh-ink); border: 1px solid var(--fh-line); }
.fh .people-search { background: var(--fh-card); color: var(--fh-ink); border: 1px solid var(--fh-line); }
.fh .story-card .ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--fh-paper); color: var(--fh-accent); }
.fh .story-card .ico svg { width: 22px; height: 22px; }
.fh .empty h2 { font-weight: 600; }
#familyBtn svg { width: 24px; height: 24px; margin: 1px; }
.fam-actions .btn + .btn { margin-top: 0; }
.fh .btn:not(.secondary) { background: var(--fh-accent); color: var(--fh-accent-fg); }
