:root {
  --maroon: #800020;
  --cream: #fff8f0;
  --gold: #ffa000;
  --ink: #3a2a2a;
  --muted: #8a7a7a;
  --card: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--maroon);
  color: #fff;
  padding: 12px 16px;
}
.brand { font-weight: 700; font-size: 18px; flex: 1; text-align: center; }
.spacer { width: 64px; }
.back {
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  min-width: 64px;
}
.back.hidden { visibility: hidden; }
main { padding: 12px; max-width: 1100px; margin: 0 auto; }
.loading, .empty, .error { text-align: center; padding: 48px 16px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  text-decoration: none;
  color: inherit;
  display: block;
}
.card img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; background: #f3e9e4; }
.card .meta { padding: 8px 10px 10px; }
.card .no { font-weight: 700; font-size: 15px; }
.card .price { color: var(--maroon); font-weight: 700; font-size: 15px; margin-top: 2px; }
.card .cat { font-size: 12px; color: var(--muted); margin-top: 2px; }
.catcard { position: relative; }
.catcard .count {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
}
h2.title { font-size: 20px; margin: 4px 4px 12px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 12px 32px; }
.card.zoomable { cursor: zoom-in; }

/* Fullscreen viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  display: flex;
  flex-direction: column;
  color: #fff;
}
.v-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0,0,0,.7);
}
.v-cap { flex: 1; font-weight: 700; font-size: 16px; }
.v-x {
  background: none; border: 1px solid #666; color: #fff;
  border-radius: 50%; width: 36px; height: 36px; font-size: 16px; cursor: pointer;
}
.v-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.v-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}
.v-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.7);
}
.v-count { font-size: 14px; color: #ccc; }
.v-foot button {
  background: none; border: 1px solid #666; color: #fff;
  border-radius: 8px; min-width: 40px; height: 36px; font-size: 18px; cursor: pointer;
}
.v-zoom { display: flex; gap: 6px; }
