:root {
  --accent: #2F5BEA;
  --accent-dark: #2348C2;
  --bg: #080a0f;
  --surface: #111318;
  --surface2: #161820;
  --border: #1e2235;
  --border-light: rgba(255,255,255,0.06);
  --text: #e8eaf0;
  --muted: #6b7280;
  --green: #22c55e;
  --yellow: #f59e0b;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(47,91,234,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 85% 80%, rgba(79,70,229,0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header */
header {
  background: rgba(8,10,15,0.75);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.logo-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.logo-name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.logo-name:hover { opacity: 0.8; }
.logo-sep {
  color: var(--border);
  margin: 0 4px;
  font-weight: 300;
}
.logo-section {
  color: var(--muted);
  font-weight: 600;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Tool switcher — jump between Lister / Collection without detouring via Home */
.tool-switcher { position: relative; }

.hamburger-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  margin: -6px;
  transition: background 0.15s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.08); }

.tool-switcher-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.tool-switcher-btn:hover { background: rgba(255,255,255,0.06); }
.tool-switcher-btn:hover .logo-section { color: var(--text); }

.tool-switcher-caret {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s;
}
.tool-switcher.open .tool-switcher-caret { transform: rotate(180deg); }

.tool-switcher-menu {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  background: #1a1d26;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
}
.tool-switcher.open .tool-switcher-menu { display: block; }

.tool-switcher-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
a.tool-switcher-item:hover, button.tool-switcher-item:hover { background: rgba(255,255,255,0.07); }

.tool-switcher-item.active { color: var(--accent); cursor: default; }

.tool-switcher-item-soon {
  color: var(--muted);
  cursor: default;
  justify-content: space-between;
}

.tool-switcher-soon {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.ebay-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.btn-link-danger {
  color: var(--accent) !important;
}
.btn-link-danger:hover {
  text-decoration: underline;
}

.ebay-tag {
  display: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}
.status-dot.connected { background: var(--green); }
.status-dot.disconnected { background: #ef4444; }

/* Main */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
  position: relative;
  z-index: 1;
}

/* Step indicator */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.35;
  transition: opacity 0.3s;
}
.step.active { opacity: 1; }
.step.done { opacity: 0.7; }

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.3s, background 0.3s;
}
.step.active .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.step.done .step-num {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.step.skipped { opacity: 0.35; }
.step.skipped .step-num {
  border-style: dashed;
  border-color: rgba(255,255,255,0.2);
  background: transparent;
  color: var(--muted);
}

.step-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.step.active .step-label { color: var(--text); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border-light);
  margin: 0 8px;
  margin-bottom: 18px;
}

/* Cards */
.card {
  background: rgba(17,19,24,0.8);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* Upload area */
.upload-area {
  border: 2px dashed rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  transition: border-color 0.2s;
  cursor: pointer;
}
.upload-area.drag-over { border-color: var(--accent); }

.upload-icon { font-size: 40px; margin-bottom: 12px; }

.upload-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 14px 0;
}

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Camera — full-screen, app-like capture view.
   height is set explicitly (not just inset:0) because iOS Safari sizes a plain
   fixed/inset:0 box against the full layout viewport, which is taller than what's
   actually visible while its address bar + toolbar are on screen — that pushed the
   shutter row below the visible fold. 100dvh tracks the real visible viewport as
   Safari's chrome shows/hides; 100vh is the fallback for browsers without dvh. */
.camera-fullscreen {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(80,120,90,0.18) 0%, transparent 70%),
    #060907;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.camera-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.camera-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.camera-icon-btn:hover { background: rgba(255,255,255,0.16); }
.camera-icon-spacer { visibility: hidden; pointer-events: none; }

.camera-context-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin: 0;
}

.camera-stage {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 20px 0;
  min-height: 0;
  overflow: hidden;
}

.camera-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255,255,255,0.08);
}

/* .camera-stage stretches .camera-wrap to fill its full height (the default
   flex align-items behaviour) so the box has a real pixel height to work
   with — the video is then cropped to fit it via object-fit, instead of
   sizing the box from the video's own (often very tall) native dimensions,
   which on real camera streams was overflowing past the on-screen controls. */
video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-frame {
  width: 78%;
  aspect-ratio: 63/88;
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
}

.camera-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-shrink: 0;
  padding-top: 8px;
}

/* Icon-only shutter button, styled like a native camera app — a plain white
   circle, the universal shutter affordance; flanked by symmetric icon buttons. */
.btn-capture {
  background: #fff;
  border: 4px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 68px;
  height: 68px;
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s;
  flex-shrink: 0;
}
.btn-capture:hover { transform: scale(1.05); }
.btn-capture:active { transform: scale(0.95); }

/* Image preview */
#imagePreview {
  text-align: center;
}
#previewImg {
  max-width: 300px;
  max-height: 420px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  object-fit: contain;
  display: block;
  margin: 0 auto 16px;
}

.preview-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 18px rgba(47,91,234,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); box-shadow: 0 0 28px rgba(47,91,234,0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background: rgba(22,24,32,0.8);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover { background: rgba(30,34,53,0.9); border-color: rgba(255,255,255,0.12); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 0;
}
.btn-back:hover { color: var(--text); }

.btn-wide { width: 100%; margin-top: 24px; padding: 14px; font-size: 15px; }

/* Identify result */
.identify-result {
  background: rgba(22,24,32,0.8);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}
.identify-result h3 { font-size: 13px; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }

.id-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: rgba(8,10,15,0.6);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
}
.chip strong { color: var(--muted); margin-right: 4px; font-weight: 500; }

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.card-option {
  background: rgba(22,24,32,0.7);
  border: 2px solid var(--border-light);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  text-align: center;
}
.card-option:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-2px); }
.card-option.selected { border-color: var(--accent); }
.card-option img { width: 100%; border-radius: 4px; display: block; margin-bottom: 8px; }
.card-option .card-opt-name { font-size: 12px; font-weight: 600; }
.card-option .card-opt-set { font-size: 11px; color: var(--muted); }
.card-option .card-opt-num { font-size: 11px; color: var(--muted); }

/* Search row */
.search-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Step 3 layout */
.step3-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  align-items: start;
}

.selected-card-preview img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.selected-card-preview .card-price-hint {
  background: rgba(22,24,32,0.7);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px;
  margin-top: 10px;
  text-align: center;
  display: block;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
  color: var(--muted);
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.selected-card-preview .card-price-hint strong {
  display: block;
  font-size: 18px;
  color: var(--green);
}
.selected-card-preview .card-price-hint strong.loading {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  animation: price-hint-pulse 1.4s ease-in-out infinite;
}
@keyframes price-hint-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Form */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 18px 0 8px;
}
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 12px; }

.input {
  width: 100%;
  background: rgba(8,10,15,0.5);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font);
}
.input:focus { border-color: rgba(47,91,234,0.5); }
.textarea { resize: vertical; min-height: 70px; }

.price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.currency-symbol { font-size: 16px; color: var(--muted); }
.price-row .input { flex: 0 0 130px; }
.market-hint { font-size: 12px; color: var(--muted); }

/* Condition grid */
.condition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.condition-option {
  background: rgba(22,24,32,0.7);
  border: 2px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
  transition: border-color 0.2s;
  text-align: center;
  font-size: 13px;
}
.condition-option:hover { border-color: rgba(255,255,255,0.2); }
.condition-option.selected { border-color: var(--accent); }
.condition-abbrev { font-weight: 700; font-size: 15px; color: var(--text); }
.condition-name { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Step 4 */
.preview-section {}
.char-count { font-size: 11px; color: var(--muted); font-weight: normal; }

.description-preview {
  background: #fff;
  color: #333;
  border-radius: 8px;
  padding: 20px;
  max-height: 380px;
  overflow-y: auto;
  font-size: 13px;
  margin-top: 4px;
}

.publish-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 20px;
}

.auth-warning {
  font-size: 13px;
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-publish {
  background: #0064d2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-publish:hover:not(:disabled) { background: #0053b5; }
.btn-publish:disabled { opacity: 0.5; cursor: not-allowed; }

/* Feedback boxes */
.error-box {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #fca5a5;
  margin-top: 14px;
}

.success-box {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 12px;
  padding: 32px 24px;
  margin-top: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.success-box h3 {
  color: var(--green);
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.success-box h3::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

#listingLink {
  margin: 0;
}
#listingLink a {
  display: inline-block;
  color: var(--green);
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.4);
  border-radius: 8px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s;
}
#listingLink a:hover { background: rgba(34,197,94,0.2); }

/* Product type selector */
.type-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.type-option {
  background: rgba(22,24,32,0.7);
  border: 2px solid var(--border-light);
  border-radius: 10px;
  padding: 16px 10px;
  cursor: pointer;
  transition: border-color 0.2s;
  text-align: center;
}
.type-option:hover { border-color: rgba(255,255,255,0.2); }
.type-option.selected { border-color: var(--accent); }
.type-icon { font-size: 24px; margin-bottom: 6px; }
.type-name { font-size: 13px; font-weight: 600; }

/* Grading fields (slab) */
.grading-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Scan grid — front + back panels */
.scan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 4px;
}

.scan-panel-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.required-badge {
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 10px;
  letter-spacing: 0;
  font-weight: 700;
}

.scan-panel .upload-area {
  padding: 20px 10px;
  cursor: default;
}

.scan-panel .upload-icon { font-size: 28px; margin-bottom: 6px; }

.inline-preview {
  text-align: center;
  margin-top: 2px;
}

.inline-preview img {
  width: 100%;
  max-height: 220px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  object-fit: contain;
  display: block;
  margin-bottom: 8px;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* Photo summary line in step 4 */
.photo-summary {
  font-size: 13px;
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 6px;
}
.photo-summary.has-photos {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
  color: var(--green);
}
.photo-summary.no-photos {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  color: var(--yellow);
}

/* Header right grouping */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.auth-username {
  font-size: 12px;
  color: var(--muted);
}

.btn-link-muted {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
}
.btn-link-muted:hover { color: var(--text); }

/* User menu dropdown */
.user-menu { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 5px 10px 5px 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.user-menu-btn:hover { background: rgba(255,255,255,0.06); }

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #2F5BEA;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #1a1d26;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
}
.user-menu.open .user-menu-dropdown { display: block; }

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.user-menu-item:hover { background: rgba(255,255,255,0.07); }
.user-menu-item-danger { color: #fca5a5; }
.user-menu-item-danger:hover { background: rgba(239,68,68,0.1); }

.user-menu-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* History button in header */
.btn-history {
  background: rgba(22,24,32,0.8);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-history:hover { background: rgba(30,34,53,0.9); border-color: rgba(255,255,255,0.12); }

/* History overlay & panel */
.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
}

.history-panel {
  background: rgba(11,13,18,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-light);
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,0.6);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.history-header h2 { font-size: 18px; font-weight: 700; }

.history-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.history-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.history-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.history-filters .input { font-size: 13px; padding: 8px 10px; }
.history-filters-row {
  display: flex;
  gap: 8px;
}
.history-filters-row .input { flex: 1; min-width: 0; }

.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-empty {
  color: var(--muted);
  text-align: center;
  margin-top: 60px;
  font-size: 14px;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(22,24,32,0.7);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px;
}

.history-thumb {
  width: 52px;
  height: 72px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(8,10,15,0.6);
}
.history-thumb-placeholder {
  width: 52px;
  height: 72px;
  background: rgba(8,10,15,0.6);
  border-radius: 4px;
  flex-shrink: 0;
}

.history-info {
  flex: 1;
  min-width: 0;
}
.history-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.history-condition {
  font-size: 11px;
  background: rgba(139,92,246,0.15);
  color: #a78bfa;
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
}
.history-sold {
  font-size: 11px;
  background: rgba(34,197,94,0.15);
  color: var(--green);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.history-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
}
.history-qty {
  font-size: 12px;
  color: var(--muted);
}
.history-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.btn-history-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 10px;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-history-link:hover { background: rgba(47,91,234,0.1); }

.btn-history-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.btn-history-delete:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* Responsive */
@media (max-width: 600px) {
  .scan-grid { grid-template-columns: 1fr; }
  .step3-layout { grid-template-columns: 1fr; }
  .selected-card-preview img { max-width: 180px; margin: 0 auto; display: block; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .steps { overflow-x: auto; }
  .history-panel { max-width: 100%; }

  /* Header — too much content for one row at phone widths, so trim it down to the
     essentials instead of letting it overflow (overflow-x:hidden on body was silently
     clipping it) */
  .header-inner { padding: 10px 14px; flex-wrap: wrap; row-gap: 8px; }
  .header-right { gap: 8px; }
  .ebay-status #statusLabel { display: none; }
  .ebay-status .ebay-tag { display: inline; }
  /* History now lives in the hamburger menu too — drop the duplicate button here,
     it's what was crowding this row out on phone widths. */
  .btn-history { display: none; }
  .user-menu-btn .user-name { display: none; }
}
