/* ============================================================
   Brickvault — design tokens
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #F5F1E8;
  --bg-deep: #EFEAE0;
  --surface: #FFFFFF;
  --surface-2: #F2EDE3;
  --surface-3: #EAE3D4;
  --line: #1C1C1E;
  --line-soft: #D5CDB8;
  --ink: #1C1C1E;
  --ink-soft: #2D2F36;
  --ink-mute: #5E6878;
  --ink-faint: #97A0B0;
  --bv-yellow: #FFD700;
  --bv-yellow-dark: #E5C000;
  --bv-red: #DA291C;
  --bv-red-dark: #B8220F;
  --accent: #FFD700;
  --up: #1A7F4B;
  --up-soft: #D4EDDA;
  --up-pale: #EAF7EE;
  --down: #C0392B;
  --down-soft: #F8D7DA;
  --down-pale: #FBEEEC;
  --r-1: 6px; --r-2: 12px; --r-3: 16px; --r-full: 9999px;
  --shadow-1: 2px 2px 0 var(--line);
  --shadow-2: 3px 3px 0 var(--line);
  --shadow-3: 4px 4px 0 var(--line);
  --shadow-4: 5px 5px 0 var(--line);
  --nav-h: 64px;
  --dur: 0.22s;
  --dur-fast: 0.12s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Geist', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

:root[data-theme="dark"] {
  --bg: #16161C;
    --bg-deep: #0F0F14;
    --surface: #1F1F26;
    --surface-2: #24242C;
    --surface-3: #2A2A34;
    --line: #F2EDE3;
    --line-soft: #4D4D5A;
    --ink: #F2EDE3;
    --ink-soft: #D9D5C8;
    --ink-mute: #9CA3B0;
    --ink-faint: #5E6878;
    --shadow-1: 2px 2px 0 var(--line-soft);
    --shadow-2: 3px 3px 0 var(--line-soft);
    --shadow-3: 4px 4px 0 var(--line-soft);
    --shadow-4: 5px 5px 0 var(--line-soft);
    --up-pale: #103823;
    --down-pale: #3A1817;
    --up-soft: #1A4A30;
    --down-soft: #4A1F1B;
}

/* ============================================================
   Reset + base
   ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* skip link for accessibility */
.skip-link {
  position: absolute; top: -200px; left: 0;
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; z-index: 200;
}
.skip-link:focus { top: 0; }

/* offline banner */
.offline-banner {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--ink); color: var(--bg);
  text-align: center; padding: 8px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
  z-index: 90;
}
body.offline .offline-banner { display: block; }

/* skeleton */
.skel {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite ease-in-out;
  border-radius: var(--r-3);
}
.skel.line { height: 14px; border-radius: var(--r-1); }
@keyframes shimmer { 0%,100% { background-position: 0% 0%; } 50% { background-position: -100% 0%; } }
.mb-12 { margin-bottom: 12px; }

/* ============================================================
   Layout primitives
   ============================================================ */
.page {
  padding: 18px 22px 28px;
  animation: pageIn 0.42s var(--ease);
}
.page.no-pad { padding: 0 0 28px; }
.page.no-pad-top { padding-top: 0; }
@keyframes pageIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 8px 0 18px;
  gap: 12px;
}
.topbar-heading { flex: 1; min-width: 0; }
.topbar-eyebrow {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; color: var(--ink-mute);
  text-transform: uppercase;
}
.topbar-title {
  font-family: var(--serif); font-weight: 500;
  font-size: 30px; letter-spacing: -0.02em;
  line-height: 1.05; margin-top: 2px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--bv-yellow);
  border: 2px solid var(--line);
  position: relative;
  box-shadow: 2px 2px 0 var(--line);
  flex-shrink: 0;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; width: 7px; height: 7px;
  border-radius: 50%; background: var(--line);
  top: 5px;
}
.brand-mark::before { left: 5px; }
.brand-mark::after  { right: 5px; }
.brand-name {
  font-family: var(--serif); font-weight: 600;
  font-size: 22px; letter-spacing: -0.02em;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 2px solid var(--line);
  position: relative;
  transition: transform var(--dur-fast) var(--ease);
  flex-shrink: 0;
  color: var(--ink);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn .dot {
  position: absolute; top: -3px; right: -3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bv-red); color: #fff;
  border: 2px solid var(--bg);
  font-size: 10px; font-weight: 700; line-height: 12px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-3);
  padding: 18px;
}

/* ============================================================
   Hero — portfolio summary
   ============================================================ */
.hero { padding: 20px; margin-bottom: 14px; }
.hero-eyebrow {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: 8px;
}
.hero-eyebrow .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 0 rgba(26, 127, 75, 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26,127,75,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(26,127,75,0); }
}
.hero-value {
  font-family: var(--serif); font-weight: 500;
  font-size: 46px; line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
  display: flex; align-items: baseline; gap: 2px;
  font-variant-numeric: tabular-nums;
}
.hero-value .cents { font-size: 24px; color: var(--ink-mute); }
.hero-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-mute);
  flex-wrap: wrap;
}
.delta {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--r-full);
  font-weight: 600; font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.delta.up { background: var(--up-pale); color: var(--up); }
.delta.down { background: var(--down-pale); color: var(--down); }
.delta .arrow { font-size: 11px; }

.spark-wrap {
  margin: 16px -6px 0; height: 88px;
  position: relative;
}
.spark-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.spark-scrub {
  position: absolute; pointer-events: none;
  padding: 4px 8px; background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 11px;
  border-radius: var(--r-1); transform: translate(-50%, -100%);
  white-space: nowrap;
  opacity: 0; transition: opacity 0.15s;
}
.spark-scrub.show { opacity: 1; }

.range-pills {
  display: flex; gap: 6px; margin-top: 14px;
  background: var(--surface-2);
  padding: 4px; border-radius: var(--r-full);
  border: 1.5px solid var(--line-soft);
}
.range-pills button {
  flex: 1; padding: 7px 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  border-radius: var(--r-full);
  transition: all var(--dur-fast) var(--ease);
}
.range-pills button.active { background: var(--ink); color: var(--bg); }

/* ============================================================
   Filter row (sort chips)
   ============================================================ */
.filter-row {
  display: flex; gap: 8px;
  margin: 18px 0 14px;
  overflow-x: auto; scrollbar-width: none;
  margin-left: -22px; margin-right: -22px;
  padding: 2px 22px;
}
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-1);
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip.active { background: var(--bv-yellow); color: var(--line); }
.chip:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--line); }

/* ============================================================
   Set list cards
   ============================================================ */
.set-list { display: flex; flex-direction: column; gap: 10px; }
.set-list-card {
  display: flex; gap: 12px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 10px;
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-fast) var(--ease);
  position: relative; overflow: hidden;
  width: 100%; text-align: left;
}
.set-list-card:active { transform: translate(1.5px, 1.5px); box-shadow: 1px 1px 0 var(--line); }
.sl-img {
  width: 80px; height: 84px; flex-shrink: 0;
  border-radius: var(--r-2);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1.5px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.sl-img .ph-mark {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  color: var(--ink-faint); text-transform: uppercase;
  text-align: center; padding: 0 4px;
}
.sl-img img.set-photo {
  position: absolute; inset: 3px;
  width: calc(100% - 6px); height: calc(100% - 6px);
  object-fit: contain;
  mix-blend-mode: multiply;
  z-index: 1;
}
/* With a real photo, drop the framed tile so the product art sits directly on
   the card — multiply makes the white studio background disappear. */
.sl-img.has-photo { background: transparent; border-color: transparent; }
:root[data-theme="dark"] .sl-img img.set-photo {
  mix-blend-mode: normal; filter: brightness(0.95);
}
/* Dark mode can't multiply away white, so float the photo on a soft glow. */
:root[data-theme="dark"] .sl-img.has-photo {
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.10), transparent 72%);
}
.sl-img .qty-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  padding: 2px 5px; border-radius: var(--r-full);
  z-index: 2;
}
.sl-img .new-badge {
  position: absolute; bottom: 4px; left: 4px;
  background: var(--bv-red); color: #fff;
  font-family: var(--mono); font-size: 8px; font-weight: 700;
  padding: 2px 5px; border-radius: var(--r-1);
  letter-spacing: 0.1em; z-index: 2;
}
.sl-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 2px 0; gap: 4px;
}
.sl-name {
  font-weight: 600; font-size: 15px;
  letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.25;
}
.sl-meta {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute);
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
}
.sl-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; flex-shrink: 0; }
.sl-right {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between;
  padding: 2px 4px; flex-shrink: 0;
}
.sl-value {
  font-family: var(--serif); font-weight: 500;
  font-size: 18px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.sl-delta {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 6px; border-radius: var(--r-full);
}
.sl-delta.up { background: var(--up-pale); color: var(--up); }
.sl-delta.down { background: var(--down-pale); color: var(--down); }
.sl-delta.flat { color: var(--ink-mute); }

/* ============================================================
   Bottom nav
   ============================================================ */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  /* box-sizing is border-box globally, so the safe-area padding must be ADDED
     to the height — otherwise it eats into the 64px content area and squishes
     the icons/labels on notched phones (no safe area = no issue on desktop). */
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 2px solid var(--line);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
  /* Lift the fixed nav out of the page's view-transition snapshot so it stays
     pinned during route crossfades instead of being captured + re-animated
     (which made it visibly drop and snap back between tabs). */
  view-transition-name: bv-nav;
}
.nav-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-mute);
  font-size: 10px; font-family: var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 600;
  position: relative;
}
.nav-tab .nav-icon { display: inline-flex; align-items: center; justify-content: center; height: 24px; }
.nav-tab svg { width: 22px; height: 22px; }
.nav-tab .nav-label { display: block; text-align: center; }
/* Scan tab floats the orb above the nav bar; needs flex-start so the orb
   negative margin moves it upward, with label falling right below. */
.nav-tab.scan-tab { justify-content: flex-start; padding-top: 10px; }
.nav-tab.active { color: var(--ink); }
.nav-tab.active::before {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%;
  height: 3px; background: var(--bv-yellow); border-radius: 0 0 4px 4px;
}
.nav-tab.scan-tab .scan-orb {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bv-red); color: #fff;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 2px 2px 0 var(--line);
  margin-top: -18px;
  transition: transform var(--dur-fast) var(--ease);
}
.nav-tab.scan-tab .scan-orb svg { width: 22px; height: 22px; }
.nav-tab.scan-tab:active .scan-orb { transform: scale(0.94); }
.nav-tab.scan-tab.active::before { display: none; }

/* ============================================================
   Onboarding empty state
   ============================================================ */
.empty { text-align: center; padding: 40px 20px; }
.empty h3 { font-family: var(--serif); font-size: 22px; margin: 12px 0 6px; font-weight: 500; }
.empty p { color: var(--ink-mute); margin: 0 0 18px; font-size: 14px; }
.empty .empty-icon {
  font-size: 48px; display: inline-flex;
  align-items: center; justify-content: center;
  width: 80px; height: 80px; border-radius: 20px;
  background: var(--bv-yellow); border: 2px solid var(--line);
  box-shadow: var(--shadow-3); color: var(--line);
  margin: 0 auto 8px;
}
.empty .empty-icon svg { width: 38px; height: 38px; }

/* ============================================================
   Search bar
   ============================================================ */
.search-wrap { display: none; margin: 0 0 14px; position: relative; }
.search-wrap.open { display: block; animation: slideDown 0.22s var(--ease); }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-input {
  width: 100%;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--r-full);
  padding: 11px 16px 11px 42px;
  font-size: 15px;
  box-shadow: var(--shadow-1);
  outline: none;
}
.search-input:focus { box-shadow: var(--shadow-2); }
.search-wrap .s-icon {
  position: absolute; left: 14px; top: 11px; pointer-events: none;
  color: var(--ink-mute);
}
.search-wrap .s-icon svg { width: 20px; height: 20px; }

/* ============================================================
   Catalog grid (Add page)
   ============================================================ */
.scan-cta {
  background: var(--bv-red); color: #fff;
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-3);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
  transition: transform var(--dur-fast) var(--ease);
  width: 100%; text-align: left;
}
.scan-cta:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.scan-cta-icon {
  width: 46px; height: 46px; border-radius: var(--r-2);
  background: rgba(255,255,255,0.16);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.scan-cta-icon svg { width: 28px; height: 28px; }
.scan-cta-text { flex: 1; text-align: left; }
.scan-cta-text .t1 { font-family: var(--serif); font-size: 18px; font-weight: 500; line-height: 1.1; }
.scan-cta-text .t2 { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.scan-cta-arrow { opacity: 0.8; }
.scan-cta-arrow svg { width: 20px; height: 20px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.set-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform var(--dur-fast) var(--ease);
  text-align: left; width: 100%;
}
.set-card:active { transform: translate(1.5px, 1.5px); box-shadow: 1px 1px 0 var(--line); }
.set-card-img {
  aspect-ratio: 1.1 / 1;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border-bottom: 2px solid var(--line);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.set-card-img img.set-photo {
  position: absolute; inset: 7%;
  width: 86%; height: 86%;
  object-fit: contain;
  mix-blend-mode: multiply;
  z-index: 1;
}
/* Photo present → strip the framed tile so the set reads as embedded art. */
.set-card-img.has-photo { background: transparent; }
/* When a real photo is present, hide the placeholder underneath it. */
.set-card-img.has-photo .brick-tile,
.sl-img.has-photo .brick-tile,
.mini-img.has-photo .mini-figure,
.detail-img.has-photo .brick-art,
.scan-result-row .si.has-photo .brick-tile { display: none; }
:root[data-theme="dark"] .set-card-img img.set-photo {
  mix-blend-mode: normal; filter: brightness(0.95);
}
:root[data-theme="dark"] .set-card-img.has-photo {
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.08), transparent 72%);
}
.set-card-img .ph-mark {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em;
  color: var(--ink-faint); text-transform: uppercase; text-align: center;
  padding: 0 6px;
}
.set-card-img .retired-tag {
  position: absolute; top: 8px; left: 8px;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  padding: 3px 6px; border-radius: var(--r-1);
  letter-spacing: 0.1em; z-index: 2;
}
.set-card-img .owned-tag {
  position: absolute; top: 8px; right: 8px;
  background: var(--bv-yellow); color: var(--line);
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  padding: 3px 6px; border-radius: var(--r-1);
  letter-spacing: 0.1em;
  border: 1.5px solid var(--line);
  display: flex; align-items: center; gap: 3px;
  z-index: 2;
}
.set-card-img .owned-tag svg { width: 10px; height: 10px; }
.set-card-body { padding: 10px 12px 12px; }
.set-card-name {
  font-weight: 600; font-size: 13.5px;
  line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px; min-height: 32px;
}
.set-card-meta {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.05em; text-transform: uppercase;
  margin-bottom: 8px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.set-card-meta span { background: var(--surface-2); padding: 2px 6px; border-radius: var(--r-1); }
.set-card-value {
  font-family: var(--serif); font-size: 17px; font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Detail page
   ============================================================ */
.detail-hero {
  position: relative; height: 320px;
  overflow: hidden;
}
/* With a real photo, ditch the blurred ambient backdrop + scrim entirely so the
   product floats directly on the page and the bigger image fades into it. */
.detail-hero.has-photo { height: 380px; }
.detail-hero.has-photo .detail-hero-bg,
.detail-hero.has-photo .detail-hero-overlay { display: none; }
.detail-hero-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(28px) saturate(140%);
  transform: scale(1.1);
  opacity: 0.55;
}
.detail-hero-bg.placeholder {
  background: var(--brick-hue, linear-gradient(135deg, #e8c97a, #d9b965));
}
.detail-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 60%, var(--bg) 100%);
  pointer-events: none;
}
.detail-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(245,241,232,0.2), rgba(245,241,232,0));
}
:root[data-theme="dark"] .detail-hero-overlay {
  background: linear-gradient(to bottom, rgba(22,22,28,0.2), rgba(22,22,28,0));
}
.detail-back {
  position: absolute; top: 16px; left: 16px;
  width: 42px; height: 42px;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.detail-img {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 300px; height: 300px;
  display: flex; align-items: center; justify-content: center;
  /* Soft light halo that fades to nothing, so the photo melts into the page
     rather than sitting in a box. */
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.55) 38%, transparent 66%);
  border-radius: 50%;
  z-index: 2;
}
.detail-hero.has-photo .detail-img { width: 320px; height: 320px; }
:root[data-theme="dark"] .detail-img {
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.14) 0%, transparent 66%);
}
.detail-img img.set-photo {
  width: 100%; height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] .detail-img img.set-photo {
  mix-blend-mode: normal; filter: brightness(0.95);
}
.detail-img .brick-art {
  width: 180px; height: 180px;
  border-radius: 18px;
  background: var(--brick-color, #d9b965);
  border: 3px solid var(--line);
  position: relative;
  box-shadow: 6px 6px 0 var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px;
  color: var(--ink); letter-spacing: 0.1em;
  text-align: center; padding: 12px;
  text-transform: uppercase;
}
.detail-img .brick-art::before, .detail-img .brick-art::after {
  content: ""; position: absolute;
  width: 28px; height: 28px;
  border-radius: 50%; top: -16px;
  background: var(--brick-color, #d9b965);
  border: 3px solid var(--line);
}
.detail-img .brick-art::before { left: 25%; transform: translateX(-50%); }
.detail-img .brick-art::after  { right: 25%; transform: translateX(50%); }

.detail-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 22px 8px;
  margin-top: -36px; position: relative; z-index: 3;
  gap: 12px;
}
.detail-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--ink-mute); text-transform: uppercase;
  margin-bottom: 4px;
}
.detail-title {
  font-family: var(--serif); font-weight: 500;
  font-size: 28px; line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: pretty;
}
.detail-share-btn {
  flex-shrink: 0;
  width: 42px; height: 42px;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-2);
  display: flex; align-items: center; justify-content: center;
}

.detail-tabs {
  display: flex; gap: 4px;
  margin: 18px 22px 0;
  background: var(--surface-2);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-full);
  padding: 4px;
}
.detail-tabs button {
  flex: 1; padding: 9px 6px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-mute);
  border-radius: var(--r-full);
  transition: all var(--dur-fast) var(--ease);
}
.detail-tabs button.active { background: var(--ink); color: var(--bg); }
.detail-tab-panel { padding: 18px 22px 8px; }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-cell {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-2);
  padding: 12px;
  box-shadow: var(--shadow-1);
}
.stat-cell .lbl {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute); text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 4px;
}
.stat-cell .lbl svg { width: 11px; height: 11px; }
.stat-cell .val {
  font-family: var(--serif); font-size: 22px; font-weight: 500;
  letter-spacing: -0.01em; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-cell .val.s { font-size: 18px; }
.stat-cell.high { background: var(--bv-yellow); color: var(--line); }
.stat-cell.high .lbl { color: var(--line); opacity: 0.7; }

/* qty stepper */
.qty-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 14px 16px;
  box-shadow: var(--shadow-2);
  margin-bottom: 12px;
}
.qty-row-lbl {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.1em; color: var(--ink-mute);
  text-transform: uppercase;
}
.qty-row-val { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 36px; height: 36px;
  border: 2px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--dur-fast) var(--ease);
}
.qty-btn:active { transform: scale(0.9); }
.qty-num {
  font-family: var(--mono); font-weight: 600;
  font-size: 17px; min-width: 30px; text-align: center;
}

/* primary CTA */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--bv-red); color: #fff;
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: 0.01em;
  transition: transform var(--dur-fast) var(--ease);
}
.btn-primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn-primary:disabled { opacity: 0.6; pointer-events: none; }
.btn-secondary {
  width: 100%;
  padding: 13px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-secondary:active { transform: translate(1.5px, 1.5px); box-shadow: 1px 1px 0 var(--line); }
.btn-danger {
  width: 100%;
  padding: 14px;
  background: var(--surface); color: var(--down);
  border: 2px solid var(--down);
  border-radius: var(--r-3);
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

/* forecast bars */
.forecast-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 16px;
  box-shadow: var(--shadow-2);
  margin-bottom: 12px;
}
.forecast-card .fh {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.forecast-card .fh-lbl {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--ink-mute); text-transform: uppercase;
}
.forecast-card .fh-val {
  font-family: var(--serif); font-size: 22px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.forecast-bar {
  height: 10px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
  border: 1.5px solid var(--line);
}
.forecast-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--bv-yellow), var(--up));
  width: 0;
  animation: barFill 1s var(--ease) forwards;
  border-right: 1.5px solid var(--line);
}
.forecast-bar.neg > div { background: linear-gradient(90deg, var(--down), var(--down-soft)); }
@keyframes barFill {
  from { width: 0; }
  to { width: var(--fill, 50%); }
}
.forecast-pct {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--up);
}
.forecast-pct.down { color: var(--down); }
.forecast-pct svg { width: 12px; height: 12px; }

/* form inputs (manage tab) */
.field {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-1);
}
.field-lbl {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%; border: 0; background: transparent;
  font-size: 16px; font-weight: 500;
  outline: none; padding: 0;
  font-family: inherit;
  color: var(--ink);
}
.field textarea { resize: none; min-height: 64px; line-height: 1.4; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%231C1C1E' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 22px;
}
:root[data-theme="dark"] .field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23F2EDE3' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ============================================================
   Wishlist
   ============================================================ */
.wishlist-card {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 12px;
  display: flex; gap: 12px;
  box-shadow: var(--shadow-2);
  margin-bottom: 10px;
  overflow: hidden;
  width: 100%; text-align: left;
}
.wishlist-card .gap-row {
  display: flex; justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-family: var(--mono); font-size: 11px;
}
.wishlist-card .progress {
  height: 6px; background: var(--surface-2);
  border-radius: var(--r-full); overflow: hidden;
  border: 1px solid var(--line-soft);
  margin-top: 4px;
}
.wishlist-card .progress > div {
  height: 100%; background: var(--up);
}
.wishlist-card .progress.over > div { background: var(--down); }

/* ============================================================
   Blind bag (minifigs)
   ============================================================ */
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-card {
  position: relative;
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  width: 100%; text-align: left;
}
.mini-card.rarity-common { background: var(--surface-2); }
.mini-card.rarity-uncommon { background: var(--up-pale); }
.mini-card.rarity-rare { background: #FFF4E0; }
.mini-card.rarity-legendary { background: #FFF8C2; }
:root[data-theme="dark"] .mini-card.rarity-rare {
  background: #3A2C1A;
}
:root[data-theme="dark"] .mini-card.rarity-legendary {
  background: #3D341A;
}
.mini-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.mini-card.rarity-common::before { background: var(--ink-faint); }
.mini-card.rarity-uncommon::before { background: var(--up); }
.mini-card.rarity-rare::before { background: #E89A2B; }
.mini-card.rarity-legendary::before { background: var(--bv-yellow-dark); }
.mini-img {
  aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  border-bottom: 1.5px solid var(--line);
  overflow: hidden;
}
.mini-img img.fig-photo {
  width: 70%; height: 86%; object-fit: contain;
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] .mini-img img.fig-photo {
  mix-blend-mode: normal; filter: brightness(0.95);
}
.mini-figure { width: 64px; height: 92px; position: relative; }
.mini-figure .head {
  width: 22px; height: 22px; border-radius: 50%;
  background: #FFE066; border: 2px solid var(--line);
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
}
.mini-figure .body {
  width: 38px; height: 36px;
  background: var(--fig-color, #DA291C);
  border: 2px solid var(--line);
  border-radius: 6px 6px 2px 2px;
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
}
.mini-figure .legs {
  width: 36px; height: 24px;
  background: var(--fig-color2, #1C2E50);
  border: 2px solid var(--line);
  border-radius: 2px 2px 6px 6px;
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%);
}
.mini-figure.owned::after {
  content: ""; position: absolute; top: -4px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--up); border: 2px solid var(--line);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='white' stroke-width='3' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.mini-body {
  padding: 8px 10px 10px;
  flex: 1;
  display: flex; flex-direction: column;
}
.mini-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.2;
  margin-bottom: 4px;
}
.mini-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-mute);
  margin-top: auto;
}
.mini-meta .price { color: var(--ink); font-weight: 600; }
.mini-rarity {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 6px;
  background: rgba(0,0,0,0.06);
  border-radius: var(--r-1);
  margin-bottom: 4px;
  display: inline-block; width: max-content;
  color: var(--ink-soft);
}
:root[data-theme="dark"] .mini-rarity {
  background: rgba(255,255,255,0.08);
}

/* ============================================================
   Me page
   ============================================================ */
.profile-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-3);
}
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bv-yellow);
  border: 2px solid var(--line);
  box-shadow: 2px 2px 0 var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 24px; font-weight: 600;
  color: var(--line);
  flex-shrink: 0;
}
.profile-name {
  font-family: var(--serif); font-size: 22px; font-weight: 500;
  letter-spacing: -0.01em;
}
.profile-handle {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-mute); letter-spacing: 0.08em;
  text-transform: uppercase;
}
.profile-pencil {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); border: 1.5px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--ink);
}

.summary-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 18px;
}
.summary-cell {
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-3); padding: 14px;
  box-shadow: var(--shadow-2);
}
.summary-cell .lbl {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute); text-transform: uppercase;
  letter-spacing: 0.1em;
}
.summary-cell .val {
  font-family: var(--serif); font-size: 22px; font-weight: 500;
  margin-top: 4px; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.summary-cell .delta { margin-top: 6px; }

.section-title {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-mute);
  margin: 18px 4px 8px;
}

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 2px solid var(--line);
  padding: 14px 16px;
  border-bottom-width: 1px;
  gap: 12px;
}
.setting-row:first-child { border-radius: var(--r-3) var(--r-3) 0 0; }
.setting-row:last-child { border-radius: 0 0 var(--r-3) var(--r-3); border-bottom-width: 2px; }
.setting-row .lbl-wrap { flex: 1; min-width: 0; }
.setting-row .lbl-wrap .lbl { font-weight: 500; font-size: 14px; }
.setting-row .lbl-wrap .desc { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }

.toggle {
  width: 44px; height: 26px; border-radius: var(--r-full);
  background: var(--surface-2); border: 2px solid var(--line);
  position: relative; flex-shrink: 0;
  transition: background var(--dur) var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 1.5px solid var(--line);
  transition: transform var(--dur) var(--ease);
}
.toggle.on { background: var(--bv-yellow); }
.toggle.on::after { transform: translateX(18px); }

/* Light / Auto / Dark segmented control */
.theme-seg {
  display: inline-flex; flex-shrink: 0;
  border: 2px solid var(--line); border-radius: var(--r-full);
  overflow: hidden; background: var(--surface-2);
}
.theme-seg button {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 7px 12px; color: var(--ink-mute);
  border-right: 2px solid var(--line);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-seg button:last-child { border-right: 0; }
.theme-seg button.active { background: var(--bv-yellow); color: var(--line); }
.import-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--bv-yellow); border: 2px solid var(--line);
  border-radius: var(--r-2); box-shadow: var(--shadow-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform var(--dur-fast) var(--ease);
}
.import-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.import-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-1); }
.import-btn svg { width: 16px; height: 16px; }

/* ============================================================
   Pull-to-refresh
   ============================================================ */
.ptr-indicator {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  color: var(--ink);
}
.ptr-indicator.show { opacity: 1; }
.ptr-indicator svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.load-sentinel {
  display: flex; align-items: center; justify-content: center;
  padding: 24px 0 8px; min-height: 48px;
}
.load-sentinel .spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--line-soft);
  border-top-color: var(--bv-red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   Toast
   ============================================================ */
#toast {
  position: fixed; bottom: 86px; left: 16px; right: 16px;
  background: var(--ink); color: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 12px 14px;
  font-size: 14px; font-weight: 500;
  z-index: 60;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: all var(--dur) var(--ease);
  box-shadow: 4px 4px 0 var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
#toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
#toast.success { background: var(--up); color: #fff; }
#toast.error { background: var(--down); color: #fff; }
#toast .t-icon { flex-shrink: 0; }
#toast .t-icon svg { width: 18px; height: 18px; }

/* ============================================================
   Scan overlay
   ============================================================ */
#scanOverlay {
  position: fixed; inset: 0;
  background: #000;
  z-index: 100;
  display: none;
  flex-direction: column;
}
#scanOverlay.open { display: flex; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.scan-video-wrap {
  position: relative; flex: 1; overflow: hidden;
  background: #111;
}
.scan-video-wrap::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 0%, transparent 40%, rgba(0,0,0,0.65) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 4px);
  pointer-events: none;
  z-index: 1;
}
.scan-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.scan-frame {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 260px; height: 260px;
  pointer-events: none;
  z-index: 2;
}
.scan-frame .corner {
  position: absolute; width: 32px; height: 32px;
  border: 3px solid var(--bv-yellow);
}
.scan-frame .corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.scan-frame .corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.scan-frame .corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.scan-frame .corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.scan-frame.barcode { height: 160px; }
.scan-frame .laser {
  position: absolute; left: 8px; right: 8px; height: 2px;
  background: var(--bv-red);
  box-shadow: 0 0 8px var(--bv-red);
  top: 50%;
  animation: laser 2s ease-in-out infinite;
}
@keyframes laser {
  0%, 100% { top: 12%; }
  50% { top: 88%; }
}
.scan-hint {
  position: absolute; bottom: 24px; left: 16px; right: 16px;
  text-align: center; color: #fff;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
  z-index: 3;
}
.scan-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 60px 18px 0;
  z-index: 3;
}
.scan-top button {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff;
  border: 1.5px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.scan-mode-toggle {
  display: flex; gap: 0;
  background: rgba(0,0,0,0.5);
  border-radius: var(--r-full);
  padding: 4px; border: 1.5px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
}
.scan-mode-toggle button {
  padding: 8px 14px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.7);
  border-radius: var(--r-full);
  width: auto; height: auto; background: none; border: 0;
}
.scan-mode-toggle button.active { background: var(--bv-yellow); color: var(--ink); }
.scan-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 24px calc(110px + env(safe-area-inset-bottom));
  z-index: 3;
}
.scan-capture-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid rgba(255,255,255,0.4);
  outline: 2px solid var(--bv-yellow);
  outline-offset: -10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45), 0 2px 0 rgba(0,0,0,0.25);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.scan-capture-btn:active {
  transform: scale(0.9) translateY(2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* scan-result card */
.scan-result {
  position: absolute; bottom: 36px; left: 16px; right: 16px;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-3); padding: 14px;
  box-shadow: var(--shadow-3);
  display: none;
  animation: slideUp 0.32s var(--ease);
  z-index: 4;
}
.scan-result.show { display: block; }
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.scan-result-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.scan-result .badge {
  font-family: var(--mono); font-size: 10px;
  padding: 3px 7px; border-radius: var(--r-1);
  background: var(--up-pale); color: var(--up);
  letter-spacing: 0.1em; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
}
.scan-result .badge.miss { background: var(--down-pale); color: var(--down); }
.scan-result .badge svg { width: 11px; height: 11px; }
.scan-result-row { display: flex; gap: 12px; }
.scan-result-row .si {
  width: 64px; height: 64px;
  background: var(--surface-2); border: 1.5px solid var(--line-soft);
  border-radius: var(--r-2);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 9px; color: var(--ink-faint);
  overflow: hidden;
}
.scan-result-row .si img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; z-index: 1; }
:root[data-theme="dark"] .scan-result-row .si img {
  mix-blend-mode: normal;
}
.scan-result-row .sx { flex: 1; min-width: 0; }
.scan-result-row .sx-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.scan-result-row .sx-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); margin-top: 2px; letter-spacing: 0.06em; text-transform: uppercase; }
.scan-result-row .sx-val { font-family: var(--serif); font-size: 18px; font-weight: 500; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ============================================================
   Quick actions sheet (long-press menu)
   ============================================================ */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 80;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 2px solid var(--line);
  border-radius: 20px 20px 0 0;
  z-index: 81;
  padding: 12px 18px calc(30px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.28s var(--ease);
  max-height: 80vh; overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet-handle {
  width: 42px; height: 4px; border-radius: 2px;
  background: var(--line-soft);
  margin: 0 auto 14px;
}
.sheet-action {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 4px;
  font-size: 16px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.sheet-action:last-child { border-bottom: 0; }
.sheet-action.danger { color: var(--down); }
.sheet-action svg { width: 22px; height: 22px; }

/* ============================================================
   Alerts sheet
   ============================================================ */
.alert-card {
  background: var(--bv-yellow);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-2);
  color: var(--line);
}
.alert-card .ah {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.alert-card .ah svg { width: 14px; height: 14px; }

/* ============================================================
   utility — color-coded brick placeholder by hue
   ============================================================ */
.brick-tile {
  border-radius: 10px;
  border: 2px solid var(--line);
  position: relative;
  background-color: oklch(0.72 0.13 var(--h, 30));
}
.brick-tile::before, .brick-tile::after {
  content: ""; position: absolute; width: 18%; aspect-ratio: 1/1;
  border-radius: 50%; border: 2px solid var(--line);
  background-color: oklch(0.72 0.13 var(--h, 30));
  top: -6%;
}
.brick-tile::before { left: 22%; }
.brick-tile::after  { right: 22%; }

.sl-img.has-tile { background: transparent; padding: 8px 8px 4px; align-items: flex-end; }
.sl-img.has-tile .brick-tile {
  width: 100%; height: 76%;
  align-self: flex-end;
  margin-top: auto;
}

.set-card-img.has-tile { padding: 18% 18% 12%; }
.set-card-img.has-tile .brick-tile { width: 100%; height: 100%; }

/* ============================================================
   v4.0 — native-feel polish
   ============================================================ */

/* A1 — View Transitions: a quick crossfade between routes. The browser
   snapshots old/new #root and fades. Reduced-motion users skip it (the JS
   guard also bypasses startViewTransition). */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.26s;
    animation-timing-function: var(--ease);
  }
}

/* A4 — chart scrub helpers (the bubble itself uses .spark-scrub above) */
.spark-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 2px; color: var(--ink-mute);
  font-size: 12.5px; line-height: 1.35;
}
.spark-empty svg { width: 16px; height: 16px; flex-shrink: 0; }

/* A2 — bigger grab target on the sheet handle */
.sheet-handle {
  cursor: grab;
  position: relative;
}
.sheet-handle::after {
  content: ""; position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 80px; height: 26px;
}

/* prompt-sheet input (matches .field aesthetics) */
.field-input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--r-2);
  font-size: 16px; font-weight: 500; font-family: inherit;
  outline: none;
}
.field-input:focus { border-color: var(--bv-red); }

/* A5 — unified button loading state (spinner replaces the label) */
.btn-primary.is-loading,
.btn-secondary.is-loading,
.btn-danger.is-loading { color: transparent; position: relative; pointer-events: none; }
.btn-primary.is-loading::after,
.btn-secondary.is-loading::after,
.btn-danger.is-loading::after {
  content: ""; position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  color: #fff;
}
.btn-secondary.is-loading::after { color: var(--ink); }

/* A5 — staggered entrance for list/grid items on first paint */
@media (prefers-reduced-motion: no-preference) {
  .set-list .set-list-card,
  .grid .set-card,
  .mini-grid .mini-card {
    animation: itemIn 0.34s var(--ease) both;
  }
  .set-list .set-list-card:nth-child(1),
  .grid .set-card:nth-child(1),
  .mini-grid .mini-card:nth-child(1) { animation-delay: 0.02s; }
  .set-list .set-list-card:nth-child(2),
  .grid .set-card:nth-child(2),
  .mini-grid .mini-card:nth-child(2) { animation-delay: 0.05s; }
  .set-list .set-list-card:nth-child(3),
  .grid .set-card:nth-child(3),
  .mini-grid .mini-card:nth-child(3) { animation-delay: 0.08s; }
  .set-list .set-list-card:nth-child(4),
  .grid .set-card:nth-child(4),
  .mini-grid .mini-card:nth-child(4) { animation-delay: 0.11s; }
  .set-list .set-list-card:nth-child(5),
  .grid .set-card:nth-child(5),
  .mini-grid .mini-card:nth-child(5) { animation-delay: 0.14s; }
  .set-list .set-list-card:nth-child(6),
  .grid .set-card:nth-child(6),
  .mini-grid .mini-card:nth-child(6) { animation-delay: 0.17s; }
  .set-list .set-list-card:nth-child(n+7),
  .grid .set-card:nth-child(n+7),
  .mini-grid .mini-card:nth-child(n+7) { animation-delay: 0.19s; }
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* A6 — scan result loading state */
.scan-loading {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 28px 0; color: #fff;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
}
.scan-loading .spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* A8 — tablet / desktop responsiveness */
@media (min-width: 640px) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
  .mini-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  #app, #nav { max-width: 760px; margin-left: auto; margin-right: auto; }
  #nav { left: 50%; right: auto; transform: translateX(-50%); }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .mini-grid { grid-template-columns: repeat(4, 1fr); }
}
/* Landscape phones: keep the set-detail hero from eating the viewport */
@media (orientation: landscape) and (max-height: 520px) {
  .detail-hero { min-height: 0 !important; }
}

/* ============================================================
   v5.0 — Collector Power + Visual Wow
   ============================================================ */

/* A1 — Brick-texture on set photo placeholder.
   Two rows of offset LEGO stud "bumps" drawn with repeating gradients. */
.brick-tile {
  background-color: oklch(0.72 0.13 var(--h, 30));
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 10px,
      rgba(0,0,0,0.06) 10px,
      rgba(0,0,0,0.06) 11px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 10px,
      rgba(0,0,0,0.06) 10px,
      rgba(0,0,0,0.06) 11px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.07),
      rgba(255,255,255,0.07) 5px,
      transparent 5px,
      transparent 10px
    );
}

/* A2 — Bouncy toast entrance */
@keyframes slideUpBounce {
  0%   { transform: translateY(24px); opacity: 0; }
  60%  { transform: translateY(-6px); opacity: 1; }
  80%  { transform: translateY(3px); }
  100% { transform: translateY(0); opacity: 1; }
}
#toast.show { animation: slideUpBounce 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
#toast.milestone { background: #7C3AED; color: #fff; }

/* A2 — added-card flash (yellow glow then fades) */
@keyframes addedFlash {
  0%   { box-shadow: 0 0 0 4px rgba(255,215,0,0.7), var(--shadow-2); }
  100% { box-shadow: var(--shadow-2); }
}
.set-list-card.just-added { animation: addedFlash 1.2s var(--ease) forwards; }

/* A3 — Theme color left border on vault cards */
.set-list-card { border-left-width: 4px; }

/* A4 — Hero aura: subtle radial tint behind the vault hero based on portfolio trend */
.hero[data-trend="up"] {
  background-image: radial-gradient(ellipse at 75% 15%, rgba(26,127,75,0.09) 0%, transparent 65%);
}
.hero[data-trend="down"] {
  background-image: radial-gradient(ellipse at 75% 15%, rgba(192,57,43,0.08) 0%, transparent 65%);
}

/* A5 — Card hover lift on pointer devices */
@media (hover: hover) {
  .set-list-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-4);
    transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  }
  .set-card:hover {
    transform: translateY(-2px) scale(1.012);
    box-shadow: var(--shadow-3);
    transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  }
}

/* A6 — Active chip yellow glow ring */
.chip.active {
  box-shadow: 0 0 0 3px rgba(255,215,0,0.4), var(--shadow-1);
}

/* Theme dot in catalog cards */
.theme-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,0.15);
}

/* ============================================================
   Collector fields — Manage tab additions
   ============================================================ */
.completeness-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.completeness-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.completeness-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--up);
}
.missing-pieces-wrap { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.missing-pieces-wrap input {
  width: 80px;
  padding: 8px 10px;
  border: 2px solid var(--line); border-radius: var(--r-2);
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-family: var(--mono);
}
.field select {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--line); border-radius: var(--r-2);
  background: var(--surface); color: var(--ink);
  font-size: 15px; font-family: inherit; font-weight: 500;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235E6878' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* ============================================================
   Profile — CSV import/export section
   ============================================================ */
.csv-import-wrap {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 8px;
}
.csv-file-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: 2px solid var(--line); border-radius: var(--r-full);
  font-size: 13px; font-weight: 500; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: all var(--dur-fast) var(--ease);
}
.csv-file-label:active { transform: translate(1px, 1px); box-shadow: none; }
.csv-file-label svg { width: 14px; height: 14px; }
.csv-file-label input { display: none; }
#csvFileName { font-size: 12px; color: var(--ink-mute); font-family: var(--mono); }

/* ============================================================
   Insights section
   ============================================================ */
.insights-toggle {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.09em;
  text-transform: uppercase; font-weight: 600;
  color: var(--ink-mute); margin: 14px 0 2px;
  cursor: pointer; user-select: none;
}
.insights-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.insights-toggle.open svg { transform: rotate(90deg); }
.insights-section { margin-bottom: 28px; }
.insights-block { margin-bottom: 16px; }
.insights-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute);
  margin-bottom: 8px;
}
.theme-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.theme-bar-name {
  font-size: 12px; font-weight: 500; width: 82px; flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.theme-bar-track {
  flex: 1; height: 10px;
  background: var(--surface-2); border-radius: var(--r-full); overflow: hidden;
  border: 1.5px solid var(--line-soft);
}
.theme-bar-fill { height: 100%; border-radius: var(--r-full); min-width: 4px; }
.theme-bar-pct {
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
  width: 36px; text-align: right; flex-shrink: 0;
}
.insights-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; background: var(--surface-2);
  border-radius: var(--r-2); margin-bottom: 4px;
  border: 1.5px solid var(--line-soft);
  transition: background var(--dur-fast) var(--ease);
}
.insights-row:active { background: var(--surface-3); }
.ir-name {
  font-size: 13px; font-weight: 500; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px;
}
.ir-roi { font-family: var(--mono); font-size: 12px; font-weight: 600; flex-shrink: 0; }
.retiring-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.retiring-pill {
  font-size: 12px; padding: 5px 11px;
  background: var(--down-pale); color: var(--down);
  border-radius: var(--r-full); border: 1.5px solid var(--down-soft);
  font-family: var(--mono); font-weight: 500;
}

/* ============================================================
   v6.0 — Confetti, advanced filters, PWA install
   ============================================================ */

/* Confetti burst (milestone celebration) */
.confetti-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 120;
  overflow: hidden;
}
.confetti-layer i {
  position: absolute; top: -16px;
  width: 9px; height: 14px; border-radius: 2px;
  opacity: 0;
  animation-name: confettiFall;
  animation-timing-function: cubic-bezier(0.3, 0.6, 0.5, 1);
  animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(102vh) translateX(var(--drift, 0)) rotate(var(--rot, 360deg)); }
}

/* Advanced filter range inputs (filter sheet) */
.range-inputs { display: flex; align-items: center; gap: 10px; }
.range-inputs input {
  flex: 1; min-width: 0;
  padding: 11px 14px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--r-2);
  font-size: 16px; font-family: var(--mono);
  outline: none;
}
.range-inputs input:focus { border-color: var(--bv-red); }
.range-dash { color: var(--ink-mute); font-weight: 600; flex-shrink: 0; }

/* PWA install card */
.install-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--bv-yellow);
  border: 2px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-3);
  padding: 16px;
  margin: 4px 0 8px;
  color: var(--line);
  transition: transform var(--dur-fast) var(--ease);
}
.install-card:active { transform: translate(2px, 2px); box-shadow: var(--shadow-1); }
.install-icon {
  width: 42px; height: 42px; border-radius: var(--r-2); flex-shrink: 0;
  background: var(--surface); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.install-icon svg { width: 22px; height: 22px; }
.install-text { flex: 1; min-width: 0; }
.install-t1 { font-weight: 700; font-size: 15px; }
.install-t2 { font-size: 12.5px; opacity: 0.8; line-height: 1.3; margin-top: 2px; }
.install-card > svg { width: 20px; height: 20px; flex-shrink: 0; }


:root[data-theme="dark"] { color-scheme: dark; }
