:root {
  --bg: #fafaf9;
  --fg: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --tile: #e7e5e4;
  --accent: #2563eb;
  --bar: rgba(250, 250, 249, 0.88);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09;
    --fg: #f5f5f4;
    --muted: #a8a29e;
    --line: #292524;
    --tile: #1c1917;
    --accent: #60a5fa;
    --bar: rgba(12, 10, 9, 0.88);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bar);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.jump select {
  font: inherit; color: inherit; background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; max-width: 46vw;
}
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.user { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout { color: var(--accent); text-decoration: none; font-size: 14px; white-space: nowrap; }
@media (max-width: 560px) { .user { display: none; } }

/* ---------- timeline ---------- */
main { padding: 0 max(16px, env(safe-area-inset-left)) 40px max(16px, env(safe-area-inset-right)); }
.status { color: var(--muted); text-align: center; padding: 48px 0; }
.month { padding-top: 20px; scroll-margin-top: 64px; }
.month h2 {
  margin: 0 0 10px; font-size: 16px; font-weight: 600;
  display: flex; gap: 8px; align-items: baseline;
}
.month h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.grid {
  display: grid; gap: 3px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (max-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 2px; } }
.tile {
  position: relative;
  display: block; padding: 0; border: 0; cursor: zoom-in;
  aspect-ratio: 1; background: var(--tile); overflow: hidden; border-radius: 2px;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.tile img.loaded { opacity: 1; }
.badge {
  position: absolute; right: 4px; bottom: 4px;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none;
}
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 10;
  background: #000; display: flex; align-items: center; justify-content: center;
  touch-action: pan-y pinch-zoom;
}
.viewer[hidden] { display: none; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.viewer [hidden] { display: none; }
.viewer video { width: 100%; height: 100%; }
/* Top, so it never covers the video player's controls. */
.viewer-bar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(rgba(0,0,0,.7), transparent);
  color: #f5f5f4;
}
.viewer-date { margin-right: auto; font-size: 14px; }
.btn {
  font: inherit; font-size: 14px; color: #f5f5f4; text-decoration: none; cursor: pointer;
  background: rgba(255,255,255,.14); border: 0; border-radius: 8px; padding: 7px 12px;
}
.btn:hover { background: rgba(255,255,255,.24); }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 72px; border: 0; cursor: pointer;
  background: rgba(255,255,255,.08); color: #fff; font-size: 34px; line-height: 1;
}
.nav:hover { background: rgba(255,255,255,.18); }
.prev { left: 0; border-radius: 0 8px 8px 0; }
.next { right: 0; border-radius: 8px 0 0 8px; }
@media (hover: none) { .nav { display: none; } }
