:root {
  --bg: #faf8f4;
  --bg2: #f2efe9;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.14);
  --text: #1a1814;
  --text2: #6b6560;
  --text3: #a09890;
  --accent: #1a1814;
  --gold: #b8860b;
  --gold-light: #f5edd0;
  --sold: #c0392b;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
}

/* ── Header ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 20px; }
.header-top {
  max-width: 900px; margin: 0 auto; padding: 16px 0 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.header-brand {
  font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500;
  color: var(--text3); text-decoration: none; letter-spacing: 0.12em;
  text-transform: uppercase; transition: color 0.15s;
}
.header-brand:hover { color: var(--text); }
.header-inner {
  max-width: 900px; margin: 0 auto; padding: 6px 0 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.listing-title { font-family: 'Playfair Display', serif; font-size: clamp(20px, 4vw, 30px); font-weight: 500; color: var(--text); line-height: 1.2; letter-spacing: -0.02em; text-align: center; padding: 8px 12px 10px; }
.listing-desc { font-size: 14px; color: var(--text2); margin-top: 4px; line-height: 1.6; max-width: 520px; }
.meta-search-btn {
  justify-self: end; background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 5px; line-height: 0; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.meta-search-btn:hover { color: var(--text); background: var(--bg2); }
.search-row {
  display: none; align-items: center; gap: 8px;
  margin-top: 8px;
}
.search-row.open { display: flex; }
.search-input-pub {
  flex: 1; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 9px 13px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
}
.search-input-pub:focus { border-color: var(--text3); }
.search-input-pub::placeholder { color: var(--text3); }
.search-close-btn {
  background: none; border: none; cursor: pointer; color: var(--text3);
  font-size: 22px; padding: 2px 8px; line-height: 1; border-radius: 6px;
  transition: color 0.15s;
}
.search-close-btn:hover { color: var(--text); }

/* ── Filter bar ── */
.filter-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 20px; position: sticky; top: 0; z-index: 10; }
.filter-inner { max-width: 900px; margin: 0 auto; padding: 10px 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; align-items: center; }
.filter-inner::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border2);
  background: transparent; color: var(--text2); font-size: 13px; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.filter-chip:hover { border-color: var(--text); color: var(--text); }
.filter-chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

/* ── Grid ── */
.grid-wrap { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; }
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (min-width: 780px) { .card-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }

/* ── Card ── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.18s ease, border-color 0.15s;
  animation: fadeUp 0.35s ease both;
}
.card:hover { transform: translateY(-3px); border-color: var(--border2); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.card:active { transform: scale(0.97); }
.card.sold { opacity: 0.55; cursor: default; pointer-events: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-img-wrap { position: relative; aspect-ratio: 3/4; background: var(--bg2); overflow: hidden; }
.card-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; display: block; }
.card:hover .card-img { transform: scale(1.04); }
.card-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg2); color: var(--text3); }
.card-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--text); color: var(--bg);
  font-size: 10px; font-family: 'DM Mono', monospace; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 4px;
}
.card-badge.sold-badge { background: var(--sold); }
.card-badge.grade-badge { background: var(--gold-light); color: var(--gold); border: 1px solid rgba(184,134,11,0.3); }
.card-tap-hint {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(4px);
  border-radius: 4px; padding: 3px 7px; font-size: 10px; color: var(--text2);
  font-family: 'DM Mono', monospace; opacity: 0; transition: opacity 0.2s;
}
.card:hover .card-tap-hint { opacity: 1; }
.card-body { padding: 10px 12px 12px; }
.card-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.card-sub { font-size: 11px; color: var(--text3); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-price { font-family: 'DM Mono', monospace; font-size: 14px; color: var(--text); font-weight: 500; }
.card-price.sold-price { color: var(--sold); font-size: 12px; }

/* ── Lightbox ── */
.lightbox { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(15,14,12,0.96); flex-direction: column; align-items: center; touch-action: pan-y; }
.lightbox.open { display: flex; }
.lb-header { width: 100%; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.lb-close {
  background: rgba(255,255,255,0.1); border: none; border-radius: 50%;
  width: 36px; height: 36px; color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1; transition: background 0.15s;
}
.lb-close:hover { background: rgba(255,255,255,0.2); }
.lb-counter { font-family: 'DM Mono', monospace; font-size: 12px; color: rgba(255,255,255,0.45); }
.lb-main { flex: 1; width: 100%; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; transition: opacity 0.2s, transform 0.2s; border-radius: 8px; user-select: none; -webkit-user-drag: none; }
.lb-img.fade { opacity: 0; transform: scale(0.96); }
.lb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.1); border: none; border-radius: 50%;
  width: 44px; height: 44px; color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s; z-index: 2;
}
.lb-arrow:hover { background: rgba(255,255,255,0.2); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-strip-wrap { width: 100%; padding: 14px 16px 20px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }
.lb-thumbs { display: flex; gap: 8px; overflow-x: auto; justify-content: center; scrollbar-width: none; padding: 2px 0; }
.lb-thumbs::-webkit-scrollbar { display: none; }
.lb-thumb {
  width: 56px; height: 56px; border-radius: 6px; border: 2px solid transparent;
  object-fit: cover; cursor: pointer; flex-shrink: 0; transition: border-color 0.15s, opacity 0.15s;
  background: var(--bg2); overflow: hidden;
}
.lb-thumb.active { border-color: #fff; }
.lb-thumb:not(.active) { opacity: 0.55; }
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb-info { text-align: center; }
.lb-card-name { font-family: 'Playfair Display', serif; font-size: 20px; color: #fff; font-weight: 400; margin-bottom: 4px; }
.lb-card-meta { font-size: 13px; color: rgba(255,255,255,0.5); margin-bottom: 6px; }
.lb-card-price { font-family: 'DM Mono', monospace; font-size: 18px; color: #fff; font-weight: 500; }

.swipe-hint {
  position: absolute; bottom: 80px; font-size: 12px; color: rgba(255,255,255,0.25);
  font-family: 'DM Mono', monospace; letter-spacing: 0.05em;
  animation: fadeIn 1s ease 1.5s both; pointer-events: none;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card:nth-child(1) { animation-delay: 0.03s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.09s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.15s; }
.card:nth-child(6) { animation-delay: 0.18s; }
.card:nth-child(7) { animation-delay: 0.21s; }
.card:nth-child(8) { animation-delay: 0.24s; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text2); }
.empty-state h2 { font-family: 'Playfair Display', serif; font-size: 22px; margin-bottom: 8px; }
.loading-state { text-align: center; padding: 80px 20px; color: var(--text3); font-family: 'DM Mono', monospace; font-size: 13px; }

/* ── View toggle ─────────────────────────────────────────────────────────── */
.view-toggle {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 20px; display: flex; justify-content: center; gap: 6px;
}
.view-btn {
  padding: 6px 20px; border-radius: 20px;
  border: 1px solid var(--border2); background: transparent;
  color: var(--text2); font-size: 13px; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: all 0.15s;
}
.view-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ── Timestamp stack ─────────────────────────────────────────────────────── */
.ts-stack {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; max-width: 680px; margin: 0 auto;
}
.ts-img {
  width: 100%; height: auto; display: block;
  border-radius: 10px; cursor: zoom-in;
  border: 1px solid var(--border);
}

/* ── Timestamp zoom overlay ──────────────────────────────────────────────── */
.ts-zoom {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.96);
  align-items: center; justify-content: center;
}
.ts-zoom.open { display: flex; }
.ts-zoom #tsZoomImg {
  max-width: 100%; max-height: 100dvh;
  object-fit: contain; touch-action: pinch-zoom;
}
.ts-zoom-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: #fff;
  font-size: 28px; line-height: 1; cursor: pointer; z-index: 1;
  opacity: 0.7; padding: 4px 8px;
}
.ts-zoom-close:hover { opacity: 1; }

.site-footer { border-top: 1px solid var(--border); padding: 20px; text-align: center; }
.site-footer a { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 500; color: var(--text3); text-decoration: none; letter-spacing: 0.08em; transition: color 0.15s; display: block; }
.site-footer a:hover { color: var(--text); }
.site-footer .signup-btn { display: inline-block; margin-top: 8px; padding: 5px 14px; border: 1px solid var(--text3); border-radius: 6px; transition: color 0.15s, border-color 0.15s; }
.site-footer .signup-btn:hover { color: var(--text); border-color: var(--text); }
