/* ClearShot app. Colours from the ClearShot site (dark + amber); layout from StoreKeep (bottom bar with a raised centre button on phones,
   the same actions in the top bar on desktop). */
:root { --bg:#111418; --surface:#1C2126; --surface2:#242b32; --border:#3c4753; --accent:#E8A020; --accent-dark:#C47D0A; --accent-text:#111418;
        --text:#E9ECEF; --muted:#9dabb8; --danger:#ff8a80; --ok:#5fd39a; --nav-h:64px; }
* { box-sizing:border-box; }
/* The canvas behind the page is the bottom bar's colour: whatever strip a phone's browser/OS leaves under the fixed bar (Safari toolbar zone, Android nav area) then looks like part of the bar, not a gap. The body still paints the dark page colour over the whole viewport. */
html { -webkit-text-size-adjust:100%; color-scheme:dark; background:var(--surface); }
body { margin:0; background:var(--bg); color:var(--text); font:16px/1.45 Inter,system-ui,-apple-system,Segoe UI,sans-serif; -webkit-font-smoothing:antialiased;
       min-height:100vh; min-height:100dvh; padding:env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); touch-action:manipulation; }
body.in { padding-bottom:calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
svg { width:1.25em; height:1.25em; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; flex:none; }
[hidden] { display:none !important; }
main { max-width:1100px; margin:0 auto; padding:0 16px 24px; }

/* ---- header ---- */
.top { max-width:1100px; margin:0 auto; padding:22px 16px 10px; text-align:center; }
.brand h1 { margin:0; font-size:2rem; font-weight:800; letter-spacing:-.02em; }
.tag { margin:4px 0 0; color:var(--muted); font-size:1.02rem; }

/* ---- cards, text, buttons ---- */
.card { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px; margin-bottom:14px; }
.h { margin:0 0 12px; font-size:1.05rem; font-weight:700; }
.lead { margin-top:0; color:var(--muted); }
.muted { color:var(--muted); } .center { text-align:center; }
.msg { margin:10px 0 0; color:var(--muted); } .msg.err { color:var(--danger); }
.hint { margin:10px 0 0; color:var(--muted); font-size:.9rem; text-align:center; }
label { display:block; font-weight:600; margin-bottom:12px; }
input:not([type=file]) { display:block; font:inherit; width:100%; padding:13px 12px; border-radius:10px; border:1px solid var(--border); background:var(--bg); color:var(--text); margin-top:5px; }
input:focus-visible, button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
button { font:inherit; cursor:pointer; color:inherit; }
button.primary { font-weight:700; padding:14px 18px; border-radius:10px; border:0; background:var(--accent); color:var(--accent-text); }
button.primary:hover { background:var(--accent-dark); }
button.primary:disabled { background:var(--surface2); color:var(--muted); cursor:not-allowed; }
button.ghost { font-weight:600; padding:9px 14px; border-radius:10px; border:1px solid var(--border); background:var(--surface); display:inline-flex; align-items:center; gap:8px; }
button.ghost:hover { border-color:var(--accent); }
button.ghost:disabled { opacity:.5; cursor:not-allowed; }
.wide { width:100%; }
.create { margin-top:14px; font-size:1.05rem; }
.chiprow { text-align:center; margin:6px 0 12px; }
.chip { display:inline-block; font-size:.86rem; font-weight:600; padding:4px 12px; border-radius:99px; border:1px solid var(--accent); color:var(--accent); }
.chip.bad { color:var(--danger); border-color:var(--danger); }

/* ---- capture area + staged photos ---- */
.drop { width:100%; min-height:190px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; padding:20px; border:2px dashed var(--border); border-radius:12px; background:var(--bg); color:var(--accent); }
.drop svg { width:44px; height:44px; }
.drop strong { font-size:1.1rem; } .drop span { color:var(--muted); font-size:.92rem; }
.drop:hover, .drop.over { border-color:var(--accent); background:var(--surface2); }
.tray { display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:10px; margin-top:12px; }
.tile { display:flex; flex-direction:column; gap:6px; min-width:0; }
.tile .sku { padding:8px 9px; font-size:.85rem; margin-top:0; }
.thumb { position:relative; aspect-ratio:1/1; border-radius:8px; overflow:hidden; border:1px solid var(--border); background:var(--bg); }
.thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.thumb button { position:absolute; top:4px; right:4px; width:26px; height:26px; border-radius:50%; border:0; background:rgba(17,20,24,.85); display:flex; align-items:center; justify-content:center; padding:0; }
.thumb button svg { width:14px; height:14px; }

/* ---- results ---- */
.rhead { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:6px 0 10px; } .rhead .h { margin:0; }

.item { background:var(--surface); border:1px solid var(--border); border-radius:12px; overflow:hidden; }
.pair { display:grid; grid-template-columns:1fr 1fr; gap:1px; background:var(--border); }
.pair figure { margin:0; background:var(--surface); aspect-ratio:1/1; display:flex; align-items:center; justify-content:center; position:relative; }
.pair img { width:100%; height:100%; object-fit:contain; }
.pair figcaption { position:absolute; left:6px; top:6px; font-size:.66rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); background:rgba(17,20,24,.8); border-radius:4px; padding:1px 6px; }
.item .meta { padding:10px 12px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.item .name { flex:1 1 100%; font-weight:600; overflow-wrap:anywhere; }
.item .state { color:var(--muted); font-size:.92rem; flex:1; } .item .state.err { color:var(--danger); }
.item .acts { display:flex; gap:8px; }
.item .acts button { padding:8px 12px; font-size:.92rem; display:inline-flex; align-items:center; gap:6px; }
.spin { display:inline-block; width:14px; height:14px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:sp .8s linear infinite; vertical-align:-2px; margin-right:6px; }
@keyframes sp { to { transform:rotate(360deg); } }

/* ---- bottom bar (phones) ---- */
.bottom { position:fixed; left:0; right:0; bottom:0; z-index:300; height:calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom:env(safe-area-inset-bottom);
          background:var(--surface); border-top:2px solid var(--border); display:flex; align-items:stretch; }
.bb { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; background:none; border:0; color:var(--muted);
      font-size:.62rem; font-weight:700; letter-spacing:.04em; text-transform:uppercase; padding:8px 2px 6px; position:relative; -webkit-tap-highlight-color:transparent; }
.bb:hover, .bb:active { color:var(--text); }
.bb .ico { position:relative; display:inline-flex; } .bb .ico svg { width:22px; height:22px; }
.bb.pic { flex:1.3; color:var(--accent); }
.ring { width:54px; height:54px; margin-top:-22px; border-radius:50%; background:var(--accent); color:var(--accent-text); display:flex; align-items:center; justify-content:center; box-shadow:0 4px 14px rgba(0,0,0,.5); transition:transform .12s; }
.ring svg { width:26px; height:26px; }
.bb.pic:active .ring { transform:scale(.94); }
.badge { position:absolute; top:-6px; right:-12px; min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:var(--accent); color:var(--accent-text); font-size:.68rem; font-weight:800; display:inline-flex; align-items:center; justify-content:center; letter-spacing:0; }
.badge.bad { background:var(--danger); }

/* ---- bottom sheet / dialog ---- */
.sheet { position:fixed; inset:0; z-index:700; display:flex; align-items:flex-end; justify-content:center; }
.scrim { position:absolute; inset:0; background:rgba(0,0,0,.6); }
.panel { position:relative; width:100%; max-width:520px; max-height:82vh; overflow:auto; background:var(--surface); border:1px solid var(--border); border-radius:16px 16px 0 0; padding:0 18px calc(18px + env(safe-area-inset-bottom)); animation:up .18s ease-out; }
@keyframes up { from { transform:translateY(30px); opacity:0; } }
.phead { display:flex; align-items:center; justify-content:space-between; padding:16px 0 8px; position:sticky; top:0; background:var(--surface); }
.phead h2 { margin:0; font-size:1.15rem; }
.x { background:none; border:0; color:var(--muted); padding:6px; display:flex; }
.pbody p { margin:0 0 12px; } .pbody ul { padding-left:20px; margin:0 0 8px; } .pbody li { margin-bottom:8px; }
.big { font-size:2rem; font-weight:800; color:var(--accent); line-height:1.1; margin:4px 0 8px; }
.meter { height:8px; border-radius:4px; background:var(--bg); border:1px solid var(--border); overflow:hidden; margin:6px 0 14px; }
.meter i { display:block; height:100%; background:var(--accent); }
.kv { display:grid; grid-template-columns:auto 1fr; gap:6px 16px; margin:0 0 14px; } .kv dt { color:var(--muted); } .kv dd { margin:0; text-align:right; font-weight:600; }
.row2 { display:flex; gap:10px; } .row2 > * { flex:1; }
.linkrow { display:flex; align-items:center; gap:10px; justify-content:space-between; padding:10px 0; border-top:1px solid var(--border); }
.linkrow:first-child { border-top:0; }
.linkrow .li-main { flex:1; min-width:0; }
.codebox { font-family:ui-monospace,Menlo,Consolas,monospace; font-size:.95rem; background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:12px; margin:10px 0; word-break:break-all; user-select:all; }

/* ---- desktop: bottom bar goes, its actions move to the top bar; two columns ---- */
.topnav { display:none; }
@media (min-width:900px) {
  body.in { padding-bottom:24px; }
  .bottom { display:none !important; }
  .top { display:flex; align-items:center; justify-content:space-between; text-align:left; padding:14px 24px; position:sticky; top:0; z-index:200; background:var(--surface); border-bottom:2px solid var(--border); max-width:none; }
  body:not(.in) .top { justify-content:center; text-align:center; background:none; border:0; position:static; }
  .brand h1 { font-size:1.35rem; } .tag { font-size:.8rem; margin:0; }
  .topnav { display:flex; gap:6px; align-items:center; }
  .tn { position:relative; display:inline-flex; align-items:center; gap:8px; background:none; border:1px solid transparent; color:var(--muted); font-weight:600; padding:9px 13px; border-radius:10px; }
  .tn:hover { color:var(--text); border-color:var(--border); }
  .tn.go { background:var(--accent); color:var(--accent-text); margin-left:8px; } .tn.go:hover { background:var(--accent-dark); border-color:transparent; }
  .tn .badge { position:static; margin-left:2px; }
  .tn.go, .tn.go.on { background:var(--accent); color:var(--accent-text); border-color:transparent; }     /* the current-page highlight must not turn its amber text amber-on-amber */
  .tn.go:hover, .tn.go.on:hover { background:var(--accent-dark); }
  main { padding-top:22px; }
  .list { grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); }
  .sheet { align-items:center; } .panel { border-radius:16px; }
  .tn.on { color:var(--accent); border-color:var(--border); }
  .login { max-width:420px; margin:24px auto; }
}
.login { margin-top:12px; }

/* ---- pages ---- */
.view { max-width:560px; margin:0 auto; }
.view[data-view=photos] { max-width:1100px; }
.tips { padding-left:20px; margin:0; } .tips li { margin-bottom:10px; }
.bb.on { color:var(--accent); }
.bb.on::before { content:''; position:absolute; top:-2px; left:24%; right:24%; height:2px; background:var(--accent); }
.bb.pic.on::before { display:none; }
.bb .ico .badge { right:-14px; }
.ghost.wide { justify-content:center; }

/* ---- picking (camera + library) ---- */
.pickrow { display:flex; gap:10px; margin-top:10px; } .pickrow > * { flex:1; justify-content:center; }
@media (pointer:fine) { #camBtn { display:none; } }              /* a desktop has no camera picker: "Choose photos" is the one button */
.legal { margin:12px 0 0; font-size:.82rem; color:var(--muted); } .legal a { color:var(--accent); }
.msg.ok { color:var(--ok); }

/* ---- the gallery: a grid of thumbnails ---- */
.list { display:grid; grid-template-columns:repeat(auto-fill,minmax(104px,1fr)); gap:8px; margin-top:12px; }
@media (min-width:600px) { .list { grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; } }
.gtile { position:relative; display:block; width:100%; padding:0; border:1px solid var(--border); border-radius:10px; overflow:hidden; background:var(--surface); aspect-ratio:1/1; cursor:pointer; text-align:left; }
.gtile img { width:100%; height:100%; object-fit:contain; display:block; background:#fff; }
.gtile[data-status=working] img, .gtile[data-status=waiting] img, .gtile[data-status=uploading] img, .gtile[data-status=preparing] img { opacity:.45; }
.gtile.sel { outline:3px solid var(--accent); outline-offset:-3px; }
.gname { position:absolute; left:0; right:0; bottom:0; padding:14px 6px 4px; font-size:.72rem; font-weight:600; color:#fff; background:linear-gradient(transparent,rgba(0,0,0,.72)); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gbadge { position:absolute; top:6px; right:6px; min-width:22px; height:22px; border-radius:11px; display:flex; align-items:center; justify-content:center; font-size:.8rem; font-weight:800; }
.gbadge .spin { margin:0; width:16px; height:16px; }
.gbadge.bad { background:var(--danger); color:#111418; }
.gbadge.pick { border:2px solid #fff; background:rgba(17,20,24,.55); }
.gbadge.pick.on { background:var(--accent); border-color:var(--accent); color:var(--accent-text); }
.rhead .bar { display:flex; gap:8px; align-items:center; } .rhead .bar .ghost { padding:8px 12px; }
.ptr { text-align:center; color:var(--muted); font-size:.85rem; overflow:hidden; height:0; } 

/* ---- select bar (above the bottom nav) ---- */
.selbar { position:fixed; left:0; right:0; bottom:calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index:320; display:flex; align-items:center; gap:10px; padding:10px 16px; background:var(--surface2); border-top:2px solid var(--border); }
.selbar span { flex:1; font-weight:700; }
button.danger { font-weight:700; padding:10px 16px; border-radius:10px; border:0; background:var(--danger); color:#111418; }
@media (min-width:900px) { .selbar { bottom:0; } }

/* ---- full-screen viewer ---- */
.viewer { position:fixed; inset:0; z-index:600; background:#0b0d10; display:flex; flex-direction:column; padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.vbar { display:flex; align-items:center; gap:10px; padding:10px 12px; } .vname { flex:1; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } .vpos { color:var(--muted); font-size:.85rem; }
.vstage { position:relative; flex:1; min-height:0; display:flex; align-items:center; justify-content:center; touch-action:pan-y; }
.vstage img { max-width:100%; max-height:100%; object-fit:contain; background:#fff; }
.vtag { position:absolute; left:12px; top:8px; font-size:.7rem; font-weight:800; text-transform:uppercase; letter-spacing:.08em; background:rgba(17,20,24,.85); border-radius:5px; padding:2px 8px; }
.vmsg { position:absolute; left:16px; right:16px; text-align:center; color:var(--muted); margin:0; } .vmsg.err { color:var(--danger); }
.vnav { position:absolute; top:50%; transform:translateY(-50%); width:44px; height:44px; border-radius:50%; border:0; background:rgba(17,20,24,.7); color:var(--text); display:flex; align-items:center; justify-content:center; }
.vnav.prev { left:8px; } .vnav.next { right:8px; }
@media (pointer:coarse) { .vnav { display:none; } }                 /* on a phone you swipe */
.vacts { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; padding:12px 12px 16px; }
.vacts button { display:inline-flex; align-items:center; gap:6px; }
body.noscroll { overflow:hidden; }

.help a, .legal a { color:var(--accent); }

/* ---- outage notice ---- */
.outage { margin:0 0 12px; padding:10px 14px; border-radius:10px; border:1px solid var(--accent); background:rgba(232,160,32,.12); color:var(--text); font-size:.95rem; }
.outage a { color:var(--accent); font-weight:700; }
