:root {
  color-scheme: light;
  --paper: #fffdf9;
  --paper-deep: #f4f0e8;
  --ink: #2d2926;
  --heading: #1e3a4f;
  --meta: #6f6962;
  --light-meta: #9c958e;
  --line: #ded7cd;
  --gold: #c9a96e;
  --gold-deep: #9e7c3d;
  --butterfly: #0066a1;
  --rose: #8b3a4a;
  --green: #48644b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100%;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}
img, video { max-width: 100%; }
button, input, select { font: inherit; }
button, select, input { border-radius: 6px; }
button {
  min-height: 46px;
  border: 0;
  padding: 0 20px;
  background: var(--heading);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: #16405c; }
button:disabled { opacity: 0.6; cursor: default; }
input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
a { color: inherit; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.gold-rule {
  width: 88px;
  height: 2px;
  margin: 20px auto;
  border: 0;
  background: var(--gold);
}
.gold-rule.short { width: 56px; margin: 14px auto; }
h1, h2, h3 {
  color: var(--heading);
  font-weight: 400;
  line-height: 1.12;
}
h1 {
  margin: 0;
  font-size: clamp(2.15rem, 7vw, 3.65rem);
}
h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.45rem);
}
h3 { margin: 0; font-size: 1.3rem; }
.subtitle {
  margin: 0;
  color: var(--meta);
  font-size: clamp(1.05rem, 3.6vw, 1.25rem);
  font-style: italic;
}
.section-note, .provenance {
  margin: 10px 0 0;
  color: var(--meta);
  font-style: italic;
}

/* App shell: top bar on mobile, left sidebar on desktop; one view at a time */
.app-body { min-height: 100svh; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.96);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--heading);
  text-decoration: none;
}
.brand-mark { width: 32px; height: auto; }
.brand-name {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand-name br { display: none; }
.sidebar-stat-line { display: block; }
.sidebar-stat-line + .sidebar-stat-line { margin-top: 2px; opacity: 0.85; }
.sidebar-stat {
  flex: 0 1 auto;
  margin: 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
}
.sidebar-stat .stat-sub { display: block; font-style: italic; font-weight: 500; font-size: 0.78rem; color: var(--meta); margin-bottom: 8px; }
.sidebar-stat .stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
.sidebar-stat .stat-row:first-child { border-top: 0; }
.sidebar-stat .stat-label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--meta); }
.sidebar-stat .stat-num { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; color: var(--heading); font-variant-numeric: tabular-nums; }
.primary-nav {
  display: flex;
  flex: 1;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}
.primary-nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.primary-nav a:hover { background: var(--paper-deep); color: var(--heading); }
.primary-nav a.active { background: var(--heading); color: #fff; }
.nav-icon { display: none; width: 22px; height: 22px; flex: none; }
.sidebar-logout { display: flex; }
.signout-button { display: inline-flex; align-items: center; gap: 8px; }
.icon-signout { width: 18px; height: 18px; flex: none; }
.sidebar-toggle {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--heading);
}
.ghost-button:hover { background: var(--paper-deep); }

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 0 20px 56px;
}

@media (min-width: 880px) {
  .layout {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    align-items: start;
  }
  .sidebar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    height: 100svh;
    gap: 16px;
    padding: 30px 20px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .brand { flex-direction: column; align-items: flex-start; gap: 12px; }
  .brand-mark { width: 44px; }
  .brand-name { font-size: 1.02rem; }
  .brand-name br { display: inline; }
  .primary-nav { flex-direction: column; flex: 0; justify-content: flex-start; gap: 4px; }
  .primary-nav a { min-height: 44px; padding: 0 14px; font-size: 0.92rem; }
  .sidebar-toggle {
    flex-basis: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
  }
}

/* iPad portrait (761–879) uses the SAME layout as phones: a fixed bottom tab bar,
   with the brand + Sign-out icon up top. Handled by the max-width:879 block below. */

.cover {
  padding: clamp(18px, 4vh, 38px) 0 8px;
  text-align: center;
}
.compact-cover {
  display: grid;
  gap: 16px;
  justify-items: center;
}
.cover-photo { width: min(100%, 340px); }
/* Logged-in home: no cover photo (already seen on login) — slim title only. */
.home-intro { padding: clamp(6px, 2vh, 18px) 0 4px; }
.home-intro .names { font-size: 1.25rem; }
.framed-photo {
  width: min(100%, 300px);
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 34px rgba(30, 58, 79, 0.12);
}
.framed-photo img {
  display: block;
  width: 100%;
  height: auto;
}
.cover-copy { text-align: center; }
.names {
  margin: 0;
  color: var(--heading);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
}
.occasion {
  margin: 4px 0 0;
  color: var(--light-meta);
  font-style: italic;
}
.stats-line {
  margin: 12px 0 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
}
.butterfly {
  display: inline-block;
  width: 42px;
  height: auto;
  margin-top: 24px;
  opacity: 0.92;
}

.section-head {
  max-width: 620px;
  margin: 0 auto 26px;
  text-align: center;
}
.section-head-left {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  text-align: left;
}
.section-head-left .gold-rule,
.section-head-left .gold-rule.short { margin-left: 0; }
section { scroll-margin-top: 82px; }
.dashboard, .view-section { padding-top: clamp(34px, 6vh, 58px); }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.summary-tile {
  display: grid;
  gap: 6px;
  min-height: 136px;
  align-content: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(30, 58, 79, 0.06);
}
.summary-tile span {
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.summary-tile strong {
  color: var(--heading);
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
  line-height: 1.1;
}
.summary-tile em {
  color: var(--meta);
  font-size: 0.95rem;
  font-style: italic;
}
.summary-tile:hover { border-color: var(--gold); }
/* ── On This Day: light header (no card) ──────────────────────────────────────────
   Left: arrows + date title. Right: "Year [All] · fwd (322)" cluster. */
.view-head.today-head { display: block; }      /* eyebrow stacks above the date/controls row */
.today-head-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;            /* controls vertically centred with the date + arrows */
  justify-content: space-between;
  gap: 10px 18px;
  margin-top: 6px;
}
.today-head-main { min-width: 0; }
.today-head .section-note { display: none; }   /* drop the "Letters and photos…" subtitle */
/* On This Day title: full month on desktop/iPad, 3-letter on phones. */
#todayTitle .md-short { display: none; }
@media (max-width: 600px) {
  #todayTitle .md-full { display: none; }
  #todayTitle .md-short { display: inline; }
}

/* Strip the bordered card off the date controls; lay them out inline, right-aligned. */
.date-tools.today-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 14px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.today-controls .ctl-hidden { display: none; }
.today-controls .ctl-year { display: flex; align-items: center; gap: 8px; }
.today-controls .ctl-year > span { display: none; }   /* dropdown reads "All years" — label is redundant */

/* The forwarded checkbox — a small CUSTOM box (native checkboxes can't be sized on iOS). */
.forward-bar .forward-check {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  letter-spacing: 0; text-transform: none;   /* beat .date-tools label (grid/uppercase) */
}
.forward-check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0;
  border: 1.5px solid var(--meta); border-radius: 4px; background: #fff;
  position: relative; cursor: pointer;
}
.forward-check input[type="checkbox"]:checked { background: var(--heading); border-color: var(--heading); }
.forward-check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.forward-check input[type="checkbox"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.fwd-text {
  display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap;
  font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  color: var(--meta); letter-spacing: 0; text-transform: none;
}
.forward-note { font-weight: 400; opacity: 0.7; }

/* In On This Day it sits in the right cluster after a "·". In All Letters, a small row. */
.today-controls #forwardBar { display: flex; align-items: center; }
.today-controls #forwardBar::before {
  content: "·"; color: var(--meta); opacity: 0.55; margin-right: 13px;
}
.filter-bar #forwardBar {
  grid-column: 1 / -1; margin-top: 2px; padding-top: 11px; border-top: 1px solid var(--line);
}
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background 0.15s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(30, 58, 79, 0.35);
  transition: transform 0.15s ease;
}
.switch-input:checked + .switch-track { background: var(--heading); }
.switch-input:checked + .switch-track::after { transform: translateX(20px); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }
.button-tile {
  width: 100%;
  min-height: 136px;
  background: #fff;
  color: inherit;
  text-align: left;
}
.button-tile:hover { background: #fff; }

/* Media: a card per letter with a photo thumbnail grid */
.media-card {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(30, 58, 79, 0.06);
  text-decoration: none;
}
.media-card:hover { border-color: var(--gold); }
.media-card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--heading);
}
.media-card-meta {
  margin: 6px 0 0;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--meta);
}
.media-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.media-thumb {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-deep);
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A lone photo spans the full width instead of half a grid. */
.media-thumb:only-child { grid-column: 1 / -1; aspect-ratio: 16 / 10; }

.view-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.day-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.day-stepper h2 { margin: 0; }
.day-step-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--gold-deep);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.day-step-btn svg { width: 20px; height: 20px; }
.day-step-btn:hover { background: var(--paper-deep); border-color: var(--gold); }
.day-step-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.date-tools, .filter-bar {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.date-tools label, .filter-bar label {
  display: grid;
  gap: 5px;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.filter-bar { margin-bottom: 22px; }
.wide-filter { min-width: 0; }

.year-groups, .archive-results { display: grid; gap: 26px; }
.year-group, .month-group {
  display: grid;
  gap: 14px;
}
.year-group > h3, .month-group > h3 {
  position: static;
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.95);
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.month-group > h3 span { color: var(--heading); }
.letter-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  /* Size each card to its own content; without this, a short card stretches to
     match a tall neighbour and warps its pills/buttons (circle, square). */
  align-items: start;
}
.letter-card {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(30, 58, 79, 0.07);
}
/* Long URLs / unbreakable tokens must wrap, not blow out the grid width. */
.letter-card h3, .letter-preview, .detail-body, .detail-card { overflow-wrap: anywhere; min-width: 0; }
.letter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  color: var(--light-meta);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.letter-meta span:first-child { color: var(--gold-deep); }
.letter-card h3 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
}
.letter-card h3 a { color: var(--heading); text-decoration: none; }
.letter-card h3 a:hover { text-decoration: underline; }

/* On This Day: a compact strip of a letter's photos as a preview. */
.thumb-strip { display: flex; flex-wrap: wrap; gap: 8px; text-decoration: none; }
.ot-thumb {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.ot-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ot-more { color: var(--meta); font-family: var(--sans); font-weight: 700; font-size: 0.95rem; }

/* The real photos/videos/audio shown inline when a card is expanded. */
.letter-media { margin-top: 4px; display: grid; gap: 12px; }
.letter-card.expanded .media-pills,
.letter-card.expanded .thumb-strip { display: none; }

/* On This Day reads as a single, comfortable column. */
#todayResults { max-width: 880px; }
#todayResults .letter-list { grid-template-columns: minmax(0, 1fr); }
.today-brief {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 240, 232, 0.58);
}
.today-brief-kicker {
  margin: 0 0 4px;
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.today-brief-main {
  margin: 0;
  color: var(--heading);
  font-family: var(--serif);
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  line-height: 1.25;
}
.today-brief-sub {
  margin: 5px 0 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.today-surprise {
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
}
.today-empty { margin-bottom: 18px; }

/* On This Day reflection — a short woven story of the day, drawn from the family's own
   letters and photo folders. Reads as a quiet lead before the year-by-year cards.
   Responsive across desktop / iPad / phone via a fluid measure + type. */
.today-reflection {
  margin: 0 0 24px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: rgba(244, 240, 232, 0.45);
}
.today-reflection[hidden] { display: none; }
.today-reflection.is-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--meta);
  font-family: var(--sans);
  font-style: italic;
}
.today-reflection-note { font-size: 0.92rem; }
.today-reflection-head { display: flex; justify-content: flex-end; margin: 0 0 8px; }
.today-reflection.is-collapsed .today-reflection-head { margin: 0; }
.today-reflection-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 0; cursor: pointer; padding: 2px 2px;
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--gold-deep);
}
.today-reflection-toggle:hover { color: var(--ink); }
.today-reflection-chev { width: 15px; height: 15px; transition: transform 0.2s ease; }
.today-reflection.is-collapsed .today-reflection-chev { transform: rotate(-90deg); }
.today-reflection.is-collapsed .today-reflection-body { display: none; }
.today-reflection-body {
  max-width: none;            /* fill the card's full width */
}
/* Two readable columns on wide screens so the full width is used without
   stretching prose into over-long lines; collapses to one column below. */
@media (min-width: 1000px) {
  .today-reflection-body {
    column-count: 2;
    column-gap: 40px;
  }
  .today-reflection-body p { break-inside: avoid; }
}
.today-reflection-body p {
  margin: 0 0 0.8em;
  font-family: var(--serif);
  font-size: clamp(1rem, 0.96rem + 0.25vw, 1.1rem);
  line-height: 1.72;
  color: var(--ink);
}
.today-reflection-body p:last-child { margin-bottom: 0; }
@media (max-width: 600px) {
  .today-reflection { padding: 16px; }
  .today-reflection-body { max-width: none; }
  .today-reflection-body p { line-height: 1.68; }
}
.today-nearby {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.today-nearby-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.today-nearby-head h3 {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.today-nearby-head p {
  margin: 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.86rem;
}
.today-nearby-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.today-nearby-card {
  width: auto;
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--heading);
  text-align: left;
}
.today-nearby-card span {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.15;
}
.today-nearby-card em {
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 600;
}
.today-nearby-card:hover { border-color: var(--gold); background: var(--paper-deep); }
.nas-day-media {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.section-kicker {
  margin-bottom: 6px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nas-day-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}
.nas-day-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3vw, 2rem);
  color: var(--heading);
}
.nas-day-head p {
  margin: 4px 0 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.92rem;
}
.nas-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}
.nas-media-tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  text-decoration: none;
}
.nas-media-tile::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(129, 115, 91, 0.22);
  border-top-color: var(--gold);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
.nas-media-tile.is-loaded::before { display: none; }
.nas-media-tile img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.nas-media-tile.is-loaded img {
  opacity: 1;
}
.nas-media-tile:hover img { transform: scale(1.025); }
.nas-play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(18, 22, 26, 0.72);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  padding-left: 3px;
}
.nas-media-tile.is-unstreamable img { filter: saturate(0.85); }
.nas-media-tile.is-unstreamable .nas-play {
  padding-left: 0;
  font-family: var(--sans);
  font-weight: 900;
}
.nas-video-note {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(18, 22, 26, 0.72);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
}
.nas-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.92rem;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
.nas-event {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.nas-event-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 0 0 10px;
}
.nas-event-title {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.nas-event-year { color: var(--meta); }
.nas-event-meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--meta);
}
.nas-inline-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 16px;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.nas-inline-loading.is-error { color: var(--gold-deep); }
.nas-more-button {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--heading);
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}
.nas-more-button span {
  display: block;
  margin-top: 2px;
  color: var(--meta);
  font-size: 0.78rem;
  font-weight: 600;
}
.nas-more-button:hover { border-color: var(--gold); }
@keyframes spin { to { transform: rotate(360deg); } }
.letter-preview p, .detail-body p {
  margin: 0 0 1em;
}
.letter-preview p:last-child, .detail-body p:last-child { margin-bottom: 0; }
.media-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.media-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--heading);
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 700;
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}
.text-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--heading);
}
.text-button:hover { background: var(--paper-deep); }
.open-button {
  border-color: var(--heading);
  background: var(--heading);
  color: var(--paper);
}
.open-button:hover { background: #16405c; }
.admin-curation {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-family: var(--sans);
}
.admin-mark {
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--meta);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}
.admin-mark.active {
  border-color: var(--gold);
  background: var(--paper-deep);
  color: var(--heading);
}
.admin-curation .admin-mark:hover { background: var(--paper); color: var(--meta); }
.admin-curation .admin-mark.active:hover { background: var(--paper-deep); color: var(--heading); }
.admin-curation.is-saving { opacity: 0.55; pointer-events: none; }
.admin-curation.is-error .admin-mark { border-color: #9b2f2f; }
/* Admin "Curate <-> Family view" toggle — sits in the forward bar, replaces the FWD
   checkbox while curating. */
.admin-mode-toggle {
  min-height: 28px;
  padding: 3px 11px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: var(--paper-deep);
  color: var(--heading);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* No hover/press visual: the global button:hover rule turns this navy and can stick. */
.admin-mode-toggle:hover,
.admin-mode-toggle:active,
.admin-mode-toggle:focus,
.admin-mode-toggle:focus-visible {
  border-color: var(--gold) !important;
  background: var(--paper-deep) !important;
  color: var(--heading) !important;
  box-shadow: none !important;
  outline: none !important;
}
.admin-mode-toggle[hidden] { display: none; }
/* Curate-view tags: letters that are off the family view, flagged so their state is obvious. */
.cur-tag {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.cur-tag-hidden { color: #9b2f2f; border-color: #d9adad; background: #fbf2f2; }
.cur-tag-fwd { color: var(--gold-deep); border-color: var(--gold); background: var(--paper-deep); }
.letter-card.cur-hidden h3 a { opacity: 0.7; }
.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--meta);
  background: #fff;
  text-align: center;
  font-style: italic;
}
.scroll-sentinel {
  width: 100%;
  height: 1px;
}

.detail-view {
  padding-top: 30px;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.inline-back-button {
  width: fit-content;
  margin: 0;
}
.detail-pager { display: flex; gap: 8px; flex: none; }
.pager-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--heading);
  font-size: 1.4rem;
  line-height: 1;
  text-decoration: none;
}
.pager-btn:hover { border-color: var(--gold); }
.pager-btn.is-disabled { color: var(--light-meta); opacity: 0.4; pointer-events: none; }
.detail-card {
  max-width: 880px;
  margin-inline: auto;
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(30, 58, 79, 0.08);
}
.detail-card h2 {
  margin: 14px 0 24px;
  font-size: clamp(1.85rem, 5vw, 2.8rem);
}
.detail-body {
  max-width: 76ch;
  font-size: clamp(1.06rem, 2vw, 1.18rem);
}
.detail-media {
  display: grid;
  gap: 14px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.detail-media h3 {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.video-block {
  margin: 0;
}
.video-block { text-align: center; }
.video-block video {
  display: inline-block;
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-deep);
}
.video-thumb {
  display: block;
  width: min(100%, 360px);
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.video-thumb img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.video-block figcaption, .media-note {
  margin: 8px 0 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.88rem;
}
.video-download {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.video-download img {
  display: block;
  width: min(100%, 420px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--heading);
  background: var(--heading);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}
.download-button:hover { background: #000; }
.audio-block {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.audio-block figcaption {
  margin: 0 0 10px;
  color: var(--heading);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.audio-block audio {
  width: 100%;
  min-height: 40px;
}
/* Media view: type filter chips + per-entry player blocks */
/* Media results is a focused single-column list (it carries inline players),
   so override the 2-column .letter-list grid it shares. */
#mediaResults { grid-template-columns: minmax(0, 1fr); }
.media-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  grid-column: 1 / -1;
  align-self: start;
}
.media-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}
.media-chip span { color: var(--light-meta); font-weight: 600; }
.media-chip:hover { border-color: var(--gold); }
.media-chip.active { background: var(--heading); color: #fff; border-color: var(--heading); }
.media-chip.active span { color: rgba(255, 255, 255, 0.72); }
/* Date-order toggle, pushed to the right of the filter chips. */
.media-order {
  margin-left: auto;
  width: auto;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--heading);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.media-order:hover { border-color: var(--gold); }
@media (max-width: 480px) { .media-order { margin-left: 0; } }
.media-entry {
  display: grid;
  gap: 12px;
  padding: clamp(18px, 4vw, 26px);
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.media-entry h3 { margin: 0; }
.media-entry .letter-link { color: var(--heading); text-decoration: none; }
.media-entry .letter-link:hover { text-decoration: underline; }
/* Uniform-height rows: every thumbnail is the same height and keeps its own
   aspect ratio (width varies), so mixed portrait/landscape photos line up in
   tidy rows with nothing cropped. Tap opens the full image. */
.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.photo-block {
  margin: 0;
  flex: 0 1 auto;
}
.photo-block a {
  display: block;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-deep);
  cursor: zoom-in;
}
.photo-block img {
  display: block;
  height: 168px;
  width: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}
@media (min-width: 620px) {
  .photo-block img { height: 200px; }
}
@media (max-width: 460px) {
  .photo-block img { height: 132px; }
}
.detail-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.detail-nav a:last-child { text-align: right; }
.detail-nav a {
  color: var(--heading);
  font-family: var(--sans);
  font-weight: 800;
  text-decoration: none;
}
.detail-nav a:hover { text-decoration: underline; }

.login-page {
  display: grid;
  min-height: 100svh;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  place-items: center;
}
.login-cover {
  width: min(100%, 560px);
  text-align: center;
}
.login-cover .framed-photo { width: min(78vw, 260px); }
.login-form {
  display: grid;
  gap: 14px;
  width: min(100%, 380px);
  margin: 26px auto 0;
  text-align: left;
}
.login-form label {
  display: grid;
  gap: 6px;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form-error {
  min-height: 1.3em;
  margin: 0;
  color: var(--rose);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}
.login-footnote {
  margin: 18px 0 0;
  color: var(--light-meta);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
}

.site-footer {
  margin-top: clamp(48px, 8vh, 76px);
  padding-top: 26px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.site-footer p {
  margin: 10px 0 0;
  color: var(--light-meta);
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.footer-butterfly { width: 34px; }

@media (min-width: 680px) {
  .date-tools { grid-template-columns: 1fr 0.8fr 1fr auto auto; align-items: end; }
  .filter-bar { grid-template-columns: minmax(200px, 1fr) 170px 110px 130px auto; align-items: end; }
}

@media (min-width: 900px) {
  .letter-list,
  .year-group .letter-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-card { margin: 0 auto; }
  /* The dashboard's six stats sit on one row. */
  #summaryTiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 879px) {
  body {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }
  /* On This Day header on phones: keep the date + Year/fwd controls on ONE row. */
  .today-head-row { gap: 8px; }
  .today-head-main { min-width: 0; }
  .today-head .day-stepper { gap: 5px; }
  .today-head .day-step-btn { width: 32px; height: 32px; }
  .today-head .day-step-btn svg { width: 15px; height: 15px; }
  .today-head h2 { font-size: 1.55rem; }
  .date-tools.today-controls { flex: 0 0 auto; flex-wrap: nowrap; margin: 0; gap: 9px; }
  .today-controls #forwardBar::before { content: none; }   /* drop the · on mobile */
  .today-brief {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }
  .today-surprise { width: 100%; }
  .today-nearby-head {
    display: grid;
    gap: 4px;
  }
  .today-nearby-list { grid-template-columns: 1fr; }
  .today-nearby-card { width: 100%; }
  /* The multi-line stat list belongs in the desktop sidebar; the compact mobile/iPad
     header (with the bottom tab bar) stays clean without it. */
  .sidebar-stat { display: none; }
  /* Top bar: solid (not sticky), subtle tan; brand + Sign-out icon on row 1,
     counter on row 2. */
  .sidebar { backdrop-filter: none; background: var(--paper-deep); position: static; }
  .brand { order: 1; min-width: 0; }
  .sidebar-logout { order: 2; margin-left: auto; }
  .sidebar-stat { order: 3; flex-basis: 100%; text-align: right; min-width: 0; }
  /* Sign out becomes an icon-only button in the header. */
  .signout-button { padding: 6px; min-height: 0; width: auto; border: 0; background: transparent; }
  .signout-button:hover { background: transparent; }
  .signout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .icon-signout { width: 23px; height: 23px; color: var(--heading); }

  /* Native tab bar: full-width, flush to the bottom edge, icon over label. */
  .primary-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    flex: 0;
    flex-wrap: nowrap;
    justify-content: space-around;
    gap: 0;
    padding: 8px 4px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--paper);
    box-shadow: 0 -2px 14px rgba(30, 58, 79, 0.07);
  }
  .primary-nav a {
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 0;
    padding: 2px;
    border-radius: 0;
    font-size: 0.66rem;
    font-weight: 600;
  }
  .primary-nav a:hover { background: transparent; }
  /* The six tabs share the row equally (min-width:0); full labels are too long, so
     swap each to its short form (data-short) on one line. Keeps every icon visible. */
  .primary-nav a { min-width: 0; }
  .primary-nav a span { white-space: nowrap; font-size: 0; line-height: 1.1; }
  .primary-nav a span::after { content: attr(data-short); font-size: 0.66rem; }
  .nav-icon { display: block; }
  .primary-nav a.active { background: transparent; color: var(--heading); }
  .primary-nav a.active .nav-icon { color: var(--gold-deep); }

  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .summary-tile { min-height: 0; padding: 14px; }
  .summary-tile strong { font-size: 1.4rem; }
  .summary-tile em { font-size: 0.82rem; }
  .year-group > h3, .month-group > h3 {
    top: 0;
  }
  /* Drop the decorative footer on phones — the tab bar owns the bottom edge. */
  .site-footer { display: none; }
  .detail-nav {
    grid-template-columns: 1fr;
  }
  .detail-nav a, .detail-nav a:last-child {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .app-shell { padding-inline: 14px; }
  .sidebar { padding-inline: 12px; }
  button { width: 100%; }
  #logoutForm button { width: auto; }
  /* More + Open letter share one row instead of stacking. */
  .card-actions { flex-wrap: nowrap; }
  .card-actions .text-button { flex: 1; width: auto; min-width: 0; }
}

/* On phones app.js drops the forwarded toggle here, at the bottom of the page,
   as a tidy card. Empty (so hidden) on desktop. */
.account-slot {
  margin-top: 24px;
}
.account-slot:empty { display: none; }
/* The forwarded toggle is hidden on non-letter views via the [hidden] attribute, but the
   display rules below (and the desktop .sidebar-toggle) would otherwise override it. Make
   [hidden] win everywhere — this is what actually hides it on iPad/iPhone. */
#forwardBar[hidden] { display: none !important; }
.account-slot .sidebar-toggle {
  display: block;
  flex-basis: auto;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-deep);
}

/* Compact filters on phones: the three dropdowns sit on one line; full-width
   fields/buttons span the row. Covers Archive filters + On This Day pickers. */
@media (max-width: 679px) {
  .filter-bar, .date-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
  }
  .filter-bar .wide-filter,
  .filter-bar #clearFilters,
  .date-tools button { grid-column: 1 / -1; }
  .filter-bar select, .date-tools select { padding-inline: 8px; }
}

/* --- Photo lightbox ----------------------------------------------------- */
body.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  background: rgba(24, 26, 30, 0.86);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.lightbox[hidden] { display: none; }
.lightbox-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 920px);
}
.lightbox-frame {
  position: relative;
  width: auto;
  max-width: 100%;
  min-width: 120px;
  min-height: 120px;
  margin: 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.lightbox-frame.is-photo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
}
.lightbox-frame.is-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  /* Visible on any backdrop: white arc + neutral-grey ring, with a soft dark halo
     so it still reads when the frame/image behind it is light. */
  border: 3px solid rgba(150, 150, 150, 0.4);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.55));
  animation: spin 0.8s linear infinite;
}
.lightbox-frame .lightbox-media {
  position: relative;
  z-index: 2;
  display: block;
  max-width: 100%;
  max-height: 78vh;
  height: auto;
  transition: opacity 0.18s ease;
}
.lightbox-frame.is-loading .lightbox-media { opacity: 0; }
/* Blur-up: thumbnail placeholder shows blurred, then sharpens when full-res swaps in. */
.lightbox-frame img.lightbox-media { transition: filter 0.35s ease, opacity 0.18s ease; }
.lightbox-frame img.lightbox-media.lb-blur { filter: blur(14px); }
.lightbox-frame.is-photo .lightbox-media {
  width: auto;
  height: auto;
  max-width: 896px;
  max-height: 736px;
  /* No object-fit: the JS sizes the element to the photo's true aspect (one dimension +
     auto), so the white frame hugs the image with just its static 12px padding — no letterbox. */
}
.lightbox-frame img.lightbox-media { width: auto; }
/* Year section headers inside a multi-source Special collection (e.g. Mt Binga
   2017 / 2020). Spans the full grid width so each year's photos sit under it. */
.nas-media-grid .special-year-head {
  grid-column: 1 / -1;
  margin: 18px 2px 2px;
  font-family: var(--serif, Georgia, serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading, #2a2a2a);
  border-bottom: 1px solid var(--line, #e2ddd4);
  padding-bottom: 6px;
}
.nas-media-grid .special-year-head:first-child { margin-top: 0; }
/* Browse-by-Year drill-down breadcrumbs */
.browse-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.browse-crumb {
  border: 0; background: none; padding: 2px 2px; cursor: pointer;
  font-family: var(--sans); font-size: 0.86rem; font-weight: 600; color: var(--gold, #b08d57);
}
.browse-crumb:hover { text-decoration: underline; }
.browse-crumb-sep { color: var(--meta); opacity: 0.6; }
.browse-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.browse-heading {
  font-family: var(--serif, Georgia, serif); font-size: 1.4rem; font-weight: 600;
  color: var(--heading, #2a2a2a); margin: 0;
}
.browse-folder-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.browse-nav-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--heading);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.browse-nav-button span {
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
}
.browse-nav-button:hover {
  border-color: var(--gold);
  background: var(--paper-deep);
}
.browse-folder-section {
  margin: 16px 0 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.browse-folder-section + .nas-media-grid {
  margin-top: 4px;
}
.special-grid.browse-folder-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-items: stretch;
}
.browse-folder-card {
  min-height: 236px;
}
.browse-folder-card .special-card-thumb {
  flex: 0 0 auto;
  aspect-ratio: 4 / 3;
  border-bottom: 1px solid var(--line);
}
.browse-folder-card .special-card-title {
  display: block;
  flex: 0 0 auto;
  padding: 11px 12px 3px;
  color: var(--heading);
  font-family: var(--serif, Georgia, serif);
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.browse-folder-card .special-card-meta {
  display: block;
  margin-top: auto;
  padding: 3px 12px 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .browse-crumbs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    margin: 0 0 12px;
    text-align: left;
  }
  .browse-crumb {
    flex: 0 0 auto;
    width: auto;
    padding: 2px 0;
  }
  .browse-crumb-sep { flex: 0 0 auto; }
  .browse-heading-row {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
  }
  .browse-heading { width: 100%; }
  .browse-folder-nav {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    margin: 4px 0 0;
  }
  .browse-nav-button {
    flex: 1 1 0;
    width: auto;
    min-height: 36px;
    justify-content: center;
    gap: 5px;
    padding: 5px 8px;
    font-size: 0.78rem;
  }
  .browse-folder-section {
    margin: 14px 0 22px;
    padding-bottom: 20px;
  }
  .special-grid.browse-folder-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .browse-folder-card {
    min-height: 198px;
  }
  .browse-folder-card .special-card-title {
    padding: 9px 9px 2px;
    font-size: 0.9rem;
    line-height: 1.22;
  }
  .browse-folder-card .special-card-meta {
    padding: 3px 9px 10px;
    font-size: 0.76rem;
  }
}
/* Interactive family-tree pedigree diagram */
.ped-hint { font-size: 0.85rem; color: var(--meta); margin: 0 0 10px; }
.ped-viewport {
  position: relative; overflow: hidden;
  height: min(72vh, 720px); width: 100%;
  border: 1px solid var(--line, #e2ddd4); border-radius: 12px;
  background: var(--bg-tint, #faf8f3);
  background-image: radial-gradient(rgba(129,115,91,0.10) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab; touch-action: none; user-select: none;
}
.ped-viewport.dragging { cursor: grabbing; }
.ped-canvas { position: absolute; top: 0; left: 0; transform-origin: top left; will-change: transform; }
.ped-links { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.ped-link { fill: none; stroke: var(--gold, #b08d57); stroke-width: 1.6; opacity: 0.55; }
.ped-node {
  position: absolute; display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; text-align: left; cursor: pointer;
  background: var(--card, #fff); border: 1px solid var(--line, #d9d2c4);
  border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.ped-node:hover { border-color: var(--gold, #b08d57); box-shadow: 0 4px 12px rgba(0,0,0,0.14); z-index: 5; }
.ped-node-thumb {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px; overflow: hidden;
  background: var(--line, #e7e1d6); display: block;
}
.ped-node-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ped-node-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ped-node-name {
  font-family: var(--serif, Georgia, serif); font-size: 0.84rem; font-weight: 600;
  color: var(--heading, #2a2a2a); line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ped-node-meta { font-family: var(--sans); font-size: 0.7rem; color: var(--meta); }
.ped-zoom-controls { position: absolute; top: 10px; right: 10px; z-index: 6; display: flex; gap: 4px; }
.ped-zoom-controls button {
  width: 32px; height: 32px; border: 1px solid var(--line, #d9d2c4); border-radius: 8px;
  background: rgba(255,255,255,0.92); color: var(--heading, #2a2a2a);
  font-size: 1.1rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ped-zoom-controls button:hover { border-color: var(--gold, #b08d57); }
.ped-extras { margin-top: 28px; }
.ped-extra-group { margin-bottom: 18px; }
/* Family Tree generation section headings */
.family-section-head {
  font-family: var(--serif, Georgia, serif);
  font-size: 1.2rem; font-weight: 600; color: var(--heading, #2a2a2a);
  border-bottom: 1px solid var(--line, #e2ddd4);
  padding-bottom: 6px; margin: 28px 2px 14px;
}
.family-section-head:first-child { margin-top: 0; }
/* Cassettes & LPs audio list — collapsible categories */
/* Cassettes & LPs: category cards are launchers in a grid; tapping drills into a full-width
   panel for that category (filterable + paginated), instead of expanding in place. */
.audio-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.audio-cat-card { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; cursor: pointer; font: inherit; color: inherit; }
.audio-cat-card:hover { border-color: var(--gold); }
.audio-cat-name { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; flex: 1; }
.audio-cat-count { color: var(--meta); font-size: 0.82rem; white-space: nowrap; }
.audio-cat-go { color: var(--gold-deep); font-weight: 700; }
.audio-panel-head { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 2px; flex-wrap: wrap; }
.audio-panel-head h3 { font-family: var(--serif); font-size: 1.6rem; margin: 0; }
.audio-panel-count { color: var(--meta); font-size: 0.9rem; }
.audio-filter { width: 100%; max-width: 540px; margin: 12px 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--paper); }
.audio-track-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) { .audio-track-list { grid-template-columns: 1fr 1fr; gap: 12px; } }
.audio-track { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.audio-track-head { display: flex; flex-direction: column; margin-bottom: 7px; }
.audio-track-title { font-family: var(--serif); font-weight: 600; line-height: 1.3; }
.audio-track-folder { color: var(--meta); font-size: 0.78rem; margin-top: 1px; }
.audio-track audio { width: 100%; height: 36px; }
.audio-group[open] { padding-bottom: 6px; }
.audio-group-title {
  display: flex; align-items: baseline; gap: 10px;
  cursor: pointer; user-select: none; list-style: none;
  font-family: var(--serif, Georgia, serif);
  font-size: 1.1rem; font-weight: 600; color: var(--heading, #2a2a2a);
  padding: 12px 14px; background: var(--card, #fff);
}
.audio-group-title::-webkit-details-marker { display: none; }
.audio-group-title::before {
  content: "▸"; display: inline-block; color: var(--gold, #b08d57);
  transition: transform 0.15s ease; font-size: 0.9em;
}
.audio-group[open] > .audio-group-title::before { transform: rotate(90deg); }
.audio-group .audio-list { padding: 4px 14px 8px; }
.audio-group-count { font-family: var(--sans); font-size: 0.8rem; font-weight: 600; color: var(--meta); }
.audio-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.audio-item {
  display: grid; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--line, #e2ddd4); border-radius: 10px;
  background: var(--card, #fff);
}
.audio-item-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.audio-item-title { font-weight: 600; color: var(--heading, #2a2a2a); }
.audio-item-folder { font-size: 0.78rem; color: var(--meta); }
.audio-item audio { width: 100%; height: 36px; }
/* Accurate video loading indicator: shows "Preparing…" while the NAS spins up the
   transcode (nothing buffered yet), then a real "Loading NN%" (buffered ÷ known
   total duration) as segments arrive, and hides the moment playback starts. It's
   an additive overlay with pointer-events:none so it never intercepts the video
   controls or interferes with decoding. */
.lightbox-frame .video-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: opacity 0.25s ease;
}
.lightbox-frame .video-loading.is-hidden { opacity: 0; }
/* Let the video size to its own aspect ratio (portrait or landscape) within the
   max bounds, so the frame wraps it snugly with no side padding. */
.lightbox-frame video.lightbox-media { width: auto; max-width: min(86vw, 760px); background: #000; }
.lightbox-download {
  display: grid;
  justify-items: center;
  gap: 14px;
  max-width: min(86vw, 760px);
  color: var(--heading);
  font-family: var(--sans);
}
.lightbox-download img {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  border-radius: 6px;
}
.lightbox-count {
  margin: 0;
  min-width: 66px;
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}
.lightbox-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.lightbox-map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.62);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.lightbox-map svg { width: 19px; height: 19px; display: block; }
.lightbox-map:hover,
.lightbox-map:focus-visible {
  outline: none;
  background: rgba(28, 28, 30, 0.8);
}
.lightbox-map:active { transform: scale(0.94); }
.lightbox-map[hidden] { display: none; }
/* Pin prev/next to the viewport edges (not the photo) so no image size can shift
   them — they stay put while you page through. */
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 110;
}
/* Sit just outside the widest a photo/video can be (image max-width is
   min(92vw, 920px), so half is min(46vw, 460px)); clamped so they stay
   on-screen on phones. Fixed position => they never move between images. */
.lightbox-nav.lb-prev { right: min(calc(50% + min(46vw, 460px) + 14px), calc(100% - 52px)); left: auto; }
.lightbox-nav.lb-next { left: min(calc(50% + min(46vw, 460px) + 14px), calc(100% - 52px)); right: auto; }
/* Bare overlay icons — no circle, no fill, no shadow. Just the glyph. */
.lightbox-close,
.lightbox-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.lightbox-close svg,
.lightbox-nav svg { width: 20px; height: 20px; display: block; }
.lightbox-close:hover,
.lightbox-nav:hover { opacity: 0.7; }
.lightbox-close:active { transform: scale(0.9); }
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible { outline: none; opacity: 0.7; }
.lightbox-nav {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: rgba(18, 22, 26, 0.18);
}
.lightbox-nav svg { width: 28px; height: 28px; }
.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  background: rgba(18, 22, 26, 0.34);
}
/* The stage is focused on open (tabindex -1) for Escape/screen-readers — no blue ring. */
.lightbox-stage:focus, .lightbox:focus { outline: none; }
/* X sits on the image itself (top-right of the frame). */
/* Elegant ✕: a small frosted circle straddling the top-right corner of the frame. */
.lightbox-close {
  position: absolute;
  top: -16px;
  right: -16px;
  z-index: 7;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.6);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.lightbox-close svg { width: 15px; height: 15px; }

/* Bigger prev/next arrows for touch devices (iPad/iPhone) in the lightbox. */
@media (pointer: coarse) {
  .lightbox .lightbox-nav { width: 68px; height: 68px; }
}
.lightbox-nav[hidden] { display: none; }
@media (max-width: 600px) {
  .lightbox { padding: 12px; gap: 4px; }
  .lightbox-frame { padding: 8px; }
  .lightbox-frame img { max-height: 70vh; }
  .lightbox-close { width: 36px; height: 36px; }
  /* On phones the archive counter wraps to two cramped rows — drop it; the brand
     and tab bar are enough. (iPad portrait keeps it: it fits on one line there.) */
  .sidebar-stat { display: none; }
}

/* ---- Special Collections (undated folders) ---- */
.special-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.special-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-deep);
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  color: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.special-card:hover {
  border-color: var(--gold);
  box-shadow: 0 6px 18px rgba(33, 27, 18, 0.12);
  transform: translateY(-2px);
  /* These cards are <button>s — stop the global button:hover navy fill from washing
     out the title/meta. Keep the card's own light background on hover. */
  background: var(--paper-deep);
  color: inherit;
}
.special-card-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--paper-deep);
  overflow: hidden;
}
.special-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Mix Books: each cover is a tight-cropped book with its own baked drop shadow, so
   show the whole book (no cropping), centred on the paper, all the same box size. */
.mixbook-card .special-card-thumb {
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px 6px;
}
.mixbook-card .special-card-thumb img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
/* The whole card is a link, so kill the default underlines: the title reads as a clean
   heading, and "Open the book" becomes a quiet gold prompt that only underlines on hover. */
.mixbook-card { text-decoration: none; color: inherit; }
.mixbook-card .special-card-title {
  text-decoration: none;
  color: var(--ink);
}
.mixbook-card .special-card-meta {
  text-decoration: none;
  color: var(--gold-deep);
  font-weight: 600;
  padding-top: 3px;
}
.mixbook-card:hover .special-card-title { color: var(--gold-deep); }
.mixbook-card:hover .special-card-meta { text-decoration: underline; }
.special-card-title {
  padding: 10px 12px 2px;
  font-weight: 600;
  line-height: 1.3;
}
.special-card-meta {
  padding: 0 12px 12px;
  font-size: 0.82rem;
  color: var(--ink-soft, #6c6453);
}
/* Mum's Books = a Recipe Book group above the Mix Books grid. Each group has its
   own heading; the recipe card shows the portrait front-cover filling the thumb. */
.book-group + .book-group { margin-top: 30px; }
.book-group-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 230px));
  gap: 16px;
}
/* Caption sits on clean near-white with a hairline divider, so the text panel reads
   as its own band instead of blending into the cream cover above it. */
.recipe-card { text-decoration: none; color: inherit; background: var(--paper); }
.recipe-card:hover { background: var(--paper); }
.recipe-card .special-card-thumb { aspect-ratio: 3 / 4; background: var(--paper); border-bottom: 1px solid var(--line); }
.recipe-card .special-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-card .special-card-title { text-decoration: none; color: var(--ink); }
.recipe-card:hover .special-card-title { color: var(--gold-deep); }
.recipe-card-meta { padding-bottom: 2px; }
.recipe-card-cta { color: var(--gold-deep); font-weight: 600; padding-top: 0; }
.recipe-card:hover .recipe-card-cta { text-decoration: underline; }
.special-collection-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
  margin-bottom: 16px;
}
.special-collection-head h3 { margin: 0; }
.special-collection-head .section-note { width: 100%; margin: 0; }

/* Loading placeholder over a lightbox video: the poster image + a spinner (so
   Safari doesn't show a bare black box while it buffers). Hidden once playing. */
.lightbox-frame { position: relative; }
.lightbox-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #000;
}
.lightbox-loading.is-on { display: flex; }
.lightbox-loading img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.5;
}
.lightbox-loading .spinner {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 46px;
  border-width: 4px;
}

/* Family Tree card context (the branch breadcrumb under the title) */
.special-card-context {
  padding: 0 12px 2px;
  font-size: 0.72rem;
  color: var(--ink-soft, #8a8270);
  line-height: 1.25;
}

/* ---- Family Tree: curated descendant view (Mum & Dad at the centre) ------- */
.famtree { margin: 0 0 8px; }
.famtree-ancestors-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px; margin-bottom: 24px;
  border: 1px dashed var(--line); border-radius: 8px; background: var(--paper-deep);
}
.famtree-up-label {
  font-family: var(--sans); font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--gold-deep);
}
.famtree-up-text { font-family: var(--sans); font-size: 0.82rem; color: var(--meta); }

.famtree-gen-label {
  margin: 0 0 12px; text-align: center;
  font-family: var(--sans); font-size: 0.64rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--light-meta);
}

.famtree-couple { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; }
.famtree-amp { font-family: var(--serif); font-size: 1.3rem; color: var(--light-meta); }
.famtree-person {
  width: 168px; padding: 12px; text-align: center;
  border: 1px solid var(--gold); border-radius: 8px; background: #fff;
  box-shadow: 0 8px 20px rgba(30, 58, 79, 0.06);
}
.famtree-avatar {
  height: 56px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--paper-deep);
  font-family: var(--serif); font-size: 1.25rem; color: var(--heading);
}
.famtree-name { font-family: var(--serif); color: var(--heading); }
.famtree-anchor .famtree-name { font-size: 1.05rem; margin-top: 8px; }
.famtree-dates { font-family: var(--sans); font-size: 0.72rem; font-weight: 700; color: var(--gold-deep); }

.famtree-trunk { width: 1px; height: 22px; margin: 8px auto 16px; background: var(--line); }

.famtree-groups { display: grid; gap: 12px; }
.famtree-group {
  display: grid; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  box-shadow: 0 8px 20px rgba(30, 58, 79, 0.05);
}
.famtree-parent .famtree-name { font-size: 1.15rem; }
.famtree-parent .famtree-dates { margin-top: 3px; }
.famtree-spouse {
  margin-left: 6px; font-family: var(--serif); font-style: italic;
  font-weight: 400; font-size: 0.9rem; color: var(--meta); letter-spacing: 0;
}

.famtree-kids { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.famtree-kid {
  min-width: 124px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--paper);
}
.famtree-kid-name { font-family: var(--serif); font-size: 0.98rem; color: var(--heading); }
.famtree-kid-sub { font-family: var(--sans); font-size: 0.66rem; color: var(--light-meta); }
.famtree-nokids {
  align-self: center; font-family: var(--sans); font-size: 0.82rem;
  font-style: italic; color: var(--light-meta);
}

.famtree-kid.has-great { border-color: var(--gold); }
.famtree-great {
  margin-top: 8px; padding: 6px 9px;
  border: 1px solid var(--gold); border-radius: 7px; background: #fff;
}
/* Match the sibling cards' name size so the newest great-grandchild is gently
   highlighted (gold border + badge), not oversized. */
.famtree-great .famtree-name { font-size: 0.9rem; }
.famtree-great .famtree-dates { font-size: 0.66rem; }
.famtree-great .famtree-badge { font-size: 0.5rem; }
.famtree-badge {
  display: block; margin-bottom: 2px;
  font-family: var(--sans); font-size: 0.55rem; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-deep);
}
.famtree-parents { margin-top: 3px; font-family: var(--sans); font-size: 0.62rem; font-style: italic; color: var(--light-meta); }

.famtree-note {
  margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  text-align: center; font-style: italic; color: var(--meta);
}
.famtree-unavailable {
  margin: 18px 0 0; text-align: center; font-style: italic;
  font-family: var(--sans); font-size: 0.86rem; color: var(--light-meta);
}
.famtree-heading {
  margin: 42px 0 6px; font-family: var(--serif); font-weight: 400;
  color: var(--heading); font-size: 1.3rem;
}

@media (min-width: 680px) {
  .famtree-group { grid-template-columns: 196px 1fr; align-items: start; }
  .famtree-parent { padding-right: 16px; border-right: 1px solid var(--line); }
}

/* ---- Family tree: phone + tablet refinements ----------------------------- */
/* Couple cards scale with the viewport so Mum & Dad stay side by side down to
   small phones before wrapping. */
.famtree-person { width: min(168px, 41vw); }
.famtree-couple { gap: 10px; }

/* iPad / tablet: two-column family groups already kick in at 680px; give the
   parent column a touch more room and let grandkids breathe. */
@media (min-width: 680px) {
  .famtree-kid { min-width: 132px; }
}

/* Small phones: tighten padding, let grandkids fill the row evenly, and keep
   the great-grandchild card readable. */
@media (max-width: 520px) {
  .famtree-group { padding: 13px 13px; }
  .famtree-kids { gap: 7px; }
  .famtree-kid { flex: 1 1 132px; min-width: 0; }
  .famtree-great { padding: 9px 10px; }
  .famtree-ancestors-strip { padding: 9px 12px; }
  .famtree-heading { margin-top: 34px; font-size: 1.2rem; }
}

/* Very small phones (iPhone SE width): shrink the couple cards a little more so
   they never force a horizontal scroll. */
@media (max-width: 360px) {
  .famtree-person { width: min(168px, 44vw); padding: 10px; }
  .famtree-avatar { height: 48px; font-size: 1.1rem; }
}

/* ---- Family tree: tappable people, ancestor cards, person page ----------- */
.famtree-tappable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
.famtree-tappable:hover { border-color: var(--gold); box-shadow: 0 8px 20px rgba(201, 169, 110, 0.25); }
.famtree-tappable:active { transform: scale(0.99); }
.famtree-tappable:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.famtree-ancestors { display: grid; gap: 18px; }
.famtree-anc-group .famtree-gen-label { text-align: left; margin-bottom: 10px; }
.famtree-anc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.famtree-anc-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px; row-gap: 1px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
/* Avatar spans both rows on the left; name on top, dates UNDERNEATH it (never collide). */
.famtree-anc-card .famtree-avatar { grid-row: 1 / 3; }
.famtree-anc-card .famtree-name { grid-column: 2; grid-row: 1; min-width: 0; font-size: 0.98rem; line-height: 1.15; }
.famtree-anc-card .famtree-dates { grid-column: 2; grid-row: 2; font-size: 0.68rem; }
.famtree-avatar.small {
  width: 38px; height: 38px; flex: 0 0 38px;
  font-size: 0.95rem; border-radius: 50%;
}

/* Life-story PDFs surfaced at the top of the Family Tree */
.lifestories { margin: 0 0 28px; }
.lifestories-note { margin: 4px 0 14px; color: var(--meta); font-style: italic; }
.lifestories-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.lifestory-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 9px;
  background: var(--paper-deep); text-decoration: none; color: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.lifestory-card:hover { border-color: var(--gold); box-shadow: 0 6px 18px rgba(33, 27, 18, 0.12); transform: translateY(-2px); }
.lifestory-icon { font-size: 1.5rem; flex: none; }
.lifestory-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lifestory-title { font-family: var(--serif); font-size: 1.05rem; color: var(--heading); line-height: 1.2; }
.lifestory-who { font-family: var(--sans); font-size: 0.78rem; color: var(--meta); margin-top: 2px; }
.lifestory-cta { font-family: var(--sans); font-size: 0.8rem; font-weight: 700; color: var(--gold-deep); flex: none; white-space: nowrap; }

/* Person page */
.person-page { width: 100%; max-width: none; }
.person-page > .ghost-button { margin-bottom: 20px; }
.person-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.person-avatar {
  width: 64px; height: 64px; flex: 0 0 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--gold);
  background: var(--paper-deep);
  font-family: var(--serif); font-size: 1.5rem; color: var(--heading);
}
.person-name { margin: 0; font-family: var(--serif); font-weight: 400; color: var(--heading); font-size: clamp(1.5rem, 4vw, 2rem); }
.person-meta { margin: 4px 0 0; font-family: var(--sans); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; color: var(--gold-deep); }
.person-bio p { margin: 0 0 1.1em; font-size: 1.06rem; line-height: 1.7; }
.person-bio p:last-child { margin-bottom: 0; }
.person-sources {
  margin: 22px 0 0;
  font-family: var(--sans); font-size: 0.82rem; font-style: italic; color: var(--meta);
}
.famtree-kid-note { margin-top: 4px; font-family: var(--sans); font-size: 0.66rem; font-style: italic; color: var(--meta); }

/* --- Ancestors: married-couple boxes, Dad's side (blue) vs Mum's side (gold) --- */
.ftc-legend { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 0.85rem; color: var(--meta); margin: 2px 0 16px; }
.ftc-legend em { color: var(--meta); }
.ftc-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.ftc-dot.dad { background: #3a6094; }
.ftc-dot.mum { background: var(--gold-deep); }
.ftc-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 640px) { .ftc-sides { grid-template-columns: 1fr; gap: 14px; } }
.ftc-side-label { font-size: 0.74rem; letter-spacing: 0.09em; text-transform: uppercase; font-weight: 700; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 2px solid; }
.ftc-dad .ftc-side-label { color: #3a6094; border-color: #3a6094; }
.ftc-mum .ftc-side-label { color: var(--gold-deep); border-color: var(--gold); }
.ftc-gen { margin-bottom: 16px; }
.ftc-gen-label { font-size: 0.7rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--meta); margin: 0 0 7px; }
.ftc-couple { background: var(--paper); border: 1px solid var(--line); border-left-width: 4px; border-radius: 9px; padding: 10px 13px; margin-bottom: 9px; }
.ftc-dad .ftc-couple { border-left-color: #3a6094; }
.ftc-mum .ftc-couple { border-left-color: var(--gold); }
.ftc-names { font-family: var(--serif); font-size: 1.04rem; line-height: 1.4; }
.ftc-amp { color: var(--meta); margin: 0 5px; }
.ftc-name.famtree-tappable { cursor: pointer; border-bottom: 1px solid transparent; }
.ftc-name.famtree-tappable:hover { border-bottom-color: currentColor; }
.ftc-name.is-greyed { color: #b1aaa0; }
.ftc-sub { font-size: 0.82rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.ftc-dad .ftc-sub { color: #3a6094; }
.ftc-mum .ftc-sub { color: var(--gold-deep); }
.ftc-deeper { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.ftc-deeper-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ftc-deeper-card { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 8px 13px; font-family: var(--serif); }
.ftc-deeper-card.famtree-tappable { cursor: pointer; }
.ftc-deeper-card.famtree-tappable:hover { border-color: var(--gold); }
.ftc-deeper-card em { color: var(--meta); font-size: 0.86rem; }
