:root {
  --tradz-red: #ff2538;
  --tradz-dark: #09090b;
  --tradz-muted: rgba(255,255,255,.72);
}

.tradz-scan-shell,
.tradz-scan-shell * { box-sizing: border-box; }

.tradz-scan-shell {
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background: #050505;
  color: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tradz-camera-stage {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 28%, rgba(255,255,255,.06), transparent 32%),
    linear-gradient(180deg, rgba(0,0,0,.08), rgba(0,0,0,.74));
}

.tradz-camera-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: .44;
  background-image: url('/leather-bg.png');
  background-size: cover;
  background-position: center;
}

.tradz-video,
.tradz-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.tradz-overlay { z-index: 3; pointer-events: none; }

.tradz-capture-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 9;
  background: #fff;
  opacity: 0;
}

.tradz-captured .tradz-capture-flash {
  animation: tradzFlash .28s ease-out;
}

@keyframes tradzFlash {
  0% { opacity: 0; }
  24% { opacity: .92; }
  100% { opacity: 0; }
}

.tradz-detect-status {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: calc(max(14px, env(safe-area-inset-top)) + 58px);
  transform: translateX(-50%);
  min-height: 34px;
  max-width: min(82vw, 340px);
  display: inline-grid;
  place-items: center;
  padding: 8px 13px;
  border-radius: 999px;
  color: rgba(255,255,255,.92);
  background: rgba(0,0,0,.32);
  border: 1px solid rgba(255,255,255,.13);
  box-shadow: 0 14px 36px rgba(0,0,0,.28);
  backdrop-filter: blur(18px);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,.44);
}

.tradz-detect-status::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 8px;
  display: inline-block;
  border-radius: 999px;
  background: rgba(255,255,255,.58);
  box-shadow: 0 0 0 0 rgba(255,255,255,.16);
}

.tradz-detect-status {
  grid-auto-flow: column;
  column-gap: 0;
}

.tradz-detect-status[data-state="found"]::before,
.tradz-detect-status[data-state="locked"]::before,
.tradz-detect-status[data-state="capturing"]::before {
  background: var(--tradz-red);
  box-shadow: 0 0 18px rgba(255,36,56,.92);
}

.tradz-detect-status[data-state="locked"] {
  background: rgba(255, 36, 56, .24);
  border-color: rgba(255, 36, 56, .42);
}

.tradz-detect-status[data-state="ready"] {
  background: rgba(21, 92, 255, .30);
  border-color: rgba(255,255,255,.18);
}

.tradz-detect-status[data-state="error"] {
  background: rgba(255, 36, 56, .36);
  border-color: rgba(255, 36, 56, .55);
}


.tradz-video { filter: contrast(1.04) saturate(1.04); }

.tradz-topbar {
  position: absolute;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  height: 52px;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  padding: 0 12px;
}

.tradz-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,.7);
}

.tradz-icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  background: rgba(0,0,0,.22);
  backdrop-filter: blur(14px);
}

.tradz-safe-dot {
  justify-self: end;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.72);
  font-size: 9px;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
}

.tradz-card-guide {
  pointer-events: none;
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
}

.tradz-card-guide span {
  position: absolute;
  width: min(78vw, 48vh);
  aspect-ratio: 0.716;
  border-radius: 22px;
  opacity: 0;
}

.tradz-card-found .tradz-card-guide span {
  opacity: 1;
  border: 1px solid rgba(255,36,56,.28);
  box-shadow: 0 0 34px rgba(255,36,56,.18), inset 0 0 24px rgba(255,36,56,.08);
  animation: tradzCardPulse .82s ease-in-out infinite alternate;
}

.tradz-card-stable .tradz-card-guide span {
  border-color: rgba(255,36,56,.48);
  box-shadow: 0 0 44px rgba(255,36,56,.34), inset 0 0 28px rgba(255,36,56,.12);
  animation-duration: .38s;
}

@keyframes tradzCardPulse {
  from { transform: scale(.992); }
  to { transform: scale(1.012); }
}

.tradz-bottom-controls {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 96px 1fr;
  align-items: center;
  padding: 0 34px 8px;
}

.tradz-gallery,
.tradz-check,
.tradz-shutter {
  justify-self: center;
  border: 0;
  cursor: pointer;
}

.tradz-gallery {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: rgba(255,255,255,.92);
  box-shadow: inset 0 0 0 5px rgba(0,0,0,.15);
}

.tradz-check {
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 20px;
  background: transparent;
}

.tradz-shutter {
  width: 76px;
  height: 76px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 7px rgba(255,255,255,.22), 0 20px 45px rgba(0,0,0,.42);
}

.tradz-is-scanning .tradz-shutter {
  transform: scale(.92);
  background: #ffebef;
}

.tradz-card-found .tradz-shutter {
  box-shadow: 0 0 0 7px rgba(255,36,56,.18), 0 20px 45px rgba(0,0,0,.42), 0 0 36px rgba(255,36,56,.22);
}

.tradz-card-stable .tradz-shutter {
  background: #fff5f6;
  animation: tradzShutterReady .42s ease-in-out infinite alternate;
}

@keyframes tradzShutterReady {
  from { transform: scale(1); }
  to { transform: scale(.94); }
}

.tradz-result-sheet {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  color: #111827;
  background: rgba(255,255,255,.96);
  border-radius: 28px 28px 0 0;
  padding: 10px 18px max(22px, env(safe-area-inset-bottom));
  box-shadow: 0 -24px 80px rgba(0,0,0,.42);
  backdrop-filter: blur(20px);
  animation: tradzSheet .22s ease-out;
}

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

.tradz-handle {
  width: 46px;
  height: 5px;
  border-radius: 999px;
  background: rgba(17,24,39,.16);
  margin: 0 auto 12px;
}

.tradz-sheet-title {
  text-align: center;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 12px;
}

.tradz-match-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 20px;
  background: #f7f7f8;
  border: 1px solid rgba(17,24,39,.06);
}

.tradz-match-card img {
  width: 70px;
  height: 98px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0,0,0,.18);
}

.tradz-no-image {
  width: 70px;
  height: 98px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e5e7eb, #f9fafb);
}

.tradz-match-card h3 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.2;
}

.tradz-match-card p {
  margin: 0 0 7px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.35;
}

.tradz-match-card b {
  display: inline-flex;
  color: #0f172a;
  background: #fff;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.tradz-candidates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.tradz-candidate {
  min-height: 58px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(17,24,39,.08);
  border-radius: 16px;
  background: #fff;
  padding: 8px;
  text-align: left;
  color: #111827;
  font-weight: 700;
  font-size: 11px;
}

.tradz-candidate img {
  width: 34px;
  height: 47px;
  object-fit: cover;
  border-radius: 5px;
}

.tradz-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 10px;
}

.tradz-secondary,
.tradz-primary {
  border: 0;
  min-height: 50px;
  border-radius: 999px;
  font-weight: 900;
}

.tradz-secondary { background: #f1f5f9; color: #1f2937; }
.tradz-primary { background: #155cff; color: #fff; box-shadow: 0 12px 26px rgba(21, 92, 255, .32); }

/* Collector detail popup upgrade */
.tradz-result-sheet {
  max-height: min(74dvh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
}

.tradz-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tradz-detail-header .tradz-sheet-title {
  text-align: left;
  margin: 0;
  font-size: 16px;
  letter-spacing: -.01em;
}

.tradz-detail-header p {
  margin: 3px 0 0;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.3;
}

.tradz-detail-header > b {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: #0f172a;
  background: #f1f5f9;
  border: 1px solid rgba(15,23,42,.08);
  font-size: 12px;
}

.tradz-detail-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 13px;
  align-items: stretch;
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff, #f7f8fb);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 16px 38px rgba(15,23,42,.09);
}

.tradz-detail-image {
  width: 86px !important;
  height: 120px !important;
  border-radius: 13px !important;
  object-fit: cover;
  box-shadow: 0 16px 28px rgba(0,0,0,.22);
}

.tradz-detail-main {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
}

.tradz-detail-main h3 {
  margin: 0;
  color: #0f172a;
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.tradz-detail-main p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.tradz-price-box {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 18px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 14px 28px rgba(15,23,42,.22);
}

.tradz-price-box span {
  color: rgba(255,255,255,.68);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.tradz-price-box strong {
  font-size: 20px;
  letter-spacing: -.03em;
}

.tradz-price-box small {
  color: rgba(255,255,255,.72);
  font-size: 10px;
  line-height: 1.3;
}

.tradz-metadata-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.tradz-meta-chip {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(15,23,42,.06);
}

.tradz-meta-chip span {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.tradz-meta-chip b {
  overflow: hidden;
  color: #111827;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tradz-legality {
  margin-bottom: 10px;
  padding: 9px 11px;
  border-radius: 15px;
  background: rgba(21, 92, 255, .08);
  color: #1e3a8a;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.tradz-condition-note {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: #fff7ed;
  border: 1px solid rgba(234,88,12,.12);
}

.tradz-condition-note span {
  color: #9a3412;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.tradz-condition-note b {
  color: #7c2d12;
  font-size: 11px;
}

.tradz-condition-note small {
  grid-column: 1 / -1;
  color: #9a3412;
  font-size: 10px;
  line-height: 1.35;
}

.tradz-candidate-title {
  margin: 10px 0 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 950;
}

.tradz-candidate {
  position: relative;
}

.tradz-candidate em {
  position: absolute;
  right: 8px;
  bottom: 6px;
  color: #64748b;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.tradz-actions {
  grid-template-columns: 1fr 1fr 1.35fr;
}

.tradz-market {
  border: 0;
  min-height: 50px;
  border-radius: 999px;
  color: #0f172a;
  background: #e0f2fe;
  font-weight: 900;
}

.tradz-actions:has(.tradz-secondary:nth-child(1):last-child),
.tradz-actions:not(:has(.tradz-market)) {
  grid-template-columns: 1fr 1.35fr;
}

@supports not selector(:has(*)) {
  .tradz-actions { grid-template-columns: 1fr 1fr 1.35fr; }
}
