/* Alex & Abigail. A private memory book. */

@font-face {
  font-family: "Cormorant";
  src: url("../fonts/cormorant.356e67f02c89.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant";
  src: url("../fonts/cormorant-italic.0b465a71dec2.woff2") format("woff2");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("../fonts/hanken-grotesk.c501f578bf3f.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --canvas: #f8f5f0;
  --surface: #fffdfc;
  --ink: #34302f;
  --ink-soft: #6c625d;      /* taupe, darkened from #817771 for 4.5:1 on canvas */
  --rose: #c38d93;
  --rose-mid: #a76c78;
  --rose-deep: #8f5563;     /* vintage rose, darkened for text and buttons */
  --rose-deeper: #7a4553;
  --sage: #a6b3a1;
  --sage-deep: #55644f;
  --sage-wash: #e7ece3;
  --line: #e9e1db;
  --line-strong: #d6cbc3;
  --blush: #f4e7e5;
  --stone-wash: #efe9e3;
  --danger: #973c45;
  --danger-wash: #f8e9e8;

  --serif: "Cormorant", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.3125rem;
  --text-lg: 1.75rem;
  --text-xl: 2.5rem;
  --text-2xl: clamp(2.75rem, 7vw, 4rem);

  --gutter: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-left), env(safe-area-inset-right));
  --ease: cubic-bezier(0.22, 0.7, 0.3, 1);
  --nav-height: 4.25rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

body.is-entry { padding-bottom: 0; }

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
[hidden] { display: none !important; }
a, button, label, summary, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn:active, .icon-button:active, .quiet-link:active, .agenda-event:active, .diary-entry:active, .tabs a:active, .tile-link:active, .site-nav a:active, .tick:active { opacity: 0.68; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; letter-spacing: -0.005em; }

:focus-visible {
  outline: 2px solid var(--rose-deep);
  outline-offset: 2px;
  border-radius: 3px;
}
main:focus, [tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: 1rem;
  z-index: 50;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-radius: 6px;
}
.skip-link:focus { top: 0.5rem; }

.amp {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--rose-deep);
}

/* ---- Buttons and links ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.875rem;
  padding: 0.5rem 1.375rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  font-size: 0.9688rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.btn-small { min-height: 2.75rem; padding: 0.25rem 1rem; font-size: var(--text-sm); }
.btn:disabled { opacity: 0.65; cursor: progress; }
.btn-primary { background: var(--rose-deep); color: #fff; }
@media (hover: hover) { .btn-primary:hover { background: var(--rose-deeper); } }
.btn-quiet { border-color: var(--line-strong); background: transparent; }
@media (hover: hover) { .btn-quiet:hover { background: var(--surface); border-color: var(--rose); } }
.btn-danger { background: var(--danger); color: #fff; }
@media (hover: hover) { .btn-danger:hover { background: #7f2f38; } }
.btn-danger-quiet { color: var(--danger); }
@media (hover: hover) { .btn-danger-quiet:hover { background: var(--danger-wash); } }

.quiet-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.2em;
  cursor: pointer;
  transition: color 160ms var(--ease), text-decoration-color 160ms var(--ease);
}
@media (hover: hover) { .quiet-link:hover { color: var(--rose-deep); text-decoration-color: currentColor; } }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease);
}
@media (hover: hover) { .icon-button:hover { background: var(--blush); } }
.icon-button svg, .site-nav svg, .lock-button svg {
  width: 1.375rem;
  height: 1.375rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Header and navigation ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.875rem var(--gutter);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1;
  padding-block: 0.5rem;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark .amp { font-size: 1.15em; }

.site-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.site-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
}
.site-nav a[aria-current="page"] { color: var(--rose-deep); }
.site-nav a[aria-current="page"] svg { stroke-width: 1.8; }
.site-nav a:focus-visible { outline-offset: -4px; }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.lock-form { margin: 0; }
.lock-button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.75rem;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: color 160ms var(--ease);
}
.lock-button svg { width: 1.125rem; height: 1.125rem; }
@media (hover: hover) { .lock-button:hover { color: var(--rose-deep); } }
.install-button[hidden] { display: none; }
/* The smallest phones can't fit the wordmark and two labels, so Install shows its icon only. */
@media (max-width: 23rem) {
  .install-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .install-button { min-width: 2.75rem; justify-content: center; }
}

.install-steps { display: grid; gap: 0.875rem; margin: 0; padding-left: 1.5rem; color: var(--ink-soft); list-style: decimal; }
.install-steps li::marker { color: var(--rose-deep); font-family: var(--serif); font-size: 1.15em; }
.install-steps strong { color: var(--ink); font-weight: 500; }
.install-share {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0 0.125rem;
  vertical-align: -0.2rem;
  fill: none;
  stroke: var(--rose-deep);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Page frame ---- */
.page {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.5rem var(--gutter) 3rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin: 0.75rem 0 1.75rem;
}
.page-head h1 { font-size: var(--text-2xl); }
.page-year { color: var(--ink-soft); font-weight: 400; font-style: italic; }
.page-note { color: var(--ink-soft); font-size: var(--text-sm); margin-top: 0.375rem; }

/* ---- Toasts ---- */
.toasts {
  position: fixed;
  z-index: 40;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 0.75rem);
  left: 50%;
  display: grid;
  gap: 0.5rem;
  width: min(26rem, 100% - 2rem);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 0.625rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(92, 70, 64, 0.14);
  font-size: 0.9375rem;
  text-align: center;
  animation: toast-in 240ms var(--ease);
  transition: opacity 300ms var(--ease);
}
.toast.is-error { border-color: #e4bdbd; background: var(--danger-wash); color: #742a33; }
.toast.is-leaving { opacity: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* ---- Lilies and tulips ---- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("../img/flowers-left.0b9e5dbed461.svg"), url("../img/flowers-right.96cebc617462.svg");
  background-repeat: no-repeat;
  background-position: left bottom, right bottom;
  background-size: min(clamp(8.5rem, 27vw, 26rem), 42vh) auto;
  opacity: 0.26;
}
.is-entry::before { opacity: 0.85; }

/* ---- The ampersand ---- */
.amp-mark { overflow: visible; }
.amp-mark path { fill: var(--rose); }

/* ---- Password screen ---- */
.is-entry {
  background:
    radial-gradient(90rem 50rem at 50% -10%, var(--blush), transparent 62%),
    var(--canvas);
}

.entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.25rem;
  text-align: center;
}

.lockup {
  position: relative;
  width: min(23rem, 84vw);
  aspect-ratio: 1.22;
  margin-bottom: 1rem;
}
.lockup .amp-mark {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.lockup .amp-mark path {
  fill: var(--rose);
  fill-opacity: 0.42;
  stroke: var(--rose-deep);
  stroke-width: 1.6;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation:
    amp-draw 2400ms cubic-bezier(0.45, 0.05, 0.25, 1) both,
    amp-fill 1100ms ease-out 1700ms both;
}
@keyframes amp-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes amp-fill {
  from { fill-opacity: 0; }
  to { fill-opacity: 0.42; }
}
.lockup-name {
  position: absolute;
  z-index: 1;
  font-size: clamp(3.25rem, 15vw, 5.25rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
}
.lockup-alex { top: 12%; left: 2%; }
.lockup-abigail { right: 0; bottom: 4%; }

.entry-line {
  max-width: 28rem;
  font-family: var(--serif);
  font-size: var(--text-md);
  font-style: italic;
  line-height: 1.35;
  color: var(--ink-soft);
}

.entry-form {
  display: grid;
  gap: 0.5rem;
  width: min(21rem, 100%);
  margin-top: 2.25rem;
  text-align: left;
}
.entry-label { font-size: var(--text-sm); font-weight: 500; color: var(--ink-soft); }

.password-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.password-row:focus-within {
  border-color: var(--rose-deep);
  box-shadow: 0 0 0 3px rgba(143, 85, 99, 0.16);
}
.password-row.has-error { border-color: var(--danger); }
.password-row input {
  flex: 1;
  min-width: 0;
  min-height: 3rem;
  padding: 0.5rem 0.875rem;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 1.0625rem;
}
.password-row input:focus { outline: none; }
.reveal {
  align-self: stretch;
  min-width: 3.5rem;
  padding: 0 0.875rem;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  cursor: pointer;
}
@media (hover: hover) { .reveal:hover { color: var(--rose-deep); } }
.entry-error { color: var(--danger); font-size: var(--text-sm); }
.entry-submit { margin-top: 0.75rem; min-height: 3.125rem; width: 100%; }

/* ---- Error pages ---- */
.error-page .amp-mark { width: 5.5rem; margin-bottom: 1.25rem; }
.error-title { font-size: var(--text-xl); margin-bottom: 0.5rem; }
.error-page .btn { margin-top: 1.5rem; }

/* ---- Home ---- */
.hero {
  padding: clamp(1.5rem, 5vw, 3.5rem) 0 clamp(2rem, 5vw, 3.5rem);
}
.hero-date { color: var(--ink-soft); font-size: var(--text-sm); }
.hero-line {
  margin-top: 0.25rem;
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-style: italic;
  line-height: 1.1;
}

.home-grid { display: grid; gap: 3rem; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.section-head h2 { font-size: var(--text-lg); }
.section-head .quiet-link { padding-block: 0.75rem; margin-block: -0.75rem; }

.diary { display: grid; gap: 0.25rem; }
.diary-entry {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  gap: 1rem;
  padding: 0.75rem 0.75rem 0.75rem 0;
  border-radius: 10px;
  text-decoration: none;
  transition: background-color 160ms var(--ease), padding-left 160ms var(--ease);
}
@media (hover: hover) { .diary-entry:hover { background: var(--surface); } }
.diary-date { display: grid; justify-items: center; align-content: start; }
.diary-day { font-family: var(--serif); font-size: 2.375rem; font-weight: 500; line-height: 0.95; color: var(--rose-deep); }
.diary-month { font-size: 0.8125rem; color: var(--ink-soft); }
.diary-text { display: grid; min-width: 0; align-content: start; }
.diary-title { font-family: var(--serif); font-size: var(--text-md); font-weight: 500; line-height: 1.2; overflow-wrap: anywhere; }
.diary-when, .diary-place { font-size: var(--text-sm); color: var(--ink-soft); overflow-wrap: anywhere; }

.film-preview li + li { border-top: 1px solid var(--line); }
.film-preview a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  min-height: 3rem;
  padding: 0.625rem 0;
  text-decoration: none;
  transition: color 160ms var(--ease);
}
@media (hover: hover) { .film-preview a:hover { color: var(--rose-deep); } }
.film-preview-title { font-family: var(--serif); font-size: var(--text-md); font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }

/* ---- Empty states ---- */
.empty { display: grid; justify-items: start; gap: 0.375rem; max-width: 30rem; }
.empty-line { font-family: var(--serif); font-size: var(--text-lg); font-weight: 500; font-style: italic; line-height: 1.2; }
.empty-hint { color: var(--ink-soft); }
.empty.is-small { margin-bottom: 1rem; }
.empty.is-small .empty-line { font-size: var(--text-md); }
.empty-feature { display: grid; justify-items: start; gap: 1.5rem; padding: clamp(1.5rem, 6vw, 4rem) 0; }
.empty-feature .empty-line { font-size: clamp(1.75rem, 5vw, 2.5rem); }

/* ---- Gallery: justified rows ---- */
/* Each tile grows in proportion to its aspect ratio, so every photo in a row shares a height. */
.ar-50 { --ratio: 0.5; }
.ar-67 { --ratio: 0.667; }
.ar-80 { --ratio: 0.8; }
.ar-100 { --ratio: 1; }
.ar-125 { --ratio: 1.25; }
.ar-150 { --ratio: 1.5; }
.ar-178 { --ratio: 1.778; }
.ar-220 { --ratio: 2.2; }

.gallery {
  --row: clamp(8.5rem, 21vw, 15.5rem);
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 0.625rem;
}
.gallery::after { content: ""; flex: 100 1 0; }
.tile {
  flex: var(--ratio) 1 calc(var(--ratio) * var(--row));
  min-width: 0;
}
.tile-link { display: block; text-decoration: none; border-radius: 4px; }
.tile-frame {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: var(--ratio);
  border-radius: 4px;
  background: var(--stone-wash);
}
.tile-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 200ms var(--ease);
}
@media (hover: hover) { .tile-link:hover img { opacity: 0.88; } }
.tile-missing {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 0.75rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  text-align: center;
}
.is-missing .tile-missing { display: grid; }
.is-missing img { display: none; }
.tile-note { display: block; padding-top: 0.4375rem; }
.tile-caption {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: var(--serif);
  font-size: 1.125rem;
  font-style: italic;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.tile-date { display: block; color: var(--ink-soft); font-size: 0.8125rem; }

.gallery.is-preview { --row: clamp(7.5rem, 15vw, 11rem); gap: 0.625rem; }
.gallery.is-preview .tile-note { display: none; }

.gallery-more { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-top: 2.5rem; }
.gallery-more:empty { display: none; }

/* ---- Photo page ---- */
.photo-page { display: grid; gap: 1.25rem; justify-items: start; }
.photo-figure { display: grid; gap: 1rem; width: 100%; }
.photo-frame { aspect-ratio: auto; min-height: 12rem; }
.photo-frame img { position: static; width: auto; max-height: 76dvh; margin-inline: auto; object-fit: contain; }
.photo-caption { font-size: var(--text-xl); font-style: italic; overflow-wrap: anywhere; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---- Lightbox ---- */
.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #231f1e;
  color: #f8f5f0;
}
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; animation: fade-in 180ms var(--ease); }
.lightbox::backdrop { background: #231f1e; }
.lb-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0.75rem;
}
.lb-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; min-height: 0; object-fit: contain; border-radius: 2px; }
.lb-stage { overflow: hidden; }
.lb-missing { padding: 2rem; font-size: var(--text-md); font-family: var(--serif); font-style: italic; text-align: center; }
.lightbox .icon-button { color: #f8f5f0; background: rgba(35, 31, 30, 0.55); }
@media (hover: hover) { .lightbox .icon-button:hover { background: rgba(255, 255, 255, 0.18); } }
.lightbox :focus-visible { outline-color: #f4e7e5; }
.lb-close { position: absolute; top: 0.75rem; right: 0.75rem; }
.lb-nav { position: absolute; top: 50%; margin-top: -2.5rem; }
.lb-prev { left: 0.5rem; }
.lb-next { right: 0.5rem; }
.lb-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding: 0.75rem 1.25rem calc(0.875rem + env(safe-area-inset-bottom));
}
.lb-text { min-width: 0; flex: 1 1 18rem; }
.lb-caption { font-family: var(--serif); font-size: var(--text-md); font-style: italic; line-height: 1.3; overflow-wrap: anywhere; }
.lb-caption:empty { display: none; }
.lb-date { color: #cfc6c0; font-size: var(--text-sm); }
.lb-actions { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.lb-actions a {
  display: inline-flex;
  align-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  color: #e9e1db;
  font-size: var(--text-sm);
  text-underline-offset: 0.2em;
  text-decoration-color: rgba(233, 225, 219, 0.4);
}
@media (hover: hover) { .lb-actions a:hover { color: #fff; text-decoration-color: currentColor; } }

@keyframes fade-in { from { opacity: 0; } }

/* ---- Modal panel: a sheet from the bottom on phones, centred above that ---- */
.panel {
  width: 100%;
  max-width: 100%;
  max-height: calc(92dvh - var(--keyboard, 0px));
  margin: auto 0 var(--keyboard, 0px);
  padding: 0;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}
.panel[open] { display: flex; flex-direction: column; animation: sheet-up 240ms var(--ease); }
.panel::backdrop { background: rgba(52, 48, 47, 0.42); animation: fade-in 200ms var(--ease); }
@keyframes sheet-up { from { opacity: 0.6; transform: translateY(1.5rem); } }
.panel-close { position: absolute; top: 0.625rem; right: 0.625rem; z-index: 1; background: var(--surface); }
.panel-body { overflow-y: auto; overscroll-behavior: contain; min-height: 6rem; scroll-padding-block: 1rem 5.5rem; }
.panel-loading { padding: 1.75rem 1.5rem; color: var(--ink-soft); font-family: var(--serif); font-size: var(--text-md); font-style: italic; }

.panel-page {
  max-width: 34rem;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.sheet { display: grid; gap: 1.125rem; padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); }
.sheet-title { padding-right: 2.5rem; font-size: var(--text-lg); overflow-wrap: anywhere; }
.sheet-text { color: var(--ink-soft); overflow-wrap: anywhere; }
.sheet-photo { max-height: 11rem; width: auto; border-radius: 4px; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; margin-top: 0.25rem; }
/* In a long form the save button stays in reach while the panel scrolls. */
.panel form > .sheet-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-block: 0 -0.5rem;
  padding-block: 0.625rem 0.5rem;
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line);
}
.sheet-actions .btn-danger-quiet { margin-right: auto; }

.detail-list { display: grid; gap: 0.875rem; }
.detail-list dt { color: var(--ink-soft); font-size: 0.8125rem; }
.detail-list dd { overflow-wrap: anywhere; }

/* ---- Forms ---- */
.field { display: grid; gap: 0.3125rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.field label, .field legend, .when-group legend { font-size: var(--text-sm); font-weight: 500; }
.optional { color: var(--ink-soft); font-weight: 400; }
.field-note { margin-top: -0.625rem; color: var(--ink-soft); font-size: 0.8125rem; }

.field input:not([type="radio"]):not([type="checkbox"]),
.field textarea {
  width: 100%;
  min-height: 2.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem; /* below 16px, iOS zooms the page on focus */
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.field textarea { resize: vertical; line-height: 1.45; }
.field input:not([type="radio"]):not([type="checkbox"]):focus,
.field textarea:focus {
  outline: none;
  border-color: var(--rose-deep);
  box-shadow: 0 0 0 3px rgba(143, 85, 99, 0.16);
}
.has-error input:not([type="radio"]):not([type="checkbox"]), .has-error textarea { border-color: var(--danger); }
.errorlist { color: var(--danger); font-size: var(--text-sm); }

.field-row { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.75rem; }

.when-group { display: grid; gap: 0.375rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.when-group legend { padding: 0 0 0.375rem; font-family: var(--serif); font-size: 1.1875rem; }
.when-group legend .optional { font-family: var(--sans); font-size: var(--text-sm); }
.when-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0.75rem; }
.when-row label { font-weight: 400; color: var(--ink-soft); font-size: 0.8125rem; }
.is-all-day .when-row { grid-template-columns: minmax(0, 1fr); }
.is-all-day .time-field { display: none; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  justify-self: start;
  min-height: 2.75rem;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 2.5rem; height: 1.5rem; margin: 0; cursor: pointer; }
.switch-track {
  position: relative;
  width: 2.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color 160ms var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms var(--ease);
}
.switch input:checked + .switch-track { background: var(--rose-deep); }
.switch input:checked + .switch-track::after { transform: translateX(1rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--rose-deep); outline-offset: 2px; }

.who-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.who-field legend { padding: 0 0 0.375rem; }
.who-option { position: relative; font-weight: 400; cursor: pointer; }
.who-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.who-option span {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: var(--text-sm);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
@media (hover: hover) { .who-option:hover span { border-color: var(--rose); } }
.who-option input:checked + span { border-color: var(--rose-deep); background: var(--blush); font-weight: 500; }
.who-option input:focus-visible + span { outline: 2px solid var(--rose-deep); outline-offset: 2px; }

/* ---- Upload ---- */
.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  padding: 1.75rem 1.25rem;
  border: 1px dashed var(--rose);
  border-radius: 14px;
  background: var(--canvas);
  text-align: center;
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.dropzone:hover, .dropzone.is-over { background: var(--blush); border-color: var(--rose-deep); }
.dropzone:focus-within { outline: 2px solid var(--rose-deep); outline-offset: 2px; }
.dropzone-title { font-family: var(--serif); font-size: var(--text-md); font-weight: 500; font-style: italic; }
.dropzone-hint { color: var(--ink-soft); font-size: var(--text-sm); }
.dropzone-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
/* Before the script runs, the plain file input must show which files were chosen. */
.upload-form:not(.is-enhanced) .dropzone-input { position: static; opacity: 1; margin-top: 0.5rem; }
.upload-form:not(.is-enhanced) .drop-only { display: none; }

.upload-list { display: grid; gap: 0.5rem; }
.upload-list:empty { display: none; }
.upload-item { display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; }
.upload-item img { width: 3rem; height: 3rem; object-fit: cover; border-radius: 4px; background: var(--stone-wash); }
.upload-item img.is-unreadable { visibility: hidden; }
.upload-item-text { display: grid; min-width: 0; gap: 0.125rem; }
.upload-item-name { overflow: hidden; font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.upload-item-state { color: var(--ink-soft); font-size: 0.8125rem; }
.upload-item-state:empty { display: none; }
.upload-bar { display: none; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.upload-bar span { display: block; width: 0; height: 100%; background: var(--rose-deep); transition: width 160ms linear; }
.is-sending .upload-bar { display: block; }
.is-done .upload-item-state { color: var(--sage-deep); }
.has-failed .upload-item-state { color: var(--danger); }
.upload-remove { min-height: 2.75rem; }
.upload-status { color: var(--danger); font-size: var(--text-sm); }

/* ---- Calendar ---- */
.cal-page-head { align-items: center; }
.cal-page-head .page-head-text { flex: 1 1 100%; }
.month-nav { display: flex; align-items: center; gap: 0.25rem; }
.month-nav .btn { margin: 0 0.25rem; }
.month-nav .is-current { background: var(--blush); border-color: transparent; }

.cal-layout { display: grid; gap: 2.5rem; }

.cal-weekdays, .cal-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cal-weekdays span {
  padding: 0 0 0.375rem;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  text-align: center;
}
.cal-week + .cal-week { border-top: 1px solid var(--line); }
.cal-weekdays { border-bottom: 1px solid var(--line); }

.c1 { grid-column-start: 1; } .c2 { grid-column-start: 2; } .c3 { grid-column-start: 3; } .c4 { grid-column-start: 4; }
.c5 { grid-column-start: 5; } .c6 { grid-column-start: 6; } .c7 { grid-column-start: 7; }
.s1 { grid-column-end: span 1; } .s2 { grid-column-end: span 2; } .s3 { grid-column-end: span 3; } .s4 { grid-column-end: span 4; }
.s5 { grid-column-end: span 5; } .s6 { grid-column-end: span 6; } .s7 { grid-column-end: span 7; }

.cal-day { position: relative; grid-row: 1; min-width: 0; }
.cal-bar { display: none; }
.cal-more { display: none; }
.cal-date-wide { display: none; }
.cal-date-narrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1875rem;
  min-height: 3.25rem;
  padding: 0.375rem 0;
  text-decoration: none;
}
.cal-num {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 50%;
  font-size: 0.9375rem;
  transition: background-color 160ms var(--ease);
}
@media (hover: hover) { .cal-date:hover .cal-num { background: var(--blush); } }
.is-outside .cal-num { color: #766b64; }
.is-today .cal-num { background: var(--rose-deep); color: #fff; font-weight: 500; }
@media (hover: hover) { .is-today .cal-date:hover .cal-num { background: var(--rose-deeper); } }
.cal-dot { width: 0.375rem; height: 0.375rem; border-radius: 50%; background: var(--rose-deep); }

.who-alex { --who: var(--rose-deep); --who-wash: var(--blush); }
.who-abigail { --who: var(--sage-deep); --who-wash: var(--sage-wash); }
.who-both { --who: var(--ink-soft); --who-wash: var(--stone-wash); }

.cal-key { display: flex; flex-wrap: wrap; gap: 0.25rem 1.125rem; margin-top: 0.875rem; color: var(--ink-soft); font-size: 0.8125rem; }
.cal-key li { display: flex; align-items: center; gap: 0.375rem; }
.cal-key li::before { content: ""; width: 0.625rem; height: 0.625rem; border-radius: 50%; background: var(--who); }

.agenda h2 { font-size: var(--text-lg); margin-bottom: 1rem; }
.agenda-days { display: grid; gap: 1.25rem; }
.agenda-date { margin-bottom: 0.375rem; font-family: var(--sans); font-size: var(--text-sm); font-weight: 500; color: var(--ink-soft); }
.agenda-today { color: var(--rose-deep); }
.agenda-day ul, .day-events { display: grid; gap: 0.375rem; }
.agenda-event {
  display: grid;
  padding: 0.5rem 0.75rem 0.5rem 0.875rem;
  border-left: 3px solid var(--who);
  border-radius: 2px 8px 8px 2px;
  background: var(--surface);
  text-decoration: none;
  transition: background-color 160ms var(--ease);
}
@media (hover: hover) { .agenda-event:hover { background: var(--who-wash); } }
.agenda-title { font-family: var(--serif); font-size: 1.1875rem; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.agenda-time, .agenda-place { color: var(--ink-soft); font-size: 0.8438rem; overflow-wrap: anywhere; }
.agenda-day.is-past .agenda-event { background: none; }
.agenda-day.is-past .agenda-title { color: var(--ink-soft); }

/* ---- Films ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1.75rem; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
@media (hover: hover) { .tabs a:hover { background: var(--surface); color: var(--ink); } }
.tabs a[aria-current="page"] { background: var(--blush); color: var(--ink); font-weight: 500; }
.tab-count { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 400; }

.film-groups { display: grid; gap: 2.75rem; max-width: 50rem; }
.film-group h2 { margin-bottom: 0.5rem; font-size: var(--text-lg); }
.film-group-empty { color: var(--ink-soft); font-family: var(--serif); font-size: 1.1875rem; font-style: italic; }

.film {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem 0.625rem;
  padding: 0.375rem 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 1rem;
}
.film:target { background: var(--blush); box-shadow: -0.75rem 0 0 var(--blush), 0.75rem 0 0 var(--blush); }
.film-tick { margin: 0; }

.tick {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.3125rem;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.tick svg {
  width: 100%;
  height: 100%;
  padding: 0.125rem;
  border: 1.5px solid var(--rose-mid);
  border-radius: 50%;
  background: var(--surface);
  fill: none;
  stroke: var(--rose-deep);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}
@media (hover: hover) { .tick:hover svg { background: var(--blush); } }
/* The gap is longer than the path: a dash offset of exactly 1 would leave a round cap showing as a dot. */
.tick path { stroke-dasharray: 1 1.3; stroke-dashoffset: 1.15; transition: stroke-dashoffset 320ms var(--ease); }
.tick[aria-checked="true"] svg { background: var(--sage-wash); border-color: var(--sage-deep); stroke: var(--sage-deep); }
.tick[aria-checked="true"] path { stroke-dashoffset: 0; }

.film-body { min-width: 0; }
.film-title { font-size: 1.3125rem; line-height: 1.2; overflow-wrap: anywhere; }
.film-name {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 55%;
  background-size: 0 1px;
  transition: background-size 420ms var(--ease), color 300ms var(--ease);
}
.film-credit { display: flex; flex-wrap: wrap; gap: 0 0.75rem; margin-top: 0.25rem; color: var(--ink-soft); font-size: 0.8125rem; }
.film-credit [data-watched-label]:empty { display: none; }
.film-credit:not(:has(span:not(:empty))) { display: none; }
.film-actions { display: flex; }
.film-actions .quiet-link { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; padding-inline: 0.25rem; }

.film.is-watched .film-name { background-size: 100% 1px; color: var(--ink-soft); }

/* ---- Letters ---- */
.letters-layout { display: grid; gap: 2.5rem; align-items: start; }

.letter-compose {
  display: grid;
  gap: 1.125rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(52, 48, 47, 0.04);
}
.letter-compose-title { font-size: var(--text-lg); }
.letter-compose textarea { min-height: 8.5rem; font-family: var(--serif); font-size: 1.1875rem; line-height: 1.4; }
.letter-count { justify-self: end; color: var(--ink-soft); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.letter-count.is-near { color: var(--danger); }
.letter-compose-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; }
.letter-forever { color: var(--ink-soft); font-size: 0.8125rem; }

.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1rem; align-items: start; }
.letter {
  display: grid;
  gap: 0.875rem;
  padding: 1.125rem 1.25rem 1rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--who);
  border-radius: 4px 4px 14px 14px;
  background: var(--surface);
  scroll-margin-top: 1rem;
}
.letter:target { background: var(--who-wash); }
.letter-body { font-family: var(--serif); font-size: 1.25rem; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.letter-sign { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 0.75rem; }
.letter-from { color: var(--who); font-family: var(--serif); font-size: 1.1875rem; font-style: italic; font-weight: 500; }
.letter-from::before { content: "\2014\00a0"; }
.letter-sign time { color: var(--ink-soft); font-size: 0.8125rem; }

/* ---- Tablet and up ---- */
@media (min-width: 48rem) and (min-height: 30rem), (min-width: 64rem) {
  body { padding-bottom: 0; }

  .site-header { padding-block: 1.25rem; }
  .wordmark { font-size: 1.75rem; }

  .site-nav {
    position: static;
    display: flex;
    flex: 1;
    justify-content: center;
    gap: 0.25rem;
    height: auto;
    padding: 0;
    background: none;
    border: 0;
  }
  .site-nav a {
    position: relative;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 0.875rem;
    color: var(--ink);
    font-size: 0.9688rem;
    font-weight: 400;
    transition: color 160ms var(--ease);
  }
  @media (hover: hover) { .site-nav a:hover { color: var(--rose-deep); } }
  .site-nav svg { display: none; }
  .site-nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0.25rem;
    width: 0.3125rem;
    height: 0.3125rem;
    margin-left: -0.15625rem;
    border-radius: 50%;
    background: var(--rose-deep);
  }
  .site-nav a:focus-visible { outline-offset: 0; }

  .panel {
    width: min(34rem, 100vw - 3rem);
    max-height: min(88dvh, 52rem);
    margin: auto;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(52, 48, 47, 0.24);
  }
  .sheet { padding: 2rem 2rem 1.75rem; }

  .lb-prev { left: 1rem; }
  .lb-next { right: 1rem; }
  .lb-stage { padding: 1.5rem 5rem 0.5rem; }
  .lb-info { padding-inline: 5rem; }

  .cal-page-head .page-head-text { flex: 1 1 auto; }

  /* The real month grid, once there's room for it. */
  .cal-week {
    grid-template-rows: 2.5rem repeat(3, 1.625rem) 1.375rem;
    row-gap: 2px;
    min-height: 7.5rem;
    padding-bottom: 0.25rem;
  }
  .cal-day {
    grid-row: 1 / -1;
    margin-bottom: -0.25rem;
  }
  .cal-day + .cal-day { border-left: 1px solid var(--line); }
  .is-outside { background: rgba(239, 233, 227, 0.4); }
  .cal-date-narrow { display: none; }
  .cal-date-wide { display: block; padding: 0.375rem 0.4375rem; text-decoration: none; }
  /* The whole cell adds an event. Bars and the "more" link sit above this. */
  .cal-date-wide::after { content: ""; position: absolute; inset: 0; }
  @media (hover: hover) { .cal-day:hover { background: rgba(244, 231, 229, 0.45); } }

  .cal-bar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.3125rem;
    min-width: 0;
    margin: 0 0.25rem;
    padding: 0 0.4375rem;
    border-radius: 5px;
    color: var(--ink);
    font-size: 0.8125rem;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 160ms var(--ease);
  }
  .l1 { grid-row: 2; } .l2 { grid-row: 3; } .l3 { grid-row: 4; }
  @media (hover: hover) { .cal-bar:hover { background: var(--who-wash); } }
  .cal-bar.is-solid { background: var(--who-wash); box-shadow: inset 2px 0 0 var(--who); font-weight: 500; }
  @media (hover: hover) { .cal-bar.is-solid:hover { filter: brightness(0.97); } }
  .cal-bar.from-before { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; box-shadow: none; }
  .cal-bar.to-after { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
  .cal-bar-dot { flex: none; width: 0.375rem; height: 0.375rem; border-radius: 50%; background: var(--who); }
  .cal-bar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .cal-more {
    position: absolute;
    z-index: 1;
    right: 0.25rem;
    bottom: 0.125rem;
    left: 0.25rem;
    display: block;
    padding: 0 0.25rem;
    color: var(--ink-soft);
    font-size: 0.75rem;
    text-underline-offset: 0.15em;
  }
  @media (hover: hover) { .cal-more:hover { color: var(--rose-deep); } }

  .toasts { bottom: 1.5rem; }

  .film-title { font-size: 1.4375rem; }
  .film-actions { gap: 0.5rem; }
}

/* ---- Desktop ---- */
@media (min-width: 64rem) {
  .letters-layout { grid-template-columns: minmax(0, 21rem) minmax(0, 1fr); gap: 2.5rem 3rem; }
  .letter-compose { position: sticky; top: 1.5rem; }
  .home-grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-rows: auto 1fr;
    gap: 3.5rem 4.5rem;
  }
  .home-next { grid-column: 1; grid-row: 1; }
  .home-memories { grid-column: 2; grid-row: 1 / span 2; }
  .home-films { grid-column: 1; grid-row: 2; }

  .cal-layout { grid-template-columns: minmax(0, 1fr) 17.5rem; gap: 3rem; }

  .film-groups[data-film-view="all"] {
    grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
    align-items: start;
    gap: 4.5rem;
    max-width: none;
  }
}

/* ---- Touch screens with room for the full month grid ---- */
@media (min-width: 48rem) and (min-height: 30rem) and (pointer: coarse) {
  .cal-date-wide { min-height: 2.75rem; }
  .cal-bar { min-height: 1.75rem; }
  .cal-more { display: flex; align-items: center; min-height: 1.5rem; }
}

/* ---- Phones held sideways ---- */
@media (max-height: 30rem) and (max-width: 63.99rem) {
  :root { --nav-height: 3rem; }
  .site-nav a { flex-direction: row; gap: 0.375rem; }
  .page-head h1 { font-size: var(--text-xl); }
  .panel { max-width: 40rem; margin-inline: auto; max-height: calc(100dvh - var(--keyboard, 0px)); }
  .panel form > .sheet-actions { position: static; box-shadow: none; }
}
@media (max-height: 30rem) and (min-width: 36rem) and (max-width: 63.99rem) {
  .entry-gate {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 21rem);
    align-content: center;
    justify-items: center;
    column-gap: 2.5rem;
    max-width: 48rem;
    margin-inline: auto;
    padding-block: 1rem;
  }
  .entry-gate .lockup { width: 17rem; margin-bottom: 0.5rem; }
  .entry-gate .lockup-name { font-size: 3rem; }
  .entry-gate .entry-form { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
