:root{
  --bg:#0f1419; --panel:#1a2129; --panel2:#212a34; --line:#2c3644;
  --fg:#e8edf2; --muted:#9aa7b4; --accent:#3b82f6; --green:#22c55e; --red:#f87171;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--fg);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
a{color:inherit;text-decoration:none}
img,video{display:block;max-width:100%}

/* ---- top bar ---- */
.bar{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:10px;
  padding:calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background:rgba(15,20,25,.94);backdrop-filter:blur(8px);
  border-bottom:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:8px;font-weight:700;font-size:15px;
  letter-spacing:.2px}
.brand img{border-radius:7px}
.bar-right{margin-left:auto;display:flex;gap:6px}
.btn{background:var(--panel2);border:1px solid var(--line);color:var(--fg);
  border-radius:8px;padding:7px 11px;font-size:13px;font-weight:600;
  -webkit-tap-highlight-color:transparent}
.btn:hover{border-color:var(--accent)}
.btn.ghost{background:transparent;color:var(--muted)}
.btn.primary{background:#1d2c3e;border-color:var(--accent)}

.flash{margin:10px 12px;padding:10px 12px;border-radius:8px;font-size:14px;
  background:#17311f;color:var(--green)}
.flash.error{background:#3b1d1d;color:var(--red)}

/* single-photo page back link (replaced the removed .tabs/.chip nav) */
.crumb{padding:12px 12px 0}

/* ---- delete / trash ---- */
.btn.danger{border-color:#5a2b2b;background:#2a1616;color:#f0b4b4}
.btn.danger:hover{background:#3a1d1d;color:#ffd7d7}
.btn.tiny{padding:3px 9px;font-size:11px;border-radius:8px}
.lb-del{margin-left:auto}
.lb-del .btn{white-space:nowrap}
.trashhead{padding:16px 14px 4px;max-width:900px;margin:0 auto}
.trashhead h1{margin:0 0 6px;font-size:19px}
.trashhead p{margin:0 0 10px;font-size:13px;line-height:1.5}
.muted{color:var(--muted)}
.trashgrid{margin:10px auto 26px;max-width:900px}
.trashcell{position:relative;display:flex;flex-direction:column;gap:4px}
.trashcell img{width:100%;aspect-ratio:1;object-fit:cover;border-radius:6px}
.trashcell form{width:100%}
.trashcell .btn{width:100%}
.trashmeta{font-size:10.5px;color:var(--muted);text-align:center}

/* ---- gallery ---- */
main{padding:0 0 20px}
/* ---- collapsible year -> month groups ---- */
details>summary{list-style:none;cursor:pointer;-webkit-tap-highlight-color:transparent}
details>summary::-webkit-details-marker{display:none}
details>summary::marker{content:""}
.chev{width:0;height:0;flex:none;border-left:7px solid var(--muted);
  border-top:5px solid transparent;border-bottom:5px solid transparent;
  margin-right:2px;transition:transform .15s}
.chev.sm{border-left-width:6px;border-top-width:4px;border-bottom-width:4px}
details[open]>summary .chev{transform:rotate(90deg)}
details>summary:hover .chev{border-left-color:var(--fg)}
/* Year and month rows are now IDENTICAL in type size and box metrics - same
   font-size, padding and margin - so a year heading is exactly as tall as a
   month heading and the list reads as one even rhythm.

   Two earlier attempts fixed only the box (padding/margin) while leaving the
   year at 19px, then 18px, against the month's 13px; that still read as a
   different, larger kind of row, which is what was actually wrong. Hierarchy
   now comes from WEIGHT and COLOUR, not size: the year is 800 in --fg with a
   slightly stronger rule, the month 700 in --muted uppercase. It was also
   split across two .year-h rules, hence the merge. */
.year-h{display:flex;align-items:center;gap:8px;margin:8px 0 6px;
  padding:8px 12px;font-size:13px;font-weight:800;letter-spacing:.6px;
  border-bottom:1px solid var(--line)}
.ymeta{margin-left:auto;font-size:11.5px;font-weight:600;color:var(--muted)}
/* Keep the year row on ONE line at large font scales. At >=1.3x the year and
   "N photos - M months" wrapped onto two lines, which made the year rows
   taller than the month rows again and undid the spacing work above - the
   same trap already fixed once on the Job Tracker index for this phone. The
   year keeps priority; the count is what gives way. */
.year-h .ytext{white-space:nowrap;flex:none}
.year-h .ymeta{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.ybody{padding-bottom:6px}
.month-h{display:flex;align-items:center;gap:8px;margin:8px 0 6px;padding:8px 12px;
  font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;
  letter-spacing:.6px;border-bottom:1px solid #1e262f}
.month-h[open]{color:var(--fg)}
.mcount{margin-left:auto;font-size:11.5px;color:var(--muted);font-weight:600}
.grid{display:grid;gap:3px;grid-template-columns:repeat(4,1fr)}
@media (max-width:640px){.grid{grid-template-columns:repeat(3,1fr)}}
.cell{position:relative;aspect-ratio:1/1;background:var(--panel);overflow:hidden;
  cursor:pointer;-webkit-tap-highlight-color:transparent}
.cell img{width:100%;height:100%;object-fit:cover;transition:filter .12s}
.cell:active img{filter:brightness(.7)}
.badge{position:absolute;left:5px;bottom:5px;background:rgba(0,0,0,.62);
  color:#fff;border-radius:5px;padding:1px 5px;font-size:11px;font-weight:700;
  pointer-events:none}
.empty{padding:40px 16px;text-align:center;color:var(--muted)}

/* ---- lightbox ---- */
.lb{position:fixed;inset:0;z-index:100;background:rgba(6,9,12,.97);
  display:none;flex-direction:column;touch-action:none}
.lb.on{display:flex}
.lb-top{display:flex;align-items:center;gap:10px;padding:calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background:linear-gradient(rgba(6,9,12,.85),transparent)}
.lb-title{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap}
.lb-sub{font-size:11.5px;color:var(--muted);margin-top:1px}
.lb-close{margin-left:auto;background:#212a34;border:1px solid var(--line);
  color:var(--fg);border-radius:8px;width:34px;height:34px;font-size:17px;cursor:pointer}
/* padding is deliberately 0. It used to be `0 2px`, which made the stage's
   content box 4px narrower than a slide - so the outer 2px on each side showed
   the edge of the neighbouring photo's preview as a 2px sliver down both sides
   of the current one. A slide is exactly one stage wide, with no gutter. */
.lb-stage{flex:1;display:flex;align-items:center;justify-content:center;
  overflow:hidden;padding:0;position:relative;touch-action:none;
  -webkit-user-select:none;user-select:none}
/* The track holds three slides side by side and is translated for paging.
   Each slide is exactly one stage wide, so translateX(-100%) == one photo.
   It rests at -100% so the MIDDLE (current) slide is the one on screen; JS
   re-asserts the exact pixel value on open. Starting at 0 would show the
   previous preview. */
.lb-track{display:flex;width:100%;height:100%;will-change:transform;
  transform:translateX(-100%)}
.lb-slide{flex:0 0 100%;height:100%;min-width:0;
  display:flex;align-items:center;justify-content:center;position:relative}
.lb-stage img,.lb-stage video{max-width:100%;max-height:100%;object-fit:contain;
  -webkit-user-select:none;user-select:none}
/* Zoom is a transform on the current image, so it composes with the track's
   paging transform instead of fighting it. transform-origin stays centred. */
#lbImg{transform-origin:center center;will-change:transform;
  transition:transform .18s ease-out}
/* While a finger is down the image must follow it with no lag. */
.lb-stage.dragging #lbImg{transition:none}
.lb-peek{opacity:.85}
/* Pointer-cursor devices get the arrows; a phone has no hover, so on touch they
   would just sit on top of the photo. */
.lb-nav{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:66px;
  background:rgba(33,42,52,.72);border:1px solid var(--line);color:var(--fg);
  font-size:26px;line-height:1;cursor:pointer;border-radius:10px;display:none}
.lb-nav.prev{left:6px}.lb-nav.next{right:6px}
@media (hover:hover) and (pointer:fine){.lb.on .lb-nav{display:block}}
.lb-hint{position:absolute;left:0;right:0;bottom:8px;text-align:center;
  font-size:11px;color:var(--muted);pointer-events:none;opacity:.85}
.lb-foot{display:flex;gap:8px;padding:8px 10px calc(env(safe-area-inset-bottom) + 10px);
  border-top:1px solid var(--line);background:rgba(15,20,25,.9)}
.lb-foot a{flex:1;text-align:center;background:var(--panel2);border:1px solid var(--line);
  border-radius:8px;padding:9px;font-size:13px;font-weight:600}
.lb-count{position:absolute;bottom:64px;left:0;right:0;text-align:center;
  font-size:12px;color:var(--muted);pointer-events:none}

/* ---- forms / pages ---- */
.card{max-width:620px;margin:16px 12px;background:var(--panel);
  border:1px solid var(--line);border-radius:12px;padding:16px}
.card h2{margin:0 0 8px;font-size:17px}
.card p{color:var(--muted);font-size:14px;line-height:1.5}
.row{display:flex;align-items:center;gap:10px;padding:10px 0;
  border-top:1px solid var(--line)}
.row .grow{flex:1;min-width:0}
.small{font-size:12.5px;color:var(--muted)}
input[type=file]{width:100%;font-size:14px;color:var(--muted)}
.prog{height:8px;background:var(--panel2);border-radius:999px;overflow:hidden;
  margin:12px 0 4px;border:1px solid var(--line)}
.prog i{display:block;height:100%;width:0;background:var(--accent);transition:width .2s}
.foot{max-width:900px;margin:0 auto;padding:10px 12px calc(env(safe-area-inset-bottom) + 14px);
  color:var(--muted);font-size:11.5px;display:flex;gap:14px;flex-wrap:wrap}
@media (max-width:640px){.foot{justify-content:center;text-align:center}}
/* Respect a stated preference for less motion: keep the paging instant and drop
   the zoom easing, rather than removing the transitions entirely (which would
   make a swipe snap with no feedback at all). */
@media (prefers-reduced-motion:reduce){
  .lb-track{transition:none !important}
  #lbImg{transition:none !important}
}
