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

/* Author `display` rules must not uncover elements marked hidden. */
[hidden] { display: none !important; }

:root {
  --red: #d01012;
  --yellow: #f7d117;
  --bg: #f5f4f0;
  --card: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --green: #1a7f37;
  --radius: 12px;
  --tap: 48px;
}

body {
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: manipulation;
}

button, .chip, .mode-btn, .export, a { -webkit-tap-highlight-color: transparent; }

header {
  background: var(--red);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
}
header h1 { font-size: 1.2rem; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
#user-label {
  font-size: 0.82rem;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.95;
}
#btn-logout, #btn-signin {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: transparent;
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}
nav { display: flex; gap: 4px; }
.guest-note {
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0.95;
  padding: 0 2px 8px;
}
.tab {
  flex: 1;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  min-height: var(--tap);
  padding: 12px 6px;
  font-size: 0.95rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}
.tab.active { background: var(--bg); color: var(--text); font-weight: 600; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }
.hint { color: var(--muted); margin-bottom: 12px; line-height: 1.4; }
.status { margin-top: 8px; color: var(--muted); min-height: 1.2em; line-height: 1.35; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}
.form-error {
  color: var(--red);
  font-size: 0.92rem;
  margin: 8px 0;
}
.form-error:empty { display: none; }

.mode, .chips { display: flex; gap: 8px; margin-bottom: 12px; }
.mode-btn, .chip {
  flex: 1;
  min-height: var(--tap);
  border: 1px solid #c9c6bd;
  background: var(--card);
  border-radius: 10px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 8px;
}
.mode-btn.active, .chip.active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.photo-slots { display: flex; gap: 12px; margin-bottom: 16px; }
.photo-slot {
  flex: 1;
  aspect-ratio: 3 / 4;
  min-height: 140px;
  background: var(--card);
  border: 2px dashed #c9c6bd;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  padding: 8px;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot.filled { border-style: solid; border-color: var(--green); }

button.primary, .export {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
button.primary:disabled { opacity: 0.4; }
button.secondary {
  width: 100%;
  margin-top: 8px;
  min-height: var(--tap);
  padding: 12px;
  font-size: 1rem;
  background: var(--card);
  border: 1px solid #c9c6bd;
  border-radius: var(--radius);
  cursor: pointer;
}

h2 { font-size: 1.05rem; margin: 16px 0 8px; }
.modal-card h2 { margin-top: 0; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.55);
}
.modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(92vh, 720px);
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}
@media (min-width: 700px) {
  .modal { place-items: center; }
}

.assessment {
  background: #fff8dc;
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.92rem;
  margin-bottom: 12px;
}
.assessment .flag { color: #9a6700; font-weight: 600; }

.candidates { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.candidates li {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 10px;
  min-height: 72px;
  cursor: pointer;
}
.candidates li.selected { border-color: var(--red); }
.candidates li.ai-pick { box-shadow: 0 0 0 2px var(--yellow); }
.candidates img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 8px; }
.candidates .meta { flex: 1; min-width: 0; }
.candidates .meta .name { font-weight: 600; font-size: 0.95rem; }
.candidates .meta .sub { color: var(--muted); font-size: 0.85rem; }
.badge {
  font-size: 0.72rem;
  background: var(--yellow);
  border-radius: 6px;
  padding: 2px 6px;
  font-weight: 700;
}

form label { display: block; margin-bottom: 10px; font-size: 0.9rem; color: var(--muted); }
form input, form select, form textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  margin-top: 4px;
  font-size: 1rem;
  border: 1px solid #c9c6bd;
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.inline-btn {
  min-height: 44px;
  min-width: 96px;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #c9c6bd;
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
}
.split { display: flex; gap: 12px; }
.split label { flex: 1; }
.price-box { margin: 12px 0; font-size: 0.92rem; color: var(--muted); }
.price-box strong { color: var(--green); }

.filters { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.filters select {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #c9c6bd;
  background: var(--card);
  font-size: 1rem;
  flex: 1;
}
.totals { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.export { margin-bottom: 12px; }

.inventory { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.inventory li.empty { display: block; }
.inventory li {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px;
}
.inventory img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: #eee; flex-shrink: 0; }
.inventory .meta { flex: 1; min-width: 0; }
.inventory .name { font-weight: 600; }
.inventory .sub { color: var(--muted); font-size: 0.85rem; }
.inventory .value { font-size: 0.9rem; margin-top: 2px; }
.inventory select.status-select {
  font-size: 0.85rem;
  min-height: 44px;
  padding: 6px;
  border-radius: 8px;
  max-width: 42%;
}
.row-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.delete-btn {
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.pill, .type-pill {
  font-size: 0.72rem;
  border-radius: 6px;
  padding: 2px 6px;
  background: #e8e6df;
  font-weight: 600;
}
.pill.listed { background: var(--yellow); }
.pill.sold { background: #c8e6c9; }
.type-pill.set { background: #dbeafe; }
.empty {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 16px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 62vh;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
#vf-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vf-frame {
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
#btn-shutter {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  width: 68px;
  height: 68px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
#btn-shutter:active { background: #fff; }

.live-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 96px;
  display: flex;
  gap: 8px;
  padding: 0 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.live-strip::-webkit-scrollbar { display: none; }
.live-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  min-height: 52px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 12px 6px 6px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.live-chip img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  flex-shrink: 0;
}
.live-chip .meta { min-width: 0; display: block; }
.live-chip .name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-chip .sub {
  display: block;
  font-size: 0.72rem;
  color: #d8d5cc;
}
.vf-hint { margin-top: 10px; text-align: center; }
#live-step .secondary { margin-top: 4px; }

.add-back {
  display: block;
  width: 100%;
  margin: 10px 0;
  min-height: var(--tap);
  padding: 12px;
  text-align: center;
  background: var(--card);
  border: 1px dashed #c9c6bd;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.price-box { display: flex; flex-direction: column; gap: 8px; }
.price-row:empty { display: none; }
.price-ai {
  background: var(--card);
  border: 1px solid #e3e0d7;
  border-radius: 8px;
  padding: 8px 10px;
}
.est-tag {
  font-size: 0.7rem;
  font-weight: 700;
  background: #e8e6df;
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 4px;
  vertical-align: 1px;
  white-space: nowrap;
}
.est-notes { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.est-sources { margin-top: 4px; font-size: 0.78rem; }
.est-sources a { color: var(--muted); }
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #c9c6bd;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

@media (max-width: 380px) {
  .mode-btn, .chip { font-size: 0.86rem; padding: 8px 4px; }
  #user-label { display: none; }
}

.auth-social {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}
.auth-social[hidden] { display: none; }
.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid #c9c6bd;
  background: var(--card);
  color: var(--text);
}
.social-btn:disabled { opacity: 0.5; cursor: wait; }
.social-btn .social-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.social-apple {
  background: #000;
  color: #fff;
  border-color: #000;
}
.social-google {
  background: #fff;
  color: #3c4043;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #d8d4ca;
}
.auth-divider span { flex-shrink: 0; }
