/* Native images for Blank Sheet. Kept separate from AI text objects and ink. */
body.bv-native-sheet-active #bvNativeSheetImageLayer {
  position: absolute;
  /* Images are always the lowest interactive content layer. Text stays above
     images, while committed/live ink remains above both. */
  z-index: 0;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

/* The full-page text layer sits above images visually, but its empty space must
   remain click-through so pictures can still be selected and moved. Only the
   actual text cards receive pointer input. */
body.bv-native-sheet-active #bvNativeSheetObjectLayer {
  pointer-events: none;
}

body.bv-native-sheet-active #bvNativeSheetObjectLayer > .bv-native-sheet-object {
  pointer-events: auto;
}

body.bv-native-sheet-active.bv-reader-pen-workspace-open
  #bvNativeSheetObjectLayer > .bv-native-sheet-object {
  pointer-events: none;
}

body.bv-native-sheet-active.bv-reader-pen-workspace-open #bvNativeSheetImageLayer {
  pointer-events: none;
}

.bv-native-sheet-image {
  position: absolute;
  box-sizing: border-box;
  margin: 0;
  overflow: visible;
  border: 1px solid transparent;
  background: transparent;
  outline: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}

body.bv-native-sheet-active.bv-reader-pen-workspace-open .bv-native-sheet-image {
  pointer-events: none;
}

.bv-native-sheet-image:hover,
.bv-native-sheet-image.is-selected,
.bv-native-sheet-image:focus-visible {
  border-color: rgba(49, 86, 217, 0.56);
  box-shadow: 0 0 0 2px rgba(49, 86, 217, 0.08);
}

.bv-native-sheet-image.is-manipulating {
  cursor: grabbing;
}

.bv-native-sheet-image__media {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.bv-native-sheet-image__controls {
  position: absolute;
  z-index: 3;
  top: -11px;
  right: -11px;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 100ms ease, transform 100ms ease;
}

.bv-native-sheet-image:hover .bv-native-sheet-image__controls,
.bv-native-sheet-image.is-selected .bv-native-sheet-image__controls,
.bv-native-sheet-image:focus-within .bv-native-sheet-image__controls,
.bv-native-sheet-image.is-error .bv-native-sheet-image__controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.bv-native-sheet-image__controls button {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(23, 34, 53, 0.28);
  border-radius: 3px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 2px 2px 0 rgba(23, 34, 53, 0.12);
  color: #172235;
  font: 700 13px/1 sans-serif;
  cursor: pointer;
}

.bv-native-sheet-image__controls button:hover {
  border-color: rgba(49, 86, 217, 0.72);
  background: #fff;
  color: #3156d9;
}

.bv-native-sheet-image__controls button[data-image-action="delete"]:hover {
  border-color: #a2333f;
  color: #a2333f;
}

.bv-native-sheet-image__resize {
  position: absolute;
  z-index: 3;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  opacity: 0;
  cursor: nwse-resize;
  touch-action: none;
  transition: opacity 90ms ease;
}

.bv-native-sheet-image__resize::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 9px;
  height: 9px;
  border-right: 2px solid rgba(49, 86, 217, 0.76);
  border-bottom: 2px solid rgba(49, 86, 217, 0.76);
  content: "";
}

.bv-native-sheet-image:hover .bv-native-sheet-image__resize,
.bv-native-sheet-image.is-selected .bv-native-sheet-image__resize {
  opacity: 1;
}

.bv-native-sheet-image__state {
  position: absolute;
  left: 7px;
  bottom: 7px;
  display: none;
  padding: 4px 6px;
  border: 1px solid rgba(23, 34, 53, 0.18);
  border-radius: 2px;
  background: rgba(255, 253, 247, 0.9);
  color: rgba(23, 34, 53, 0.68);
  font: 700 8px/1 "Courier Prime", monospace;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.bv-native-sheet-image.is-uploading .bv-native-sheet-image__state,
.bv-native-sheet-image.is-error .bv-native-sheet-image__state {
  display: inline-block;
}

.bv-native-sheet-image.is-uploading {
  opacity: 0.74;
}

.bv-native-sheet-image.is-error {
  border-color: rgba(162, 51, 63, 0.52);
}

#bvNativeSheetPaper:has(.bv-native-sheet-image) .bv-native-sheet-paper__hint {
  display: none !important;
}

#bvNativeSheetPaper.bv-image-sheet-drop-target {
  outline: 3px solid rgba(46, 151, 163, 0.64);
  outline-offset: 5px;
}

#bvNativeSheetPaper.bv-image-sheet-drop-target::before {
  position: absolute;
  z-index: 30;
  inset: 18px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(46, 151, 163, 0.56);
  border-radius: 6px;
  background: rgba(46, 151, 163, 0.05);
  color: rgba(35, 112, 121, 0.84);
  font: 700 11px/1.2 "Courier Prime", monospace;
  letter-spacing: 0.09em;
  pointer-events: none;
  content: "DROP IMAGE";
}

.bv-native-sheet-image-status {
  position: sticky;
  z-index: 16;
  left: 12px;
  bottom: 10px;
  width: fit-content;
  max-width: min(320px, 80%);
  margin: 0 0 0 8px;
  padding: 5px 8px;
  border-left: 3px solid #2e97a3;
  border-radius: 2px;
  background: rgba(251, 250, 244, 0.92);
  color: #667085;
  font: 700 9px/1.25 "Courier Prime", monospace;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
}

.bv-native-sheet-image-status.is-visible {
  opacity: 1;
}

body.bv-native-sheet-active #bvNativeSheetImageLauncher {
  display: flex;
  order: 40;
}

/* MARK's existing sync routine may reinsert itself next to Pen. Flex order keeps
   the native-sheet rail visually stable as AI / NOTES / MARK / IMAGE / PEN. */
body.bv-native-sheet-active #bvNativeSheetMarkLauncher {
  order: 30;
}

body.bv-native-sheet-active #bvReaderPenLauncher {
  order: 50;
}

@media (pointer: coarse) {
  .bv-native-sheet-image__controls {
    top: -14px;
    right: -14px;
  }

  .bv-native-sheet-image__controls button {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .bv-native-sheet-image__resize {
    right: -5px;
    bottom: -5px;
    width: 34px;
    height: 34px;
  }

  .bv-native-sheet-image__resize::after {
    right: 7px;
    bottom: 7px;
    width: 11px;
    height: 11px;
  }
}
