/* Self-hosted fonts (latin subset) — preloaded in index.html to avoid FOUT */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/vendor/fonts/cormorant-garamond.woff2) format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/vendor/fonts/cormorant-garamond-italic.woff2) format("woff2");
}
@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 300 500;
  font-display: swap;
  src: url(/vendor/fonts/jost.woff2) format("woff2");
}

:root {
  --cream: #f7f3ee;
  --cream-2: #efe8df;
  --ink: #3a352f;
  --muted: #8a8073;
  --blush: #d9b8a8;
  --sage: #9caf95;
  --sage-deep: #6f8268;
  --line: #e2d8cb;
  --gold: #b89b6e;
  --danger: #b4553f;
  --white: #fffdfa;
  --shadow: 0 8px 30px rgba(58, 53, 47, 0.10);
  --radius: 14px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
a, button, .btn, .linkbtn, .tile, .lb-nav, .lb-close, .dropzone { touch-action: manipulation; }

html, body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
/* Larger base so all rem-based type scales up for older readers; set on
   html only (not body) to avoid compounding the percentage. */
html { font-size: 118.75%; }

body { min-height: 100vh; min-height: 100dvh; }
[hidden] { display: none !important; }

.btn {
  font-family: var(--sans);
  font-size: 0.95rem;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s;
  letter-spacing: 0.03em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sage-deep); color: #fff; }
.btn-primary:hover { background: #5f7159; }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn.sm { padding: 0.35rem 0.9rem; font-size: 0.8rem; }
.linkbtn {
  background: none; border: none; color: var(--sage-deep);
  font: inherit; cursor: pointer; text-decoration: underline; padding: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.42em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.hint { font-size: 0.85rem; color: var(--muted); text-align: center; margin: 0.4rem 0 0; line-height: 1.5; }

/* ================= APP ================= */
.app {
  max-width: 1200px; margin: 0 auto;
  padding: 0 max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-right)) max(4rem, env(safe-area-inset-bottom)) max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-left));
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: max(1.4rem, env(safe-area-inset-top)) 0 1.4rem; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; position: sticky; top: 0; background: var(--cream);
  z-index: 20;
}
.brand { display: flex; flex-direction: column; }
.brand-names { font-family: var(--serif); font-size: 1.7rem; font-weight: 500; line-height: 1; }
.brand-sub { font-size: 0.72rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--muted); margin-top: 0.25rem; }

/* Dropzone */
.dropzone {
  margin-top: 1.6rem;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--white);
  padding: clamp(1.8rem, 5vw, 3rem);
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--sage); }
.dropzone:focus-visible { outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px rgba(156,175,149,0.25); }
.dropzone.drag { border-color: var(--sage-deep); background: #f2f5f0; transform: scale(1.005); }
.dz-icon {
  width: 58px; height: 58px; margin: 0 auto 0.8rem;
  display: grid; place-items: center; font-size: 1.6rem;
  border-radius: 50%; background: var(--cream-2); color: var(--sage-deep);
}
.dropzone h2 { font-family: var(--serif); font-weight: 500; font-size: 1.7rem; margin: 0 0 0.3rem; }
.dropzone p { margin: 0.2rem 0; color: var(--muted); }
.dz-formats { font-size: 0.85rem; }

/* Progress panel */
.progress-panel {
  margin-top: 1.4rem; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.pp-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pp-head strong { font-size: 1.05rem; }
.pp-eta { color: var(--muted); font-size: 0.9rem; margin-left: 0.5rem; }
.pp-stats { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.9rem; }
.pp-overall { height: 8px; background: var(--cream-2); border-radius: 999px; margin: 0.8rem 0; overflow: hidden; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--sage), var(--sage-deep)); border-radius: 999px; transition: width 0.25s ease; }
.pp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; max-height: 240px; overflow-y: auto; }
.pp-item { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.8rem; align-items: center; font-size: 0.88rem; }
.pp-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-item .state { color: var(--muted); font-variant-numeric: tabular-nums; }
.pp-item .mini { grid-column: 1 / -1; height: 5px; background: var(--cream-2); border-radius: 999px; overflow: hidden; }
.pp-item .mini > div { height: 100%; width: 0; background: var(--sage); transition: width 0.2s; }
.pp-item.done .state { color: var(--sage-deep); }
.pp-item.dup .state { color: var(--gold); }
.pp-item.err .state { color: var(--danger); }
.pp-hint { color: var(--muted); font-size: 0.82rem; margin: -0.2rem 0 0.6rem; }

/* Storage meter */
.meter-row { display: flex; align-items: center; gap: 0.8rem; margin: 1.4rem 0 0.4rem; }
.meter { flex: 1; height: 6px; background: var(--cream-2); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--blush); transition: width 0.4s ease; }
.meter-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

/* Gallery */
.gallery-section { margin-top: 2rem; }
.gallery-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }
.gallery-head h3 { font-family: var(--serif); font-weight: 500; font-size: 1.8rem; margin: 0; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.tile {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--cream-2); cursor: pointer; border: 1px solid var(--line);
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.35s ease; }
.tile:hover img { transform: scale(1.05); }
.tile .badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 0.72rem;
  padding: 2px 7px; border-radius: 999px; display: flex; align-items: center; gap: 4px;
}
.tile .play {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.tile .play span {
  width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,0.45);
  color: #fff; display: grid; place-items: center; font-size: 1.1rem;
}
.tile .noimg {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 0.8rem; text-align: center; padding: 0.5rem;
  font-family: var(--serif);
}
.empty { text-align: center; padding: 3rem 1rem; color: var(--ink); }
.empty .muted { color: var(--muted); }
.muted { color: var(--muted); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(28,25,22,0.94);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  /* dvh tracks the *visible* viewport, so the box shrinks with the mobile
     toolbar instead of hiding the photo's bottom edge behind it. */
  height: 100vh; height: 100dvh;
}
.lb-stage { display: grid; place-items: center; padding: 2vh 1vw; max-height: 100vh; }
.lb-stage img, .lb-stage video {
  max-width: 92vw; max-height: 86vh; border-radius: 8px; background: #000;
}
.lb-nav {
  background: rgba(255,255,255,0.08); color: #fff; border: none; cursor: pointer;
  font-size: 2.2rem; width: 64px; height: 100%; transition: background 0.2s;
}
.lb-nav:hover { background: rgba(255,255,255,0.16); }
.lb-close {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); z-index: 2;
  background: none; border: none; color: #fff; font-size: 2.4rem; cursor: pointer; line-height: 1;
}
.lb-delete {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); z-index: 2;
  background: rgba(255,255,255,0.1); color: #fff; border: none; cursor: pointer;
  font: inherit; font-size: 0.9rem; line-height: 1; padding: 8px 14px; border-radius: 999px;
  transition: background 0.2s;
}
.lb-delete:hover { background: rgba(255,255,255,0.18); }
.lb-delete.armed { background: #c0392b; }
.lb-caption {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  color: #f2ece3; font-size: 0.9rem; background: rgba(0,0,0,0.4);
  padding: 6px 14px; border-radius: 999px; max-width: 90vw;
  display: flex; align-items: baseline; min-width: 0;
}
/* Only the metadata ellipsizes, so a long date/filename can't clip the link. */
.lb-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Inline separator between metadata and the download link; hidden on mobile
   where the link stacks onto its own line. */
.lb-dl { color: inherit; text-decoration: underline; white-space: nowrap; flex: none; }
.lb-sep { white-space: pre; flex: none; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 0.8rem 1.4rem; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 200; font-size: 0.9rem; animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 640px) {
  .gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 7px; }
  /* Float the arrows over the photo as round tap targets: both stay on screen,
     and switching photos is a deliberate tap — never confused with pinch-zoom.
     Absolute positioning drops them out of the grid, so the image fills the
     screen edge-to-edge (empty auto columns collapse to 0). */
  .lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 44px; height: 44px; border-radius: 999px; display: grid;
    place-items: center; font-size: 1.9rem; background: rgba(0,0,0,0.4);
  }
  .lb-prev { left: max(8px, env(safe-area-inset-left)); }
  .lb-next { right: max(8px, env(safe-area-inset-right)); }
  .lb-stage { padding: 0; }
  /* Download drops to its own centered line — full tap target, never clipped. */
  .lb-caption { flex-direction: column; align-items: center; gap: 2px; }
  .lb-meta { max-width: 100%; }
  .lb-sep { display: none; }
  .lb-stage img, .lb-stage video { max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .topbar { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- iOS-native polish (progressive; inert where unsupported) ---- */

/* Frosted-glass chrome — only where the browser can actually blur, so
   everything else keeps the current solid fills. */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: rgba(247, 243, 238, 0.72);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
  }
  .lb-nav { background: rgba(40, 36, 32, 0.28); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
  .lb-delete:not(.armed) { background: rgba(40, 36, 32, 0.28); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
  .lb-caption { background: rgba(0, 0, 0, 0.28); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  /* Move sheet, cover picker, and right-click menu share the topbar's frosted
     treatment so overlay chrome feels native on iOS. */
  .move-panel { background: rgba(247, 243, 238, 0.82); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
  .cp-panel { background: rgba(247, 243, 238, 0.86); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
  .ctx-menu { background: rgba(255, 253, 250, 0.8); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px); }
}

/* Keep overlays from rubber-banding the page behind them into view. */
.lightbox, .move-panel, .cp-panel, .move-sheet, .cover-picker { overscroll-behavior: contain; }

/* Ease the tap-to-open morph on the iOS sheet curve (Safari View
   Transitions; inert in browsers without them). */
::view-transition-group(lb-media) {
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

/* Gentle slide-up as tiles scroll into view — CSS-only, GPU-driven, Safari
   26+. Transform-only on purpose: opacity is never animated, so a tile is
   always fully opaque even before it enters or if iOS momentum-scroll stalls
   the view() timeline mid-fling (which otherwise strands tiles invisible).
   Un-entered tiles just sit 14px low; the reduced-motion block neutralizes it. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .gallery .tile {
      animation: tile-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
    @keyframes tile-in {
      from { transform: translateY(14px) scale(0.985); }
      to   { transform: none; }
    }
  }
}

/* Album switch: the gallery view cross-fades and slides in the direction of
   travel, on the same sheet curve as the rest of the app. #album-view is named
   (and data-album-dir set) only for the duration of a switch — see app.js — so
   no other view transition (e.g. the lightbox) captures or flashes it. Inert
   without View Transitions; the reduced-motion path skips it in JS. */
@supports (view-transition-name: none) {
  ::view-transition-group(album-view),
  ::view-transition-old(album-view),
  ::view-transition-new(album-view) {
    animation-duration: 0.42s;
    animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
  }
  html[data-album-dir="fwd"]::view-transition-old(album-view)  { animation-name: album-out-up; }
  html[data-album-dir="fwd"]::view-transition-new(album-view)  { animation-name: album-in-up; }
  html[data-album-dir="back"]::view-transition-old(album-view) { animation-name: album-out-down; }
  html[data-album-dir="back"]::view-transition-new(album-view) { animation-name: album-in-down; }

  @keyframes album-out-up   { to   { opacity: 0; transform: translateY(-12px); } }
  @keyframes album-in-up    { from { opacity: 0; transform: translateY(16px);  } }
  @keyframes album-out-down { to   { opacity: 0; transform: translateY(12px);  } }
  @keyframes album-in-down  { from { opacity: 0; transform: translateY(-16px); } }
}

/* ================= ALBUMS ================= */

/* Upload page shell: an album rail beside the upload/gallery column. Single
   column by default (and whenever there are no albums); `.has-rail` switches on
   the sidebar grid at tablet/desktop widths. */
.layout { margin-top: 1.4rem; }
@media (min-width: 760px) {
  .layout.has-rail {
    display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 1.8rem; align-items: start;
  }
  /* Sticky under the sticky topbar so albums stay reachable while scrolling. */
  .layout.has-rail .rail { position: sticky; top: 5.4rem; }
}

.rail-head {
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 0.7rem; font-weight: 400;
}
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.rail-item {
  width: 100%; display: flex; align-items: center; gap: 0.7rem; cursor: pointer; text-align: left;
  padding: 0.4rem 0.5rem; border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--ink); font-family: var(--sans); font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s;
}
.rail-item:hover { background: var(--white); border-color: var(--line); }
.rail-item[aria-selected="true"] { background: var(--white); border-color: var(--sage); }
.rail-item.drop { background: #eef2ea; border-color: var(--sage-deep); border-style: dashed; }
.rail-cover {
  flex: none; width: 40px; height: 40px; border-radius: 9px; overflow: hidden;
  background: var(--cream-2); display: grid; place-items: center;
}
.rail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-count { flex: none; color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* Phone: the rail becomes a wrapping strip of pills above the dropzone — every
   album stays visible without horizontal scrolling. */
@media (max-width: 759px) {
  .rail-head { margin-bottom: 0.5rem; }
  .rail-list {
    flex-direction: row; flex-wrap: wrap; gap: 0.5rem;
  }
  .rail-item {
    flex: none; border-color: var(--line); background: var(--white);
    border-radius: 999px; padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  }
  /* Filled sage pill so the chosen album reads at a glance, not a faint border. */
  .rail-item[aria-selected="true"] {
    background: var(--sage); border-color: var(--sage-deep); color: var(--white); font-weight: 500;
  }
  .rail-cover { width: 30px; height: 30px; border-radius: 7px; }
  .rail-count { display: none; }
}

/* Being dragged to an album. */
.tile.dragging { opacity: 0.45; }
/* Dragging a whole selection dims every picked tile, not just the grabbed one. */
body.dragging-many .tile.selected { opacity: 0.45; }

/* ---- multi-select ------------------------------------------------------- */
/* A round checkbox in each tile's corner. Hidden until the tile is hovered
   (desktop) or selection mode is on (touch enters it via long-press), so the
   grid stays clean until you start picking. */
.tile-check {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, 0.28);
  display: none; place-items: center; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.tile-check::after { content: "\2713"; color: #fff; font-size: 0.95rem; line-height: 1; opacity: 0; }
.tile:hover .tile-check, body.selecting .tile-check { display: grid; }
.tile.selected .tile-check { background: var(--sage-deep); border-color: var(--sage-deep); }
.tile.selected .tile-check::after { opacity: 1; }
.tile.selected { outline: 3px solid var(--sage-deep); outline-offset: -3px; }
.tile.selected img { transform: none; } /* hold still while picked */
/* While selecting, a tap picks tiles rather than panning — keep the browser
   from stealing the gesture so drag-to-paint (touch) stays smooth. */
body.selecting .gallery { touch-action: pan-y; }

/* Selection action bar pinned to the top while picking. */
.sel-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  display: flex; align-items: center; gap: 0.6rem;
  padding: max(0.6rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.6rem max(1rem, env(safe-area-inset-left));
  background: var(--sage-deep); color: #fff; box-shadow: var(--shadow);
}
.sel-cancel {
  flex: none; background: none; border: none; color: #fff;
  font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 0 0.2rem;
}
.sel-count {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--sans); font-size: 1rem; font-variant-numeric: tabular-nums;
}
.sel-act {
  flex: none; cursor: pointer; font-family: var(--sans); font-size: 0.88rem; font-weight: 500;
  padding: 0.5rem 0.95rem; border-radius: 999px; border: none; background: #fff; color: var(--sage-deep);
}
.sel-act:disabled { opacity: 0.5; cursor: default; }


/* Move affordances: desktop right-click menu + mobile bottom sheet. */
.ctx-menu {
  position: fixed; z-index: 60; list-style: none; margin: 0; padding: 0.3rem;
  min-width: 170px; background: var(--white); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.ctx-item {
  width: 100%; text-align: left; cursor: pointer; border: 0; background: transparent;
  font-family: var(--sans); font-size: 0.92rem; color: var(--ink);
  padding: 0.5rem 0.7rem; border-radius: 8px;
}
.ctx-item:hover:not(:disabled) { background: var(--cream-2); }
.ctx-item.current { color: var(--muted); cursor: default; }
.ctx-item.current::after { content: " \2713"; color: var(--sage-deep); }
.ctx-sep { height: 1px; margin: 0.3rem 0.4rem; background: var(--line); }
.ctx-heading {
  padding: 0.35rem 0.7rem 0.15rem; font-family: var(--sans);
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}

.move-sheet { position: fixed; inset: 0; z-index: 60; }
.move-scrim { position: absolute; inset: 0; background: rgba(58,53,47,0.35); opacity: 0; transition: opacity 0.2s; }
.move-sheet.open .move-scrim { opacity: 1; }
.move-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--cream); border-radius: 18px 18px 0 0; padding: 0.6rem 1rem max(1.2rem, env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s cubic-bezier(0.32,0.72,0,1);
  max-height: 70vh; overflow-y: auto;
}
.move-sheet.open .move-panel { transform: translateY(0); }
.move-title {
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  text-align: center; padding: 0.7rem 0 0.5rem;
}
.move-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.move-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  cursor: pointer; text-align: left; font-family: var(--sans); font-size: 1.05rem; color: var(--ink);
  padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white);
}
.move-item:active:not(:disabled) { background: var(--cream-2); }
.move-item.current { color: var(--muted); background: var(--cream-2); cursor: default; }
.move-item-tag { font-size: 0.78rem; color: var(--muted); }
.pills {
  display: flex; gap: 0.5rem; flex: 1; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; scroll-snap-align: start; white-space: nowrap; cursor: pointer;
  font-family: var(--sans); font-size: 0.9rem; padding: 0.5rem 1rem; min-height: 40px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pill:hover { border-color: var(--sage); }
.pill[aria-checked="true"], .pill[aria-selected="true"] {
  background: var(--sage-deep); border-color: var(--sage-deep); color: #fff;
}

.dz-target { font-size: 0.9rem; color: var(--sage-deep); margin-top: 0.6rem; }
.dz-target strong { font-weight: 500; }

/* Gallery: album tabs under the heading; download button beside it. */
.gallery-head { flex-wrap: wrap; gap: 0.5rem 1rem; }
.gallery-head .dl-btn { flex: none; white-space: nowrap; text-decoration: none; }
.gallery-section .tabs { margin: 0 0 1rem; }

/* Guest page: a small, unobtrusive sort dropdown above the grids. */
.main .sort { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin: 0.2rem 0 1.1rem; }
.sort-label { font-size: 0.8rem; color: var(--muted); }
.sort-select {
  font-family: var(--sans); font-size: 0.85rem; color: var(--ink); cursor: pointer;
  padding: 0.35rem 1.9rem 0.35rem 0.7rem; min-height: 34px;
  border: 1px solid var(--line); border-radius: 8px; background-color: var(--white);
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.65rem center; background-size: 10px;
}
.sort-select:hover { border-color: var(--sage); }
.sort-select:focus-visible { outline: 2px solid var(--sage); outline-offset: 1px; }

/* ---- /albums manager ---- */
.albums-intro { max-width: 60ch; margin: 1.4rem 0 1.2rem; line-height: 1.6; }
.album-create { display: flex; gap: 0.6rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.album-create input {
  flex: 1; min-width: 0; font-family: var(--sans); font-size: 16px; /* >=16px: no iOS focus zoom */
  padding: 0.7rem 1rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--white); color: var(--ink);
}
.album-create input:focus { outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px rgba(156,175,149,0.25); }
.album-create .btn { flex: none; }

.album-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.album-item {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white);
}
.ai-name {
  flex: 1 1 12rem; min-width: 0; font-family: var(--serif); font-size: 1.3rem; font-weight: 500; color: var(--ink);
  border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 0.3rem 0.5rem;
}
.ai-name:focus { outline: none; border-color: var(--sage); background: var(--cream); }
.ai-meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.ai-note { font-size: 0.8rem; white-space: nowrap; }
.ai-actions { display: flex; gap: 0.4rem; margin-left: auto; }
.iconbtn {
  min-width: 40px; min-height: 40px; padding: 0 0.7rem; cursor: pointer;
  font-family: var(--sans); font-size: 0.85rem; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.iconbtn:hover:not(:disabled) { border-color: var(--muted); color: var(--ink); }
.iconbtn:disabled { opacity: 0.4; cursor: default; }
.iconbtn.danger:not(:disabled):hover { border-color: var(--danger); color: var(--danger); }
.iconbtn.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Empty-album note inside a gallery grid spans the full width. */
.album-empty { grid-column: 1 / -1; padding: 1.4rem 0; }

/* /albums: per-album cover thumbnail (opens the picker) + the picker overlay. */
.ai-cover {
  position: relative; flex: none; width: 52px; height: 52px; padding: 0; cursor: pointer; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: var(--cream-2);
  display: grid; place-items: center; color: var(--muted); font-size: 0.68rem; font-family: var(--sans);
}
.ai-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-cover:hover { border-color: var(--sage); }
/* Always-visible "Change" bar so the thumbnail reads as a control on any device. */
.ai-cover-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0; text-align: center;
  font-size: 0.6rem; letter-spacing: 0.06em; line-height: 1.2;
  color: #fff; background: rgba(0, 0, 0, 0.55);
}
.ai-cover:hover .ai-cover-label { background: var(--sage-deep); }
/* Empty album: a dashed placeholder that still invites a tap (which explains
   photos are needed first) rather than a dead grey square. */
.ai-cover.empty {
  border-style: dashed; text-transform: uppercase; letter-spacing: 0.1em;
}

.cover-picker { position: fixed; inset: 0; z-index: 60; }
.cp-scrim { position: absolute; inset: 0; background: rgba(58,53,47,0.4); opacity: 0; transition: opacity 0.2s; }
.cover-picker.open .cp-scrim { opacity: 1; }
.cp-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%);
  width: min(680px, 92vw); max-height: 84vh; overflow-y: auto;
  background: var(--cream); border-radius: 16px; box-shadow: var(--shadow);
  padding: 1rem 1.2rem 1.4rem; opacity: 0; transition: opacity 0.2s, transform 0.2s;
}
.cover-picker.open .cp-panel { opacity: 1; transform: translate(-50%, -50%); }
.cp-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.cp-title { font-family: var(--serif); font-size: 1.4rem; font-weight: 500; }
.cp-actions { display: flex; gap: 0.4rem; }
.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cp-cell {
  position: relative; aspect-ratio: 1; padding: 0; cursor: pointer; overflow: hidden;
  border: 2px solid transparent; border-radius: 10px; background: var(--cream-2);
}
.cp-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-cell:hover { border-color: var(--sage); }
.cp-cell.chosen { border-color: var(--sage-deep); }
.cp-cell.chosen::after {
  content: "\2713"; position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--sage-deep); color: #fff;
  display: grid; place-items: center; font-size: 0.8rem;
}
.cp-empty { padding: 1.4rem 0; text-align: center; }

@media (max-width: 640px) {
  .ai-actions { width: 100%; margin-left: 0; }
  .ai-note { display: none; }
}

/* Header download button + its picker modal (choose all / one album). */
.dl-btn-header { flex: none; white-space: nowrap; text-decoration: none; }

.dl-modal { position: fixed; inset: 0; z-index: 80; }
.dl-scrim { position: absolute; inset: 0; background: rgba(58,53,47,0.4); opacity: 0; transition: opacity 0.2s; }
.dl-modal.open .dl-scrim { opacity: 1; }
.dl-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%);
  width: min(440px, 92vw); max-height: 84vh; overflow-y: auto;
  background: var(--cream); border-radius: 16px; box-shadow: var(--shadow);
  padding: 1rem 1.2rem 1.4rem; opacity: 0; transition: opacity 0.2s, transform 0.2s;
}
.dl-modal.open .dl-panel { opacity: 1; transform: translate(-50%, -50%); }
.dl-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.dl-title { font-family: var(--serif); font-size: 1.4rem; font-weight: 500; }
.dl-close { background: none; border: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0; }
.dl-close:hover { color: var(--ink); }
.dl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dl-sep { height: 1px; margin: 0.2rem 0.2rem; background: var(--line); }
.dl-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  cursor: pointer; text-align: left; font-family: var(--sans); color: var(--ink);
  padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white);
  transition: border-color 0.15s, background 0.15s;
}
.dl-item:hover { border-color: var(--sage); }
.dl-item:active { background: var(--cream-2); }
.dl-item-label { display: flex; flex-direction: column; gap: 0.2rem; }
.dl-item-name { font-size: 1.05rem; }
.dl-item-meta { font-size: 0.82rem; color: var(--muted); }

.dl-progress { display: flex; flex-direction: column; gap: 0.9rem; padding: 0.4rem 0; }
.dl-progress-bar { height: 8px; border-radius: 999px; background: var(--cream-2); overflow: hidden; }
.dl-progress-bar > div { height: 100%; width: 0; background: var(--sage-deep); border-radius: 999px; transition: width 0.2s; }
.dl-progress-text { margin: 0; font-size: 0.9rem; color: var(--ink); text-align: center; }
.dl-progress .btn { align-self: center; }
