*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:         #F0B429;
  --gold-dark:    #C9900A;
  --gold-dim:     rgba(240,180,41,0.15);
  --gold-border:  rgba(240,180,41,0.28);
  --gold-glow:    rgba(240,180,41,0.07);
  --bg:           #0a0a0a;
  --surface:      #141414;
  --surface-2:    #1e1e1e;
  --surface-3:    #282828;
  --border:       #2a2a2a;
  --text:         #f0f0f0;
  --text-dim:     #c2c2c2;
  --text-muted:   #909090;
  --red:          #f87171;
}

/* ── Themes (premium) ── */
[data-theme="pokeball"] {
  --gold:        #EF4444;
  --gold-dark:   #DC2626;
  --gold-dim:    rgba(239,68,68,0.15);
  --gold-border: rgba(239,68,68,0.28);
  --gold-glow:   rgba(239,68,68,0.07);
}
[data-theme="masterball"] {
  --gold:        #C77DFF;
  --gold-dark:   #9D4EDD;
  --gold-dim:    rgba(199,125,255,0.15);
  --gold-border: rgba(199,125,255,0.28);
  --gold-glow:   rgba(199,125,255,0.07);
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% 0%, var(--gold-glow) 0%, transparent 70%);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── App body (scan col + list panel) ── */
#app-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  align-items: center;
}
#scan-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 390px;
  flex: 1;
}

/* ── Header ── */
header {
  width: 100%;
  max-width: 390px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid var(--gold-border);
}
header h1 {
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
#wordmark-logo {
  flex-shrink: 0;
  border-radius: 6px;
}
#version-badge {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--gold);
  background: rgba(245, 200, 66, 0.12);
  border: 1px solid rgba(245, 200, 66, 0.4);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.15rem;
  align-self: center;
  cursor: default;
}
.experimental-badge {
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--text-muted);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  line-height: 1;
  vertical-align: middle;
  margin-left: 0.3rem;
}


#list-toggle {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
#list-toggle:active { background: #333; }

/* ── Account indicator ── */
#account-wrap {
  position: relative;
  min-width: 32px;
  display: flex;
  align-items: center;
}
#account-btn[hidden], #signin-btn[hidden] { display: none; }
#signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 20px;
  padding: 0.28rem 0.75rem 0.28rem 0.55rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
#signin-btn:hover {
  background: rgba(240,180,41,0.22);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(240,180,41,0.18);
}
#signin-btn .g-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
#account-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#account-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,0.7);
}
#account-menu[hidden] { display: none; }
#account-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}
#account-menu a:not(#signout-btn) {
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.2rem 0;
}
#account-menu a:not(#signout-btn):hover { color: var(--gold); }
#signout-btn {
  font-size: 0.85rem;
  color: var(--red);
  text-decoration: none;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.2rem;
}
/* ── Theme picker row ── */
.theme-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--border);
}
.theme-row-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.theme-swatches {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch.active { border-color: var(--text); }
.theme-swatch[data-theme="default"]    { background: radial-gradient(circle at 40% 38%, #F0B429 50%, #7a5a00 50%); }
.theme-swatch[data-theme="pokeball"]   { background: radial-gradient(circle at 50% 50%, #EF4444 50%, #111 50%); border-top-color: transparent; background: linear-gradient(180deg, #EF4444 50%, #111 50%); outline: 1px solid #444; outline-offset: 1px; }
.theme-swatch[data-theme="masterball"] { background: linear-gradient(180deg, #C77DFF 50%, #111 50%); outline: 1px solid #444; outline-offset: 1px; }
.theme-swatch-lock {
  font-size: 0.6rem;
  position: absolute;
  bottom: -2px;
  right: -2px;
  line-height: 1;
  pointer-events: none;
}

/* ── Mobile notice ── */
#mobile-notice {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.3rem 1rem 0.5rem;
  letter-spacing: 0.02em;
}

#scan-tips-notice {
  margin: 0 1rem 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.scan-tips-head {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}
#scan-tips-notice ul {
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
#scan-tips-notice li {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.scan-tips-era {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-top: 0.2rem;
  border-top: 1px solid var(--border);
}

/* ── Scan tip dialog ── */
#scan-tip-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
#scan-tip-dialog.visible { display: flex; }
#scan-tip-box {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
#scan-tip-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
#scan-tip-list {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#scan-tip-list li {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.5;
}
#scan-tip-ok {
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

/* ── Main area ── */
#camera-wrap {
  position: relative;
  width: calc(100% - 2rem);
  max-width: 358px;
  flex: 1;
  min-height: 320px;
  margin: 0.75rem auto 0;
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(240,180,41,0.06), inset 0 1px 0 rgba(240,180,41,0.08);
}

/* ── Spinner ── */
#spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  gap: 0.75rem;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
#spinner.visible { opacity: 1; pointer-events: all; }
.spin {
  width: 36px; height: 36px;
  border: 3px solid rgba(240,180,41,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#spinner p { font-size: 0.85rem; color: var(--text-dim); }

/* ── Result overlay ── */
#result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.93);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  border-radius: 16px;
}
#result-overlay.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

/* Card image + shimmer */
.card-img-wrap {
  position: relative;
  width: 120px;
  height: 168px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--gold-border);
}
#card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}
#card-image.loaded { opacity: 1; }
.shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(-45deg, #1a1a1a 40%, #2a2a2a 50%, #1a1a1a 60%);
  background-size: 300%;
  background-position-x: 100%;
  animation: shimmer 0.8s infinite linear;
}
@keyframes shimmer { to { background-position-x: 0% } }

#card-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
#card-name    { font-size: 1rem; font-weight: 500; }
#set-info     { font-size: 0.75rem; color: var(--text-dim); }
#price-market { font-size: 1rem; font-weight: 400; color: var(--gold); margin-top: 0.3rem; }
.price-pct-row { font-size: 0.8rem; color: var(--text-dim); }

#tcgplayer-link {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  text-decoration: underline;
}

/* Print-variant pricing warning */
.price-note {
  font-size: 0.72rem;
  color: #b8860b;
  background: rgba(184, 134, 11, 0.08);
  border: 1px solid rgba(184, 134, 11, 0.3);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* Stamp badge */
#stamp-badge {
  font-size: 0.72rem;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  margin-top: 0.25rem;
}

/* ── Quantity stepper ── */
.qty-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.1rem;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:active { background: #333; }
#qty-display {
  font-size: 1.1rem;
  font-weight: 500;
  min-width: 1.5rem;
  text-align: center;
}

/* ── Result buttons ── */
.result-btns {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.result-btns button {
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 400;
}
#accept-btn { background: var(--gold); color: #0a0a0a; font-weight: 500; }
#accept-btn:active { background: var(--gold-dark); }
#reject-btn { background: var(--surface-3); color: var(--text); }
#reject-btn:active { background: #333; }

/* ── Toast ── */
#toast {
  position: absolute;
  bottom: 12%;
  left: 0; right: 0;
  text-align: center;
  color: var(--gold);
  font-weight: 500;
  font-size: 1rem;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: scale(1); }

/* ── Scan button ── */
#controls {
  padding: 1.5rem 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
#scan-quota {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  opacity: 0.75;
}
#quota-arc {
  width: 22px;
  height: 22px;
  transform: rotate(-90deg);
}
.quota-track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 3;
}
.quota-fill {
  fill: none;
  stroke: var(--gold);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  transition: stroke-dasharray 0.4s ease, stroke 0.3s;
}
.quota-fill.low  { stroke: #f87171; }
#quota-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
#scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 2.5rem;
  background: var(--gold);
  color: #0a0a0a;
  font-size: 1.05rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 0 24px rgba(240,180,41,0.35), 0 4px 12px rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
}
#scan-btn:active { background: var(--gold-dark); transform: scale(0.97); box-shadow: 0 0 12px rgba(240,180,41,0.2); }

/* ── Mode toggle ── */
#mode-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mode-btn.active {
  background: var(--gold);
  color: #0a0a0a;
}
.mode-btn:not(.active):hover { color: var(--text); }

/* ── Live viewfinder ── */
#viewfinder {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 24px;
}
body.live-mode #viewfinder  { display: block; }
body.live-mode #scan-btn    { display: none; }

/* Shrink the viewfinder to card proportions (63×88 mm) so the frame
   aligns naturally with the card edges. */
body.live-mode #camera-wrap {
  max-width: 252px;
  aspect-ratio: 63 / 88;
  min-height: unset;
  flex: none;
}

/* Tap-to-scan overlay — sits over the viewfinder between scans */
#live-trigger {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: 24px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(0,0,0,0.45);
  z-index: 10;
}
body.live-ready #live-trigger { display: flex; }

#live-trigger-label {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--gold);
  color: var(--bg);
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* In live mode, show result as a full-screen overlay so it isn't
   cramped inside the tiny card-proportioned viewfinder.
   Scoped to .visible so the invisible layer never eats touch events
   (iOS Safari ignores pointer-events:none on fixed elements). */
body.live-mode #result-overlay.visible {
  position: fixed;
  inset: 0;
  border-radius: 0;
  z-index: 300;
  overflow-y: auto;
}

#live-overlay {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: 24px;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.6rem;
}
body.live-mode #live-overlay { display: flex; }

/* Corner bracket viewfinder decoration */
#scan-corners {
  position: absolute;
  inset: 20px;
  pointer-events: none;
}
.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--gold);
  border-style: solid;
  border-width: 0;
  opacity: 0.9;
}
.corner.tl { top: 0; left: 0;  border-top-width: 3px; border-left-width:  3px; border-radius: 4px 0 0 0; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 0; left: 0;  border-bottom-width: 3px; border-left-width:  3px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }

body.live-scanning .corner { animation: corner-pulse 1.2s ease-in-out infinite; }
@keyframes corner-pulse {
  0%, 100% { opacity: 0.9; }
  50%       { opacity: 0.35; }
}

/* Sweep-line progress indicator */
#sweep-line {
  display: none;
  position: absolute;
  left: 24px;
  right: 24px;
  height: 2px;
  top: 24px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 40%, var(--gold) 60%, transparent 100%);
  box-shadow: 0 0 8px 2px rgba(240,180,41,0.55);
  pointer-events: none;
  border-radius: 1px;
}
body.live-scanning #sweep-line {
  display: block;
  animation: sweep 2.2s ease-in-out infinite;
}
@keyframes sweep {
  0%   { top: 24px;              opacity: 0.2; }
  8%   { top: 24px;              opacity: 1;   }
  88%  { top: calc(100% - 24px); opacity: 1;   }
  100% { top: calc(100% - 24px); opacity: 0;   }
}

#scan-status {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: background 0.2s;
}
#scan-status.motion-warning {
  background: rgba(200,100,0,0.7);
}

/* ── Stamp picker ── */
#stamp-picker {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 400;
  align-items: center;
  justify-content: center;
}
#stamp-picker.visible { display: flex; }
#stamp-picker-box {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  max-width: 320px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}
#stamp-picker-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gold);
  line-height: 1.4;
}
#stamp-picker-title span {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-dim);
}
#stamp-picker-btns {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
#stamp-regular {
  padding: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
}
#stamp-regular:active { background: #333; }
#stamp-stamped {
  padding: 0.75rem;
  border-radius: 999px;
  border: none;
  background: var(--gold);
  color: #0a0a0a;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
#stamp-stamped:active { background: var(--gold-dark); }
#stamp-cancel {
  padding: 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

/* ── Printing picker ── */
#picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 400;
  align-items: center;
  justify-content: center;
}
#picker-overlay.visible { display: flex; }
#picker-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  max-width: 340px;
  width: 90%;
  max-height: 75dvh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#picker-title {
  color: var(--text-dim);
  font-size: 0.95rem;
  text-align: center;
}
#picker-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.picker-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.4;
}
.picker-btn:active { background: var(--surface-3); }
.picker-btn .picker-set {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
  text-decoration: underline;
}
#picker-cancel {
  padding: 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
}

/* ── List panel ── */
#list-panel {
  position: fixed;
  inset: 0;
  background: var(--surface);
  z-index: 200;
  display: flex;
  flex-direction: column;
  max-width: 390px;
  margin: 0 auto;
}
#list-panel[hidden] { display: none; }
#list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--gold-border);
}
#list-header h2 { font-size: 1rem; font-weight: 500; color: var(--gold); }
#collection-switcher {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 6px;
}
#collection-switcher:hover { background: var(--gold-dim); }
#collection-switcher .caret { color: var(--text-muted); font-size: 0.8rem; }
#collection-save-state {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}
#collection-save-state.saving { background: var(--gold); opacity: 0.7; }
#collection-save-state.saved  { background: #4ec07b; }
#collection-save-state.error  { background: var(--red); }

#list-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

#list-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  gap: 0.75rem;
}
.list-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}
.list-item-name {
  font-size: 0.9rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-set {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.list-item-stamp-badge {
  font-size: 0.65rem;
  color: var(--gold);
  letter-spacing: 0.03em;
  margin-bottom: 0.1rem;
}
.list-item-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.list-item-price {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--gold);
  min-width: 3.5rem;
  text-align: right;
}
.list-item-del {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  line-height: 1;
}
.list-item-del:active { color: var(--red); }
.list-item-thumb {
  width: 36px;
  height: 50px;
  object-fit: cover;
  object-position: center top;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── List footer ── */
#list-footer {
  padding: 0.75rem 1rem 1.25rem;
  border-top: 1px solid var(--gold-border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
#list-totals {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--gold-border);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.1rem;
}
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}
.total-row span:first-child { color: var(--text-muted); }
.total-row span:last-child  { color: var(--text); }
#total-market { color: var(--gold) !important; }

#price-disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.35;
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.65rem;
  border-left: 2px solid var(--gold);
  background: rgba(245, 200, 66, 0.04);
  border-radius: 0 4px 4px 0;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 0.25rem;
}

/* ── Percentage settings ── */
#pct-settings {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.1rem 0;
}
#pct-settings label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
#pct-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  min-width: 0;
}
#pct-input:focus { outline: 1px solid var(--gold); border-color: var(--gold); }
#pct-save {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}
#pct-save:active { background: var(--surface-3); }

/* ── Share / Export / Clear buttons ── */
#share-btn {
  padding: 0.75rem;
  border-radius: 999px;
  border: none;
  background: var(--gold);
  color: #0a0a0a;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
#share-btn:active { background: var(--gold-dark); }
#share-btn:disabled { opacity: 0.6; cursor: not-allowed; }

#export-btn {
  padding: 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}
#export-btn:active { color: var(--gold); border-color: var(--gold); }

#clear-btn {
  padding: 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}
#clear-btn:active { color: var(--red); border-color: var(--red); }

/* ── Confirm dialog ── */
#confirm-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#confirm-dialog.visible { display: flex; }
#confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  max-width: 300px;
  width: 88%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: center;
}
#confirm-text { font-size: 0.9rem; color: var(--text-dim); line-height: 1.45; }
#confirm-actions { display: flex; gap: 0.75rem; }
#confirm-yes {
  flex: 1;
  padding: 0.65rem;
  border-radius: 999px;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
#confirm-no {
  flex: 1;
  padding: 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
}

/* ── Error dialog ── */
#error-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 700;
  align-items: center;
  justify-content: center;
}
#error-dialog.visible { display: flex; }
#error-box {
  background: var(--surface);
  border: 1px solid var(--red);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  max-width: 340px;
  max-height: 70dvh;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}
#error-text {
  color: var(--red);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-y: auto;
}
#error-actions { display: flex; justify-content: flex-end; }
#error-copy {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}
#error-copy.copied { color: var(--gold); border-color: var(--gold); }
#error-dismiss {
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
}

/* ── Batch skipped dialog ── */
#skipped-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#skipped-dialog.visible { display: flex; }
#skipped-box {
  background: var(--surface);
  border: 1px solid var(--gold-border);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  max-width: 340px;
  width: 90%;
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}
#skipped-title {
  font-size: 0.9rem;
  color: var(--gold);
  text-align: center;
  line-height: 1.4;
}
#skipped-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.skipped-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}
.skipped-label { font-size: 0.88rem; color: var(--text); }
.skipped-reason { font-size: 0.75rem; color: var(--text-muted); }
.stamp-choice-btns { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.stamp-choice-regular {
  flex: 1; padding: 0.4rem 0; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-3);
  color: var(--text-dim); font-size: 0.8rem; cursor: pointer;
}
.stamp-choice-stamped {
  flex: 1; padding: 0.4rem 0; border-radius: 999px;
  border: none; background: var(--gold); color: #0a0a0a;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
}
.stamp-choice-stamped:active { background: var(--gold-dark); }
#skipped-dismiss {
  padding: 0.65rem;
  border-radius: 999px;
  border: none;
  background: var(--gold);
  color: #0a0a0a;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
#skipped-dismiss:active { background: var(--gold-dark); }

/* ── Desktop layout ── */
@media (min-width: 768px) {
  body {
    background-image: radial-gradient(ellipse 60% 40% at 35% 0%, rgba(240,180,41,0.07) 0%, transparent 70%);
    font-size: 18px;
  }

  header {
    max-width: none;
    padding: 0.6rem 2.5rem;
    font-size: 1.05rem;
  }

  header h1 { font-size: 1.1rem; }

  #wordmark-logo { width: 30px; height: 30px; }

  #list-toggle { font-size: 0.9rem; padding: 0.4rem 1rem; }

  #app-body {
    flex-direction: row;
    align-items: stretch;
    max-width: 1240px;
    width: 100%;
    padding: 2rem 2.5rem;
    gap: 2rem;
    margin: 0 auto;
  }

  #scan-col {
    max-width: 500px;
    flex-shrink: 0;
  }

  #mobile-notice { display: none; }
  #list-toggle   { display: none; }

  #scan-tips-notice {
    font-size: 0.8rem;
    margin: 0 0 0.75rem;
  }

  /* Sidebar: override hidden attribute, go static */
  #list-panel {
    display: flex !important;
    position: static;
    flex: 1;
    min-width: 340px;
    max-width: 500px;
    height: auto;
    max-height: calc(100dvh - 100px);
    border-radius: 20px;
    border: 1px solid var(--gold-border);
    align-self: flex-start;
    top: 0;
  }

  #list-close { display: none; }

  #camera-wrap {
    width: 100%;
    max-width: 500px;
  }

  #card-name    { font-size: 1.15rem; }
  #set-info     { font-size: 0.85rem; }
  #price-market { font-size: 1.15rem; }
  .price-pct-row { font-size: 0.9rem; }

  #scan-btn {
    padding: 1.05rem 3rem;
    font-size: 1.15rem;
  }

  #list-header h2 { font-size: 1.1rem; }
  #list-items { font-size: 0.95rem; }
  #list-footer { font-size: 0.95rem; }
}

#site-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
#site-footer a {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
}
#site-footer a:hover { color: var(--gold); }

/* ── Correction picker ── */
.wrong-card-link {
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem;
}
.wrong-card-link:hover { color: var(--gold); }

#correct-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#correct-dialog.visible { display: flex; }
#correct-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#correct-title { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0; }
#correct-subtitle { font-size: 0.78rem; color: var(--text-dim); margin: 0; line-height: 1.4; }
#correct-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
#correct-search:focus { outline: none; border-color: var(--gold); }
#correct-results {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 80px;
  max-height: 50vh;
}
.correct-result {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.correct-result:hover { border-color: var(--gold); }
.correct-result img {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--border);
  flex-shrink: 0;
}
.correct-result-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.correct-result-name { font-size: 0.85rem; color: var(--text); font-weight: 500; }
.correct-result-set  { font-size: 0.72rem; color: var(--text-dim); }
.correct-result-empty { padding: 0.75rem; color: var(--text-dim); font-size: 0.8rem; text-align: center; }
#correct-actions { display: flex; gap: 0.75rem; }
#correct-cancel {
  flex: 1;
  padding: 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
}
#correct-status {
  font-size: 0.8rem;
  color: var(--gold);
  margin: 0;
  text-align: center;
}

/* ── Sign-in dialog ── */
#signin-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 650;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
#signin-dialog.visible { display: flex; }
#signin-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#signin-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
#signin-subtitle {
  font-size: 0.825rem;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}
#signin-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#signin-email {
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
#signin-email:focus { outline: none; border-color: var(--gold); }
#signin-submit {
  padding: 0.7rem;
  border-radius: 999px;
  border: none;
  background: var(--gold);
  color: #0a0a0a;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
#signin-submit:active { background: var(--gold-dark); }
#signin-submit:disabled { opacity: 0.6; cursor: not-allowed; }
#signin-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin: 0.25rem 0;
}
#signin-divider::before,
#signin-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
#signin-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}
#signin-google:hover { border-color: var(--gold); color: var(--gold); }
#signin-google .g-icon { width: 16px; height: 16px; }
#signin-cancel {
  padding: 0.5rem;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.25rem;
}
#signin-cancel:hover { color: var(--text); }

/* ── Collection dialogs ── */
#collection-picker, #collection-name-dialog, #collection-import-dialog {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 660;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* Name dialog opens on top of the import dialog — needs higher z-index
   because #collection-import-dialog is later in the DOM at the same level. */
#collection-name-dialog {
  z-index: 670;
}
#collection-picker.visible,
#collection-name-dialog.visible,
#collection-import-dialog.visible { display: flex; }

#collection-picker-box,
#collection-name-box,
#collection-import-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 80vh;
  overflow-y: auto;
}
#collection-picker-title,
#collection-name-title,
#collection-import-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
#collection-import-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}
#collection-import-count { color: var(--gold); font-weight: 600; }

#collection-list, #collection-import-targets {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 50vh;
  overflow-y: auto;
}
.collection-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}
.collection-row:hover { border-color: var(--gold); }
.collection-row.active { border-color: var(--gold); background: var(--gold-dim); }
.collection-row-main { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.collection-row-name { font-size: 0.9rem; color: var(--text); font-weight: 500; }
.collection-row-meta { font-size: 0.75rem; color: var(--text-dim); }
.collection-row-actions { display: flex; gap: 0.25rem; }
.collection-row-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  border-radius: 6px;
}
.collection-row-actions button:hover { color: var(--gold); background: var(--gold-dim); }
.collection-row-actions .delete:hover { color: var(--red); background: rgba(224,92,92,0.1); }

#collection-name-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
#collection-name-input:focus { outline: none; border-color: var(--gold); }
#collection-name-actions { display: flex; gap: 0.6rem; }
#collection-name-confirm, #collection-new-btn, #collection-import-new {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: none;
  background: var(--gold);
  color: #0a0a0a;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
#collection-name-cancel, #collection-picker-close, #collection-import-discard {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
}
#collection-name-cancel:hover, #collection-picker-close:hover { color: var(--text); }
#collection-import-discard { color: var(--red); border-color: var(--red); }
#collection-import-discard:hover { background: rgba(224,92,92,0.1); }


