:root {
  --bg: #f4f2ee;
  --fg: #1f2420;
  --muted: #6b716b;
  --card: #ffffff;
  --accent: #4a6b3a;
  --border: #dedad2;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141614;
    --fg: #e8ebe6;
    --muted: #9aa198;
    --card: #1f221f;
    --accent: #8fb87a;
    --border: #2e322e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.25rem; }

select {
  font: inherit;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  min-width: 12rem;
}

main { padding: 16px; max-width: 1600px; margin: 0 auto; }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.grid li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.grid a { display: block; }

.grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--border);
}

.meta {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 0.875rem;
  color: var(--muted);
}

.cam { color: var(--accent); font-weight: 600; }

.empty { color: var(--muted); text-align: center; margin-top: 3rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Full-screen viewer */
dialog {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
}

dialog::backdrop { background: #000; }

dialog[open] { display: flex; align-items: center; justify-content: center; }

figure { margin: 0; text-align: center; }

figure img {
  max-width: 100vw;
  max-height: calc(100vh - 3rem);
  object-fit: contain;
}

figcaption { padding: 8px; font-size: 0.9rem; color: #ccc; }

dialog button {
  position: absolute;
  border: 0;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px;
}

.close { top: 8px; right: 8px; }
.prev { left: 8px; top: 50%; transform: translateY(-50%); }
.next { right: 8px; top: 50%; transform: translateY(-50%); }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  main { padding: 8px; }
  .meta { flex-direction: column; padding: 6px 8px; font-size: 0.8rem; }
  .nav { display: none; } /* swipe on phones */
}
