/* Album design system. Three token layers: primitive -> semantic -> component. Dark, photo-first, one warm accent. */
:root {
  /* primitive */
  --ink-950: #0b0908; --ink-900: #110e0c; --ink-800: #1a1613; --ink-700: #26201c; --ink-600: #3a322c;
  --sand-500: #9f9488; --sand-300: #cdc2b4; --sand-100: #f5eee5;
  --ember-400: #f2a064; --ember-500: #e8853d; --ember-600: #c56a26;
  --leaf-400: #7cc596; --rose-400: #f0796c;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --r-1: 8px; --r-2: 14px; --r-3: 22px; --r-full: 999px;
  --t-fast: 140ms; --t-mid: 240ms; --ease-out: cubic-bezier(.2,.8,.2,1); --ease-in: cubic-bezier(.5,0,.9,.4);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* semantic */
  --bg: var(--ink-900); --surface: var(--ink-800); --surface-2: var(--ink-700); --line: var(--ink-600);
  --text: var(--sand-100); --text-2: var(--sand-300); --text-3: var(--sand-500);
  --accent: var(--ember-500); --accent-hover: var(--ember-400); --accent-press: var(--ember-600); --on-accent: var(--ink-950);
  --ok: var(--leaf-400); --bad: var(--rose-400); --focus: var(--ember-400); --scrim: rgba(6,5,4,.72);
  /* component */
  --btn-h: 52px; --chip-h: 44px; --tile-gap: 3px; --dock-h: calc(var(--btn-h) + var(--s-4) * 2);
  --z-top: 10; --z-dock: 20; --z-tray: 30; --z-overlay: 40; --z-sheet: 60; --z-toast: 80;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 17px/1.5 var(--font-body); min-height: 100dvh;
  padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + var(--s-4)); -webkit-tap-highlight-color: transparent; }
body.locked { overflow: hidden; }
h1, h2 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 7vw, 40px); line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.2; }
p { margin: 0; }
button, a { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.big { width: 56px; height: 56px; stroke-width: 1.5; color: var(--text-3); }
.skip { position: absolute; left: var(--s-4); top: -60px; background: var(--accent); color: var(--on-accent); padding: var(--s-2) var(--s-4); border-radius: var(--r-1); z-index: 100; }
.skip:focus { top: var(--s-4); }
.eyebrow { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }

/* header */
.top { position: sticky; top: 0; z-index: var(--z-top); background: linear-gradient(var(--bg) 78%, transparent); padding: calc(env(safe-area-inset-top) + var(--s-4)) var(--s-4) var(--s-3); }
.top-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); max-width: 1180px; margin: 0 auto; }
.count { color: var(--text-2); font-size: 15px; white-space: nowrap; padding-bottom: 4px; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: var(--s-2); margin: var(--s-4) auto 0; max-width: 1180px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { height: var(--chip-h); padding: 0 var(--s-4); border-radius: var(--r-full); border: 1px solid var(--line); background: transparent; color: var(--text-2); white-space: nowrap; transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out); }
.chip:hover { border-color: var(--sand-500); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--sand-100); border-color: var(--sand-100); color: var(--ink-950); font-weight: 700; }

.banner { display: flex; gap: var(--s-3); align-items: center; margin: 0 var(--s-4) var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-2); background: var(--surface-2); color: var(--text); font-size: 15px; }
.banner .ic { color: var(--accent); }

/* grid */
main#grid { max-width: 1180px; margin: 0 auto; outline: none; }
.day { padding: var(--s-5) var(--s-4) var(--s-2); color: var(--text-2); font-size: 15px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--tile-gap); }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 0 var(--s-4); } }
.tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: var(--surface); overflow: hidden; display: block; width: 100%; }
@media (min-width: 900px) { .tile { border-radius: var(--r-1); } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity var(--t-mid) var(--ease-out), transform var(--t-fast) var(--ease-out); }
.tile img.in { opacity: 1; }
.tile:active img { transform: scale(.97); }
.tile.wait::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.06) 50%, transparent 70%); background-size: 220% 100%; animation: shimmer 1.6s linear infinite; }
.tile.wait::after { content: 'Getting ready'; position: absolute; left: 0; right: 0; bottom: var(--s-2); text-align: center; font-size: 12px; color: var(--text-3); }
.tile.hid img { opacity: .35 !important; }
.badge { position: absolute; display: flex; align-items: center; gap: 4px; height: 24px; padding: 0 var(--s-2); border-radius: var(--r-full); background: rgba(6,5,4,.66); color: var(--sand-100); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge .ic { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.badge.vid { right: 6px; bottom: 6px; }
.badge.star { left: 6px; top: 6px; background: var(--accent); color: var(--on-accent); }
@keyframes shimmer { to { background-position: -220% 0; } }

.empty { text-align: center; padding: var(--s-7) var(--s-5); max-width: 420px; margin: 0 auto; display: grid; gap: var(--s-3); justify-items: center; }
.empty p { color: var(--text-2); }

/* dock + buttons */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-dock); display: flex; gap: var(--s-3); justify-content: center; padding: var(--s-4) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 34%); }
.btn { height: var(--btn-h); display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); padding: 0 var(--s-5); border-radius: var(--r-full); border: 1px solid transparent; font-weight: 700; white-space: nowrap; text-decoration: none; transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); flex: 1; max-width: 420px; box-shadow: 0 10px 30px rgba(232,133,61,.22); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: var(--accent-press); }
.btn.quiet { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.quiet:hover { border-color: var(--sand-500); }
.btn.small { height: 44px; padding: 0 var(--s-4); font-size: 15px; background: rgba(245,238,229,.12); color: var(--sand-100); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
@media (max-width: 380px) { .btn.quiet span { display: none; } .btn.quiet { padding: 0; width: var(--btn-h); } }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: var(--r-full); background: rgba(6,5,4,.5); color: var(--sand-100); transition: background var(--t-fast) var(--ease-out); }
.icon-btn:hover { background: rgba(245,238,229,.16); }

/* upload tray */
.tray { position: fixed; left: var(--s-3); right: var(--s-3); bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); z-index: var(--z-tray); max-width: 520px; margin: 0 auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-3) var(--s-4) var(--s-4); box-shadow: 0 18px 50px rgba(0,0,0,.5); animation: rise var(--t-mid) var(--ease-out); }
.tray-head { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); background: none; border: 0; padding: 0; font-weight: 700; text-align: left; }
.tray-head .chev { transition: transform var(--t-mid) var(--ease-out); color: var(--text-2); }
.tray-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.bar { height: 6px; border-radius: var(--r-full); background: var(--ink-600); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: inherit; transform-origin: left; transform: scaleX(0); transition: transform var(--t-mid) linear; }
.tray.done .bar i { background: var(--ok); }
.tray-note { color: var(--text-2); font-size: 14px; margin-top: var(--s-2); }
.tray-list { list-style: none; margin: var(--s-3) 0 0; padding: 0; max-height: 38dvh; overflow-y: auto; display: grid; gap: var(--s-3); }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3); align-items: center; }
.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.row .st { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.row.ok .st { color: var(--ok); } .row.bad .st { color: var(--bad); grid-column: 1 / -1; white-space: normal; }
.row .bar { grid-column: 1 / -1; height: 4px; }
.row .retry { height: 36px; padding: 0 var(--s-3); border-radius: var(--r-full); border: 1px solid var(--line); background: none; font-size: 14px; font-weight: 700; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

/* viewer */
.viewer, .reel { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--ink-950); animation: fade var(--t-mid) var(--ease-out); }
@keyframes fade { from { opacity: 0; } }
.v-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: var(--s-3); padding: calc(env(safe-area-inset-top) + var(--s-3)) var(--s-3) var(--s-5); background: linear-gradient(rgba(6,5,4,.7), transparent); }
.v-meta { flex: 1; text-align: center; font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-stage { position: absolute; inset: 0; display: grid; place-items: center; touch-action: pan-y pinch-zoom; }
.v-stage img, .v-stage video { max-width: 100%; max-height: 100dvh; object-fit: contain; animation: pop var(--t-mid) var(--ease-out); }
.v-stage video { width: 100%; background: #000; }
@keyframes pop { from { opacity: 0; transform: scale(.98); } }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 48px; height: 72px; display: grid; place-items: center; border: 0; background: rgba(6,5,4,.4); color: var(--sand-100); }
.v-nav.prev { left: 0; border-radius: 0 var(--r-2) var(--r-2) 0; } .v-nav.next { right: 0; border-radius: var(--r-2) 0 0 var(--r-2); }
.v-nav[disabled] { opacity: 0; pointer-events: none; }
@media (hover: none) { .v-nav { display: none; } }
.v-owner { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; padding: var(--s-5) var(--s-3) calc(env(safe-area-inset-bottom) + var(--s-4)); background: linear-gradient(transparent, rgba(6,5,4,.8)); }

/* reel */
.r-bars { position: absolute; top: calc(env(safe-area-inset-top) + var(--s-2)); left: var(--s-3); right: var(--s-3); z-index: 3; display: flex; gap: 3px; }
.r-bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(245,238,229,.28); overflow: hidden; }
.r-bars i b { display: block; height: 100%; background: var(--sand-100); transform-origin: left; transform: scaleX(0); }
.r-bars i.past b { transform: scaleX(1); }
.r-bars i.now b { animation: fill var(--dur, 3.5s) linear forwards; }
.reel.paused .r-bars i.now b, .reel.paused .r-stage .kb { animation-play-state: paused; }
@keyframes fill { to { transform: scaleX(1); } }
.r-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.r-stage img, .r-stage video { width: 100%; height: 100%; object-fit: contain; }
.r-stage .kb { animation: kb var(--dur, 3.5s) linear forwards; }
@keyframes kb { from { transform: scale(1); } to { transform: scale(1.07); } }
.r-top { position: absolute; top: calc(env(safe-area-inset-top) + var(--s-4)); left: var(--s-3); right: var(--s-3); z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.r-title { font-family: var(--font-display); font-size: 18px; text-shadow: 0 1px 12px rgba(0,0,0,.7); }
.r-zone { position: absolute; top: 80px; bottom: 0; width: 34%; z-index: 3; background: none; border: 0; }
.r-zone.left { left: 0; } .r-zone.right { right: 0; width: 66%; }
.r-hint { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + var(--s-5)); z-index: 2; text-align: center; font-size: 14px; color: var(--text-2); text-shadow: 0 1px 10px rgba(0,0,0,.8); transition: opacity var(--t-mid) var(--ease-in); pointer-events: none; }
.r-hint.gone { opacity: 0; }

/* sheet + toast */
.sheet-wrap { position: fixed; inset: 0; z-index: var(--z-sheet); background: var(--scrim); display: grid; align-items: end; animation: fade var(--t-fast) var(--ease-out); }
.sheet { background: var(--surface-2); border-radius: var(--r-3) var(--r-3) 0 0; padding: var(--s-5) var(--s-5) calc(var(--s-5) + env(safe-area-inset-bottom)); display: grid; gap: var(--s-3); max-width: 520px; width: 100%; margin: 0 auto; animation: rise var(--t-mid) var(--ease-out); }
.sheet p { color: var(--text-2); }
.sheet-row { display: flex; gap: var(--s-3); margin-top: var(--s-3); } .sheet-row .btn { flex: 1; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + var(--s-4)); z-index: var(--z-toast); background: var(--sand-100); color: var(--ink-950); padding: var(--s-3) var(--s-5); border-radius: var(--r-full); font-weight: 700; font-size: 15px; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: rise var(--t-mid) var(--ease-out); }

/* plain page */
.plain { padding: 0; display: grid; place-items: center; }
.lone { max-width: 440px; padding: var(--s-6) var(--s-5); display: grid; gap: var(--s-3); }
.lone p:last-child { color: var(--text-2); }

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .r-bars i.now b { animation-duration: var(--dur, 3.5s) !important; }
  .r-stage .kb { animation: none !important; }
}
