:root {
  --bg: #05070d;
  --panel: rgba(13, 18, 30, 0.92);
  --panel-solid: #0d121e;
  --border: rgba(255, 255, 255, 0.1);
  --text: #e8ecf4;
  --muted: #94a0b8;
  --accent: #f5c451;
  --tier1: #f5c451;
  --tier2: #e8833a;
  --tier3: #3fb6a8;
  --owned: #7a869c;
  --danger: #e0574b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
/* static content pages (about/terms/privacy/refunds) scroll normally */
html:has(.legal-page), html:has(.legal-page) body {
  height: auto;
  overflow: visible;
}

#globe {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ---------- top bar ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.9), rgba(5, 7, 13, 0));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; flex: none; display: block; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: 0.5px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }

.topbar-actions { display: flex; gap: 10px; margin-left: auto; }
#search {
  width: 260px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}
#search:focus { outline: 1px solid var(--accent); }

.headline-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.headline-stats b { color: var(--text); font-size: 14px; display: block; }

button {
  font: inherit;
  cursor: pointer;
}
.ghost-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
}
.ghost-btn:hover { border-color: var(--accent); }
.ghost-btn.small { padding: 6px 10px; font-size: 12px; }

.primary-btn {
  background: var(--accent);
  color: #1c1400;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.primary-btn:hover { filter: brightness(1.07); }
.primary-btn:disabled { opacity: 0.5; cursor: wait; }

/* ---------- sidebar ---------- */
#sidebar {
  position: fixed;
  top: 84px;
  right: 0;
  bottom: 44px;
  width: 340px;
  z-index: 9;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 12px 0 0 12px;
  backdrop-filter: blur(8px);
  transition: transform 0.25s ease;
}
#sidebar.collapsed { transform: translateX(340px); }
#sidebar-toggle {
  position: absolute;
  left: -26px;
  top: 16px;
  width: 26px;
  height: 44px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  background: var(--panel-solid);
  color: var(--text);
}
#sidebar.collapsed #sidebar-toggle { transform: scaleX(-1); }

.sidebar-inner {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}
.filters h2, .results h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 10px;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.filters select {
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 13px;
}
.filter-row { display: flex; gap: 10px; }
.filter-row label { flex: 1; }
.era-values { color: var(--text); font-variant-numeric: tabular-nums; }
.era-sliders { position: relative; height: 30px; }
.era-sliders input {
  position: absolute;
  width: 100%;
  margin: 0;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  background: none;
}
.era-sliders input::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1c1400;
  cursor: pointer;
}
.era-sliders input::-moz-range-thumb {
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1c1400;
  cursor: pointer;
}
.era-sliders::before {
  content: "";
  position: absolute;
  top: 13px; left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.results { margin-top: 18px; }
#results-list { list-style: none; margin: 0; padding: 0; }
.result-item {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.result-item:hover { background: rgba(255, 255, 255, 0.04); }
.result-item.active { border-color: var(--accent); background: rgba(245, 196, 81, 0.08); }
.result-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  flex: none;
}
.result-item h3 { margin: 0; font-size: 13px; font-weight: 600; }
.result-item p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.result-item .yr { font-variant-numeric: tabular-nums; }
.list-more {
  padding: 12px 10px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}
.badge-owned {
  font-size: 10px;
  color: var(--owned);
  border: 1px solid var(--owned);
  border-radius: 4px;
  padding: 0 4px;
}

/* ---------- detail panel ---------- */
.panel {
  position: fixed;
  left: 20px;
  bottom: 60px;
  z-index: 9;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 480px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.panel.hidden, .modal-root.hidden { display: none; }
.panel .close-x {
  position: absolute;
  top: 10px; right: 12px;
  z-index: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
}
.detail { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.detail-head { flex: none; }
.detail-head h2 { padding-right: 22px; }
.detail-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 8px;
  margin-right: -10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.detail-body::-webkit-scrollbar { width: 6px; }
.detail-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.detail { animation: detail-in 0.16s ease; }
@keyframes detail-in { from { opacity: 0.45; } to { opacity: 1; } }
.detail-tier {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.detail h2 { margin: 0 0 4px; font-size: 17px; line-height: 1.3; }
.detail .where { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.detail .blurb { font-size: 13px; line-height: 1.5; margin: 0 0 14px; }
.detail .summary { font-size: 12.5px; line-height: 1.6; color: var(--text); margin: 0 0 10px; }
.detail-img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 0 12px;
  background: var(--panel-solid);
}
.detail a.wiki { font-size: 12px; color: var(--accent); display: inline-block; margin-bottom: 4px; }
.detail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.price { font-size: 20px; font-weight: 700; }
.price small { font-size: 11px; color: var(--muted); font-weight: 400; }
.owned-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}
.owned-box .owner-name { color: var(--text); font-weight: 600; font-size: 13px; }
.owned-box .owner-msg { color: var(--muted); margin-top: 4px; font-style: italic; }

/* ---------- modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 7, 0.7);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: 460px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.hint-muted { color: var(--muted); font-size: 12px; margin: -10px 0 16px; opacity: 0.8; }
.modal-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.modal-card input[type="text"],
.modal-card input[type="url"],
.modal-card textarea {
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.modal-card textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions button { flex: 1; }
.test-note {
  font-size: 11px;
  color: var(--muted);
  background: rgba(63, 182, 168, 0.08);
  border: 1px solid rgba(63, 182, 168, 0.3);
  border-radius: 7px;
  padding: 8px 10px;
  margin: 4px 0 16px;
}
.error-note {
  font-size: 12px;
  color: #ffb4ac;
  margin-top: 10px;
}
.disclaimer-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin: 4px 0 14px;
}
.hidden { display: none !important; }
.toggle-row, .radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin: 10px 0;
  cursor: pointer;
}
.toggle-row input, .radio-row input { width: auto; margin: 0; }
.link-toggle { margin: 4px 0 12px; }
.link-toggle a { color: var(--accent); font-size: 12px; }
.collection-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 18px 0 6px;
}
#voucher-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 74px;
  z-index: 30;
  background: rgba(245, 196, 81, 0.14);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#voucher-banner button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

/* certificate */
.certificate {
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(245, 196, 81, 0.08), transparent 70%),
    var(--panel-solid);
}
.certificate .seal { font-size: 34px; display: block; margin: 0 auto 6px; }
.certificate .kicker {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 0;
}
.certificate .cert-title { font-size: 18px; margin: 6px 0; line-height: 1.3; }
.certificate .holder { font-size: 15px; color: var(--accent); margin: 12px 0 4px; }
.certificate .serial {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
}
.collection-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.collection-item:last-child { border: none; }
.collection-item button { font-size: 11px; }
.empty-note { color: var(--muted); font-size: 13px; }

/* ---------- ticker ---------- */
#ticker {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 32px;
  z-index: 8;
  background: var(--panel-solid);
  border-top: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
}
#ticker-track {
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  animation: scroll-left 120s linear infinite;  /* JS overrides with a pace-based duration */
  padding-left: 100%;
}
#ticker:hover #ticker-track { animation-play-state: paused; }
#ticker-track span { margin: 0 28px; }
#ticker-track b { color: var(--text); }
@keyframes scroll-left {
  to { transform: translateX(-100%); }
}

#user-slot .ghost-btn { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.globe-count { float: right; font-size: 10px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

.list-more { list-style: none; padding: 12px 4px; text-align: center; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translate(-50%, 20px);
  z-index: 60;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#footer {
  position: fixed;
  left: 20px;
  bottom: 40px;
  z-index: 7;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  background: linear-gradient(0deg, rgba(5, 7, 13, 0.85), rgba(5, 7, 13, 0));
  padding: 8px 4px 4px;
}
#footer a { color: var(--muted); text-decoration: none; }
#footer a:hover { color: var(--accent); }
#footer .footer-note { opacity: 0.7; }

.legal-page {
  position: relative;
  z-index: 20;
  max-width: 720px;
  margin: 80px auto 120px;
  padding: 0 24px;
  line-height: 1.6;
}
.legal-page h1 { font-size: 26px; }
.legal-page h2 { font-size: 17px; margin-top: 28px; }
.legal-page a { color: var(--accent); }
.legal-page a.primary-btn { color: #1c1400; }
.legal-page .back { font-size: 13px; }
.legal-page ul { padding-left: 22px; }
.legal-page li { margin: 4px 0; }
.legal-page .event-hero { margin: 18px 0; max-width: 440px; }
.legal-page .event-hero img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.legal-page .event-hero figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* on this day */
.otd { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line, rgba(255,255,255,0.08)); }
.otd h2 { font-size: 13px; margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; }
.otd .otd-date { color: var(--muted); font-weight: 400; font-size: 11px; }
.otd-list { list-style: none; margin: 0; padding: 0; }
.otd-list li { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; cursor: pointer; font-size: 12px; }
.otd-list li:hover .otd-title { color: var(--accent); }
.otd-yr { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 60px; }
.otd-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.otd-price { color: var(--muted); flex: none; }

/* related moments */
.related { margin-top: 16px; }
.related-h { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.related-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.related-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  background: var(--panel-solid); border: 1px solid rgba(255,255,255,0.08); color: var(--text);
  border-radius: 9px; padding: 9px 10px; cursor: pointer; text-align: left;
  min-height: 84px;
}
.related-card:hover { border-color: var(--accent); background: rgba(245,196,81,0.06); }
.rc-title {
  font-size: 12px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.rc-foot { display: flex; justify-content: space-between; align-items: baseline; font-size: 10.5px; }
.rc-yr { color: var(--muted); font-variant-numeric: tabular-nums; }
.rc-tag { color: var(--accent); }

.detail-share { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.share-grid .share-target { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }

/* honeypot: off-screen, never shown to a real user */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.turnstile-box { margin: 12px 0; min-height: 65px; }

.modal-sep { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 18px 0 12px; }
.ghost-btn.danger, .primary-btn.danger { color: #ff8a8a; border-color: rgba(255,138,138,0.4); background: rgba(255,138,138,0.08); }
.primary-btn.danger { color: #2b0b0b; background: #ff8a8a; }

/* admin */
.admin-nav { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-lookup { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-lookup input { flex: 1 1 220px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 12px; }
.admin-lookup #claim-lookup-result { flex: 1 1 100%; }
.admin-nav .ghost-btn.active { border-color: var(--accent); color: var(--accent); }
.admin-table { width: 100%; font-size: 11.5px; border-collapse: collapse; }
.admin-table td, .admin-table th { text-align: left; padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.07); vertical-align: top; }
.admin-bars { display: flex; flex-direction: column; gap: 4px; }
.admin-bar { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.admin-bar i { height: 8px; background: var(--accent); border-radius: 2px; display: block; }

@media (max-width: 760px) {
  /* top bar: brand on row 1, search full-width on row 2, buttons on row 3 */
  #topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(5, 7, 13, 0.96), rgba(5, 7, 13, 0));
  }
  .brand { gap: 8px; min-width: 0; }
  .brand p { display: none; }
  .brand h1 { font-size: 16px; }
  .brand-mark { width: 26px; height: 24px; }
  .headline-stats { display: none; }

  .topbar-actions {
    width: 100%;
    margin-left: 0;
    gap: 6px;
    flex-wrap: wrap;
  }
  #search { order: -1; flex: 1 1 100%; width: auto; }
  .topbar-actions .ghost-btn { flex: 1 1 auto; padding: 8px 10px; font-size: 12px; white-space: nowrap; }
  #user-slot { flex: 1 1 auto; }
  #user-slot .ghost-btn { width: 100%; max-width: none; }

  /* filters drawer: near full width, starts collapsed (see app.js), clears the taller bar */
  #sidebar { top: 132px; bottom: 40px; width: 92vw; border-radius: 12px 0 0 12px; }
  #sidebar.collapsed { transform: translateX(92vw); }
  .filter-row { flex-wrap: wrap; }
  .filter-row label { flex: 1 1 100%; }

  /* event detail: bottom sheet, sized to its content */
  .panel {
    left: 8px; right: 8px; bottom: 40px;
    width: auto;
    height: auto;
    max-height: 64vh;
  }

  .modal-card { padding: 18px; }
  #ticker { font-size: 11px; }
  #footer { display: none; }
}

@media print {
  body > *:not(#modal-root) { display: none !important; }
  .modal-root, .modal-card { position: static; display: block; }
  .modal-backdrop, .modal-actions, .close-x { display: none !important; }
  .certificate { border-color: #333; }
  body { background: #fff; color: #000; overflow: visible; }
}
