/* ============================================================
   Family Tree — house styles
   Warm, family-album feel. Light default, dark via [data-theme].
   No frameworks, no webfonts, everything same-origin.
   ============================================================ */

:root {
  --bg: #f7f2e9;
  --bg-tint: radial-gradient(1200px 600px at 50% -10%, #fdf8ee 0%, #f7f2e9 60%);
  --panel: #ffffff;
  --panel-2: #fdfaf3;
  --ink: #262119;
  --ink-soft: #6f675a;
  --line: #e5ddca;
  --brand: #2f5d3a;
  --brand-ink: #ffffff;
  --brand-soft: #e9efe3;
  --accent: #c96f4a;
  --gold: #e8b04b;
  --danger: #a03d2e;
  --danger-soft: #f6e4df;
  --shadow: 0 2px 14px rgba(74, 60, 34, 0.10);
  --shadow-lg: 0 -8px 40px rgba(74, 60, 34, 0.18);
  --radius: 16px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #16130e;
  --bg-tint: radial-gradient(1200px 600px at 50% -10%, #1d1913 0%, #16130e 60%);
  --panel: #221e17;
  --panel-2: #2a251c;
  --ink: #ede7da;
  --ink-soft: #a69c88;
  --line: #3a3428;
  --brand: #4e8a5e;
  --brand-ink: #ffffff;
  --brand-soft: #24301f;
  --accent: #d98a63;
  --gold: #d9a94f;
  --danger: #c65b48;
  --danger-soft: #3a2620;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 -8px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image: var(--bg-tint);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1, h2, h3, .serif {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

img { max-width: 100%; }

/* ---------- buttons, links, fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--brand);
  text-decoration: underline;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
}

.field { display: block; margin: 0 0 14px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field-input, .field-select, .field-textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
.field-textarea { min-height: 84px; resize: vertical; }
.field-hint { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.form-row { display: flex; gap: 10px; }
.form-row > .field { flex: 1; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  margin: 0 0 14px;
}

.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented label {
  flex: 1;
  min-width: 70px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 600;
  cursor: pointer;
}
.segmented input:checked + span {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.card-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- avatars & chips ---------- */

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  flex: none;
}
.avatar-sm { width: 30px; height: 30px; border-width: 1.5px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 96px; height: 96px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { background: var(--panel-2); }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.group-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 12px 0 4px;
}

.personrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.personrow:active, .personrow:hover { background: var(--panel-2); }
.personrow .personrow-name { font-weight: 650; }
.personrow .personrow-meta { font-size: 13px; color: var(--ink-soft); }

/* ---------- toasts ---------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
  max-width: 88vw;
}
.toast.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- landing ---------- */

.landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
  max-width: 430px;
  margin: 0 auto;
  padding: 32px 22px calc(24px + env(safe-area-inset-bottom));
}
.landing-hero { text-align: center; }
.landing-mark img { border-radius: 18px; box-shadow: var(--shadow); }
.landing-title { font-size: 34px; margin: 14px 0 6px; }
.landing-sub { color: var(--ink-soft); margin: 0 auto; max-width: 32ch; }
.landing-form .code-input {
  text-align: center;
  font-size: 22px;
  letter-spacing: 0.18em;
  font-weight: 700;
  text-transform: uppercase;
}
.landing-foot {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- onboarding wizard ---------- */

.wizard {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 460px;
  margin: 0 auto;
  padding: 26px 22px calc(24px + env(safe-area-inset-bottom));
}
.wizard-step { display: none; flex: 1; flex-direction: column; }
.wizard-step.active { display: flex; }
.wizard-title { font-size: 28px; margin: 8px 0 4px; }
.wizard-sub { color: var(--ink-soft); margin: 0 0 18px; }
.wizard-spacer { flex: 1; }
.wizard-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.wizard-hero { text-align: center; margin: 26px 0; }
.wizard-hero .avatar-xl { width: 120px; height: 120px; }

.bigsearch { position: relative; }
.bigsearch .field-input { font-size: 18px; }
.results-list {
  margin: 10px 0 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 46dvh;
  overflow-y: auto;
}
.results-list:empty { display: none; }

.selfie-stage { text-align: center; margin: 16px 0; }
.selfie-preview {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--panel);
  box-shadow: var(--shadow);
  background: var(--panel-2);
}

/* ---------- tree page ---------- */

.page-tree {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
}

.tree-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
/* Only the controls catch taps; the gaps between them belong to the canvas,
   so the tree can still be dragged from up here. */
.tree-topbar .tree-brand,
.tree-topbar .iconbtn,
.tree-topbar .backlink,
.tree-topbar .rootpick { pointer-events: auto; }
.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
/* Keeps the icons together on the right instead of letting space-between
   strand one of them in the middle of the row. */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.tree-brand {
  font-size: 19px;
  margin: 0;
  padding: 7px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  border: 1px solid var(--line);
  /* One line, always: "Meier Family" wrapping into two made the bar tall
     and pushed everything else off the screen. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.rootpick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.rootpick-caption {
  font-size: 13px;
  color: var(--ink-soft);
  flex: none;
}

/* The album's way back to the tree. Same pill as everything else up here, but
   it carries its label: this is the only exit from that page, and a lone tree
   emoji did not read as one to anybody being shown the app. */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.backlink:active { transform: scale(0.98); }

/* 46px: Apple's minimum tappable target is 44, and half this family is
   tapping with reading glasses on. */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pill {
  position: fixed;
  /* Clears whatever the topbar currently measures (see trackChrome). */
  top: calc(var(--topbar-h, 128px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 8px 8px 8px 16px;
  font-size: 13px;
  font-weight: 600;
  max-width: 94vw;
  white-space: nowrap;
}
.pill span { overflow: hidden; text-overflow: ellipsis; }
.pill .linklike { text-decoration: none; font-weight: 700; }

/* ---------- the tree canvas ----------
   Branch color runs bark -> tip so generation depth is readable without
   counting rows; both come off the brand green so the tree sits in the
   house palette in either theme. */
:root {
  --tree-branch: #4f7a55;
  --tree-tip: #8fb27c;
}
html[data-theme="dark"] {
  --tree-branch: #5d8763;
  --tree-tip: #aecba0;
}

.tree-stage { cursor: grab; overflow: hidden; }
.tree-svg { width: 100%; height: 100%; display: block; }

.tree-branch { fill: none; stroke-linecap: round; }
.tree-pairbar { stroke-width: 2; opacity: 0.55; }
.tree-disc { stroke: var(--bg); stroke-width: 2; }
.tree-person { cursor: pointer; }
.tree-person:focus-visible .tree-disc { stroke: var(--gold); stroke-width: 3; }
.tree-initials {
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  fill: var(--bg);
  pointer-events: none;
}
.tree-name {
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.tree-sub {
  font-size: 10px;
  text-anchor: middle;
  fill: var(--ink-soft);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
}
/* Sprig rows label sideways, like writing along a stalk. */
.tree-name-side { text-anchor: start; font-size: 14px; }
.tree-sub-inline {
  font-size: 10.5px;
  font-weight: 400;
  fill: var(--ink-soft);
}
.tree-empty {
  margin: 40vh auto 0;
  max-width: 300px;
  text-align: center;
  color: var(--ink-soft);
}
/* Fills its pill and stands 44px tall: this is the control people reach for
   most, and it used to be a 13px chip capped at 40vw. */
.tree-root-select {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 0 4px;
  min-height: 44px;
  flex: 1;
  min-width: 0;
}

/* ---------- bottom bar ---------- */

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
/* The two bottom actions match the search field's height instead of being
   38px chips wedged beside it. Bigger buttons squeeze the search box, so the
   row is allowed to wrap: on a narrow phone the field takes the top line and
   the buttons drop below it, rather than the placeholder being sliced off. */
.bottombar { flex-wrap: wrap; }
.bottombar .btn { min-height: 46px; font-size: 15px; padding: 8px 14px; }
.bottombar-search { position: relative; flex: 1 1 170px; min-width: 170px; }
/* On a small phone the three don't fit side by side. Give search the whole
   first line and let the two actions split the second evenly, instead of
   "Add" wrapping alone into a corner. */
@media (max-width: 380px) {
  .bottombar-search { flex: 1 1 100%; min-width: 0; }
  .bottombar .btn { flex: 1; }
}
.bottombar-search .field-input {
  min-height: 46px;
  border-radius: 999px;
  padding-left: 40px;
  background-image: none;
}
.bottombar-search::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  opacity: 0.6;
  pointer-events: none;
}
.bottombar .search-results {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
}

/* ---------- bottom sheets ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 14, 6, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.22, 1);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
/* --sheet-drag is how far a finger has pulled the sheet down; see sheets.js. */
.sheet.open { transform: translateY(var(--sheet-drag, 0px)); }
/* Under the finger there is no animation to run — the sheet is where the
   finger is. The transition comes back for the release, either way it goes. */
.sheet.dragging { transition: none; }
.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 10px auto 4px;
  flex: none;
  position: relative;
  cursor: grab;
  touch-action: none;
}
.sheet.dragging .sheet-handle { cursor: grabbing; }
/* The bar is 5px tall and people aim a thumb at it. Give it a target the size
   of the thumb without changing anything anyone can see. */
.sheet-handle::before {
  content: '';
  position: absolute;
  left: -60px;
  right: -60px;
  top: -14px;
  bottom: -14px;
}
.sheet-handle:focus-visible { outline: 2px solid var(--brand); outline-offset: 6px; }
.sheet-title { font-size: 21px; margin: 6px 22px 2px; }
/* A sheet you can see your way out of. The handle and the dimmed strip above
   both close, but neither looks like a control, and an opened photo leaves
   barely a strip of backdrop showing to tap. */
.sheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sheet-close:active { transform: scale(0.95); }
.sheet-body { padding: 10px 22px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.sheet-actions .btn { flex: 1; min-width: 130px; }

@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 105%); }
  .sheet.open { transform: translate(-50%, var(--sheet-drag, 0px)); }
}

/* ---------- profile sheet ---------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin: 8px 0 6px; }
/* The avatar is a button: it is the first thing anyone taps when they want to
   change a picture, and it used to be inert. */
.profile-photo {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.profile-photo:active { transform: scale(0.97); }
.profile-photo-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.profile-name { font-size: 24px; margin: 0; }
.profile-years { color: var(--ink-soft); font-weight: 600; margin: 2px 0 0; }
.profile-born { color: var(--ink-soft); font-size: 13px; margin: 2px 0 0; }
.anniversary-line { display: block; margin: -6px 0 12px 4px; font-size: 14px; text-align: left; }
.profile-bio { color: var(--ink-soft); margin: 8px 0 0; white-space: pre-line; }
.profile-flag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid currentColor;
  padding: 1px 8px;
  border-radius: 999px;
  margin-top: 6px;
}

.notice {
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  margin: 10px 0;
}

/* ---------- how-related ---------- */

.rel-term {
  font-size: 26px;
  text-align: center;
  margin: 10px 0 2px;
  color: var(--brand);
}
.rel-sentence { text-align: center; font-size: 17px; margin: 4px 0 16px; }
.rel-path {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  padding: 8px 2px 14px;
  -webkit-overflow-scrolling: touch;
}
.rel-hop {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 76px;
  text-align: center;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.rel-hop .rel-hop-name { font-size: 12px; font-weight: 650; line-height: 1.2; }
.rel-arrow { flex: none; color: var(--ink-soft); font-size: 18px; padding-bottom: 22px; }

/* ---------- admin ---------- */

.admin {
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 20px 60px;
  display: grid;
  gap: 18px;
}
.admin h1 { margin: 0; }
.code-display {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  display: inline-block;
}
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.table-scroll { overflow-x: auto; }

/* ---------- QR sheet (screen + print) ---------- */

.qr-sheet {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
}
.qr-sheet h1 { font-size: 40px; margin: 0 0 4px; }
.qr-sheet .qr-sub { font-size: 20px; color: var(--ink-soft); margin: 0 0 24px; }
.qr-img { width: 340px; max-width: 80vw; image-rendering: pixelated; }
.qr-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; margin: 10px 0 26px; word-break: break-all; }
.qr-steps { text-align: left; display: inline-block; font-size: 18px; line-height: 1.9; }
.qr-print-hint { margin-top: 30px; }

@media print {
  body { background: #fff !important; }
  .qr-sheet { max-width: none; }
  .qr-print-hint, .iconbtn, .toast-host { display: none !important; }
}

/* ---------- invite sheet (the QR you hold up at the table) ---------- */

.invite-lead { margin: 0 0 14px; color: var(--ink-soft); }
/* The white plate is not decoration: a scanner needs the quiet zone light,
   and in dark mode the sheet behind it is not. */
.invite-qr {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  justify-content: center;
}
.invite-qr img { width: 260px; max-width: 100%; image-rendering: pixelated; }
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px;
  letter-spacing: 0.08em;
  text-align: center;
  margin: 14px 0 2px;
}

/* ---------- the album ---------- */

.page-photos { padding-bottom: 90px; }
.album {
  max-width: 900px;
  margin: 0 auto;
  padding: calc(96px + env(safe-area-inset-top)) 14px 24px;
}
/* ---------- uploading ---------- */

/* Sits above the bottom bar for as long as the batch runs. A toast could not
   do this job: it takes itself away after a couple of seconds, and an upload
   on hall wifi is only getting started by then. */
.upload-panel {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 45;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  transform: translateY(14px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  /* A status display, never a control. If it ever outlived its upload it must
     not be able to swallow a tap meant for the button underneath. */
  pointer-events: none;
}
.upload-panel.open { opacity: 1; transform: translateY(0); }
.upload-label { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.upload-track {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.upload-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--brand);
  transition: width 0.18s linear;
}
@media (min-width: 640px) {
  .upload-panel { left: 50%; right: auto; width: 420px; margin-left: -210px; }
}

/* A photo that is still on its way up, drawn from the file on the phone. */
.album-tile-pending { position: relative; cursor: default; }
.album-tile-pending img { opacity: 0.45; filter: saturate(0.5); }
.album-tile-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--panel) 70%, transparent);
  border-top-color: var(--brand);
  animation: upload-spin 0.8s linear infinite;
}
/* No preview to show — a HEIC outside Safari. Still a tile, still waiting. */
.album-tile-blank { background: var(--panel-2); border: 1px solid var(--line); }
.album-tile-done img { opacity: 1; filter: none; }
.album-tile-done .album-tile-spinner { display: none; }
.album-tile-failed img { opacity: 0.3; filter: grayscale(1); }
.album-tile-failed .album-tile-spinner {
  animation: none;
  border-color: var(--danger);
  border-top-color: var(--danger);
}
@keyframes upload-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .album-tile-spinner { animation: none; }
  .upload-fill { transition: none; }
}

.album-claim {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 6px;
}
.album-claim .field-hint { margin: 0 0 10px; }
.album-day {
  font-size: 17px;
  margin: 22px 2px 10px;
  position: sticky;
  top: calc(64px + env(safe-area-inset-top));
  background: var(--bg);
  padding: 6px 0;
  z-index: 5;
}
/* Square tiles, three across on a phone and more as the screen allows —
   thumbnails are 400px, so they stay crisp at any of these sizes. */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}
.album-tile {
  position: relative;
  padding: 0;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-2);
  aspect-ratio: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.album-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-tile:active { transform: scale(0.98); }
.album-tile-tags {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(12, 10, 8, 0.66);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.album-count { flex: 1; font-size: 14px; color: var(--ink-soft); padding-left: 6px; }

.photo-frame {
  background: var(--panel-2);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.photo-frame img { max-height: 52dvh; width: auto; max-width: 100%; object-fit: contain; }
.photo-caption { margin: 0 0 4px; font-weight: 600; }
.photo-when { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }

/* Where this photo came from on the left, the way out on the right — above
   the picture, so both are on screen before anyone has scrolled anywhere. */
.photo-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
}
.photo-up {
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  /* A 46px-tall target on a 15px label: this is the control people reach for
     with a thumb while holding a phone one-handed. */
  min-height: 46px;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* A tagged name is two things: a way to that person, and — for whoever may
   remove it — a ✕. Splitting them means the ordinary tap navigates instead of
   asking whether you want to take your grandmother out of the picture. */
.chip-tag { padding: 0 6px 0 0; gap: 0; }
.chip-go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border: none;
  background: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: var(--panel-2);
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-remove:active { background: var(--line); }

/* ---------- history ---------- */

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.history-item:last-of-type { border-bottom: none; }
.history-what { margin: 0 0 3px; font-weight: 600; }
.history-who { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
/* Struck through rather than hidden: that it happened is part of the story,
   even once it has been put back. */
.history-undone .history-what { text-decoration: line-through; opacity: 0.6; }

/* ---------- map controls + the ☰ menu ---------- */

.zoom-cluster {
  position: fixed;
  right: 14px;
  /* Sits above the bottom bar, within thumb reach rather than up in the
     corner where a phone needs two hands. The height comes from JS because
     the bar wraps to two rows on a narrow phone, and a hardcoded offset put
     these buttons underneath it. */
  bottom: calc(var(--bottombar-h, 66px) + 16px);
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-cluster .iconbtn {
  font-size: 20px;
  box-shadow: var(--shadow);
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 10px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.menu-row:active { transform: scale(0.99); }
.menu-emoji { font-size: 24px; flex: none; width: 30px; text-align: center; }
.menu-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-label { font-size: 17px; font-weight: 700; }
.menu-sub { font-size: 13px; color: var(--ink-soft); }

/* Shown instead of reloading when someone is mid-way through typing. It sits
   at the top because the reason it is on screen at all is that a sheet or the
   cropper is open, and those own the bottom of the screen — a notice there
   would cover the very fields it is protecting. Above the cropper's layer
   too, or it would be invisible exactly when it is needed. */
.build-nudge {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--topbar-h, 12px) + 12px + env(safe-area-inset-top));
  z-index: 96;
  /* max-content, or the half-width containing block that left:50% creates
     wraps this into a three-line lump. */
  width: max-content;
  max-width: 92vw;
  padding: 12px 20px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

/* ---------- photo framing ---------- */

.cropper {
  position: fixed;
  inset: 0;
  z-index: 95;               /* above the sheets, which stop at 60 */
  background: rgba(12, 10, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cropper-panel {
  background: var(--panel);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  width: min(380px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
}
.cropper-title { font-size: 22px; margin: 0 0 4px; }
.cropper-hint { font-size: 14px; color: var(--ink-soft); margin: 0 0 14px; }
.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  background: var(--panel-2);
  cursor: grab;
  user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-layer { position: absolute; top: 0; left: 0; will-change: transform; }
.crop-img { display: block; max-width: none; pointer-events: none; }
/* The circle is the truth: avatars render round everywhere in this app, so
   framing against a square would quietly crop the ears off. */
.crop-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(12, 10, 8, 0.45);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
}
.crop-zoom { width: 100%; margin: 16px 0 2px; accent-color: var(--brand); }

/* ---------- misc ---------- */

.muted { color: var(--ink-soft); }
.center { text-align: center; }
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
