:root {
  --bg: #0c0d0f; --panel: #17191d; --panel2: #1f2227; --line: #2b2f36;
  --text: #f1f2f4; --dim: #9aa1ac;
  --grab: #3ddc84; --inspect: #ffb020; --skip: #7b828e; --bad: #ff6b5e;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --tabs: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h4, p, dl, ul { margin: 0; }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.view { min-height: 100%; padding: 0 var(--sar) calc(var(--tabs) + var(--sab) + 12px) var(--sal); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); color: var(--text); text-decoration: none; font-weight: 600; }
.btn.primary { background: var(--grab); border-color: var(--grab); color: #06240f; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.small .ic { width: 17px; height: 17px; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn:disabled { opacity: .6; }
.round { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: rgba(20, 22, 26, .66); color: var(--text); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.round.wide { width: auto; min-width: 42px; padding: 0 12px; font-weight: 700; font-size: 14px; }
.round.big { width: 52px; height: 52px; }
.round.on { background: var(--inspect); color: #2a1a00; }
.round:disabled { opacity: .35; }

/* ---------- login ---------- */
#login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(320px, 100%); }
.login-box img { border-radius: 18px; }
.login-box h1 { font-size: 24px; letter-spacing: -.01em; }
.login-box input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 16px; }
.login-box .btn { width: 100%; }
.msg { min-height: 20px; color: var(--bad); font-size: 14px; text-align: center; }

/* ---------- camera ---------- */
#scan { position: fixed; inset: 0; padding: 0; background: #000; overflow: hidden; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-msg { position: absolute; left: 24px; right: 24px; top: 34%; padding: 16px; border-radius: 14px; background: rgba(23, 25, 29, .92); text-align: center; color: var(--text); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .28s ease-out; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 10px) calc(var(--sar) + 12px) 26px calc(var(--sal) + 12px); background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 34px; max-width: 70vw; padding: 0 13px; border: 0; border-radius: 17px; background: rgba(20, 22, 26, .66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--skip); flex: none; }
.pill.ok .dot { background: var(--grab); }
.pill.warn .dot { background: var(--inspect); }
.pill.bad .dot { background: var(--bad); }

.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 40px calc(var(--sar) + 14px) calc(var(--tabs) + var(--sab) + 12px) calc(var(--sal) + 14px); background: linear-gradient(transparent, rgba(0, 0, 0, .72) 45%); }
.strip { display: flex; gap: 8px; align-self: stretch; overflow-x: auto; scrollbar-width: none; min-height: 0; }
.strip::-webkit-scrollbar { display: none; }
.thumb { position: relative; flex: none; width: 50px; height: 50px; padding: 0; border: 1.5px solid rgba(255, 255, 255, .5); border-radius: 10px; background: #222 center/cover; }
.thumb b { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--inspect); color: #2a1a00; font-size: 12px; line-height: 20px; }
.thumb b.grab { background: var(--grab); color: #06240f; }
.thumb.busy { border-color: var(--text); }
.thumb .spin { position: absolute; inset: 0; margin: auto; }
.zoom { width: min(260px, 70%); accent-color: var(--text); }
.seg { display: flex; padding: 3px; border-radius: 14px; background: rgba(20, 22, 26, .7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.seg button { min-width: 78px; height: 36px; border: 0; border-radius: 11px; background: transparent; color: var(--dim); font-weight: 600; }
.seg button.on { background: var(--text); color: #111; }
.hint { max-width: 330px; min-height: 36px; color: #d6d9de; font-size: 13px; line-height: 1.35; text-align: center; text-shadow: 0 1px 3px #000; }
.shutter-row { display: flex; align-items: center; justify-content: center; gap: 38px; }
.shutter { width: 74px; height: 74px; padding: 0; border: 4px solid #fff; border-radius: 50%; background: transparent; }
.shutter span { display: block; width: 58px; height: 58px; margin: auto; border-radius: 50%; background: #fff; transition: transform .1s, border-radius .15s, background .15s; }
.shutter:active span { transform: scale(.9); }
.shutter.auto span { width: 28px; height: 28px; border-radius: 7px; background: var(--inspect); }
label.round { cursor: pointer; }
@media (orientation: landscape) and (max-height: 520px) {
  .hint, .strip { display: none; }
  .cam-bottom { padding-bottom: calc(var(--tabs) + var(--sab) + 6px); gap: 6px; }
  .shutter { width: 60px; height: 60px; } .shutter span { width: 46px; height: 46px; }
}

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: calc(var(--sat) + 8px) 12px 8px; background: rgba(12, 13, 15, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bar .round { background: var(--panel2); flex: none; }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar-title strong { font-size: 17px; }
.bar-title span { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 3px; background: var(--line); }
.progress div { height: 100%; background: var(--inspect); transition: width .4s; }
.progress.pulse div { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- photo with call-outs ---------- */
#result { padding-bottom: calc(var(--sab) + 20px); }
.stage-wrap { overflow: auto; background: #000; -webkit-overflow-scrolling: touch; }
.stage { position: relative; margin: 0 auto; }
.stage img { display: block; width: 100%; height: 100%; }
#overlay { position: absolute; inset: 0; }
.box { position: absolute; border: 1.5px solid; border-radius: 4px; opacity: .5; pointer-events: none; }
.box.sel { opacity: 1; border-width: 2.5px; box-shadow: 0 0 0 2000px rgba(0, 0, 0, .38); z-index: 150; }
.pin { position: absolute; display: inline-flex; align-items: center; gap: 3px; height: 26px; padding: 0 7px 0 5px; border: 1.5px solid rgba(0, 0, 0, .55); border-radius: 13px; color: #111; font-size: 12px; font-weight: 700; line-height: 1; white-space: nowrap; transform: translate(-50%, -50%); box-shadow: 0 1px 5px rgba(0, 0, 0, .6); }
.pin .ic { width: 15px; height: 15px; stroke-width: 2.1; }
.pin:not(:has(span)) { padding: 0 5px; }
.pin.sel { transform: translate(-50%, -50%) scale(1.25); z-index: 200 !important; border-color: #fff; }
.pin.busy { animation: pulse 1s ease-in-out infinite; }
.v-grab { border-color: var(--grab); }
.v-inspect { border-color: var(--inspect); }
.v-skip { border-color: var(--skip); }
.pin.v-grab { background: var(--grab); border-color: rgba(0, 0, 0, .55); }
.pin.v-inspect { background: var(--inspect); border-color: rgba(0, 0, 0, .55); }
.pin.v-skip { background: var(--skip); border-color: rgba(0, 0, 0, .55); opacity: .8; }

/* ---------- cards ---------- */
.cards { display: flex; flex-direction: column; gap: 10px; padding: 12px; max-width: 640px; margin: 0 auto; }
.scene { color: var(--dim); font-size: 14px; }
.empty { padding: 28px 12px; color: var(--dim); text-align: center; }
.err { color: var(--bad); font-size: 14px; }
.err.banner { padding: 12px; border: 1px solid var(--bad); border-radius: 12px; }
.card { border: 1px solid var(--line); border-left: 4px solid var(--skip); border-radius: 14px; background: var(--panel); overflow: hidden; }
.card.v-grab { border-left-color: var(--grab); }
.card.v-inspect { border-left-color: var(--inspect); }
.card.sel { border-color: var(--text); border-left-color: var(--text); }
.card.gone, .card.v-skip { opacity: .55; }
.card-head { display: flex; align-items: center; gap: 11px; padding: 11px 12px; cursor: pointer; }
.badge { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--panel2); color: var(--skip); flex: none; }
.v-grab .badge { color: var(--grab); }
.v-inspect .badge { color: var(--inspect); }
.crop { width: 54px; height: 54px; border-radius: 10px; background-color: #000; background-repeat: no-repeat; flex: none; }
.card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.card-title strong { font-size: 15.5px; line-height: 1.25; }
.sub { color: var(--dim); font-size: 13px; }
.sub em { font-style: normal; font-weight: 600; }
.v-grab .sub em { color: var(--grab); }
.v-inspect .sub em { color: var(--inspect); }
.price { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .why { padding: 0 12px 11px; color: #d5d8dd; font-size: 14.5px; cursor: pointer; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.card.sel .why, .card.open .why { display: block; }
.card-body { display: none; flex-direction: column; gap: 9px; padding: 0 12px 12px; font-size: 14.5px; }
.card.sel .card-body, .card.open .card-body { display: flex; }
.card-body p { color: #d5d8dd; }
.card-body .check b { color: var(--text); }
.card-body h4 { margin-top: 2px; color: var(--dim); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.card-body ul { padding-left: 19px; display: flex; flex-direction: column; gap: 3px; }
.card-body ul.flags { color: #ffb4ac; }
.card-body dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.card-body dt { color: var(--dim); }
.card-body dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.actions.end { justify-content: center; margin: 8px 0 4px; }

/* ---------- settings ---------- */
.field { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.field > span { font-weight: 600; }
.field small { color: var(--dim); font-size: 13px; }
.field textarea, .field select { width: 100%; min-height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); font-size: 16px; }
.field.row { flex-direction: row; align-items: center; justify-content: space-between; }
.field.row input { width: 24px; height: 24px; accent-color: var(--grab); }
.note { color: var(--dim); font-size: 13.5px; }

/* ---------- tab bar, toast, spinner ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; display: flex; height: calc(var(--tabs) + var(--sab)); padding: 0 var(--sar) var(--sab) var(--sal); border-top: 1px solid var(--line); background: rgba(12, 13, 15, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tabs button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--dim); font-size: 11.5px; font-weight: 600; }
.tabs button span { display: flex; }
.tabs button.on { color: var(--text); }
.tabs b { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--inspect); color: #2a1a00; font-size: 11px; line-height: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + var(--sab) + 190px); z-index: 700; max-width: 86vw; padding: 10px 14px; border-radius: 12px; background: rgba(241, 242, 244, .96); color: #111; font-size: 14px; font-weight: 600; text-align: center; transform: translateX(-50%); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
.spin.dark { width: 15px; height: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin, .progress.pulse div, .pin.busy { animation-duration: 3s; } .flash.go { animation: none; } }
