/* Feed, posts, the composer, photos, albums, the lightbox and stories. Mobile first (375 px);
   every colour, font and radius is a token (tokens.css + the theme). */
/* ---- Home: the greeting, the prompts strip, the composer bar, then the family's posts ---- */
.feed > * + *, .feed__list > * + * { margin-top: var(--gap-cards); }
.feed > .feed__list { margin-top: var(--space-5); }
.home__hello { margin: 0 0 var(--space-2); font-size: calc(var(--step-h2) * var(--title-scale)); overflow-wrap: anywhere; }
@media (min-width: 640px) { .home__hello { font-size: calc(var(--step-h1) * var(--title-scale)); } }

/* The prompts strip: a holiday suggestion, a letter that opened, "On this day", the setup checklist.
   One compact surface with one row each, never a stack of cards before the family's own posts. */
.prompts { padding: 0 var(--space-4); background: var(--card-bg); border: var(--card-edge); border-radius: var(--card-radius); box-shadow: var(--card-elev); }
.prompt { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; }
.prompt + .prompt { border-top: 1px solid var(--line); }
.prompt__icon, .prompt > .capsule-seal { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); }
.prompt__text { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.prompt__text p { margin: 0; }
.prompt__text > p:first-child, p.prompt__text { font-weight: 600; color: var(--text-strong); line-height: 1.4; }
.prompt__actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.prompt__actions form { margin: 0; }
.prompt .prompt__thumbs { display: block; width: 44px; height: 44px; border-radius: var(--radius-sm); overflow: hidden; }
.prompt__thumbs { grid-column: 1; }
.prompt__thumbs .memory-thumb { display: block; width: 44px; height: 44px; object-fit: cover; }
.prompt__thumbs .memory-thumb + .memory-thumb { display: none; }
.setup-card__items { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); }
.setup-card__item { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }
/* On a phone "For you" is one compact row: the prompts sit side by side and swipe, the next one
   peeking in from the edge, instead of stacking three tall rows before the family's posts. */
@media (max-width: 719px) {
  .prompts { display: flex; gap: var(--space-2); margin-inline: calc(-1 * var(--space-4)); padding: 0 var(--space-4) var(--space-1); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--space-4); scrollbar-width: none; background: none; border: 0; box-shadow: none; }
  .prompts::-webkit-scrollbar { display: none; }
  .prompts > .prompt { flex: 0 0 86%; min-width: 0; scroll-snap-align: start; align-content: start; padding: var(--space-3); background: var(--surface); border: var(--card-edge); border-radius: var(--card-radius); box-shadow: var(--card-elev); }
  .prompts > .prompt:only-child { flex-basis: 100%; }
  .prompts > .prompt + .prompt { border-top: var(--card-edge); }
  .prompt__text > p:first-child, p.prompt__text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .prompt__actions { grid-column: 1 / -1; flex-wrap: nowrap; }
  .prompt__actions .btn { white-space: nowrap; }
  .setup-card__items { flex-wrap: nowrap; overflow: hidden; }
}
@media (min-width: 720px) {
  .prompt { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .prompt__actions { grid-column: auto; justify-content: flex-end; }
}

/* Composer: a one-line bar that opens the full form (a <details>, so no JavaScript is needed) */
.composer { padding: 0; }
.composer__bar { display: flex; align-items: center; gap: var(--space-3); min-height: 68px; padding: var(--space-3) var(--space-4); list-style: none; cursor: pointer; border-radius: var(--radius-lg); }
.composer__bar::-webkit-details-marker { display: none; }
.composer__bar:hover .composer__prompt { color: var(--text); }
.composer__bar:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.composer__prompt { flex: 1; min-width: 0; min-height: var(--control-h); display: flex; align-items: center; padding: 0 var(--space-4); border-radius: 999px; background: var(--surface-2); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer__icon { flex: none; display: inline-flex; color: var(--accent-strong); }
.composer[open] .composer__icon { visibility: hidden; }
.composer__body { padding: 0 var(--space-4) var(--space-4); }
@media (min-width: 640px) { .composer__bar { padding: var(--space-3) var(--space-5); } .composer__body { padding: 0 var(--space-5) var(--space-5); } }
@media (max-width: 479px) {
  .composer__icon { display: none; }
  .composer__bar { gap: var(--space-2); padding-inline: var(--space-3); }
  .composer__prompt { padding-inline: var(--space-3); }
}
.composer textarea { width: 100%; min-height: 112px; resize: vertical; }
.composer, .composer form, .composer .field { min-width: 0; max-width: 100%; }
.composer__add { display: flex; width: 100%; min-width: 0; max-width: 100%; gap: var(--space-2); padding: 0 var(--space-4); position: relative; white-space: nowrap; }
.composer__add:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.composer__add svg { flex: none; }
.composer__row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.composer__audience { flex: 1 1 0; min-width: 0; }
.composer__audience select { min-width: 0; max-width: 100%; }
.composer__post { flex: 0 0 104px; }
.composer__row > .composer__post:only-child { flex: 1 1 100%; }
.composer__post:disabled { opacity: 0.55; cursor: not-allowed; }
.composer .error { color: var(--danger); margin: 0; }
.composer__hello { font-size: var(--step-name); margin: 0 0 var(--space-3); overflow-wrap: anywhere; } /* the setup guide's composer */

.uploads:empty { display: none; }
.uploads > li + li { margin-top: var(--space-2); }
.upload { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.upload__preview { flex: none; width: 56px; height: 56px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); display: inline-flex; align-items: center; justify-content: center; font-size: var(--step-small); font-weight: 600; overflow: hidden; }
.upload__preview img { width: 100%; height: 100%; object-fit: cover; }
.upload__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.upload__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload__status { font-size: var(--step-small); overflow-wrap: anywhere; }
.upload__bar { width: 100%; height: 6px; }
.upload__remove { flex: none; padding: 0 var(--space-3); }
.upload--failed { border-color: var(--danger); }
.upload--failed .upload__status { color: var(--danger); }

/* ---- Post card: who and when in the display face, the words, the photographs, hearts and a
   comment count that opens the thread. Edit and Delete sit in the "⋯" menu. ---- */
.post { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4) var(--card-pad) var(--space-2); }
.post__head { display: flex; align-items: center; gap: var(--space-3); }
.post__who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.post__author { font-family: var(--font-heading); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking); font-size: var(--step-name); line-height: 1.2; color: var(--text-strong); overflow-wrap: anywhere; }
.post__date { align-self: flex-start; display: inline-flex; align-items: center; min-height: var(--tap); margin: -11px 0; color: var(--muted); font-size: var(--step-small); text-decoration: none; }
a.post__date:hover { text-decoration: underline; color: var(--text); }
.post__chip { flex: none; }
.post__body { margin: 0; overflow-wrap: anywhere; line-height: 1.55; max-width: var(--measure); }
.post__menu { margin-right: calc(-1 * var(--space-2)); }
@media (min-width: 640px) { .post { padding: var(--space-5) calc(var(--card-pad) * 1.25) var(--space-3); } }
/* Photo Album: the photographs come first on a card, the words under them like an album's label */
.post > .media-grid { order: var(--media-order); }

/* Photographs: one picture runs the full width at its own shape; 2 sit side by side; 3 are one large
   and two small; 4 or more are one large over three (the last carries "+N"). On phones the pictures
   run to the card's edges. */
.media-grid { display: grid; gap: max(4px, var(--photo-mat)); overflow: hidden; margin-inline: calc(-1 * var(--media-bleed)); background: var(--card-bg); }
.media-grid--1 { grid-template-columns: 1fr; }
.media-grid--2 { grid-template-columns: 1fr 1fr; aspect-ratio: 5 / 3; }
.media-grid--3 { grid-template-columns: 3fr 2fr; grid-template-rows: 1fr 1fr; aspect-ratio: 4 / 3; }
.media-grid--3 .tile:first-child { grid-row: 1 / span 2; }
.media-grid--4 { grid-template-columns: repeat(3, 1fr); grid-template-rows: 2fr 1fr; aspect-ratio: 1 / 1; }
.media-grid--4 .tile:first-child { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .media-grid { margin-inline: 0; border-radius: var(--photo-radius); }
  .media-grid--4 { aspect-ratio: 6 / 5; }
}
.tile { position: relative; display: block; min-height: 120px; padding: var(--photo-mat); background: var(--photo-mat-bg); border: var(--photo-frame); overflow: hidden; color: var(--muted); text-decoration: none; }
.media-grid--1 .tile { min-height: 0; max-height: min(78vh, 680px); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid--1 .tile img { height: auto; max-height: min(78vh, 680px); }
.media-grid--2 .tile, .media-grid--3 .tile, .media-grid--4 .tile { min-height: 0; }
.tile:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.tile--wait { display: flex; align-items: center; justify-content: center; min-height: 160px; }
.tile__note { font-size: var(--step-small); padding: var(--space-3); text-align: center; }
/* Video: a real play button on a dark disc, visible on any frame */
.tile__play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--on-media); pointer-events: none; }
.tile__play-disc { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; padding-left: 4px; border-radius: 50%; background: var(--scrim); box-shadow: 0 0 0 2px var(--on-media-soft); }
.photo-grid .tile__play-disc { width: 44px; height: 44px; }
.tile__more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--on-media); background: var(--scrim); font-size: var(--step-h1); font-weight: 650; }

.loadmore { text-align: center; }
.loadmore [aria-busy="true"] { opacity: 0.6; }

/* Post detail */
.detail-media { display: flex; flex-direction: column; gap: var(--space-3); }
.detail-media__item { width: 100%; height: auto; border-radius: var(--radius); display: block; background: var(--accent-soft); }
.detail-media__wait { margin: 0; padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }

/* Edit: choose media to remove */
.remove-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-3); }
.remove-tile { display: flex; flex-direction: column; gap: var(--space-1); cursor: pointer; }
.remove-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.remove-tile__check { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); }
.remove-tile__check input { width: 20px; height: 20px; }

/* Photos: tabs, album cards, grids */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pagehead h1 { margin: 0; }
.tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); }
.tabs__link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-4); color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; }
.tabs__link:hover { color: var(--text); border-bottom-color: var(--line-strong); }
.tabs__link[aria-current="page"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.album-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.album-card { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.album-card__cover { display: block; aspect-ratio: 1; padding: var(--photo-mat); border-radius: var(--photo-radius); border: var(--photo-frame); overflow: hidden; background: var(--photo-mat-bg); }
.album-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-card__empty { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; color: var(--muted); }
.album-card__title { font-family: var(--font-heading); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking); font-size: var(--step-name); color: var(--text-strong); margin-top: var(--space-1); overflow-wrap: anywhere; }
.album-card__meta { font-size: var(--step-small); }
.album-card:hover .album-card__title { text-decoration: underline; text-underline-offset: 0.15em; }
.album-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius); }
@media (min-width: 640px) { .album-grid { grid-template-columns: repeat(3, 1fr); } }
.album-head h1 { margin: 0; overflow-wrap: anywhere; }
.album-head__meta { margin: 0; }
.album-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.album-danger { margin: 0; font-size: var(--step-small); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: max(3px, var(--photo-mat)); }
.photo-grid .tile { border-radius: min(var(--photo-radius), 6px); }
/* Grids that are the page's pictures run edge to edge on phones, 2px apart: only pictures, no menus */
@media (max-width: 639px) { .photo-grid--bleed { margin-inline: calc(-1 * var(--space-4)); gap: 2px; } .photo-grid--bleed + .photo-grid--bleed { margin-top: 2px; } }
.photo-grid + .photo-grid { margin-top: 3px; } /* a "Load more" page of an album */
.photo-grid .tile { aspect-ratio: 1; min-height: 0; }
.photo-grid .tile img { height: 100%; }
@media (min-width: 640px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .container--wide .photo-grid { grid-template-columns: repeat(6, 1fr); } .container--wide .album-grid { grid-template-columns: repeat(4, 1fr); } }
.month__title { font-size: var(--step-name); margin: var(--space-4) 0 var(--space-2); }
.tile-actions { display: flex; flex-wrap: wrap; gap: 2px; }
.tile-actions form { flex: 1 1 auto; }
.tile-actions__btn { width: 100%; min-height: var(--tap); border: 0; background: none; color: var(--muted); font: inherit; font-size: var(--step-small); font-weight: 600; cursor: pointer; }
.tile-actions__btn:hover { color: var(--accent-strong); background: var(--accent-soft); }
.pick { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: var(--accent-soft); cursor: pointer; }
.pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pick__mark { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--on-media); background: var(--scrim); pointer-events: none; }
.pick input:checked + .pick__mark { background: var(--accent); border-color: var(--on-accent); }
.pick input:checked + .pick__mark::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 12px; border: solid var(--on-accent); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.pick input:disabled ~ .pick__mark { opacity: 0.6; }
.pick input:focus-visible ~ .pick__mark { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- The photo viewer: the same dark viewer over any grid (static/js/lightbox.js, .pv) and as the
   photo's own page without JavaScript (.pv--page). The picture as large as the screen allows, a quiet
   bar (close, "3 of 12", the "⋯"), who and when, hearts and comments: a sheet that slides up on
   phones, a side panel from 1024px. Dark in every template; theme tokens are remapped inside it so
   hearts, comments and menus read on the dark ground. ---- */
.lightbox-open { overflow: hidden; }
.pv {
  --text: var(--on-media); --text-strong: var(--on-media); --muted: var(--on-media-muted);
  --surface: var(--viewer-sheet); --surface-2: var(--viewer-raise); --accent-soft: var(--viewer-raise-2);
  --line: var(--viewer-line); --line-strong: var(--viewer-field-line); --field-line: var(--viewer-field-line);
  --danger: var(--viewer-heart); --danger-soft: var(--viewer-raise-2); --accent-strong: var(--on-media);
  --focus: var(--on-media); --shadow-pop: none; --card-line: transparent;
  position: fixed; inset: 0; z-index: 100;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--viewer); color: var(--on-media); color-scheme: dark;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.pv[hidden] { display: none; }
.pv:focus { outline: none; }
.pv__bar { grid-row: 1; display: flex; align-items: center; gap: var(--space-2); min-height: 56px; padding: var(--space-1) var(--space-2); z-index: 3; transition: opacity 0.2s ease; }
.pv__pos { flex: 1; min-width: 0; margin: 0; text-align: center; color: var(--on-media-muted); font-size: var(--step-small); font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv__tools { flex: none; display: flex; justify-content: flex-end; min-width: var(--tap); }
.pv__icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 50%; background: none; color: var(--on-media); cursor: pointer; }
.pv__icon:hover, .pv .menu__button:hover, .pv .menu[open] > .menu__button { background: var(--on-media-soft); color: var(--on-media); }
.pv__icon:focus-visible, .pv__edge:focus-visible { outline: 3px solid var(--on-media); outline-offset: 2px; }
.pv .menu__button { color: var(--on-media); }
.pv .menu__list { background: var(--viewer-sheet); border-color: var(--viewer-line); }

.pv__stage { grid-row: 2; position: relative; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.pv__frame { margin: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.pv__media { display: block; max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; -webkit-user-drag: none; }
.pv--zoomed .pv__media { cursor: grab; }
video.pv__media { width: 100%; height: 100%; background: var(--viewer); }
.pv__edge { position: absolute; top: 50%; z-index: 2; display: flex; align-items: center; justify-content: center; width: 56px; height: 96px; margin-top: -48px; padding: 0; border: 0; background: none; color: var(--on-media); cursor: pointer; text-decoration: none; transition: opacity 0.2s ease; }
.pv__edge[hidden] { display: none; }
.pv__edge--prev { left: 0; }
.pv__edge--next { right: 0; }
.pv__arrow { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: 50%; background: var(--scrim); }
.pv__edge:hover .pv__arrow { background: var(--on-media-hover); }
.pv--zoomed .pv__edge { opacity: 0; pointer-events: none; }
/* On touch screens a swipe or a tap near either edge moves on (the arrows still show the way and
   stay in the keyboard order); the arrows never swallow a swipe that starts on them. */
@media (hover: none) { .pv:not(.pv--page) .pv__edge { pointer-events: none; } }

/* Who and when, the heart and the comment count; the thread opens as a sheet on phones */
.pv__side { grid-row: 3; position: relative; z-index: 3; min-width: 0; padding: var(--space-2) var(--space-4) var(--space-3); transition: opacity 0.2s ease; }
.pv__meta { min-width: 0; }
.pv__who { margin: 0; font-family: var(--font-heading); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking); font-size: var(--step-name); line-height: 1.25; color: var(--on-media); overflow-wrap: anywhere; }
.pv__when { margin: 0; color: var(--on-media-muted); font-size: var(--step-small); overflow-wrap: anywhere; }
.pv .social { margin-top: var(--space-2); min-height: var(--tap); }
.pv .social__heart { left: calc(-1 * var(--space-2)); }
.pv .heart-btn { color: var(--on-media); }
.pv .heart-btn:hover { background: var(--on-media-soft); }
.pv__comments { position: absolute; left: 72px; top: 0; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-3); border: 0; border-radius: var(--radius); background: none; color: var(--on-media); font: inherit; font-weight: 600; cursor: pointer; }
.pv__comments:hover { background: var(--on-media-soft); }
.pv__comments:focus-visible { outline: 3px solid var(--on-media); outline-offset: 2px; }
.pv .social__thread--open { padding-top: var(--tap); }
.pv .comment { background: var(--viewer-raise); }
.pv .comment-form textarea { background: var(--viewer-raise); }
.pv .btn { background: var(--viewer-raise-2); border-color: var(--viewer-line); color: var(--on-media); }
.pv .btn--danger { background: var(--viewer-heart); color: var(--viewer); }
.pv__sheet-close { display: none; position: absolute; top: var(--space-2); right: var(--space-2); }
.pv--bare .pv__bar, .pv--bare .pv__side, .pv--bare .pv__edge { opacity: 0; pointer-events: none; }

/* Over a grid on a phone: the thread is folded away until the comment count is tapped, then the
   panel rises as a sheet over the picture. */
@media (max-width: 1023px) {
  .pv:not(.pv--page) .social__thread--open { display: none; }
  .pv--sheet .pv__side { grid-row: 1 / -1; grid-column: 1 / -1; position: absolute; left: 0; right: 0; bottom: 0; max-height: 78%; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-5) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); background: var(--viewer-sheet); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-pop); animation: pv-rise 0.26s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .pv--sheet:not(.pv--page) .social__thread--open { display: block; }
  .pv--sheet .pv__sheet-close { display: inline-flex; }
  .pv--sheet .pv__meta { padding-right: var(--tap); }
}
@keyframes pv-rise { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }

/* From 1024px: the picture on the left, a panel with who, when, hearts and every comment beside it */
@media (min-width: 1024px) {
  .pv { grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto minmax(0, 1fr); }
  .pv__bar { grid-column: 1; }
  .pv__stage { grid-column: 1; grid-row: 2; padding: 0 var(--space-7) var(--space-5); }
  .pv__side { grid-column: 2; grid-row: 1 / -1; overflow-y: auto; padding: var(--space-6) var(--space-5); background: var(--viewer-raise); }
  .pv__comments { display: none; }
  .pv__edge { width: 88px; }
  .pv__edge--prev { left: var(--space-2); }
  .pv__edge--next { right: var(--space-2); }
  .pv__arrow { width: 52px; height: 52px; background: var(--on-media-soft); }
}

/* The photo's own page (no JavaScript needed): the same viewer as a page, the family's bars hidden */
.viewer-page { background: var(--viewer); }
.viewer-page .topbar, .viewer-page .appnav { display: none; }
.has-tabbar main.pv--page, main.pv--page { position: relative; inset: auto; z-index: auto; min-height: 100vh; min-height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.pv--page .pv__stage { min-height: 62vh; touch-action: auto; }
.pv--page .pv__media { max-height: 78vh; max-height: 78dvh; }
.pv--page > .messages { grid-column: 1 / -1; margin: var(--space-2) var(--space-4) 0; }
.pv--page > .messages li { background: var(--viewer-raise-2); color: var(--on-media); border-color: var(--viewer-line); }
@media (min-width: 1024px) {
  .pv--page { grid-template-rows: auto minmax(0, 1fr); }
  .pv--page .pv__stage { min-height: 0; }
  .pv--page .pv__media { max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); }
  .pv--page .pv__side { min-height: 100vh; }
}
@media (prefers-reduced-motion: reduce) {
  .pv__bar, .pv__side, .pv__edge { transition: none; }
  .pv--sheet .pv__side { animation: none; }
}
.detail-media__link { display: block; }

.composer__storage { margin: 0; font-size: var(--step-small); color: var(--danger); }

/* ---- Stories: cards, the reading page and the editor ---- */
.stories__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.stories__head h1 { margin: 0; }

.story-card { padding: 0; overflow: hidden; }
.story-card__cover { border-radius: 0; }
.story-card__link { display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.story-card__cover { display: block; aspect-ratio: 16 / 9; background: var(--accent-soft); overflow: hidden; }
.story-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-card__cover--type { display: flex; align-items: center; justify-content: center; color: var(--accent-strong); font-size: 3.5rem; font-weight: var(--heading-weight); font-family: var(--font-heading); }
.story-card__body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); min-width: 0; }
.story-card__label { align-self: flex-start; font-size: var(--step-small); font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); padding: 2px var(--space-2); border-radius: var(--radius-sm); }
.story-card__title { font-family: var(--font-heading); color: var(--text-strong); font-size: var(--step-name); font-weight: var(--heading-weight); letter-spacing: var(--heading-tracking); line-height: 1.3; overflow-wrap: anywhere; }
.story-card__excerpt { line-height: 1.5; overflow-wrap: anywhere; }
.story-card__meta { font-size: var(--step-small); overflow-wrap: anywhere; }
.story-card__link:hover .story-card__title { color: var(--accent-strong); }
.story-card__link:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
@media (min-width: 640px) {
  .story-card__link { flex-direction: row; }
  .story-card__cover { flex: none; width: 200px; aspect-ratio: auto; min-height: 150px; }
}

/* Reading view */
.story { max-width: calc(var(--measure) + 2rem); margin: 0 auto; padding: var(--space-2) 0 var(--space-6); }
.story__title { font-size: var(--step-h1); line-height: 1.1; margin: 0 0 var(--space-2); overflow-wrap: anywhere; }
.story__byline { margin: 0 0 var(--space-5); font-size: var(--step-small); }
/* Reading: every block (paragraph, picture) is spaced from the one before it; the selector outranks
   .story__p / .story__media, which reset their own margins. */
.story .story__content > * + * { margin-top: var(--space-5); }
.story .story__content > .story__p + .story__p { margin-top: 1em; }
.story__p { margin: 0; max-width: var(--measure); font-size: var(--step-read); line-height: 1.7; color: var(--text); overflow-wrap: anywhere; text-wrap: pretty; }
.story__figure { display: block; }
.story__media { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); background: var(--accent-soft); }
.story__wait { margin: 0; padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }

/* Editor */
.editor h1 { margin: 0; }
.editor .error { color: var(--danger); margin: 0; }
.blocks > li + li { margin-top: var(--space-3); }
.block { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.block textarea { width: 100%; min-height: 140px; padding: var(--space-3); resize: vertical; border-radius: var(--radius-sm); line-height: 1.6; }
.block__media { display: flex; align-items: center; gap: var(--space-3); }
.block__preview { flex: none; width: 72px; height: 72px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); display: inline-flex; align-items: center; justify-content: center; font-size: var(--step-small); font-weight: 600; overflow: hidden; }
.block__preview img { width: 100%; height: 100%; object-fit: cover; }
.block__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.block__name { font-weight: 600; overflow-wrap: anywhere; }
.block__status { font-size: var(--step-small); overflow-wrap: anywhere; }
.block__bar { width: 100%; height: 6px; }
.block--failed { border-color: var(--danger); }
.block--failed .block__status { color: var(--danger); }
.block__bar-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.block__bar-actions .btn { flex: 1 1 auto; }
.block__bar-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.editor__add { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.editor__add .btn { flex: 1 1 140px; }
/* An album's head follows the template's title alignment (centred in Classic, Photo Album, Festive) */
.album-head { text-align: var(--title-align); }
.album-head .album-actions { justify-content: var(--brand-justify); }
