.scanner-dialog {
  width: min(760px, calc(100vw - 18px));
  max-height: calc(100dvh - 18px);
  padding: 0;
  overflow: hidden;
}

.scanner-shell {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scanner-head h2 {
  margin: 0;
  font-size: 20px;
}

.scanner-camera {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #070b12;
  aspect-ratio: 3 / 4;
  min-height: 360px;
  isolation: isolate;
}

.scanner-camera video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.scanner-display-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  background: #070b12;
}

.scanner-frame,
.scanner-auto-toggle,
.scanner-actions,
.scanner-status,
.scanner-results,
.scanner-placeholder,
.scanner-head .eyebrow,
.scanner-head p {
  display: none !important;
}

.scanner-live-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.scanner-live-outline polygon {
  fill: rgba(34,197,94,.035);
  stroke: #22c55e;
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.55));
}

.scanner-live-outline polygon[data-strong="true"] {
  stroke-width: 6;
  fill: rgba(34,197,94,.07);
}

.scanner-live-hit {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px;
  background: rgba(8,12,20,.9);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  color: #fff;
}

.scanner-live-hit.is-stable {
  border-color: rgba(255,255,255,.24);
}

.scanner-live-hit img {
  width: 42px;
  height: 58px;
  object-fit: cover;
  border-radius: 5px;
}

.scanner-live-hit span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.scanner-live-hit strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scanner-live-hit small {
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scanner-live-hit b {
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
}

.scanner-camera-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,.5);
  color: rgba(255,255,255,.9);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}

.scanner-error {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 40;
  padding: 9px 11px;
  border: 1px solid rgba(248,113,113,.35);
  border-radius: 12px;
  background: rgba(127,29,29,.82);
  color: #fecaca;
  font-size: 13px;
}

.scanner-hidden { display: none !important; }

@media (max-width: 640px) {
  .scanner-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .scanner-shell {
    height: 100dvh;
    padding: 8px;
    grid-template-rows: auto minmax(0,1fr);
  }

  .scanner-head {
    min-height: 46px;
    padding: 0 2px;
  }

  .scanner-head h2 { font-size: 18px; }

  .scanner-camera {
    min-height: 0;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 14px;
  }

  .scanner-live-hit {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}
