:root {
  --bg: #f5f3ef;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #e2ddd4;
  --accent: #b4532a;
  --accent-soft: #f6e3d8;
  --chip-bg: #ffffff;
  /* The gallery stays dark in both schemes: pixel art reads best on a dark, flat surface. */
  --tile: #1c1b19;
  --tile-hover: #262421;
  --tile-border: #2e2b27;
  --tile-text: #ece8e1;
  --tile-muted: #a39d93;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #36332f;
    --accent: #e48a5c;
    --accent-soft: #3b2a20;
    --chip-bg: #211f1d;
    --tile: #0f0e0d;
    --tile-hover: #1a1917;
    --tile-border: #2a2724;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; }
header { padding: 28px 0 8px; }
.home { display: inline-block; margin-bottom: 6px; font-size: 14px; color: var(--muted); text-decoration: none; }
.home:hover, .home:focus-visible { text-decoration: underline; color: var(--text); }
h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.01em; }
.intro { margin: 0 0 6px; max-width: 70ch; color: var(--muted); }
.jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 4px; }
.jump a {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 10px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}
.jump a:hover, .jump a:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
section { padding-top: 28px; scroll-margin-top: 8px; }
h2 {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}
/* Wide enough for the largest picture at 2x: boxes are 84 wide, frames up to 160. */
.grid.boxes { grid-template-columns: repeat(auto-fill, minmax(192px, 1fr)); }
.grid.frames { grid-template-columns: repeat(auto-fill, minmax(min(100%, 348px), 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: stretch;
  min-width: 0;
  margin: 0; padding: 12px 10px 10px;
  background: var(--tile);
  border: 1px solid var(--tile-border);
  border-radius: 8px;
  color: var(--tile-text);
  font: inherit;
  text-align: center;
  text-decoration: none;
  scroll-margin-top: 12px;
}
.tile:hover { background: var(--tile-hover); border-color: var(--accent); }
/* A ring drawn outside the border, in the grid's gap: selecting moves nothing. */
.tile.selected { background: var(--tile-hover); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile.wide { grid-column: 1 / -1; }
.art {
  display: flex; align-items: center; justify-content: center;
  min-height: 96px;
  overflow-x: auto;
}
.art img, .detail canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.art img { display: block; flex: none; }
.label { margin-top: 10px; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.size { margin-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--tile-muted); }
.note { margin-top: 2px; font-size: 11px; color: var(--tile-muted); font-style: italic; }
/* The selected picture's detail: a full row of the grid, right under the selected tile's row. */
.detail {
  position: relative;
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 14px;
  background: var(--tile);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--tile-text);
}
.detail[hidden] { display: none; }
/* Points up at the selected tile; page.js sets --caret. */
.detail::before {
  content: "";
  position: absolute; top: -8px; left: calc(var(--caret, 50%) - 8px);
  width: 14px; height: 14px;
  background: var(--tile);
  border: solid var(--accent); border-width: 1px 0 0 1px;
  transform: rotate(45deg);
}
.detail-close {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px;
  background: none; border: 1px solid var(--tile-border); border-radius: 6px;
  color: var(--tile-muted); font: 18px/1 system-ui, sans-serif;
  cursor: pointer;
}
.detail-close:hover, .detail-close:focus-visible { color: var(--tile-text); border-color: var(--accent); outline: none; }
.detail-art { display: flex; gap: 12px; align-items: flex-start; justify-content: center; overflow-x: auto; }
.detail-art.stacked { flex-direction: column; align-items: center; }
.detail-art figure { margin: 0; }
.detail-art figcaption { margin-top: 4px; font-size: 11px; color: var(--tile-muted); }
.detail canvas { display: block; }
.detail-info { margin-top: 12px; font-size: 13px; }
.detail-info .title { font-weight: 600; padding-right: 36px; }
.detail-info .title a { color: inherit; text-decoration: none; }
.detail-info .title a:hover { text-decoration: underline; }
.detail-info .meta { color: var(--tile-muted); font-size: 12px; }
.detail-info ul { margin: 6px 0 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 12px; }
.detail-info li { overflow-wrap: anywhere; }
.detail-info li .dim { color: var(--tile-muted); }
