#scan-page { max-width: 780px; margin-inline: auto; }
#scan-page h1 { text-wrap: balance; }
#scan-page p { line-height: 1.55; }
#scan-page button, #scan-page textarea { font-size: 16px; }
.scan-panel { margin: 16px 0; padding: clamp(16px, 3vw, 28px); }
.scan-panel h2, .scan-panel h3 { margin: 0 0 8px; }
.scan-panel p { margin: 4px 0 14px; }
.scan-capture {
  border-color: #dfc9b7;
  background: linear-gradient(122deg, #fffaf3, #f9e9dc 76%, #f4ebda);
  box-shadow: inset 0 1px 0 #fff, 0 8px 28px #6843280b;
}
.scan-capture > p { max-width: 52ch; }
.scan-choices { display: flex; align-items: stretch; flex-wrap: wrap; gap: 9px; margin: 14px 0 2px; }
.scan-pick {
  position: relative; overflow: hidden; margin: 0; display: inline-flex; justify-content: center; align-items: center;
  gap: 12px; min-height: 48px; padding: 9px 16px; border: 1px solid #b99f89; border-radius: 13px;
  background: #fffcf8; color: #503c2e; font-weight: 600; cursor: pointer;
}
.scan-pick.scan-primary { background: #67503d; color: #fff; border-color: #67503d; }
.scan-pick:focus-within { outline: 3px solid #816146; outline-offset: 3px; }
.scan-pick input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0; border: 0;
  opacity: 0; cursor: pointer; font-size: 16px;
}
.scan-camera-icon { position: relative; width: 20px; height: 15px; border: 1.5px solid; border-radius: 3px; display: inline-grid; place-items: center; }
.scan-camera-icon::before { content: ''; position: absolute; width: 7px; height: 3px; border: 1.5px solid; border-bottom: none; border-radius: 2px 2px 0 0; top: -4px; left: 4px; background: #67503d; }
.scan-camera-icon::after { content: ''; display: block; width: 6px; height: 6px; border: 1.5px solid; border-radius: 50%; }
.scan-text-action { background: transparent; color: #61452f; text-decoration: underline; text-underline-offset: 3px; margin: 3px 0 0; padding: 4px 0; min-height: 44px; font-weight: 550; }
.scan-category { border: 0; padding: 0; margin: 18px 0; min-width: 0; }
.scan-category legend { font-weight: 650; margin: 0 0 8px; }
.scan-category > div { display: flex; flex-wrap: wrap; align-items: stretch; gap: 7px; }
.scan-category label { position: relative; display: flex; align-items: stretch; margin: 0; }
.scan-category input { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
.scan-category span { display: inline-flex; align-items: center; justify-content: center; border: 1px solid #c9b9a7; border-radius: 12px; color: #625344; padding: 8px 13px; min-height: 44px; cursor: pointer; }
.scan-category input:checked + span { background: #67503d; color: #fff; border-color: #67503d; }
.scan-category input:focus-visible + span { outline: 3px solid #85664e; outline-offset: 2px; }
.scan-panel label[for=scan-text] { font-weight: 650; margin-bottom: 4px; }
.scan-panel p.scan-hint, .scan-foot { color: #665d51; font-size: 14px; }
#scan-text { display: block; width: 100%; min-height: 140px; line-height: 1.5; }
.scan-check { margin-top: 14px; }
.scan-warning, .scan-panel p.scan-warning { border-left: 3px solid #8c6828; background: #fbf2db; color: #5c471d; padding: 10px 14px; border-radius: 8px; }
.scan-preview, .scan-replace { margin-top: 10px; }
.scan-add-side { margin-top: 12px; border: 1px solid #d7c9b8; border-radius: 12px; background: #fbf6ef; padding: 0 13px; }
.scan-add-side[open] { padding-bottom: 13px; }
.scan-add-side p { font-size: 14px; color: #625344; }
.scan-add-side .scan-choices { margin: 8px 0 0; }
#scan-page summary { padding: 10px 2px; min-height: 44px; cursor: pointer; font-size: 16px; font-family: inherit; font-weight: 550; }
.scan-preview > div { text-align: center; border-radius: 10px; overflow: hidden; background: #f3eee6; }
.scan-preview img { display: inline-block; max-height: 34rem; max-width: 100%; }
.scan-found { background: #fae9e2; border-color: #ceab9e; }
.scan-verdict { background: #f6f1e8; }
.scan-matches { display: grid; gap: 12px; margin: 12px 0; }
.scan-match { border: 1px solid #d8cbbc; border-left: 4px solid #b99b74; border-radius: 15px; padding: 15px 18px; background: #fffaf3; }
.scan-match-avoid { border-left-color: #965145; }
.scan-match-ask { border-left-color: #88748b; }
.scan-badge { display: inline-block; padding: 5px 9px; border-radius: 7px; color: #5b492f; background: #f4ead3; font-size: 13px; font-weight: 650; }
.scan-match-avoid .scan-badge { background: #f6e1da; color: #74372c; }
.scan-match-ask .scan-badge { background: #efe7f1; color: #5c465e; }
.scan-match h3 { margin: 12px 0 5px; }
.scan-match small, .scan-unmatched li { overflow-wrap: anywhere; }
.scan-match p { margin: 6px 0; }
.scan-match .text-link, .scan-foot .text-link { display: inline-flex; align-items: center; min-height: 44px; margin: 0; }
.scan-unmatched ul { padding-inline-start: 20px; margin: 10px 0 0; }
.scan-unmatched { padding-block: 7px; }
#scan-page .scan-unmatched summary { color: #61452f; font-weight: 650; }
.scan-unmatched[open] { padding-bottom: 18px; }
.scan-unmatched li { margin: 5px 0; }
.scan-foot { margin-top: 20px; }
.scan-foot p { margin: 0; }
@media (max-width: 440px) {
  .scan-pick { flex: 1 1 120px; padding-inline: 10px; }
  .scan-category span { padding-inline: 10px; }
  #scan-page .card { padding: 17px; }
}
@media (prefers-reduced-transparency: reduce) {
  .scan-capture { background: #fff6e9; box-shadow: none; }
}

#scan-page [hidden] { display: none; }
.scan-crop-image { position:relative; width:fit-content; max-width:100%; overflow:hidden; margin:12px auto; }
.scan-crop-image img { display:block; max-width:100%; max-height:45vh; height:auto; }
#scan-crop-frame { position:absolute; border:3px solid #fff; outline:2px solid #543f2c; box-shadow:0 0 0 999px rgba(30,23,17,.58); pointer-events:none; }
.scan-crop-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 18px; margin:12px 0; }
.scan-crop-controls label { font-size:.875rem; margin:0; }
.scan-crop-controls input[type=range] { display:block; padding:0; width:100%; min-height:44px; accent-color:#67503d; }
