: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;
  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 {
  margin: 0;
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
}
.primary-nav {
  display: flex;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  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;
  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;
  }
}
.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); }
.forward-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-deep);
}
/* Forwarded toggle as a compact switch row: icon + label/count + toggle. */
.forward-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  cursor: pointer;
}
.forward-icon { width: 20px; height: 20px; flex: none; color: var(--meta); }
.forward-text { display: grid; gap: 1px; margin-right: auto; min-width: 0; }
.forward-title {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--heading);
}
.forward-note {
  color: var(--meta);
  font-family: var(--sans);
  font-size: 0.74rem;
}
.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; }

/* People: avatar cards */
.person-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(30, 58, 79, 0.06);
  text-align: center;
  cursor: pointer;
}
.person-card:hover { border-color: var(--gold); }
.person-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-deep);
  color: var(--heading);
  font-family: var(--serif);
  font-size: 1.5rem;
}
.person-name {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.2;
  color: var(--heading);
}
.person-meta {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

/* 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);
}
.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: sticky;
  top: 63px;
  z-index: 5;
  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-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; }
.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 (the People grid keeps auto-fit). */
  #summaryTiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }
  /* 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; }
  .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; }
.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 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 920px);
}
.lightbox-frame {
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.lightbox-frame .lightbox-media {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  height: auto;
}
.lightbox-frame img.lightbox-media { width: auto; }
.lightbox-frame video.lightbox-media { width: min(86vw, 760px); background: var(--paper-deep); }
.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;
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}
.lightbox-close,
.lightbox-nav {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(18, 22, 26, 0.62);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(18, 22, 26, 0.85); }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
}
.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, .lightbox-nav { width: 40px; height: 40px; }
  /* Float the prev/next over the photo so they don't squeeze it on phones. */
  .lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(18, 22, 26, 0.72);
    border-color: rgba(255, 255, 255, 0.65);
  }
  .lightbox-nav.lb-prev { left: 10px; }
  .lightbox-nav.lb-next { right: 10px; }
}
