/* ── Shared ───────────────────────────────────────────────────────────────────── */
.col-stats {
  font-size: 12px;
  color: var(--muted);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-loading { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }

/* ── My Progress section ─────────────────────────────────────────────────────── */
#progressSection { margin-bottom: 36px; }

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.progress-card {
  background: rgba(17,19,24,0.8);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
}
.progress-card:hover { border-color: rgba(47,91,234,0.4); transform: translateY(-1px); }
.progress-card-complete { border-color: rgba(34,197,94,0.25); }
.progress-card-complete:hover { border-color: rgba(34,197,94,0.5); }

.progress-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.progress-card-name  { font-size: 13px; font-weight: 700; }
.progress-card-count { font-size: 11px; color: var(--muted); margin-bottom: 8px; }

.progress-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.bar-complete { background: #22c55e; }

.progress-untrack {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.progress-untrack:hover { color: #ef4444; }

/* ── Era browser ─────────────────────────────────────────────────────────────── */
.era-section { margin-bottom: 4px; }

.era-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(17,19,24,0.6);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  margin-bottom: 0;
}
.era-header:hover { background: rgba(17,19,24,0.9); border-color: rgba(255,255,255,0.1); }

/* When body is visible, connect header to body visually */
.era-section:has(.era-body:not(.era-collapsed)) .era-header {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
  margin-bottom: 0;
}
.era-section:has(.era-body:not(.era-collapsed)) .era-body { margin-top: 0; }

.era-name {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}
.era-meta {
  font-size: 12px;
  color: var(--muted);
}
.era-chevron {
  width: 16px;
  height: 16px;
  position: relative;
  flex-shrink: 0;
}
.era-chevron::before,
.era-chevron::after {
  content: '';
  position: absolute;
  background: var(--muted);
  border-radius: 2px;
  transition: transform 0.2s;
}
/* Draw a ▶ chevron using two bars */
.era-chevron::before {
  width: 2px; height: 10px;
  top: 3px; left: 7px;
  transform: rotate(30deg);
}
.era-chevron::after {
  width: 2px; height: 10px;
  top: 3px; left: 7px;
  transform: rotate(-30deg) translateY(6px);
}
.era-chevron.open::before { transform: rotate(-30deg); }
.era-chevron.open::after  { transform: rotate(30deg) translateY(-6px); }

.era-body {
  background: rgba(11,13,18,0.5);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 16px;
  margin-bottom: 6px;
}
.era-collapsed { display: none; }

.era-sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

/* ── Era set card ─────────────────────────────────────────────────────────────── */
.era-set-card {
  background: rgba(17,19,24,0.8);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.era-set-card:hover {
  border-color: rgba(47,91,234,0.5);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.era-set-tracked { border-color: rgba(47,91,234,0.2); }
.era-set-complete { border-color: rgba(34,197,94,0.3); }
.era-set-complete:hover { border-color: rgba(34,197,94,0.6); }

.era-set-logo {
  height: 32px;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}
.era-set-logo img {
  max-height: 32px;
  max-width: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}
.era-set-logo-fallback { font-size: 20px; }

.era-set-name  { font-size: 12px; font-weight: 700; line-height: 1.3; }
.era-set-count { font-size: 11px; color: var(--muted); }

.era-set-prog-wrap {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 2px;
}
.era-set-prog-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}
.era-set-pct { font-size: 10px; color: var(--muted); font-weight: 700; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.col-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ── Set detail view ─────────────────────────────────────────────────────────── */
.set-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.set-detail-meta { flex: 1; min-width: 0; }
.set-detail-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin-bottom: 10px;
}
.set-detail-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.set-detail-count {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 110px;
}
.set-detail-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}
.set-detail-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.set-detail-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  min-width: 36px;
  text-align: right;
}

/* ── Card checklist grid ─────────────────────────────────────────────────────── */
.set-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
}

.set-item {
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.set-item:hover { transform: scale(1.04); }

.set-item img {
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  display: block;
  object-fit: cover;
}

.set-item.not-owned {
  opacity: 0.28;
  filter: grayscale(40%);
}
.set-item.not-owned:hover {
  opacity: 0.7;
  filter: grayscale(0%);
}

.set-item.owned {
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34,197,94,0.35);
  opacity: 1;
  filter: none;
}

.set-item-check {
  position: absolute;
  top: 3px;
  right: 3px;
  background: #22c55e;
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.set-item-num {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.65);
  color: rgba(255,255,255,0.8);
  font-size: 9px;
  text-align: center;
  padding: 2px 0;
  font-weight: 600;
}

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(17,19,24,0.95);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { border-color: rgba(239,68,68,0.4); color: #fca5a5; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .era-sets-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .set-card-grid  { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 5px; }
  .progress-grid  { grid-template-columns: 1fr; }
  .set-detail-name { font-size: 18px; }
}

/* ── Card lookup ─────────────────────────────────────────────────────────────── */
.lookup { margin-bottom: 36px; }
.lookup-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.lookup-bar .input { flex: 1 1 200px; margin: 0; }
.lookup-bar .lookup-number { flex: 0 1 110px; }
.lookup-btn { margin: 0; padding: 10px 18px; width: auto; }
.lookup-status { margin-top: 12px; font-size: 13px; color: var(--muted); }
.lookup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.lookup-card {
  background: rgba(17,19,24,0.8);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.2s, transform 0.2s;
}
.lookup-card:hover { border-color: rgba(47,91,234,0.4); transform: translateY(-2px); }
.lookup-card img { width: 100%; border-radius: 4px; display: block; margin-bottom: 6px; }
.lookup-card .lc-name { font-size: 12px; font-weight: 600; }
.lookup-card .lc-sub { font-size: 11px; color: var(--muted); }

.lk-modal {
  position: fixed; inset: 0; z-index: 500;
  /* `dvh` tracks the *currently visible* viewport as Safari's address bar shows/hides,
     instead of a snapshot height taken when the modal opened — content that grows
     after opening (like Recent Sold loading in async) was overflowing above a height
     that had gone stale, pushing the sheet's top out of reach. `inset:0` above already
     covers non-supporting browsers; here `height` overrides its implied `bottom:0`. */
  height: 100dvh;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  /* On a notch/Dynamic-Island phone, 16px alone isn't enough clearance from the status
     bar — without this the sheet (and its close button) butted right up against it,
     which is what made the close button look cramped/misplaced in testing. */
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
.lk-sheet {
  position: relative;
  background: #111318;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  max-width: 640px; width: 100%; max-height: 100%;
  /* Only .lk-scroll inside scrolls — the sheet itself doesn't, so .lk-close (an
     absolutely-positioned child of the sheet, not of the scrolling part) always stays
     put in the corner instead of scrolling away with long content. */
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.lk-scroll {
  flex: 1 1 auto;
  min-height: 0; /* lets this shrink inside the flex column instead of forcing .lk-sheet to grow past max-height */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px;
}
.lk-close {
  /* Fixed to the actual screen, not to .lk-sheet — on iOS Safari the sheet's visible
     height can shrink/shift as the address bar shows or hides, which was pushing the
     sheet's own top (and an absolutely-positioned close button inside it) off-screen
     with no way to scroll back up to it. A viewport-fixed button has no such failure
     mode: it's reachable no matter what the sheet's content or scroll position does. */
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 510;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,11,15,0.75); backdrop-filter: blur(4px);
  border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.lk-body { display: flex; gap: 20px; flex-wrap: wrap; }
.lk-img { width: 220px; max-width: 100%; border-radius: 8px; align-self: flex-start; }
.lk-info { flex: 1 1 220px; min-width: 0; }
.lk-info h2 { margin: 0 0 4px; font-size: 20px; }
.lk-meta { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.lk-prices { display: grid; gap: 6px; margin-bottom: 14px; }
.lk-price {
  display: flex; justify-content: space-between; gap: 10px;
  background: rgba(255,255,255,0.04); border-radius: 8px; padding: 8px 12px; font-size: 13px;
  text-decoration: none; color: inherit;
}
.lk-price span { color: var(--muted); }
.lk-qty { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; }
.lk-qty span { color: var(--muted); margin-right: auto; }
.lk-qty button {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border-light); color: inherit; font-size: 16px;
}
.lk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lk-actions > * { flex: 1 1 140px; margin: 0; text-align: center; text-decoration: none; padding: 11px 14px; }
.lk-price.lk-link { cursor: pointer; }
.lk-price.lk-link:hover { background: rgba(255,255,255,0.09); }
.lk-price.lk-link strong::after { content: " ↗"; font-size: 11px; color: var(--muted); }
.lookup-or { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; color: var(--muted); font-size: 12px; }
.lookup-or::before, .lookup-or::after { content: ""; flex: 1; height: 1px; background: var(--border-light); }
.lookup .card { margin-bottom: 0; }

/* ── Batch scanning tray ─────────────────────────────────────────────────────── */
.batch { margin-top: 28px; }
.batch-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.batch-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.batch-totals div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.batch-totals span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.batch-totals strong { font-size: 18px; }
.batch-totals small { font-size: 11px; color: var(--muted); }
.batch-list { display: grid; gap: 10px; }
.batch-item {
  position: relative; display: flex; gap: 10px; align-items: flex-start;
  background: rgba(17,19,24,0.8); border: 1px solid var(--border-light); border-radius: 10px; padding: 10px 34px 10px 10px;
}
.batch-item img { width: 56px; border-radius: 4px; flex: none; object-fit: cover; }
.bi-scan { aspect-ratio: 5 / 7; opacity: 0.85; }
.bi-body { flex: 1; min-width: 0; }
.bi-name { font-weight: 600; font-size: 14px; }
.bi-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.bi-alt { font-size: 12px; max-width: 100%; margin-bottom: 6px; background: rgba(255,255,255,0.06); color: inherit; border: 1px solid var(--border-light); border-radius: 6px; padding: 3px 6px; }
.bi-prices { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bi-prices b { color: var(--text, #fff); }
.bi-actions { display: flex; gap: 6px; }
.bi-actions .btn-sm { text-decoration: none; }
.bi-wait { font-size: 13px; color: var(--muted); padding: 6px 0; }
.bi-err { font-size: 13px; color: #fca5a5; margin-bottom: 8px; }
.bi-remove { position: absolute; top: 4px; right: 8px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
.camera-wrap.lk-flash { filter: brightness(1.8); }

/* ── Recent Sold list (card popup) ───────────────────────────────────────────── */
.lk-sales { margin-top: 16px; border-top: 1px solid var(--border-light); padding-top: 14px; }
.lk-sales-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 10px;
}
.lk-sales-head span { font-weight: 400; text-transform: none; letter-spacing: 0; }
.lk-sales-list { display: flex; flex-direction: column; gap: 2px; }
.lk-sale {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; border-radius: 8px;
  text-decoration: none; color: inherit;
}
.lk-sale[href] { cursor: pointer; }
.lk-sale[href]:hover { background: rgba(255,255,255,0.05); }
.lk-sale img, .lk-sale-noimg {
  width: 40px; height: 56px; border-radius: 4px; object-fit: cover; flex: none;
  background: rgba(255,255,255,0.06);
}
.lk-sale-noimg { display: flex; align-items: center; justify-content: center; font-size: 16px; }
.lk-sale-body { flex: 1; min-width: 0; }
.lk-sale-title {
  font-size: 12.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lk-sale-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.lk-sale-price { font-weight: 700; font-size: 13px; flex: none; }
