:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6d6a64;
  --line: #e6e3de;
  --accent: #2f5d8a;
  --danger: #b3261e;
  --ok: #2e7d32;
  --radius: 6px;
  --row: 240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1c;
    --text: #ece9e4;
    --muted: #9b978f;
    --line: #2d2c2a;
    --accent: #8db7e2;
    --danger: #f2827a;
    --ok: #81c784;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
img { display: block; max-width: 100%; }

.wrap { max-width: 1600px; margin: 0 auto; padding: 0 24px; }

/* ---------- headers ---------- */
.site-head { padding: 56px 24px 32px; }
.site-head h1, .album-head h1 {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}
.site-head h1 { font-size: clamp(2rem, 4vw, 3rem); }
.intro { color: var(--muted); margin: 8px 0 0; max-width: 60ch; }

.album-head { padding: 32px 24px 28px; }
.album-head h1 { font-size: clamp(1.8rem, 4vw, 2.75rem); margin-top: 16px; }
.back { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.back:hover { color: var(--text); }
.meta { color: var(--muted); font-size: 0.92rem; margin: 6px 0 0; }
.desc { margin-top: 14px; max-width: 70ch; }

.empty { color: var(--muted); padding: 48px 0; }
main.empty h1 { color: var(--text); font-weight: 500; }

/* ---------- album list ---------- */
.albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 36px 28px;
}
.album-card { color: inherit; text-decoration: none; }
.album-card .cover {
  aspect-ratio: 4 / 3;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.album-card .cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s ease;
}
.album-card:hover .cover img { transform: scale(1.03); }
.album-card h2 { font-size: 1.1rem; font-weight: 600; margin: 12px 0 0; }

/* ---------- justified photo grid ---------- */
.grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.grid::after { content: ""; flex-grow: 999999; }
.tile {
  flex-grow: var(--r);
  flex-basis: calc(var(--r) * var(--row));
  aspect-ratio: var(--r);
  max-height: calc(var(--row) * 1.6);
  background: var(--line);
  overflow: hidden;
  position: relative;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.tile:hover img { opacity: .88; }

@media (max-width: 700px) {
  :root { --row: 150px; }
  .wrap { padding: 0 16px; }
  .site-head { padding: 36px 16px 20px; }
  .album-head { padding: 20px 16px 20px; }
  .grid { gap: 4px; }
}

.site-foot { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 56px 16px 40px; }

.admin-bar {
  background: var(--text); color: var(--bg);
  font-size: 0.9rem; padding: 8px 16px; text-align: center;
}
.admin-bar a { color: inherit; margin-left: 12px; }

/* ---------- lightbox ---------- */
.lb {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 8, 8, 0.96);
  color: #eee;
  display: flex; flex-direction: column;
  touch-action: pan-y pinch-zoom;
}
.lb[hidden] { display: none; }
.lb-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 12px 64px; }
.lb-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  user-select: none; -webkit-user-drag: none;
  transition: opacity .2s;
}
.lb-stage img.loading { opacity: .3; }
.lb-bar { display: flex; align-items: center; gap: 16px; padding: 12px 20px 18px; min-height: 56px; }
.lb-caption { flex: 1; font-size: 0.95rem; }
.lb-count { color: #aaa; font-size: 0.85rem; white-space: nowrap; }
.lb button, .lb a.lb-btn {
  background: none; border: 0; color: #ddd; cursor: pointer;
  font: inherit; padding: 8px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.lb button:hover, .lb a.lb-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.lb svg { width: 26px; height: 26px; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
@media (max-width: 700px) {
  .lb-stage { padding: 0; }
  .lb-prev, .lb-next { display: none !important; }
}
