:root{
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:#f7f8ff;
  background:#0e1326;
  color-scheme:dark;
}
*{box-sizing:border-box}
html{background:#0e1326}
body{
  margin:0;
  min-height:100vh;
  background:radial-gradient(circle at top,#172445 0,#0e1326 42%);
}
body.viewer-open{overflow:hidden}
button,input{font:inherit}
button{touch-action:manipulation}
.app{
  width:min(760px,100%);
  margin:0 auto;
  padding:18px 18px calc(28px + env(safe-area-inset-bottom));
}
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}
.brand{
  display:flex;
  align-items:center;
  gap:9px;
  min-width:0;
  font-weight:900;
}
.brand-logo{
  width:28px;
  height:28px;
  object-fit:contain;
}
.back{
  flex:0 0 auto;
  color:#d7ddf5;
  text-decoration:none;
  font-weight:700;
}
.intro{margin-bottom:16px}
.intro h1{
  margin:0 0 7px;
  font-size:clamp(29px,6vw,42px);
  line-height:1.08;
  letter-spacing:-.035em;
}
.intro p{
  margin:0;
  color:#b9c2dc;
  line-height:1.45;
}
.camera-shell{
  position:relative;
  width:100%;
  aspect-ratio:3/4;
  overflow:hidden;
  border:1px solid #34405f;
  border-radius:26px;
  background:#070b16;
  box-shadow:0 18px 44px rgba(0,0,0,.22);
  --guide-left:5%;
  --guide-right:95%;
  --guide-top:7%;
  --guide-bottom:93%;
  --guide-width:90%;
  --guide-center-x:50%;
}
#camera{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.guide{
  position:absolute;
  inset:0;
  pointer-events:none;
}
.guide-card{
  position:absolute;
  left:50%;
  top:7%;
  width:auto;
  height:86%;
  aspect-ratio:63/88;
  transform:translateX(-50%);
  border:3px solid #f5cd49;
  border-radius:21px;
  box-shadow:0 0 0 999px rgba(0,0,0,.20);
}

.torch-button{
  position:absolute;
  top:calc(var(--guide-top) + 14px);
  right:calc(100% - var(--guide-right) + 14px);
  z-index:6;
  display:flex;
  align-items:center;
  gap:7px;
  min-height:42px;
  padding:0 13px;
  border:1px solid transparent;
  border-radius:999px;
  background:transparent;
  color:#fff;
  font-size:13px;
  font-weight:900;
  cursor:pointer;
  backdrop-filter:none;
  box-shadow:none;
}
.torch-button[hidden]{display:none}
.torch-button.is-on{
  background:transparent;
  color:#f5cd49;
  border-color:#f5cd49;
}
.torch-button:disabled{
  opacity:.5;
  cursor:not-allowed;
}

.camera-progress{
  position:absolute;
  left:var(--guide-center-x);
  bottom:calc(100% - var(--guide-bottom) + 10px);
  z-index:4;
  width:calc(var(--guide-width) - 24px);
  max-width:420px;
  transform:translateX(-50%);
  padding:10px 12px 11px;
  border:1px solid transparent;
  border-radius:15px;
  background:transparent;
  box-shadow:none;
  backdrop-filter:none;
  transition:opacity .18s ease;
}
.camera-progress.is-hidden{opacity:0;pointer-events:none}
.camera-progress-copy{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin-bottom:7px;
}
.camera-progress-copy strong{
  min-width:0;
  color:#f5cd49;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:13px;
}
.camera-progress-copy span{
  flex:0 0 auto;
  color:#f5cd49;
  font-size:13px;
  font-weight:900;
}
.camera-progress-bar{
  height:5px;
  overflow:hidden;
  border-radius:99px;
  background:rgba(245,205,73,.20);
}
.camera-progress-bar span{
  display:block;
  width:0;
  height:100%;
  border-radius:inherit;
  background:#f5cd49;
  transition:width .16s linear;
}
.scan-match-price{
  position:absolute;
  left:50%;
  top:28px;
  z-index:5;
  transform:translateX(-50%);
  padding:8px 13px;
  border:1px solid rgba(245,205,73,.55);
  border-radius:999px;
  background:rgba(7,11,22,.82);
  color:#fff;
  box-shadow:0 8px 24px rgba(0,0,0,.28);
  font-size:18px;
  font-weight:900;
  line-height:1;
  pointer-events:none;
}
.scan-match-price[hidden]{display:none}
.scan-match-thumb{
  position:absolute;
  left:calc(var(--guide-left) + 14px);
  bottom:76px;
  z-index:5;
  width:68px;
  aspect-ratio:63/88;
  overflow:hidden;
  border:2px solid #f5cd49;
  border-radius:9px;
  background:#0b1020;
  box-shadow:0 10px 28px rgba(0,0,0,.38);
  padding:0;
  cursor:zoom-in;
}
.scan-match-thumb[hidden]{display:none}
.scan-match-thumb:focus-visible{outline:3px solid #71e7d1;outline-offset:3px}
.scan-match-thumb img{
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}

.camera-error{
  position:absolute;
  inset:auto 16px 86px;
  z-index:5;
  padding:12px 14px;
  border-radius:14px;
  background:rgba(83,24,30,.9);
  color:#fff;
  font-size:13px;
  line-height:1.4;
}
.controls{
  display:grid;
  grid-template-columns:1fr auto auto;
  gap:11px;
  margin-top:13px;
}
.button,.file-label{
  min-height:56px;
  border-radius:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0 20px;
  font-weight:900;
  font-size:16px;
}
.button{
  border:0;
  background:#f5cd49;
  color:#11162a;
  cursor:pointer;
}
.quick-add-button{
  width:56px;
  min-height:56px;
  padding:0;
  border:0;
  border-radius:16px;
  background:#f5cd49;
  color:#11162a;
  font-size:28px;
  font-weight:900;
  line-height:1;
  cursor:pointer;
}
.quick-add-button:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.quick-add-button:active:not(:disabled){transform:scale(.96)}
.quick-add-button:focus-visible,.candidate-add:focus-visible,.button:focus-visible{outline:3px solid #68dfcf;outline-offset:3px}
.button:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.file-label{
  gap:8px;
  border:1px solid #333d5b;
  background:#1a2138;
  color:#fff;
  cursor:pointer;
}
.file-label:has(input:disabled){opacity:.45;cursor:not-allowed}
.file-label input{display:none}
.status-note{
  min-height:20px;
  margin:12px 2px 0;
  color:#aeb8d3;
  font-size:13px;
  line-height:1.45;
}
.status-note.error{color:#ffb3b3}
.scan-save-success[hidden],.scan-full-add[hidden]{display:none !important}
.scan-save-success{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
  margin-top:12px;
  padding:11px 13px;
  border:1px solid rgba(104,223,207,.4);
  border-radius:13px;
  background:rgba(104,223,207,.09);
  color:#f7f8ff;
  font-size:13px;
  font-weight:750;
}
.scan-save-success a,.scan-full-add{color:#68dfcf;font-weight:800;text-decoration:none}
.scan-save-success a:focus-visible,.scan-full-add:focus-visible{outline:3px solid #68dfcf;outline-offset:3px}
.scan-full-add{display:inline-block;min-height:44px;margin:8px 2px 0;padding:11px 0;font-size:13px}
.results-wrap{margin-top:24px}
.section-title h2{
  margin:0 0 5px;
  font-size:24px;
}
.section-title p{
  margin:0 0 13px;
  color:#aeb8d3;
  font-size:13px;
}
.results{
  display:grid;
  gap:10px;
}
.candidate{
  display:grid;
  grid-template-columns:76px minmax(0,1fr) auto;
  gap:13px;
  align-items:center;
  padding:9px;
  border:1px solid #33405f;
  border-radius:17px;
  background:#141c31;
}
.candidate-image-button{
  width:76px;
  padding:0;
  border:0;
  border-radius:10px;
  overflow:hidden;
  background:#0b1020;
  color:#9fa9c5;
  cursor:zoom-in;
  aspect-ratio:63/88;
}
.candidate-image-button img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}
.candidate-image-button.is-missing{
  display:grid;
  place-items:center;
  font-size:11px;
}
.candidate-copy{
  min-width:0;
}
.candidate-rank{
  margin-bottom:2px;
  color:#f5cd49;
  font-size:11px;
  font-weight:900;
}
.candidate-copy strong{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:16px;
}
.candidate-copy small{
  display:block;
  margin-top:5px;
  overflow:hidden;
  color:#aeb8d3;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.candidate-side{
  display:flex;
  align-items:center;
  gap:9px;
}
.candidate-score{
  display:inline-block;
  visibility:visible;
  opacity:1;
  min-width:42px;
  text-align:right;
  color:#68dfcf;
  font-weight:900;
  font-size:14px;
}
.candidate-add{
  width:46px;
  height:46px;
  border:0;
  border-radius:14px;
  background:#f5cd49;
  color:#11162a;
  font-size:27px;
  font-weight:900;
  line-height:1;
  cursor:pointer;
}
.candidate-add:active{transform:scale(.96)}
.image-viewer[hidden]{display:none}
.image-viewer{
  position:fixed;
  inset:0;
  z-index:9999;
  display:grid;
  place-items:center;
  padding:58px 18px 24px;
  background:rgba(3,7,15,.92);
  backdrop-filter:blur(7px);
}
.image-viewer img{
  display:block;
  width:auto;
  height:auto;
  max-width:min(92vw,620px);
  max-height:82vh;
  border-radius:16px;
  box-shadow:0 24px 70px rgba(0,0,0,.55);
}
.image-viewer-close{
  position:fixed;
  right:max(18px,env(safe-area-inset-right));
  top:max(18px,env(safe-area-inset-top));
  width:46px;
  height:46px;
  border:1px solid rgba(255,255,255,.2);
  border-radius:50%;
  background:#141c31;
  color:#fff;
  font-size:28px;
  cursor:pointer;
}

@media(min-width:561px){
  .camera-shell{
    height:min(56vh,560px);
    height:min(56svh,560px);
    aspect-ratio:auto;
  }
}

@media(max-width:560px){
  .app{padding:12px 12px calc(22px + env(safe-area-inset-bottom))}
  .topbar{margin-bottom:13px}
  .brand-logo{width:25px;height:25px}
  .brand span{font-size:14px}
  .back{font-size:14px}
  .intro{margin-bottom:11px}
  .intro h1{font-size:30px}
  .intro p{font-size:14px}
  .camera-shell{
    max-height:66vh;
    border-radius:21px;
  }
  
.torch-button{
  position:absolute;
  top:calc(var(--guide-top) + 14px);
  right:calc(100% - var(--guide-right) + 14px);
  z-index:6;
  display:flex;
  align-items:center;
  gap:7px;
  min-height:42px;
  padding:0 13px;
  border:1px solid transparent;
  border-radius:999px;
  background:transparent;
  color:#fff;
  font-size:13px;
  font-weight:900;
  cursor:pointer;
  backdrop-filter:blur(8px);
  box-shadow:0 8px 24px rgba(0,0,0,.22);
}
.torch-button[hidden]{display:none}
.torch-button.is-on{
  background:transparent;
  color:#f5cd49;
  border-color:#f5cd49;
}
.torch-button:disabled{
  opacity:.5;
  cursor:not-allowed;
}

.camera-progress{
    bottom:calc(100% - var(--guide-bottom) + 8px);
    width:calc(var(--guide-width) - 20px);
    max-width:none;
  }
  .scan-match-price{
    top:46px;
    padding:7px 11px;
    font-size:17px;
  }
  .scan-match-thumb{
    left:calc(var(--guide-left) + 12px);
    bottom:108px;
    width:60px;
  }
  .controls{margin-top:10px}
  .button,.file-label{
    min-height:52px;
    border-radius:14px;
  }
  .quick-add-button{
    width:52px;
    min-height:52px;
    border-radius:14px;
  }
  .file-label{
    width:60px;
    padding:0;
  }
  .file-label-text{display:none}
  .results-wrap{margin-top:20px}
  .candidate{
    grid-template-columns:65px minmax(0,1fr) auto;
    gap:10px;
    padding:8px;
  }
  .candidate-image-button{width:65px}
  .candidate-copy strong{font-size:15px}
  .candidate-copy small{font-size:11px}
  .candidate-side{
    flex-direction:column;
    gap:6px;
  }
  .candidate-score{
    min-width:0;
    font-size:12px;
  }
  .candidate-add{
    width:46px;
    height:46px;
    border-radius:12px;
  }
}
@media(max-width:390px){
  .candidate{
    grid-template-columns:58px minmax(0,1fr) 46px;
    gap:8px;
  }
  .candidate-image-button{width:58px}
  .candidate-score{display:inline-block}
}
