/* Shared scanner chrome; recognition controls keep their original IDs. */
.scanner-toolbar { position: relative; gap: 8px; }
.scanner-settings { margin-left: auto; }
.scanner-settings > summary, .secondary-disclosure > summary, .crop-details > summary {
  cursor: pointer; color: #d4e0ec; font-size: 13px; font-weight: 600;
  padding: 11px 14px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px;
  background: #192330;
}
summary:focus-visible { outline: 2px solid #93caff; outline-offset: 2px; }
.scanner-settings[open] > summary { border-color: #77bfa0; }
.scanner-settings-body {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 8;
  width: min(560px, 100%); max-height: min(680px, 72svh); overflow: auto;
  overscroll-behavior: contain; padding: 18px; border: 1px solid #526575;
  border-radius: 12px; background: #141d28; box-shadow: 0 14px 40px #0009;
}
.scanner-settings-body .camera-label { width: 100%; }
.scanner-settings-body .detection-controls { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0; }
.scanner-settings-body .extraction-controls { margin-bottom: 18px; }
.scanner-settings-body .match-controls { gap: 12px 18px; }
.scanner-settings-body .match-controls select { width: auto; }
.scanner-settings-body .advanced { margin: 18px 0; }
.scanner-settings-body .snapshot-note { margin: 0; }
.crop-details { min-width: 0; }
.crop-details > summary { display: none; }
.sample-details { margin-top: 16px; }
.sample-details .sample-tools { margin: 8px 0 0; }

@media (max-width: 680px), (max-width: 1000px) and (max-height: 600px) {
  html { scrollbar-gutter: auto; }
  main { padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .scanner-header { margin: 0 0 6px; }
  .scanner-header .eyebrow { margin: 0; font-size: 10px; }
  .scanner-header h1, .scanner-header .intro, .scanner-header .local { display: none; }
  .experiment-page .scanner-header { display: none; }
  .scanner-toolbar { flex-wrap: nowrap; margin: 0 0 8px; gap: 6px; }
  .scanner-toolbar button, .scanner-settings > summary { min-height: 44px; padding: 9px 12px; font-size: 12px; }
  .scanner-toolbar #start { flex: 1; }
  .scanner-toolbar .wide-label { display: none; }
  .scanner-settings { margin-left: 0; }
  .scanner-settings-body { left: 0; width: 100%; padding: 14px; }
  .scanner-settings-body select, .scanner-settings-body input[type=url], .sample-controls input { font-size: 16px; }
  .workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .feed-panel { grid-row: 1; height: clamp(180px, 35svh, 290px); }
  .matches-panel { grid-row: 2; grid-column: auto; --match-row-height: clamp(46px, 6.2svh, 54px); height: calc(5 * var(--match-row-height) + 70px); }
  .crop-details { grid-row: 3; }
  .panel { border-radius: 10px; }
  .panel-heading { height: 28px; flex: 0 0 28px; padding: 0 10px; }
  .panel-heading h2 { font-size: 11px; }
  .badge, .ratio { padding: 2px 6px; font-size: 9px; }
  .badge { width: auto; min-width: 60px; }
  .feed-stage { min-height: 0; }
  .feed-stage .placeholder { padding: 12px; }
  .feed-stage .viewfinder { width: 60px; height: 40px; border-radius: 8px; }
  .feed-stage .placeholder h3 { font-size: 13px; margin: 8px 0 0; }
  .feed-stage .placeholder p { display: none; }
  .feed-footer { flex: 0 0 30px; min-height: 30px; padding: 4px 10px; gap: 8px; font-size: 10px; }
  #status { -webkit-line-clamp: 1; }
  #latency { flex-shrink: 0; font-variant-numeric: tabular-nums; }
  .matches-panel .catalog-status { flex: 0 0 21px; min-height: 21px; padding: 2px 10px; font-size: 10px; line-height: 16px; }
  .matches-panel #match-status:empty { display: block; }
  .matches { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(5, minmax(0, 1fr)); }
  .matches .match-row { grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding: 1px 10px; gap: 8px; border-right: 0; }
  .matches .match-image { width: 44px; height: 44px; }
  .matches .match-copy { gap: 1px; }
  .matches .match-copy strong { font-size: 12px; line-height: 14px; -webkit-line-clamp: 2; }
  .matches .match-copy p { display: none; }
  .matches .match-copy span { font-size: 10px; line-height: 12px; }
  .matches-panel .similarity-note { display: none; }
  .crop-details > summary { display: list-item; }
  .crop-details .crop-panel { height: 420px; margin-top: 8px; }
  .crop-details .capture-actions { grid-template-columns: 1fr 1fr; flex-basis: 64px; }
  .sample-details { margin-top: 8px; }
  .scan-history { margin-top: 12px; padding: 12px; }
  .scan-history .history-heading { gap: 8px; }
  .scan-history .history-heading h2 { font-size: 14px; }
  footer { margin-top: 14px; font-size: 11px; }
}
@media (max-width: 680px) and (max-height: 650px) {
  .feed-panel { height: clamp(130px, 25svh, 162px); }
}
@media (min-width: 681px) and (max-width: 1000px) and (max-height: 600px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .feed-panel { grid-column: 1; grid-row: 1; height: max(276px, calc(100svh - 108px)); }
  .matches-panel { grid-column: 2; grid-row: 1; height: max(276px, calc(100svh - 108px)); }
  .crop-details { grid-column: 1 / -1; grid-row: 2; }
  .matches .match-copy strong { -webkit-line-clamp: 1; }
  .matches .match-image { height: 36px; }
}
