:root {
  color-scheme: dark;
  --bg: #0b1020;
  --card: #111827;
  --card2: #151f33;
  --text: #edf2ff;
  --muted: #98a2b3;
  --line: rgba(255,255,255,0.09);
  --accent: #7c3aed;
  --accent2: #06b6d4;
  --danger: #ef4444;
  --ok: #22c55e;
  --shadow: 0 16px 45px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at top, #18203a 0, var(--bg) 46%, #060914 100%); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(960px, 100%); margin: 0 auto; padding: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 2px 16px; }
.eyebrow { color: var(--accent2); text-transform: uppercase; letter-spacing: 0.18em; font-size: 11px; font-weight: 800; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font-size: clamp(28px, 8vw, 44px); }
h2 { font-size: clamp(22px, 6vw, 30px); }
h3 { font-size: 18px; }
p { margin: 0; }
.card { background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025)); border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; backdrop-filter: blur(16px); }
.login-card { max-width: 420px; margin: 20vh auto 0; display: grid; gap: 12px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 14px; margin-top: 5px; }
.hidden { display: none !important; }
.photo-stage { position: relative; margin: 14px 0; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.photo-choice { min-height: 126px; display: grid; align-content: center; justify-items: center; gap: 7px; text-align: center; border: 2px dashed rgba(255,255,255,0.18); border-radius: 22px; background: rgba(255,255,255,0.035); color: var(--text); }
.photo-choice:active { transform: scale(0.99); }
.photo-choice-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), var(--accent2)); font-size: 26px; }
.photo-choice strong { font-size: clamp(15px, 4.2vw, 18px); }
.photo-choice small { color: var(--muted); font-weight: 600; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-bottom: 14px; }
.preview { position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: var(--card2); border: 1px solid var(--line); }
.preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview button { position: absolute; top: 6px; right: 6px; border: 0; border-radius: 999px; width: 30px; height: 30px; background: rgba(0,0,0,0.68); color: white; font-size: 19px; }
label { display: grid; gap: 7px; color: #dbe4ff; font-size: 14px; font-weight: 650; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,0.24); color: var(--text); padding: 13px 14px; outline: none; }
input:focus, textarea:focus { border-color: rgba(124,58,237,0.8); box-shadow: 0 0 0 3px rgba(124,58,237,0.14); }
.toggle-row { grid-template-columns: auto 1fr; align-items: center; margin: 14px 0; font-weight: 600; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.notes-box { display: grid; gap: 8px; margin: 10px 0 14px; color: #dbe4ff; font-size: 14px; font-weight: 700; }
.notes-box span { color: #dbe4ff; }
.notes-box textarea { min-height: 82px; resize: vertical; line-height: 1.35; }
.notes-box textarea::placeholder { color: rgba(219,228,255,0.48); }
.primary, .ghost { border: 0; border-radius: 15px; padding: 14px 16px; font-weight: 850; }
.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; box-shadow: 0 10px 26px rgba(124,58,237,0.28); font-size: 17px; }
.primary:disabled { opacity: 0.55; cursor: not-allowed; }
.wide { width: 100%; }
.ghost { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--line); }
.link-btn { text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }
.status { min-height: 24px; color: var(--muted); margin-top: 12px; font-size: 14px; }
.error { color: var(--danger); font-weight: 700; min-height: 20px; }
.progress-box { position: absolute; inset: 0; z-index: 5; display: grid; grid-template-columns: 66% 34%; gap: 0; overflow: hidden; background: linear-gradient(135deg, rgba(5,10,24,0.94), rgba(17,24,39,0.94)); border: 1px solid rgba(165,243,252,0.22); border-radius: 22px; box-shadow: 0 18px 45px rgba(0,0,0,0.46); backdrop-filter: blur(12px); }
.progress-log-panel { min-width: 0; padding: 13px 12px; overflow: hidden; border-right: 1px solid rgba(255,255,255,0.08); }
.progress-log { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; overflow: hidden; }
.progress-line { color: #dbe4ff; font-weight: 850; font-size: clamp(13px, 3.7vw, 16px); line-height: 1.22; transform-origin: bottom left; animation: progressLineRise 520ms ease both; }
.progress-line.old { color: rgba(219,228,255,0.54); font-weight: 700; }
@keyframes progressLineRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.progress-percent-panel { display: grid; align-content: center; justify-items: center; gap: 10px; padding: 12px 9px; background: rgba(6,182,212,0.08); }
.progress-percent-panel span { color: #a5f3fc; font-weight: 950; text-align: center; font-size: clamp(34px, 12vw, 54px); line-height: 0.92; letter-spacing: -0.06em; }
.progress-track { width: min(72px, 82%); height: 10px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,0.10); }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 260ms ease; }
.result-card { border-color: rgba(6,182,212,0.3); }
.result-hero { display: grid; grid-template-columns: minmax(0, 1fr) 98px; grid-template-rows: auto auto; gap: 10px; align-items: stretch; margin-bottom: 14px; }
.result-name { min-height: 72px; background: rgba(0,0,0,0.22); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.result-name small { display: block; color: var(--muted); margin-bottom: 5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }
.result-name h2 { font-size: clamp(24px, 7vw, 34px); line-height: 1.08; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.confidence-box { grid-column: 2; grid-row: 1 / span 2; display: grid; place-items: center; text-align: center; border-radius: 18px; background: rgba(6,182,212,0.16); border: 1px solid rgba(6,182,212,0.27); color: #a5f3fc; padding: 8px; }
.confidence-box strong { display: block; font-size: clamp(28px, 8vw, 38px); line-height: 1; }
.confidence-box small { display: block; margin-top: 6px; color: #d5fbff; font-weight: 850; }
.summary-box { grid-column: 1 / -1; background: rgba(255,255,255,0.045); border: 1px solid var(--line); border-radius: 18px; padding: 14px; font-size: clamp(16px, 4.5vw, 19px); line-height: 1.4; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.kv { background: rgba(0,0,0,0.22); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.kv small { display: block; color: var(--muted); margin-bottom: 5px; font-size: 12px; }
.kv strong { font-size: 15px; }
.value-main { margin: 14px 0; padding: 16px; border-radius: 18px; background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.27); }
.value-main small { display: block; color: #b7f7cb; font-weight: 800; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }
.value-main strong { display: block; font-size: clamp(27px, 8vw, 38px); line-height: 1; }
.value-main span { display: block; margin-top: 8px; color: #d2f8dc; font-size: 15px; }
.value-main em { display: block; margin-top: 8px; color: #a7f3d0; font-size: 13px; font-style: normal; font-weight: 800; }

.ebay-query-box {
  margin: -4px 0 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(59,130,246,0.10);
  border: 1px solid rgba(59,130,246,0.25);
}
.ebay-query-box small {
  display: block;
  color: #bfdbfe;
  font-weight: 850;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.ebay-query-box a {
  color: #dbeafe;
  font-weight: 850;
  word-break: break-word;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.compare-box { margin: 12px 0 15px; padding: 13px; border-radius: 18px; background: rgba(255,255,255,0.045); border: 1px solid var(--line); }
.compare-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.compare-head h3 { font-size: 17px; }
.compare-head small { color: var(--muted); font-weight: 750; text-align: right; }
.compare-list { display: grid; gap: 7px; }
.compare-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 38px; padding: 9px 10px; border-radius: 13px; background: rgba(0,0,0,0.22); border: 1px solid rgba(255,255,255,0.08); color: var(--text); text-decoration: none; }
.compare-row .compare-main { min-width: 0; display: grid; gap: 2px; overflow: hidden; }
.compare-row .compare-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 850; }
.compare-row .compare-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; font-weight: 700; }
.compare-row strong { color: #b7f7cb; font-size: 14px; white-space: nowrap; }
.compare-row:active { transform: scale(0.99); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: rgba(255,255,255,0.055); padding: 7px 9px; border-radius: 999px; color: #dbe4ff; font-size: 13px; }
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions button { flex: 1 1 130px; }
.object-list { display: grid; gap: 10px; margin-top: 14px; }
.object-item { display: grid; grid-template-columns: 68px 1fr; gap: 12px; align-items: center; padding: 10px; border-radius: 17px; background: rgba(0,0,0,0.2); border: 1px solid var(--line); color: var(--text); text-align: left; }
.thumb { width: 68px; height: 68px; border-radius: 13px; background: var(--card2); object-fit: cover; }
.object-meta { min-width: 0; }
.object-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.object-meta small { color: var(--muted); display: block; margin-top: 4px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.62); display: grid; place-items: end center; padding: 16px; z-index: 20; }
.modal-card { width: min(920px, 100%); max-height: 88vh; overflow: auto; background: #0f172a; border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); position: relative; }
.modal-close { position: sticky; top: 0; margin-left: auto; display: block; z-index: 1; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,0.08); color: var(--text); font-size: 24px; }
.photo-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 14px 0; }
.photo-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 15px; border: 1px solid var(--line); }
@media (max-width: 380px) {
  .app-shell { padding: 10px; }
  .card { padding: 13px; border-radius: 18px; }
  .photo-actions { gap: 8px; }
  .photo-choice { min-height: 114px; }
  .result-hero { grid-template-columns: minmax(0, 1fr) 86px; }
  .kv-grid { grid-template-columns: 1fr; }
}
@media (min-width: 780px) {
  main { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; align-items: start; }
  .scan-card { grid-column: 1; }
  .result-card { grid-column: 2; grid-row: 1 / span 2; }
  .list-card { grid-column: 1; }
  .card { padding: 20px; }
}

.top-actions { display:flex; gap:8px; align-items:center; }
.top-actions .link-btn { text-decoration:none; display:inline-flex; align-items:center; justify-content:center; }

.market-debug {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.35;
}
.market-debug strong {
  display: block;
  color: var(--text);
  margin-bottom: 3px;
}
.market-debug span {
  display: block;
}
.priority-summary {
  margin: 8px 0 10px;
  color: var(--muted);
  line-height: 1.4;
}
.priority-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 14px;
}
.priority-grid > div {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 10px;
}
.priority-grid small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 5px;
}
@media (max-width: 520px) {
  .priority-grid { grid-template-columns: 1fr; }
}

.ai-provider-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
