:root {
  --bg: #f7f5f1;
  --surface: #ffffff;
  --ink: #1b1a17;
  --muted: #7a756c;
  --line: rgba(27, 26, 23, .1);
  --accent: #1b1a17;
  --ok: #3d7a5a;
  --err: #b4432f;
  --radius: 14px;
  --gap: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
body.lock { overflow: hidden; }

/* ─── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: clamp(64px, 14vh, 140px) 24px clamp(40px, 7vh, 72px);
  max-width: 720px;
  margin: 0 auto;
}
.hero__kicker {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero__names {
  margin: 0;
  font: 400 clamp(44px, 10vw, 92px)/1 var(--serif);
  letter-spacing: -.01em;
}
.hero__names em { font-style: italic; color: var(--muted); padding: 0 .06em; }
.hero__date {
  margin: 18px 0 0;
  font-size: 12px;
  letter-spacing: .28em;
  color: var(--muted);
}
.hero__msg {
  margin: 28px auto 0;
  max-width: 34ch;
  font: italic 400 21px/1.4 var(--serif);
  color: #4a463f;
}
.hero__stats {
  margin: 22px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  min-height: 1.5em;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(6px);
  animation: rise 1s var(--ease) forwards;
  animation-delay: calc(var(--i) * 110ms + 80ms);
}
@keyframes rise { to { opacity: 1; transform: none; filter: none; } }

/* ─── Botoncito discreto (Álbum / Subir) ──────────────────────────────── */
.corner {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  background: rgba(247,245,241,.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: .75;
  transition: opacity .25s, color .25s, background .25s;
}
.corner svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.corner:hover, .corner:focus-visible { opacity: 1; color: var(--ink); background: rgba(27,26,23,.05); }

/* ─── Página de subida: todo centrado, un solo botón ───────────────────── */
body[data-view="upload"] .hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: calc(64px + env(safe-area-inset-top));
  padding-bottom: calc(64px + var(--safe-b));
}
.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  margin-top: 36px;
  padding: 0 34px 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .01em;
  box-shadow: 0 12px 32px -10px rgba(27,26,23,.5), 0 2px 6px rgba(27,26,23,.15);
  transition: transform .2s var(--ease), box-shadow .25s;
}
.cta svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.cta::after { /* halo que "respira" para invitar a tocar */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(27,26,23,.25);
  animation: breathe 2.8s var(--ease) 2s infinite;
}
@keyframes breathe { 0% { box-shadow: 0 0 0 0 rgba(27,26,23,.22); } 70%, 100% { box-shadow: 0 0 0 16px rgba(27,26,23,0); } }
.cta:active { transform: scale(.96); }
@media (hover: hover) { .cta:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -12px rgba(27,26,23,.55), 0 2px 6px rgba(27,26,23,.15); } }
body[data-view="upload"] .hero__stats { margin-top: 18px; }

/* ─── Álbum: línea de tiempo ────────────────────────────────────────── */
#gallery { display: flex; flex-direction: column; }
body[data-view="album"] #gallery {
  --rail: 14px;                      /* posición de la línea */
  --pad: calc(var(--rail) + 22px);   /* espacio entre la línea y las fotos */
  --tsize: 40px;
  position: relative;
  gap: 44px;
  padding-left: var(--pad);
}
/* la línea gris y el tramo recorrido, que se llena al scrollear */
body[data-view="album"] #gallery::before,
body[data-view="album"] #gallery::after {
  content: "";
  position: absolute;
  left: var(--rail);
  top: 8px;
  width: 1px;
  border-radius: 1px;
}
body[data-view="album"] #gallery::before { bottom: 0; background: var(--line); }
body[data-view="album"] #gallery::after {
  height: var(--p, 0px);
  max-height: calc(100% - 8px);
  width: 2px;
  margin-left: -.5px;
  background: var(--ink);
}

@media (min-width: 1000px) {
  body[data-view="album"] #gallery { --rail: 28px; --pad: 76px; --tsize: 46px; gap: 56px; }
}
.tl-day {
  position: relative;
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--muted);
}
.tl-day::before { /* rombo en la línea */
  content: "";
  position: absolute;
  left: calc(var(--rail) - var(--pad) - 3.5px);
  top: 50%;
  width: 8px; height: 8px;
  margin-top: -4px;
  background: var(--bg);
  border: 1px solid var(--muted);
  transform: rotate(45deg);
}

.moment__head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 var(--gap) calc(-1 * var(--pad) - var(--gap));
  padding: calc(12px + env(safe-area-inset-top)) var(--gap) 14px calc(var(--pad) + var(--gap));
  background: linear-gradient(var(--bg) 72%, rgba(247,245,241,0));
}
.moment__dot {
  position: absolute;
  left: calc(var(--gap) + var(--rail) - 6px);
  top: calc(12px + env(safe-area-inset-top) + var(--tsize) / 2 - 6px);
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid #c9c3b8;
  transition: background .35s, border-color .35s, transform .5s var(--spring), box-shadow .5s;
}
.moment.passed .moment__dot {
  background: var(--ink);
  border-color: var(--ink);
  transform: scale(1.1);
  box-shadow: 0 0 0 5px rgba(27,26,23,.07);
}
.moment__time {
  margin: 0;
  font: 400 var(--tsize)/1 var(--serif);
  font-variant-numeric: lining-nums;
  color: #a39d92;
  transition: color .4s;
}
.moment.passed .moment__time { color: var(--ink); }
.moment__time small {
  font: 500 11px var(--sans);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 6px;
}
.moment__count { font: italic 18px var(--serif); color: var(--muted); }

.tl-end {
  position: relative;
  padding: 6px 0 0;
  font: italic 22px var(--serif);
  color: var(--muted);
}
.tl-end::before { /* corazón al final de la línea */
  content: "♥";
  position: absolute;
  left: calc(var(--rail) - var(--pad) - 8px);
  top: 4px;
  width: 17px;
  text-align: center;
  font: 15px/1.6 var(--sans);
  color: var(--ink);
  background: var(--bg);
}

/* ─── Grilla (masonry por columnas, armada en JS) ───────────────────────── */
main { padding: 0 var(--gap) calc(120px + var(--safe-b)); max-width: 1600px; margin: 0 auto; }
.grid { display: flex; gap: var(--gap); align-items: flex-start; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: var(--ar);
  background: var(--c, #e8e4dc);
  opacity: 0;
  transform: translateY(18px) scale(.985);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--d, 0ms);
}
.tile.in { opacity: 1; transform: none; }
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity .6s var(--ease), transform 1.2s var(--ease);
}
.tile.loaded img { opacity: 1; transform: none; }
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.28));
  opacity: 0;
  transition: opacity .3s;
}
.tile:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) {
  .tile:hover img { transform: scale(1.03); }
  .tile:hover::after { opacity: 1; }
}
.tile.fresh { animation: fresh 1.6s var(--ease); }
@keyframes fresh {
  0% { box-shadow: 0 0 0 0 rgba(27,26,23,.35); }
  100% { box-shadow: 0 0 0 14px rgba(27,26,23,0); }
}

.empty { text-align: center; padding: 40px 24px 60px; color: var(--muted); animation: rise .9s var(--ease) both; }
.empty__icon { width: 56px; height: 56px; margin: 0 auto 16px; color: #b8b2a6; }
.empty__title { margin: 0; font: 400 26px/1.2 var(--serif); color: var(--ink); }
.empty__text { margin: 6px 0 0; }

.sentinel { display: grid; place-items: center; height: 80px; }
.sentinel.done .spinner { display: none; }
.spinner {
  width: 18px; height: 18px;
  border: 1.5px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Botones y hojas ───────────────────────────────────────────────────── */
.btn {
  height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  transition: transform .15s var(--ease), background .2s;
}
.btn:active { transform: scale(.97); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

.sheet { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; justify-items: center; }
@media (min-width: 640px) { .sheet { align-items: center; } }
.sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(27,26,23,.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade .35s var(--ease);
}
.sheet__panel {
  position: relative;
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 30px 24px calc(24px + var(--safe-b));
  animation: sheetUp .5s var(--ease);
}
@media (min-width: 640px) { .sheet__panel { border-radius: 24px; padding: 34px 32px 28px; } }
.sheet__panel h2 { margin: 0; font: 400 32px/1.1 var(--serif); }
.sheet__panel p { margin: 8px 0 20px; color: var(--muted); }
.sheet__panel input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font: 16px var(--sans);
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.sheet__panel input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(27,26,23,.06); }
.sheet__actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet__actions .btn { flex: 1; }
.sheet.closing .sheet__backdrop { animation: fade .25s reverse forwards; }
.sheet.closing .sheet__panel { animation: sheetUp .25s var(--ease) reverse forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { opacity: 0; transform: translateY(40px); } }

/* QR */
.sheet__panel--qr { text-align: center; }
.qr__names { font: 400 40px/1.05 var(--serif) !important; }
.qr__names em { font-style: italic; color: var(--muted); }
.qr__code { width: 220px; margin: 22px auto 12px; }
.qr__code svg { width: 100%; height: auto; }
.qr__hint { margin: 0 !important; color: var(--ink) !important; font: italic 20px var(--serif); }
.qr__url { font-size: 12px; word-break: break-all; margin: 4px 0 0 !important; }

/* ─── Bandeja de subida ─────────────────────────────────────────────────── */
.tray {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  z-index: 30;
  width: min(420px, calc(100% - 24px));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: 20px;
  box-shadow: 0 20px 50px -12px rgba(27,26,23,.3), 0 0 0 1px var(--line);
  padding: 14px 14px 12px;
  transform: translateX(-50%);
  animation: trayIn .55s var(--spring);
}
.tray.closing { animation: trayOut .3s var(--ease) forwards; }
@keyframes trayIn { from { opacity: 0; transform: translateX(-50%) translateY(30px) scale(.96); } }
@keyframes trayOut { to { opacity: 0; transform: translateX(-50%) translateY(20px) scale(.97); } }
.tray__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tray__status { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.tray__status span:not(.tray__check) { color: var(--muted); font-variant-numeric: tabular-nums; }
.tray__check {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok); color: #fff;
  display: none; place-items: center;
}
.tray__check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-dasharray: 24; stroke-dashoffset: 24; }
.tray.done .tray__check { display: grid; animation: pop .45s var(--spring); }
.tray.done .tray__check svg { animation: draw .45s var(--ease) .15s forwards; }
@keyframes pop { from { transform: scale(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.tray__close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.tray__close svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.tray__bar { height: 3px; background: var(--line); border-radius: 3px; margin: 10px 2px 12px; overflow: hidden; }
.tray__bar i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: inherit; transition: width .4s var(--ease), background .3s; }
.tray.done .tray__bar i { background: var(--ok); }
.tray__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px;
  max-height: 158px; overflow-y: auto; overscroll-behavior: contain;
}
.tray__item {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: #ece8e1;
  animation: pop .35s var(--spring) both;
}
.tray__item img { width: 100%; height: 100%; object-fit: cover; opacity: .45; transition: opacity .3s; }
.tray__item.ok img { opacity: 1; }
.tray__item svg.ring { position: absolute; inset: 50% auto auto 50%; width: 24px; height: 24px; transform: translate(-50%,-50%) rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: rgba(255,255,255,.55); }
.ring .fg { stroke: #fff; stroke-dasharray: 57; stroke-dashoffset: 57; transition: stroke-dashoffset .25s; stroke-linecap: round; }
.tray__item.ok svg.ring, .tray__item.err svg.ring { display: none; }
.tray__item.err { box-shadow: inset 0 0 0 2px var(--err); }
.tray__item.err::after {
  content: "!"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-weight: 600; background: rgba(180,67,47,.55);
}

/* ─── Soltar archivos ───────────────────────────────────────────────────── */
.drop {
  position: fixed; inset: 12px; z-index: 50;
  display: grid; place-items: center;
  border: 1.5px dashed rgba(27,26,23,.35);
  border-radius: 24px;
  background: rgba(247,245,241,.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade .25s var(--ease);
  pointer-events: none;
}
.drop p { font: italic 32px var(--serif); margin: 0; }

/* ─── Visor ─────────────────────────────────────────────────────────────── */
.lb {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12,12,11,.96);
  color: #fff;
  animation: fade .3s var(--ease);
  touch-action: pan-y pinch-zoom;
}
.lb.closing { animation: fade .22s var(--ease) reverse forwards; }
.lb__stage { position: absolute; inset: 64px 0 64px; display: grid; place-items: center; overflow: hidden; }
.lb__img {
  max-width: calc(100% - 16px);
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}
.lb__img.enter { animation: zoomIn .45s var(--ease); }
@keyframes zoomIn { from { opacity: 0; transform: scale(.94); } }
.lb__top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 0 20px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.lb__count { font-size: 13px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
.lb__tools { display: flex; gap: 4px; }
.lb__btn, .lb__nav {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: #fff;
  display: grid; place-items: center;
  transition: background .2s;
}
.lb__btn svg, .lb__nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.lb__btn:hover, .lb__nav:hover { background: rgba(255,255,255,.1); }
.lb__nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.06); }
.lb__nav--prev { left: 16px; }
.lb__nav--next { right: 16px; }
@media (hover: none), (max-width: 640px) { .lb__nav { display: none; } }
.lb__caption {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
  padding: 0 20px max(22px, env(safe-area-inset-bottom));
  text-align: center;
  font: italic 19px var(--serif);
  color: rgba(255,255,255,.75);
  min-height: 1.4em;
}

/* ─── Barra admin y toast ───────────────────────────────────────────────── */
.adminbar {
  position: fixed; top: 12px; right: 12px; z-index: 25;
  display: flex; align-items: center; gap: 2px;
  padding: 4px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line), 0 6px 20px -8px rgba(0,0,0,.2);
  font-size: 13px;
  animation: fade .5s var(--ease) .4s both;
}
.adminbar__tag { padding: 0 10px; font-size: 10px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.adminbar a, .adminbar button { padding: 7px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); text-decoration: none; }
.adminbar a:hover, .adminbar button:hover { background: rgba(27,26,23,.06); }

.toast {
  position: fixed; left: 50%; top: 18px; z-index: 70;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink); color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4);
  animation: toastIn .45s var(--spring);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-16px); } }

/* ─── Celular ───────────────────────────────────────────────────────────── */
@media (hover: none) {
  .tile { transition-property: opacity, transform; }
  .tile:active { transform: scale(.97); transition-duration: .15s; transition-delay: 0ms; }
}
@media (max-width: 640px) {
  :root { --gap: 6px; }
  .hero { padding: calc(56px + env(safe-area-inset-top)) 22px 34px; }
  .hero__kicker { font-size: 10px; margin-bottom: 12px; }
  .hero__msg { font-size: 19px; margin-top: 22px; }
  .tile { border-radius: 4px; }
  body[data-view="album"] #gallery { --rail: 8px; --pad: 26px; --tsize: 32px; gap: 30px; }
  .moment__count { font-size: 16px; }
  .tl-end { font-size: 19px; }
  .cta { height: 58px; width: 100%; max-width: 300px; justify-content: center; }
  .tray { border-radius: 18px; }
  .lb__stage { inset: 56px 0 60px; }
  .lb__img { max-width: 100%; border-radius: 0; }
  .adminbar { top: auto; bottom: calc(16px + var(--safe-b)); right: 50%; transform: translateX(50%); }
  .adminbar__tag { display: none; }
  .sheet__panel { padding-top: 14px; }
  .sheet__panel::before {
    content: ""; display: block; width: 36px; height: 4px; border-radius: 2px;
    background: var(--line); margin: 0 auto 18px;
  }
  .sheet__panel--qr::before { display: none; }
  .toast { top: calc(12px + env(safe-area-inset-top)); }
}

/* ─── Impresión del QR ──────────────────────────────────────────────────── */
@media print {
  body > *:not(#qrSheet) { display: none !important; }
  #qrSheet { position: static; display: block !important; }
  .sheet__backdrop, .sheet__actions { display: none; }
  .sheet__panel { box-shadow: none; margin: 60px auto; animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
  .reveal, .tile { opacity: 1; transform: none; filter: none; }
}
