body {
  transition: scale 0.15s, filter 0.15s;
}

body.webview-drag-start {
  scale: 0.99;
}

/*
    2023-01-01 Note: macOS Ventura has a bug with dragging on WebView. Disable this feature for now.
    body.webview-mousedown,
    body.webview-mousedown .background:active,
    body.webview-mousedown .background:hover {
      cursor: -webkit-grabbing !important;
      cursor: grabbing !important;
    }
    */

#draw-canvas {
  opacity: 1;
  transition: opacity 0.15s;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

body.redact-mode #target * {
  -webkit-user-select: none;
  user-select: none;
}

body.redact-mode rect.text-rects {
  pointer-events: auto !important;
}

body.redact-mode rect.text-rects:hover {
  stroke-width: 3px;
  stroke: rgb(35 103 251 / 70%);
}

rect.text-rects.redacted {
  fill-opacity: 1 !important;
  pointer-events: auto;
}

body.redact-mode rect.text-rects.redacted:hover {
  fill-opacity: 0.8;
}

body.redact-mode rect.text-rects:hover {
  fill-opacity: 0.5;
}

rect.text-rects.annotation-selected {
  stroke-width: 3px;
  stroke: rgb(35 103 251 / 70%);
}

body:not(.redact-mode) rect.redacted[data-redact-provenance='user'] {
  cursor: grab;
}

rect.redacted[data-redact-provenance='user']:focus {
  outline: none;
}

.redact-resize-handle {
  fill: white;
  stroke: rgb(35 103 251 / 90%);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  pointer-events: auto;
}

.redact-resize-handle[data-handle='n'],
.redact-resize-handle[data-handle='s'] {
  cursor: ns-resize;
}

.redact-resize-handle[data-handle='e'],
.redact-resize-handle[data-handle='w'] {
  cursor: ew-resize;
}

.redact-resize-handle[data-handle='ne'],
.redact-resize-handle[data-handle='sw'] {
  cursor: nesw-resize;
}

.redact-resize-handle[data-handle='nw'],
.redact-resize-handle[data-handle='se'] {
  cursor: nwse-resize;
}

.draggable {
  pointer-events: auto;
}

#draw-canvas {
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.draggable {
  pointer-events: auto;
}

.draw-item-text {
  position: fixed;
  display: inline-block;
  color: var(--annotation-color, #ff0000);

  text-shadow: -2px -2px 0 #fff, 0 -2px 0 #fff, 2px -2px 0 #fff, 2px 0 0 #fff,
    2px 2px 0 #fff, 0 2px 0 #fff, -2px 2px 0 #fff, -2px 0 0 #fff,
    3px 3px 8px #000;

  font-weight: 600;
  font-size: var(--text-font-size, 32px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  background: transparent;
  cursor: -webkit-grab;
  cursor: grab;
  padding: 8px 10px;
  border-radius: 6px;
  border: 2px dashed transparent;
  transition: border-color 0.2s;
  /* resize: horizontal; */
  /* overflow: hidden; */
}

.draw-item-text.text-small {
  --text-font-size: 16px;
}

.draw-item-text.text-big {
  --text-font-size: 56px;
}

.draw-item-text:before {
  /* drag handle */
  display: none;
  content: '';
  position: absolute;
  top: 50%;
  left: -13px;
  width: 10px;
  height: 25px;
  background: #6092ff;
  border: 2px solid #2367fb;
  border-radius: 5px 0 0 5px;
  border-right: 0;
  transform: translateY(-50%);
  cursor: -webkit-grab !important;
  cursor: grab !important;
}

.draw-item-text:after {
  /* drag handle */
  display: none;
  content: '';
  position: absolute;
  top: 50%;
  right: -13px;
  width: 10px;
  height: 25px;
  background: #6092ff;
  border: 2px solid #2367fb;
  border-radius: 0 5px 5px 0;
  border-left: 0;
  transform: translateY(-50%);
  cursor: -webkit-grab !important;
  cursor: grab !important;
}

.draw-item-text[contenteditable]:before,
.draw-item-text[contenteditable]:after {
  display: block;
}

.draw-item-text[contenteditable].preview {
  cursor: crosshair;
  opacity: 0.5;
  border: 2px dashed transparent;
}

.draw-item-text.dragging {
  cursor: -webkit-grabbing !important;
  cursor: grabbing !important;
}

.draw-item-text[contenteditable]:before,
.draw-item-text[contenteditable]:after {
  display: block;
}

.draw-item-text.preview[contenteditable]:before,
.draw-item-text.preview[contenteditable]:after {
  display: none;
}

.draw-item-text:focus,
.draw-item-text.annotation-selected {
  cursor: -webkit-grab;
  cursor: grab;
  border: 2px dashed rgb(35 103 251 / 70%);
  outline: 0;
}

.draw-item-text[contenteditable] {
  cursor: auto;
  border: 2px solid rgb(35 103 251 / 70%);
}

.draw-item-arrow {
  position: absolute;
  display: block;
  cursor: -webkit-grab;
  cursor: grab;
  outline: none;
  border: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  transform-origin: 0 0;
}

.draw-item-arrow svg {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  transform: translateY(-50%);
  pointer-events: auto;
}

.draw-item-arrow svg path {
  pointer-events: visiblePainted;
}

.draw-item-arrow.preview {
  cursor: crosshair;
  opacity: 0.5;
  outline: none;
}

body.screenshot-mode {
  transition: none !important;
  scale: 1 !important;
  filter: grayscale(0) !important;
}

body.screenshot-mode * {
  transition: none !important;
}

body.screenshot-mode .redact-instruction {
  display: none;
}

body.screenshot-mode rect.text-rects {
  fill-opacity: 0;
}

body.screenshot-mode rect.text-rects.redacted {
  fill-opacity: 1;
}

body.screenshot-mode .draw-item-text {
  border: 2px dashed transparent !important;
}

body.screenshot-mode .draw-item-text::before,
body.screenshot-mode .draw-item-text::after {
  display: none !important;
}

body.screenshot-mode .draw-item-text[contenteditable] {
  caret-color: transparent !important;
}

body.screenshot-mode .draw-item-text[contenteditable]::selection {
  color: inherit;
  background: transparent;
}

body.screenshot-mode .annotation-selected {
  border-color: transparent !important;
  outline: 0 !important;
}

body.screenshot-mode rect.text-rects.annotation-selected {
  stroke-width: 0 !important;
  stroke: transparent !important;
}

body.screenshot-mode .draw-item-shape.annotation-selected {
  box-shadow: 0px 0 2px 0px rgb(0 0 0 / 30%) inset, 0px 0 2px 0 rgb(0 0 0 / 30%);
}

body.screenshot-mode .draw-item-shape.shape-oval.annotation-selected {
  box-shadow: 0px 0 2px 0px rgb(0 0 0 / 30%) inset, 0px 0 0px 5px var(--annotation-color, #ff0000) inset;
}

body.screenshot-mode .shape-resize-handle {
  display: none !important;
}

body.screenshot-mode .arrow-resize-handle {
  display: none !important;
}

body.screenshot-mode .redact-resize-handle {
  display: none !important;
}

body.screenshot-mode #draw-canvas {
  opacity: 1 !important;
}

body.redact-mode #draw-canvas {
  opacity: 0.2;
}

body.redact-mode #draw-canvas * {
  pointer-events: none;
}

body.show-crosshair,
body.show-crosshair * {
  cursor: crosshair !important;
}

body.show-cursor-none,
body.show-cursor-none * {
  cursor: none !important;
}

body.show-cursor-move,
body.show-cursor-move * {
  cursor: move !important;
}

@keyframes animated-color {
  0% {
    stroke: rgb(35 103 251 / 70%);
  }
  50% {
    stroke: rgb(35 103 251 / 20%);
  }
  0% {
    stroke: rgb(35 103 251 / 70%);
  }
}

.redact-instruction {
  position: absolute;
  border-radius: 4px;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}

.draw-item-shape {
  position: absolute;
  border: 5px solid var(--annotation-color, #ff0000);
  box-shadow: 0px 0 2px 0px rgb(0 0 0 / 30%) inset, 0px 0 2px 0 rgb(0 0 0 / 30%);
  border-radius: 2px;

  cursor: -webkit-grab;
  cursor: grab;

  transition: border 0.2s, opacity 0.2s, box-shadow 0.2s;
}

.draw-item-shape.preview {
  opacity: 0.5;
}

.draw-item-shape.shape-rectangle {
  --border-size: 15px;
  --focus-ring-size: -5px;
  clip-path: polygon(
    evenodd,
    var(--focus-ring-size) var(--focus-ring-size),
    calc(100% - var(--focus-ring-size)) var(--focus-ring-size),
    calc(100% - var(--focus-ring-size)) calc(100% - var(--focus-ring-size)),
    var(--focus-ring-size) calc(100% - var(--focus-ring-size)),
    var(--focus-ring-size) var(--focus-ring-size),
    /* and top - left again */ /* do the same with inner rect */
      var(--border-size) var(--border-size),
    calc(100% - var(--border-size)) var(--border-size),
    calc(100% - var(--border-size)) calc(100% - var(--border-size)),
    var(--border-size) calc(100% - var(--border-size)),
    var(--border-size) var(--border-size)
  );
}

.draw-item-shape.shape-rounded {
  border-radius: 15px;

  --border-size: 18px;
  --focus-ring-size: -5px;
  clip-path: polygon(
    evenodd,
    var(--focus-ring-size) var(--focus-ring-size),
    calc(100% - var(--focus-ring-size)) var(--focus-ring-size),
    calc(100% - var(--focus-ring-size)) calc(100% - var(--focus-ring-size)),
    var(--focus-ring-size) calc(100% - var(--focus-ring-size)),
    var(--focus-ring-size) var(--focus-ring-size),
    /* and top - left again */ /* do the same with inner rect */
      var(--border-size) var(--border-size),
    calc(100% - var(--border-size)) var(--border-size),
    calc(100% - var(--border-size)) calc(100% - var(--border-size)),
    var(--border-size) calc(100% - var(--border-size)),
    var(--border-size) var(--border-size)
  );
}

.draw-item-shape.shape-oval {
  border-radius: 100%;
  border: 3px solid transparent;
  clip-path: url(#oval);
  box-shadow: 0px 0 2px 0px rgb(0 0 0 / 30%) inset, 0px 0 0px 5px var(--annotation-color, #ff0000) inset;
}

.draw-item-shape.shape-line {
  transform-origin: 0 0;
  border: 2.5px solid var(--annotation-color, #ff0000);
}

.draw-item-shape:focus,
.draw-item-shape.annotation-selected {
  cursor: -webkit-grab;
  cursor: grab;
  outline: 0;
  box-shadow: 1px 0 2px 0px rgb(0 0 0 / 30%) inset, 0px 0 2px 0 rgb(0 0 0 / 30%),
    0 0 0 3px rgb(35 103 251 / 70%), 0 0 0 3px rgb(35 103 251 / 70%) inset;
}

.draw-item-shape.shape-oval:focus,
.draw-item-shape.shape-oval.annotation-selected {
  border: 3px solid rgb(35 103 251 / 70%);
  box-shadow: 0px 0 2px 0px rgb(0 0 0 / 30%) inset, 0px 0 0px 5px var(--annotation-color, #ff0000) inset,
    0px 0 0px 8px rgb(35 103 251 / 70%) inset, 0px 0 2px 0 rgb(0 0 0 / 30%);
}

.shape-resize-handle {
  position: absolute;
  z-index: 2147483647;
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 2px solid rgb(35 103 251 / 85%);
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
  pointer-events: auto;
}

.shape-resize-handle[data-handle='n'],
.shape-resize-handle[data-handle='s'] {
  cursor: ns-resize;
}

.shape-resize-handle[data-handle='e'],
.shape-resize-handle[data-handle='w'] {
  cursor: ew-resize;
}

.shape-resize-handle[data-handle='nw'],
.shape-resize-handle[data-handle='se'] {
  cursor: nwse-resize;
}

.shape-resize-handle[data-handle='ne'],
.shape-resize-handle[data-handle='sw'] {
  cursor: nesw-resize;
}

.shape-resize-handle[data-handle='line-start'],
.shape-resize-handle[data-handle='line-end'] {
  cursor: grab;
}

.arrow-resize-handle {
  position: absolute;
  z-index: 2147483647;
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 2px solid rgb(35 103 251 / 85%);
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
  pointer-events: auto;
  cursor: grab;
}
