:root {
  --bg: #f7f7f5;
  --text: #1f1d1a;
  --muted: #6c675f;
  --card: #ffffff;
  --line: #e2e0da;
  --placeholder: #e6e8ee;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --text: #e9ecf2;
    --muted: #9aa3b5;
    --card: #171b24;
    --line: #2a3140;
    --placeholder: #212735;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar h1 {
  margin: 0;
  font-size: 1.15rem;
}

.counter {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem;
}

.hint {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.card p {
  margin: 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
}

/* The box keeps its shape before the image arrives, so nothing jumps. */
.thumb {
  margin: 0;
  aspect-ratio: 4 / 3;
  background: var(--placeholder);
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.thumb img.is-loaded {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .thumb img {
    transition: none;
  }
}
