/* Camera-first scan surface. This stylesheet is loaded after the shared brand
   styles; the app adds scanner-camera only while the live camera is visible. */
body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) {
  color-scheme: light;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #view-scan > .app-page-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) :is(#scan-hint, #btn-manual-set, #live-hint, .live-consent-note, .scan-photo-panel-head, .app-footer) {
  display: none;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-setup .mode {
  max-width: 480px;
  margin: 0 auto 8px;
  gap: 6px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-setup .mode-btn {
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
  font-size: 13px;
  line-height: 1.2;
  border-radius: 8px;
  color: #141110;
  background: #fffdf8;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-setup .mode-btn.active {
  color: #fff;
  background: #a5080c;
  border-color: #a5080c;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-step {
  max-width: 480px;
  margin: 0 auto;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) .viewfinder {
  width: min(100%, 52.5svh, 480px);
  height: min(70svh, 640px);
  max-height: none;
  aspect-ratio: auto;
  margin: 0 auto;
  background: #141110;
  border-radius: 12px;
  isolation: isolate;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #vf-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) .vf-frame {
  inset: 15% 10% 21%;
  border-color: #ffffffad;
  border-radius: 16px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #camera-status {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  right: 12px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #141110e8;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
  pointer-events: none;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #camera-status:empty {
  display: none;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-candidates {
  bottom: 84px;
  z-index: 2;
  padding: 0 10px;
  gap: 8px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-candidates .live-chip {
  max-width: min(260px, calc(100% - 8px));
  min-height: 48px;
  background: #141110eb;
  color: #fff;
  border: 1px solid #ffffff70;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-candidates .live-chip .sub {
  color: #f0ece3;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #btn-shutter {
  z-index: 2;
  bottom: 12px;
  width: 60px;
  height: 60px;
  min-width: 60px;
  min-height: 60px;
  border: 4px solid #fff;
  background: #14111080;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) :is(#btn-shutter, .live-chip):focus-visible {
  outline: 3px solid #f7d117;
  outline-offset: 3px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #sweep-flash {
  top: 28%;
  background: #fffdf8;
  color: #981014;
  font-size: 17px;
  line-height: 1.4;
  padding: 12px;
  box-shadow: 0 4px 20px #0004;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #sweep-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  flex: none;
  margin: 6px 0 0;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-step .secondary {
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fffdf8;
  border: 1px solid #b9ae9d;
  color: #141110;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #btn-sweep {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 4px 8px;
  border-color: #141110;
  font-size: 13px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #btn-sweep.locked {
  opacity: 1;
  color: #655d52;
  border-color: #b9ae9d;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #btn-sweep[aria-pressed="true"] {
  color: #141110;
  background: #f7d117;
  border-color: #141110;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #sweep-count {
  min-width: 20px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: #141110;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) :is(#btn-sweep-undo, #btn-sweep-review) {
  flex: none;
  width: auto;
  padding: 8px;
  font-size: 13px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) .camera-bottom-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex: none;
  margin: 6px 0 0;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-step .camera-bottom-actions button {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 8px 6px;
  font-size: 13px;
}

body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #btn-use-files {
  color: #141110;
  background: #f7d117;
  border-color: #141110;
}

@media (max-width: 768px) {
  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) {
    height: 100svh;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell > header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    flex: none;
    position: relative;
    padding: calc(4px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left));
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .topbar {
    display: contents;
    padding: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .brand-row {
    grid-column: 1;
    grid-row: 1;
    flex: initial;
    min-width: 0;
    gap: 6px;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) .app-brand {
    min-height: 44px;
    gap: 7px;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) .app-brand > span:not(.mk-brick) {
    font-size: 20px !important;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) :is(.catalog-app-link, #guest-note, #trial-banner) {
    display: none;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .account-menu {
    grid-column: 2;
    grid-row: 1;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .account-menu > summary {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 13px;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .account-menu .account-row {
    width: min(280px, calc(100vw - 16px));
    top: 48px;
    right: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell #app-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .tab {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 6px 2px;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 8px;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #view-scan {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    width: 100%;
    min-height: 0;
    max-width: 100%;
    overflow: hidden;
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-setup {
    flex: none;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-photo-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    width: 100%;
    min-height: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-setup .mode {
    max-width: none;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #live-step {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) .viewfinder {
    flex: 1 1 0;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 10px;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #scan-status {
    display: none;
  }
}

/* Keep the camera controls reachable if a phone is turned sideways. */
@media (max-width: 768px) and (max-height: 460px) {
  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell > header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell .brand-row {
    display: none;
  }

  body.in-app.scanner-camera:has(#view-scan:not([hidden])):has(#live-step:not([hidden])) #app-shell #app-nav {
    grid-column: 1;
    grid-row: 1;
  }
}
