:root{
  --bg:#f3f4f6;
  --surface:#ffffff;
  --surface-soft:#f8f9fa;
  --ink:#171a1f;
  --muted:#6f757d;
  --line:#d9dde2;
  --line-strong:#c7ccd2;
  --accent:#1f5d75;
  --accent-soft:#eaf1f4;
  --red:#c83a43;
  --red-bg:#fff4f4;
  --yellow:#a87300;
  --yellow-bg:#fff8df;
  --green:#3f765d;
  --gray:#747b82;
  --gray-bg:#f0f1f2;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  color:var(--ink);
  background:var(--bg);
  font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
}
.shell{
  width:min(760px,100%);
  margin:0 auto;
  padding:14px 14px calc(28px + env(safe-area-inset-bottom));
}
header{
  min-height:48px;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
header .brand{
  grid-column:2;
  font-size:14px;
  font-weight:700;
  letter-spacing:.01em;
  white-space:nowrap;
}
header .back{justify-self:start}
header .pill{justify-self:end}
header>.brand:first-child{grid-column:1;justify-self:start}
header>.brand:first-child+.pill{grid-column:3}
.back{
  color:var(--ink);
  text-decoration:none;
  font-weight:600;
  font-size:13px;
}
.pill{
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--muted);
  padding:5px 9px;
  border-radius:8px;
  font-size:11px;
  font-weight:600;
}
.hero{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:10px;
  padding:18px 16px;
  margin-bottom:10px;
}
.hero.compact{padding:15px 16px}
.eyebrow,.category{
  display:block;
  margin:0 0 5px;
  color:var(--muted);
  font-size:11px;
  line-height:1.2;
  font-weight:700;
  letter-spacing:.02em;
  text-transform:none;
}
h1{
  margin:0;
  font-size:24px;
  line-height:1.15;
  letter-spacing:-.02em;
  font-weight:700;
}
.hero h1 span{color:inherit}
.hero p:last-child{
  margin:7px 0 0;
  color:var(--muted);
  max-width:620px;
}
.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:10px;
  padding:15px;
  box-shadow:none;
}
.modeGrid{display:grid;gap:10px}
.modeCard{
  display:grid;
  grid-template-columns:42px 1fr auto;
  gap:12px;
  align-items:center;
  min-height:92px;
  padding:14px;
  color:var(--ink);
  text-decoration:none;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:10px;
}
.modeCard:hover,.modeCard:focus-visible{border-color:var(--line-strong);background:#fbfbfc}
.modeCard h2{margin:1px 0 3px;font-size:17px;line-height:1.25}
.modeCard p{margin:0;color:var(--muted);font-size:12px}
.modeIcon{
  width:42px;height:42px;
  border-radius:8px;
  display:grid;place-items:center;
  background:var(--accent-soft);
  color:var(--accent);
  font-size:22px;
  font-weight:700;
}
.modeArrow{color:var(--muted);font-size:18px}
.legend{
  margin-top:10px;
  overflow:hidden;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:10px;
}
.legend>div{
  display:grid;
  grid-template-columns:12px 52px 1fr;
  gap:8px;
  align-items:center;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
}
.legend>div:last-child{border-bottom:0}
.legend b{font-size:12px}
.legend span{color:var(--muted);font-size:12px}
.dot{width:8px;height:8px;border-radius:50%;display:block}
.dot.red{background:var(--red)} .dot.yellow{background:#d3a126}
.dot.gray{background:#8d949b}.dot.green{background:var(--green)}
footer{padding:17px 6px 2px;color:#858a91;text-align:center;font-size:10.5px}

.field{display:grid;gap:6px;color:#4f555c;font-size:12px;font-weight:600}
.field textarea{
  width:100%;
  min-height:84px;
  resize:vertical;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  padding:10px 11px;
  color:var(--ink);
  font:inherit;
}
.field textarea:focus,.searchInputWrap:focus-within{outline:2px solid rgba(31,93,117,.13);border-color:#8caab6}
button{
  width:100%;
  margin-top:12px;
  padding:12px 14px;
  border:1px solid #17495d;
  border-radius:8px;
  background:var(--accent);
  color:#fff;
  font:inherit;
  font-weight:700;
  cursor:pointer;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
button:disabled{opacity:.6;cursor:wait}
.secondaryBtn{
  margin:0;
  justify-content:center;
  background:var(--surface);
  color:var(--ink);
  border-color:var(--line-strong);
  font-size:12px;
}
.or{display:flex;align-items:center;gap:9px;color:#8b9096;font-size:11px;margin:13px 0}
.or span{height:1px;background:var(--line);flex:1}
.loading{text-align:center;color:var(--muted);padding:11px 0 0;font-size:12px;font-weight:600}

.camera{
  min-height:150px;
  border:1px dashed #adb4bb;
  border-radius:9px;
  background:var(--surface-soft);
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;
  text-align:center;
}
.camera input{position:absolute;opacity:0;pointer-events:none}
.cameraIcon{
  width:40px;height:40px;
  border-radius:8px;
  display:grid;place-items:center;
  background:var(--accent-soft);
  color:var(--accent);
  font-size:22px;
}
.camera strong{font-size:13px}
.camera small{font-size:11px;color:var(--muted)}
.camera.cameraCompact{
  min-height:66px;
  display:grid;
  grid-template-columns:40px 1fr;
  text-align:left;
  justify-items:start;
  padding:10px;
}
.cameraCompact .cameraIcon{grid-row:span 2}
.cameraCompact small{grid-column:2}
.cropSection{margin-top:13px}
.cropHelp{display:grid;gap:2px;margin-bottom:8px}
.cropHelp b{font-size:12px}
.cropHelp span,.cropInfo{font-size:11px;color:var(--muted)}
.canvasWrap{overflow:hidden;background:#1d2125;border-radius:8px;line-height:0;touch-action:none}
.canvasWrap canvas{display:block;width:100%;height:auto;touch-action:none;cursor:crosshair}
.cropActions{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin-top:8px}
.cropInfo{padding:7px 1px 0}

.searchCard{min-height:240px}
.searchInputWrap{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  padding:0 10px;
}
.searchInputWrap span{font-size:19px;color:var(--muted)}
.searchInputWrap input{
  width:100%;
  border:0;
  outline:0;
  background:transparent;
  color:var(--ink);
  padding:12px 0;
  font:inherit;
  font-size:16px;
}
.searchStatus{padding:9px 1px 5px;color:var(--muted);font-size:11px}
.suggestions{display:grid;gap:5px}
.suggestion{
  display:grid;
  grid-template-columns:5px 1fr 16px;
  gap:9px;
  align-items:center;
  padding:10px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  text-decoration:none;
}
.suggestion:hover{background:#fafafa}
.suggestion b{font-size:13px}
.suggestion small{display:block;margin-top:1px;color:var(--muted);font-size:11px}
.suggestion strong{color:var(--muted)}
.suggestFlag{width:4px;height:32px;border-radius:4px;background:#a7adb3}
.suggestFlag.red{background:var(--red)}
.suggestFlag.yellow{background:#d3a126}
.suggestFlag.normal{background:#7e9f8e}

.results{display:grid;gap:9px}
.med{
  background:var(--surface);
  border:1px solid var(--line);
  border-left:4px solid #9da5ac;
  border-radius:10px;
  padding:14px;
  box-shadow:none;
}
.med.red{border-left-color:var(--red)}
.med.yellow{border-left-color:#d1a02b}
.medTop{display:flex;justify-content:space-between;gap:10px}
.med h2{margin:1px 0 1px;font-size:19px;line-height:1.2}
.active{margin:0;color:var(--muted);font-size:12px}
.confidence{
  height:max-content;
  padding:4px 7px;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--surface-soft);
  color:#51575e;
  font-size:11px;
  font-weight:700;
}
.purpose{margin:11px 0;color:#343940;font-size:13px}
.notice{
  margin-top:9px;
  padding:9px 10px;
  border-radius:8px;
  font-size:11px;
  font-weight:700;
  letter-spacing:0;
}
.notice span{font-weight:400}
.danger{background:var(--red-bg);color:#a12c34;border:1px solid #efc9cc}
.caution{background:var(--yellow-bg);color:#795900;border:1px solid #ecdca4}
details{margin-top:10px;color:var(--muted);font-size:11px}
summary{cursor:pointer;font-weight:600}
.ocr{margin-top:10px}
.ocr pre{white-space:pre-wrap;overflow-wrap:anywhere;color:#4e555c;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace}
.empty{text-align:left}
.empty h2{font-size:17px;margin:0 0 5px}
.empty p{margin:0;color:var(--muted)}

.med.uncertain{
  background:var(--gray-bg);
  border-color:#cfd3d6;
  border-left-color:#858c92;
}
.med.uncertain .category{color:#666d73}
.confidence-uncertain{background:#e1e3e5!important;color:#51575c!important}
.uncertainBox{
  margin:10px 0 8px;
  padding:8px 9px;
  display:grid;
  gap:2px;
  border:1px solid #c8ccd0;
  border-radius:8px;
  background:#e7e9ea;
  color:#535a60;
  font-size:11px;
}
.uncertainBox b{font-size:11px}
.med.uncertain .risk-hint{background:#fff}
.detailCard{max-width:none}
.detailRow{
  display:grid;
  gap:2px;
  margin-top:12px;
  padding-top:10px;
  border-top:1px solid var(--line);
  font-size:12px;
}
.detailRow span{color:var(--muted)}

@media(min-width:650px){
  .shell{padding-top:22px}
  .hero{padding:20px}
  .modeGrid{grid-template-columns:1fr 1fr}
  .results{grid-template-columns:1fr 1fr}
  .med.red,.med.yellow{grid-column:span 2}
}
