:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #6366f1;
  --brand-d: #4f46e5;
  --accent: #10b981;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.12);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules on a class. */
[hidden] { display: none !important; }

/* Solid dark base so mobile overscroll / areas the gradient doesn't paint
   never flash white. */
html { background: var(--bg); }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--bg) 0%, #334155 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.topbar {
  padding: 18px 20px 22px;
  color: #fff;
  text-align: center;
}
.brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brandmark { flex: 0 0 auto; }
.wordmark .hoo { color: #a5b4fc; }
.wordmark .sells { color: #ffffff; }
.tagline { color: #cbd5e1; font-size: 14px; margin-top: 4px; }
.seller-link {
  display: inline-block;
  margin-top: 10px;
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.seller-link:hover { color: #c7d2fe; text-decoration: underline; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

/* Camera */
.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0b1220;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#video { width: 100%; height: 100%; object-fit: cover; display: none; }
#video.live { display: block; }
.placeholder { color: #94a3b8; text-align: center; padding: 20px; }
.placeholder span { font-size: 48px; display: block; }
.placeholder p { margin: 10px 0 0; font-size: 14px; }
.placeholder.hidden { display: none; }

.controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  flex: 1 1 auto;
  min-width: 110px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.05s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.loc-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}
.loc-status { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 16px; }

/* Result */
.preview-row { display: flex; gap: 16px; }
#preview {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-info h2 { margin: 0 0 4px; font-size: 20px; }
.brand-line { margin: 0 0 8px; color: var(--brand-d); font-weight: 600; }
.desc { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.confidence {
  display: inline-block;
  font-size: 12px;
  background: #eef2ff;
  color: var(--brand-d);
  padding: 3px 10px;
  border-radius: 999px;
}
.result-actions { margin-top: 14px; }
.result-actions .btn { flex: 0 0 auto; }

/* In-house partner block */
.inhouse-block {
  background: linear-gradient(180deg, #eef2ff 0%, #f8faff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.inhouse-block h3 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.badge.sm { background: var(--brand); font-size: 9.5px; padding: 2px 7px; vertical-align: middle; }
.inhouse-item { background: #fff; border-color: #c7d2fe; display: flex; gap: 12px; align-items: center; }
.inhouse-item:hover { border-color: var(--brand-d); }
.inhouse-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); flex: 0 0 auto; }
.inhouse-body { flex: 1; min-width: 0; }
.badge.sm.vmatch { background: #ecfdf5; color: #065f46; }
.badge.sm.vseller { background: #eff6ff; color: #1d4ed8; }
.price-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.price-tag { color: var(--ink); font-weight: 800; font-size: 15px; }

/* Sellers */
.sellers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.seller-col h3 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.note { font-size: 11px; color: var(--muted); font-weight: 400; }

.sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.sort-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.sort-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.sort-btn:hover { border-color: var(--brand); color: var(--ink); }
.sort-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.price { color: var(--accent); font-weight: 700; }
.seller-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.seller-item {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, transform 0.05s;
}
.seller-item:hover { border-color: var(--brand); }
.seller-item:active { transform: scale(0.99); }
.seller-name { font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.seller-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.dist { color: var(--brand-d); font-weight: 700; font-size: 13px; white-space: nowrap; }
.open { color: var(--accent); font-weight: 600; }
.closed { color: var(--danger); font-weight: 600; }
.online-logo { font-weight: 700; }
.arrow { color: var(--muted); }

/* Shared */
.loading { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}

.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

footer { text-align: center; color: #94a3b8; font-size: 12px; padding: 0 16px 30px; }
footer b { color: #cbd5e1; }
.affiliate-disclosure { color: #64748b; font-size: 11px; margin-top: 6px; max-width: 520px; margin-left: auto; margin-right: auto; }

@media (max-width: 560px) {
  .sellers-grid { grid-template-columns: 1fr; }
  .preview-row { flex-direction: column; align-items: center; text-align: center; }
  .product-info { text-align: center; }
}

/* ------------------------------------------------------------------ */
/* Comp & List (reseller tool)                                         */
/* ------------------------------------------------------------------ */
.hint-input {
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
}
.hint-input:focus { outline: none; border-color: var(--brand); }

.btn.block { width: 100%; flex: none; margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  background: #eef2ff; color: var(--brand-d);
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}

.cond-block { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.cond-label, .price-title, .mini-label, .field-head label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.cond-block ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink); font-size: 14px; }
.cond-block li { margin-bottom: 4px; }

.price-block {
  margin-top: 16px;
  background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf9 100%);
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  padding: 14px 16px;
}
.price-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price-basis { font-size: 11px; color: #047857; font-weight: 700; }
.price-range { display: flex; gap: 10px; margin-top: 12px; }
.pr-col { flex: 1; text-align: center; background: #fff; border: 1px solid #d1fae5; border-radius: 12px; padding: 10px 6px; }
.pr-col.pr-mid { border-color: var(--accent); box-shadow: 0 4px 14px rgba(16,185,129,0.18); }
.pr-num { display: block; font-size: 20px; font-weight: 800; color: var(--ink); }
.pr-col.pr-mid .pr-num { color: #047857; }
.pr-lbl { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.pr-sample { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--brand-d); text-decoration: none; }
.pr-sample:hover { text-decoration: underline; }

.section-h { margin: 0 0 14px; font-size: 17px; }

.lock-card { display: flex; gap: 14px; align-items: flex-start; background: #f8fafc; border: 1px dashed var(--line); border-radius: 14px; padding: 16px; }
.lock-icon { font-size: 28px; line-height: 1; }
.lock-body strong { display: block; font-size: 15px; margin-bottom: 4px; }
.lock-body p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.unlock-note { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.field { margin-bottom: 16px; }
.field-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.copy {
  border: 1px solid var(--line); background: #fff; color: var(--brand-d);
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.copy:hover { border-color: var(--brand); }
.field-val { font-size: 14.5px; color: var(--ink); line-height: 1.55; white-space: pre-wrap; }
.field-val.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
ul.field-val { margin: 0; padding-left: 18px; white-space: normal; }
ul.field-val li { margin-bottom: 4px; }
.field-inline { display: flex; gap: 24px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.field-inline .mini-label { display: block; margin-bottom: 3px; }
.cond-inline { font-size: 14px; color: var(--ink); }
