html {
  scroll-behavior: smooth;
  scroll-padding-top: 82px;
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 72px;
  }

  body {
    overflow-x: hidden;
  }

  .app-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel {
    margin-bottom: 12px;
    padding: 14px;
  }

  .section-head {
    gap: 8px;
    margin-bottom: 10px;
  }

  .stack {
    gap: 10px;
  }

  .two,
  .three,
  .four {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  input,
  select,
  textarea,
  button,
  .button {
    min-height: 44px;
  }

  textarea {
    min-height: 90px;
  }

  /*
   * Keep public mobile actions visible.
   */
  .site-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding-left: 12px;
    padding-right: 12px;
  }

  .site-header .site-brand {
    min-width: 0;
  }

  .site-header .header-actions {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
  }

  .site-header .header-actions a,
  .site-header .mobile-signin-link {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.86rem;
  }

  .site-header nav {
    grid-column: 1 / -1;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .site-header nav::-webkit-scrollbar {
    display: none;
  }
}

/*
 * Responsive scanner sizing. These rules only affect video inside
 * scanner/camera containers and do not alter scanner JavaScript.
 */
.scanner-stage,
.scanner-camera,
.scanner-camera-wrap,
.camera-stage,
.camera-shell,
.camera-preview,
.scan-camera,
.scan-camera-shell,
[data-scanner-stage],
[data-camera-stage] {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.scanner-stage video,
.scanner-camera video,
.scanner-camera-wrap video,
.camera-stage video,
.camera-shell video,
.camera-preview video,
.scan-camera video,
.scan-camera-shell video,
[data-scanner-stage] video,
[data-camera-stage] video {
  display: block;
  width: 100%;
  max-width: 100%;
  height: min(68dvh, calc(100vw * 1.3));
  min-height: 280px;
  object-fit: cover;
  object-position: center;
}

@media (orientation: landscape) and (max-height: 600px) {
  .scanner-stage video,
  .scanner-camera video,
  .scanner-camera-wrap video,
  .camera-stage video,
  .camera-shell video,
  .camera-preview video,
  .scan-camera video,
  .scan-camera-shell video,
  [data-scanner-stage] video,
  [data-camera-stage] video {
    height: 62dvh;
    min-height: 210px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* HoloRyn compact captured-image workflow v1 */

/*
 * The camera canvas already displays the photograph after capture.
 * Hide the second duplicated photograph underneath the camera.
 */
.alignment-preview[data-preview-for="slabImage"],
.alignment-preview[data-preview-for="inventorySlabImage"],
.alignment-preview[data-preview-for="tradeSlabImage"],
.alignment-preview[data-preview-for="tradeBuilderImage"] {
  display: none !important;
}

/*
 * Keep the retained captured photograph as the main preview area.
 */
#guidedCamera[data-inline-camera="1"] .camera-shell.camera-paused {
  position: relative;
}

#guidedCamera[data-inline-camera="1"]
.camera-shell.camera-paused
.camera-live-preview {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/*
 * Put the existing retake control directly over the retained image.
 */
#guidedCamera[data-inline-camera="1"]
.camera-shell.camera-paused
#restartInlineCamera {
  display: inline-flex !important;
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  width: auto;
  min-width: 132px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
}

/*
 * Hide the retake button while the live camera is active.
 */
#guidedCamera[data-inline-camera="1"]
.camera-shell:not(.camera-paused)
#restartInlineCamera {
  display: none !important;
}

/*
 * Prevent the camera controls area from reserving unnecessary height
 * after capture. The retake button is positioned over the image.
 */
#guidedCamera[data-inline-camera="1"]
.camera-shell.camera-paused
.camera-controls {
  min-height: 0;
  padding: 0;
  margin: 0;
}

/*
 * Seven catalogue results remain large enough to select accurately,
 * but use less vertical space.
 */
#matchResults,
#inventoryMatchResults,
#tradeMatchResults,
#tradeBuilderMatchResults {
  gap: 8px;
}

@media (max-width: 760px) {
  #guidedCamera[data-inline-camera="1"]
  .camera-shell.camera-paused
  #restartInlineCamera {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    min-width: 120px;
    min-height: 42px;
    padding: 8px 12px;
    font-size: 0.86rem;
  }

  #matchResults,
  #inventoryMatchResults,
  #tradeMatchResults,
  #tradeBuilderMatchResults {
    gap: 7px;
  }
}

/* HoloRyn minimal card workflow v1 */

.minimal-primary-value {
  scroll-margin-top: 84px;
  margin-top: 10px;
  margin-bottom: 10px;
  border: 1px solid rgba(122, 106, 255, 0.35);
  background:
    linear-gradient(
      145deg,
      rgba(122, 106, 255, 0.10),
      rgba(45, 212, 191, 0.05)
    );
}

.minimal-card-details {
  margin: 10px 0;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.025);
}

.minimal-card-details > summary,
.owner-debug-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.minimal-card-details > summary::-webkit-details-marker,
.owner-debug-details > summary::-webkit-details-marker {
  display: none;
}

.minimal-card-details > summary span:first-child,
.owner-debug-details > summary span:first-child {
  display: grid;
  gap: 2px;
}

.minimal-card-details > summary strong,
.owner-debug-details > summary strong {
  line-height: 1.2;
}

.minimal-card-details > summary small,
.owner-debug-details > summary small {
  line-height: 1.3;
  opacity: 0.68;
}

.minimal-details-chevron,
.owner-debug-details > summary span:last-child {
  transition: transform 160ms ease;
}

.minimal-card-details[open] .minimal-details-chevron,
.owner-debug-details[open] > summary span:last-child {
  transform: rotate(180deg);
}

.minimal-card-details-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.owner-scan-debug-dock {
  margin-top: 28px;
  opacity: 0.92;
}

.owner-debug-content {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.owner-debug-content .debug-box,
.owner-debug-content .scanner-debug,
.owner-debug-content .scan-debug {
  display: block;
  margin: 0;
}

#matchResults,
#inventoryMatchResults,
#tradeMatchResults,
#tradeBuilderMatchResults {
  max-height: none;
}

@media (max-width: 760px) {
  .minimal-primary-value {
    scroll-margin-top: 72px;
    margin-top: 8px;
    margin-bottom: 8px;
    padding: 12px;
  }

  .minimal-card-details {
    margin: 8px 0;
  }

  .minimal-card-details > summary,
  .owner-debug-details > summary {
    min-height: 48px;
    padding: 10px 12px;
  }

  .minimal-card-details-body {
    gap: 8px;
    padding: 0 12px 12px;
  }

  .owner-scan-debug-dock {
    margin-top: 18px;
  }

  #matchResults,
  #inventoryMatchResults,
  #tradeMatchResults,
  #tradeBuilderMatchResults {
    gap: 6px;
  }
}

/* Manual slab grading details popup */
.manual-slab-details-dialog {
  width: min(620px, calc(100vw - 24px));
  max-height: min(760px, calc(100dvh - 24px));
}

.manual-slab-details-dialog::backdrop {
  background: rgba(3, 5, 10, 0.76);
  backdrop-filter: blur(4px);
}

@media (max-width: 760px) {
  .manual-slab-details-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
    padding: 14px;
  }

  .manual-slab-details-dialog .three {
    grid-template-columns: 1fr !important;
    gap: 9px;
  }

  .manual-slab-details-dialog .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .manual-slab-details-dialog .dialog-actions .button {
    width: 100%;
    min-height: 48px;
  }
}
