:root {
  --bg: #f6f6f4;
  --fg: #1c1c1a;
  --muted: #6b6b66;
  --card: #ffffff;
  --border: #e2e2dd;
  --accent: #2f6fde;
  --stage: #eceae6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --fg: #ecece8;
    --muted: #9a9a94;
    --card: #1e1e1c;
    --border: #2e2e2b;
    --accent: #6b9bff;
    --stage: #1a1a19;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.top { padding: 24px 16px 8px; max-width: 1200px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 22px; font-weight: 600; }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.card {
  display: block; width: 100%; padding: 0; text-align: left;
  background: var(--card); color: inherit;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; font: inherit; text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .thumb {
  aspect-ratio: 1; width: 100%; display: block; object-fit: cover;
  background: var(--stage);
}
.thumb.missing {
  display: grid; place-items: center; color: var(--muted); font-size: 13px;
}
.card .name { display: block; padding: 10px 12px; font-weight: 500; }

.empty { color: var(--muted); }

.btn {
  font: inherit; font-size: 14px; color: var(--fg); text-decoration: none;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }

.viewer {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.viewer[hidden] { display: none; }
.viewer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.viewer-bar h2 {
  margin: 0 auto 0 0; font-size: 16px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stage { flex: 1; min-height: 0; background: var(--stage); touch-action: none; }
.stage canvas { display: block; width: 100%; height: 100%; }
.status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(90%, 480px); margin: 0; text-align: center; overflow-wrap: anywhere;
  color: var(--muted); pointer-events: none;
}

