/* Palmi Photos — warm editorial: Instrument Serif display, Geist UI,
   one terracotta accent on paper. Photos carry the colour. */

@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/instrument-serif-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("/static/fonts/instrument-serif-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/geist-latin-wght-normal.woff2") format("woff2"); }

:root {
  --bg: #f4f1ea; --bg-deep: #ebe6dc; --surface: #fbf9f5; --text: #221e19; --muted: #6f675d;
  --faint: #a39a8e; --line: #e2dcd0; --accent: #a8532f; --accent-hover: #934626; --accent-text: #fdf8f3;
  --accent-soft: #f1e2d8; --danger: #a3352b; --ok: #3f6b45; --tile: #e6e0d4;
  --shadow-sm: 0 1px 2px rgb(70 50 30 / .07);
  --shadow: 0 1px 2px rgb(70 50 30 / .06), 0 8px 24px -8px rgb(70 50 30 / .14);
  --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --ui: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --r-sm: 6px; --r: 10px; --r-lg: 18px;
  --z-sticky: 10; --z-header: 20; --z-fab: 30; --z-overlay: 50; --z-toast: 60;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --row: 210px;   /* gallery row height */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412; --bg-deep: #100f0d; --surface: #1f1c19; --text: #ece6dc; --muted: #a0978a;
    --faint: #6f675d; --line: #2e2a25; --accent: #d58c66; --accent-hover: #e29d78; --accent-text: #1b120c;
    --accent-soft: #33241b; --danger: #e88a7f; --ok: #8fbf92; --tile: #27231f;
    --shadow-sm: none; --shadow: 0 10px 30px -12px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg);
  color: var(--text); font: 16px/1.55 var(--ui); font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased; }
/* Paper grain: fixed, non-interactive, very faint */
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) { body::before { opacity: .5; mix-blend-mode: screen; } }
body.noscroll { overflow: hidden; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2 { font-family: var(--display); font-weight: 400; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.02; margin: 0 0 .5rem; }
h2 { font-size: 1.65rem; line-height: 1.1; margin: 0 0 .75rem; }
h1 em, h2 em { color: var(--accent); }
p { text-wrap: pretty; }
.muted { color: var(--muted); }
.small, small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.tight { margin: 0; }
.signout { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 600px) { .hide-phone { display: none; } }
.skip { position: absolute; left: 16px; top: -48px; z-index: var(--z-toast); background: var(--text);
  color: var(--bg); padding: 8px 14px; border-radius: var(--r-sm); }
.skip:focus { top: 12px; }

/* --- header & footer ----------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: var(--z-header);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-family: var(--display);
  font-size: 1.35rem; line-height: 1; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.brand, .topbar nav a, .topbar nav button { white-space: nowrap; }
.topbar nav { display: flex; align-items: center; gap: 4px; font-size: .9rem; }
.topbar nav > a, .topbar nav button.link { color: var(--muted); padding: 6px 10px; border-radius: var(--r-sm);
  transition: background .2s var(--ease), color .2s var(--ease); }
.topbar nav > a:hover, .topbar nav button.link:hover { color: var(--text); background: var(--bg-deep); text-decoration: none; }
.topbar nav > a.current { color: var(--text); font-weight: 550; }
.lang { display: inline-flex; margin-right: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 2px; }
.lang a { color: var(--faint); padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600;
  letter-spacing: .04em; }
.lang a:hover { text-decoration: none; color: var(--text); }
.lang a.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
@media (max-width: 520px) { .topbar { padding-left: 16px; padding-right: 12px; }
  .topbar nav .logout { display: none; }
  .topbar nav { min-width: 0; }
  .topbar nav .who { min-width: 3em; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
  .brand { flex-shrink: 0; }
  .topbar nav > a, .topbar nav button.link { padding: 6px 7px; } }
@media (max-width: 360px) { .brand span { display: none; } }

.footer { margin-top: auto; padding: 28px 20px calc(28px + env(safe-area-inset-bottom)); color: var(--faint);
  font-size: .82rem; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* --- page frame ---------------------------------------------------------- */
main { width: 100%; margin: 0 auto; padding: 32px 20px 72px; }
main.narrow { max-width: 520px; padding-top: 48px; }
main.wide { max-width: 1320px; }
main.bleed { max-width: none; padding: 0 0 72px; }

/* Panels: no border, a quiet surface; only overlays get real elevation */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 28px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm); }
.card.center { text-align: center; }
.card > h1:first-child { font-size: 2.3rem; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > .btn { align-self: flex-start; }
.stack > .btn.block { align-self: stretch; }
.card form + h2, .card .rows + h2 { margin-top: 30px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.inline { display: inline; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 550; font-size: .92rem; }
label .muted, label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; font-size: 1rem; cursor: pointer; }
fieldset { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 550; font-size: .92rem; margin-bottom: 8px; }
input, textarea, select { font: inherit; font-weight: 400; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; width: 100%;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
input:hover, textarea:hover { border-color: var(--faint); }
input:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); }
input:disabled { color: var(--muted); }
details summary { cursor: pointer; color: var(--accent); font-size: .9rem; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "+ "; }
details[open] summary::before { content: "− "; }
details[open] summary { margin-bottom: 12px; }

/* Album type: segmented radio pair; the end date and "Start" label only for trips */
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px;
  background: var(--bg-deep); border-radius: 11px; margin-bottom: 14px; }
.segmented label { position: relative; display: block; cursor: pointer; font-weight: 550; font-size: .92rem; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; text-align: center; padding: 8px 16px; border-radius: 8px; color: var(--muted);
  transition: background .2s var(--ease), color .2s var(--ease); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.event-kind .when-trip, .event-kind:has(input[value=day]:checked) .end-date { display: none; }
.event-kind:has(input[value=trip]:checked) .when-trip { display: inline; }
.event-kind:has(input[value=trip]:checked) .when-day { display: none; }

/* --- buttons ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit;
  font-weight: 550; font-size: .92rem; line-height: 1; padding: 11px 16px; border-radius: var(--r);
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .12s var(--ease), box-shadow .2s var(--ease); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { text-decoration: none; border-color: var(--faint); background: var(--bg); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  box-shadow: 0 1px 0 rgb(255 255 255 / .15) inset, 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--bg-deep); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 8px 12px; font-size: .84rem; }
.btn.large { padding: 15px 22px; font-size: 1rem; }
.btn.block { width: 100%; }
button.link { background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.link:hover { text-decoration: underline; text-underline-offset: 3px; }
button.link.danger, .danger { color: var(--danger); }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); margin: 18px 0; font-size: .8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* --- messages -------------------------------------------------------------- */
.alert, .notice { padding: 11px 14px; border-radius: var(--r); font-size: .92rem; }
.alert { background: color-mix(in srgb, var(--danger) 11%, transparent); color: var(--danger); }
.notice { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.tag { font-size: .72rem; font-weight: 600; letter-spacing: .03em; color: var(--accent);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: var(--z-toast);
  transform: translate(-50%, 12px); opacity: 0; background: var(--text); color: var(--bg); padding: 11px 18px;
  border-radius: var(--r); font-size: .9rem; box-shadow: var(--shadow); pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- empty states ---------------------------------------------------------- */
.empty { text-align: center; padding: 56px 20px 64px; max-width: 420px; margin: 0 auto; }
.empty .frames { display: flex; justify-content: center; margin-bottom: 22px; }
.empty .frames span { width: 64px; height: 80px; border-radius: 6px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); margin: 0 -10px; }
.empty .frames span:nth-child(1) { transform: rotate(-8deg) translateY(6px); }
.empty .frames span:nth-child(2) { transform: translateY(-4px); background: var(--accent-soft); z-index: 1; }
.empty .frames span:nth-child(3) { transform: rotate(7deg) translateY(8px); }
.empty h2 { margin-bottom: .4rem; }
.empty p { color: var(--muted); margin: 0 0 20px; }

/* --- lists (admin, settings) ---------------------------------------------- */
.rows { list-style: none; padding: 0; margin: 14px 0 4px; }
.rows li { padding: 11px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap;
  gap: 4px 12px; align-items: baseline; }
.rows li .push { margin-left: auto; display: flex; gap: 14px; }
.rows li.blocked { opacity: .5; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 18px; align-items: start; }
.meter { height: 6px; background: var(--bg-deep); border-radius: 99px; overflow: hidden; margin: 6px 0 8px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.danger-zone { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent); }
.back svg { width: 16px; height: 16px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; margin-bottom: 16px; }
.back:hover { color: var(--text); text-decoration: none; }

/* --- landing ---------------------------------------------------------------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 56px; align-items: center;
  padding: 56px 0 40px; }
.hero h1 { font-size: clamp(3rem, 7vw, 5.4rem); line-height: .95; letter-spacing: -.02em; margin-bottom: 22px; }
.hero .lead { font-size: 1.18rem; color: var(--muted); max-width: 34ch; margin: 0 0 30px; }
.hero .points { list-style: none; padding: 0; margin: 0 0 34px; display: grid; gap: 12px; max-width: 42ch; }
.hero .points li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.hero .points svg { width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.stackshot { position: relative; aspect-ratio: 1 / 1; max-width: 480px; justify-self: center; width: 100%; }
.stackshot figure { position: absolute; margin: 0; padding: 10px 10px 34px; background: #fbf9f5;
  border-radius: 4px; box-shadow: 0 2px 4px rgb(60 40 20 / .1), 0 22px 44px -16px rgb(60 40 20 / .35); }
.stackshot figure div { width: 100%; height: 100%; border-radius: 2px; }
.stackshot figcaption { position: absolute; left: 12px; bottom: 9px; font: italic 1.02rem var(--display); color: #5b5248; }
.stackshot .f1 { width: 58%; height: 62%; left: 2%; top: 10%; transform: rotate(-7deg); }
.stackshot .f1 div { background: radial-gradient(circle at 70% 75%, #6d3a52 0 18%, transparent 19%),
  radial-gradient(circle at 30% 85%, #8a4a3a 0 22%, transparent 23%), linear-gradient(#f2a65a, #b8647a 70%, #5a3c6e); }
.stackshot .f2 { width: 52%; height: 58%; right: 0; top: 0; transform: rotate(5deg); }
.stackshot .f2 div { background: radial-gradient(circle at 25% 80%, #20363f 0 20%, transparent 21%),
  radial-gradient(circle at 75% 70%, #2d4a3c 0 26%, transparent 27%), linear-gradient(#a9c6d6, #5f8aa3 60%, #2a4458); }
.stackshot .f3 { width: 56%; height: 54%; left: 24%; bottom: 0; transform: rotate(-1.5deg); }
.stackshot .f3 div { background: radial-gradient(circle at 60% 60%, #7a3b2a 0 24%, transparent 25%),
  radial-gradient(circle at 20% 90%, #5e3a26 0 20%, transparent 21%), linear-gradient(#f3dcc0, #d9a476 55%, #8f5a3c); }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 24px; }
  .stackshot { max-width: 340px; order: -1; }
}

/* --- home: album list ----------------------------------------------------- */
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { margin: 0; }
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 28px 22px; }
.album-card { color: var(--text); display: block; }
.album-card:hover { text-decoration: none; }
.album-card .cover { aspect-ratio: 4 / 3; background: var(--tile); border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-sm); }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--ease); }
.album-card:hover .cover img { transform: scale(1.035); }
.album-card .meta { padding: 12px 2px 0; display: flex; flex-direction: column; gap: 2px; }
.album-card strong { font: 400 1.45rem/1.15 var(--display); }
.album-card .meta span { font-size: .86rem; }

/* --- album hero ------------------------------------------------------------ */
.album-hero { position: relative; min-height: min(56vh, 520px); display: flex; align-items: flex-end;
  color: #fbf6ef; overflow: hidden; background: #2a231d; }
.album-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.album-hero::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(20 14 10 / .1) 30%, rgb(20 14 10 / .72) 100%); }
.album-hero.plain { min-height: 0; background: none; color: var(--text); }
.album-hero.plain::after { display: none; }
.album-hero .inner { position: relative; z-index: 1; width: 100%; max-width: 1320px; margin: 0 auto;
  padding: 72px 20px 30px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.album-hero.plain .inner { padding-top: 36px; padding-bottom: 8px; }
.album-hero h1 { font-size: clamp(2.6rem, 6.5vw, 4.6rem); margin: 0 0 8px; max-width: 18ch; }
.album-hero .when { font-size: .95rem; opacity: .88; }
.album-hero .description { white-space: pre-line; max-width: 58ch; margin: 10px 0 0; opacity: .92; }
.album-hero .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.album-hero:not(.plain) .btn { background: rgb(255 255 255 / .14); border-color: rgb(255 255 255 / .22); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.album-hero:not(.plain) .btn:hover { background: rgb(255 255 255 / .24); }
.album-body { max-width: 1320px; margin: 0 auto; padding: 28px 20px 0; }

/* --- join + upload --------------------------------------------------------- */
.join { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 28px; align-items: center; }
.join h2 { font-size: 2rem; }
.join p { margin: 0; }
@media (max-width: 760px) { .join { grid-template-columns: 1fr; gap: 18px; } }
.uploader { margin-bottom: 26px; }
.dropzone { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 18px 20px;
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer;
  border: 1.5px dashed transparent; font-weight: 400; font-size: 1rem;
  transition: border-color .2s var(--ease), background .2s var(--ease); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.dropzone .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.dropzone .icon svg { width: 24px; height: 24px; }
.dropzone .text { display: flex; flex-direction: column; gap: 2px; }
.dropzone strong { font-weight: 600; }
.dropzone .text span { font-size: .87rem; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
@media (max-width: 600px) { .dropzone { grid-template-columns: auto 1fr; } .dropzone .btn { display: none; } }
.uploader .foot { margin: 10px 4px 0; font-size: .82rem; color: var(--muted); }
.queue { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.queue li { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: .86rem;
  background: var(--surface); border-radius: var(--r); padding: 10px 12px; }
.queue .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .state { color: var(--muted); font-variant-numeric: tabular-nums; }
.queue progress { grid-column: 1 / -1; width: 100%; height: 3px; appearance: none; border: none; border-radius: 99px;
  background: var(--bg-deep); overflow: hidden; }
.queue progress::-webkit-progress-bar { background: var(--bg-deep); }
.queue progress::-webkit-progress-value { background: var(--accent); transition: width .3s var(--ease); }
.queue progress::-moz-progress-bar { background: var(--accent); }
.queue li.done .state { color: var(--ok); }
.queue li.dup .state { color: var(--faint); }
.queue li.error .state { color: var(--danger); }

/* Phone: the upload action stays under the thumb */
.fab { display: none; }
@media (max-width: 600px) {
  .fab { display: inline-flex; flex-direction: row; position: fixed; z-index: var(--z-fab); left: 16px; right: 16px;
    bottom: calc(14px + env(safe-area-inset-bottom)); padding: 16px; font-size: 1rem; border-radius: 14px;
    box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--accent) 70%, transparent), var(--shadow); }
  .has-fab main { padding-bottom: 110px; }
  .has-fab .footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* --- gallery ---------------------------------------------------------------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 4px; }
.tabs { display: inline-flex; gap: 2px; background: var(--bg-deep); padding: 3px; border-radius: 11px; }
.tabs a { padding: 7px 15px; border-radius: 8px; color: var(--muted); font-size: .88rem; font-weight: 550;
  transition: background .2s var(--ease), color .2s var(--ease); }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.select-tools { display: flex; gap: 8px; }

.day h3 { position: sticky; top: 57px; z-index: var(--z-sticky); margin: 0 -20px; padding: 18px 20px 10px;
  font: italic 400 1.4rem/1.1 var(--display); color: var(--text);
  background: linear-gradient(var(--bg) 70%, color-mix(in srgb, var(--bg) 0%, transparent)); }
.day h3 .dayno { font: 600 .74rem var(--ui); font-style: normal; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 3px 7px; border-radius: 4px; margin-right: 10px;
  vertical-align: .3em; }
.day h3 .count { font: 500 .78rem var(--ui); color: var(--faint); margin-left: 8px; font-style: normal;
  font-variant-numeric: tabular-nums; }

/* Justified rows: each tile grows in proportion to its aspect ratio (--w/--h),
   so every row fills the width at an equal height without cropping. */
.grid { display: flex; flex-wrap: wrap; gap: 5px; }
.grid::after { content: ""; flex-grow: 999999; }
.tile { --w: 1; --h: 1; position: relative; display: block; overflow: hidden; border-radius: 3px;
  background: var(--tile); flex-grow: calc(var(--w) / var(--h)); flex-basis: calc(var(--row) * var(--w) / var(--h));
  aspect-ratio: var(--w) / var(--h); }
@media (max-width: 600px) { :root { --row: 116px; } .grid { gap: 3px; } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .45s var(--ease), opacity .3s; }
.tile::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgb(0 0 0 / .4)); opacity: 0; transition: opacity .25s var(--ease); }
.tile:hover img { transform: scale(1.04); }
.tile:hover::before { opacity: 1; }
.tile:active img { transform: scale(.985); }
.tile .by { position: absolute; left: 9px; bottom: 7px; z-index: 2; color: #fff; font-size: .76rem; font-weight: 550;
  opacity: 0; transform: translateY(4px); transition: opacity .25s var(--ease), transform .25s var(--ease); }
.tile:hover .by { opacity: 1; transform: none; }
@media (hover: none) { .tile .by { display: none; } }
.tile .placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px;
  font-size: .74rem; color: var(--muted); text-align: center; word-break: break-all; }
.tile.processing { background: linear-gradient(100deg, var(--tile) 30%, var(--bg-deep) 50%, var(--tile) 70%);
  background-size: 300% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.tile .badge { position: absolute; right: 7px; top: 7px; z-index: 2; display: inline-flex; align-items: center; gap: 4px;
  background: rgb(20 14 10 / .55); color: #fff; font-size: .72rem; font-weight: 600; padding: 3px 7px;
  border-radius: 5px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-variant-numeric: tabular-nums; }
.tile .badge svg { width: 10px; height: 10px; }
.tile .hidden-badge { right: auto; left: 7px; }
.tile.hidden img { opacity: .35; filter: grayscale(1); }
.selecting .tile::after { content: ""; position: absolute; top: 8px; left: 8px; z-index: 3; width: 22px; height: 22px;
  border-radius: 50%; border: 2px solid #fff; background: rgb(0 0 0 / .2); box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.selecting .tile.selected::after { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; border-color: var(--accent); }
.selecting .tile.selected img { transform: scale(.9); border-radius: 4px; }

/* --- lightbox ---------------------------------------------------------------- */
.lightbox { position: fixed; inset: 0; z-index: var(--z-overlay); background: rgb(14 11 9 / .96); display: flex;
  flex-direction: column; color: #f3ede4; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.lb-stage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 60px 8px 0; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 2px;
  animation: rise .28s var(--ease); }
@keyframes rise { from { opacity: 0; transform: scale(.985); } }
.lb-nopreview { color: #b9b0a4; }
.lb-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.lb-info { display: flex; flex-direction: column; font-size: .9rem; }
.lb-info strong { font: 400 1.3rem/1.2 var(--display); }
.lb-info span { color: #b2a99c; font-variant-numeric: tabular-nums; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lb-actions .btn { background: rgb(255 255 255 / .08); border-color: rgb(255 255 255 / .14); color: #f3ede4; }
.lb-actions .btn:hover { background: rgb(255 255 255 / .16); }
.lb-actions .btn.danger { color: #f0a59b; }
.lb-close, .lb-prev, .lb-next { position: absolute; display: grid; place-items: center; background: rgb(255 255 255 / .08);
  border: none; color: #f3ede4; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; z-index: 2;
  transition: background .2s var(--ease), transform .12s var(--ease); }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgb(255 255 255 / .18); }
.lb-close:active, .lb-prev:active, .lb-next:active { transform: scale(.94); }
.lb-close svg, .lb-prev svg, .lb-next svg { width: 20px; height: 20px; }
.lb-close { top: max(10px, env(safe-area-inset-top)); right: 10px; }
.lb-prev { left: 12px; top: 50%; translate: 0 -50%; }
.lb-next { right: 12px; top: 50%; translate: 0 -50%; }
@media (hover: none) { .lb-prev, .lb-next { display: none; } }

/* --- share ------------------------------------------------------------------ */
.qr { display: block; margin: 20px auto; background: #fff; border-radius: 14px; padding: 6px; max-width: 100%;
  height: auto; box-shadow: var(--shadow); }
.copy { margin: 14px 0; }
.share-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* --- error page -------------------------------------------------------------- */
.error-page { text-align: center; padding: 64px 0; }
.error-page .code { font: italic 400 6rem/1 var(--display); color: var(--accent); margin-bottom: 8px; }
.prose { max-width: 62ch; }
.prose h2 { margin-top: 1.8rem; }
.prose li { margin-bottom: .4rem; }

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

@media print {
  body::before, .topbar, .footer, .back, .copy, .share-actions { display: none; }
  .card { box-shadow: none; }
}
