/* Extracted from index.html. Crop and annotation tool modal styles. */

.tool-modal-card.canvas-crop-modal-card,
.tool-modal-card.reference-annotate-modal-card {
  --reference-editor-topbar-height: 62px;
  --reference-editor-footer-height: 64px;
  width: min(840px, 96vw);
  height: min(840px, 94vh);
  max-height: min(94vh, 840px);
  min-height: 0;
  overflow: hidden;
  gap: 4px;
  padding: 12px 14px 10px;
}

.tool-modal-card.canvas-crop-modal-card .tool-modal-content,
.tool-modal-card.reference-annotate-modal-card .tool-modal-content {
  flex: 1 1 auto;
  min-height: 0;
}

.tool-modal-content.reference-editor-content-pending {
  visibility: hidden;
}

.reference-editor-content-ghost {
  position: absolute;
  z-index: 3;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
  background: #fff;
}

.reference-editor-content-ghost [data-reference-editor-control],
.tool-modal-content [data-reference-editor-control] {
  transform-origin: center;
  will-change: transform, opacity;
}

.reference-editor-content-ghost.is-controls-exiting [data-reference-editor-control="exit"] {
  animation: reference-editor-control-exit 120ms cubic-bezier(0.4, 0, 0.8, 0.3) both;
  animation-delay: var(--reference-editor-control-delay, 0ms);
}

.tool-modal-content.reference-editor-controls-enter-pending [data-reference-editor-control="enter"] {
  opacity: 0;
  transform: scale(0.78);
}

.tool-modal-content.is-controls-entering [data-reference-editor-control="enter"] {
  animation: reference-editor-control-enter 200ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--reference-editor-control-delay, 0ms);
}

@keyframes reference-editor-control-exit {
  from { opacity: var(--reference-editor-control-opacity, 1); transform: scale(1); }
  to { opacity: 0; transform: scale(0.78); }
}

@keyframes reference-editor-control-enter {
  0% { opacity: 0; transform: scale(0.78); }
  72% { opacity: var(--reference-editor-control-opacity, 1); transform: scale(1.035); }
  100% { opacity: var(--reference-editor-control-opacity, 1); transform: scale(1); }
}

html.theme-dark .reference-editor-content-ghost {
  background: #202020;
}

.reference-editor-mode-switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, 43px);
  align-items: center;
  width: 94px;
  height: 28px;
  margin-left: 12px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.16);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  isolation: isolate;
  box-sizing: border-box;
}

.reference-editor-mode-thumb {
  position: absolute;
  z-index: 0;
  left: 4px;
  top: 4px;
  width: 43px;
  height: 20px;
  box-sizing: border-box;
  border: 1px solid #e1ac00;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe477 0%, #ffd13f 52%, #f0b900 100%);
  box-shadow:
    0 1px 2px rgba(177, 126, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.68),
    inset 0 -1px 0 rgba(150, 104, 0, 0.14);
  transform: translateX(0);
  transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 220ms ease;
  pointer-events: none;
}

.reference-editor-mode-switch[data-active-mode="annotate"] .reference-editor-mode-thumb {
  transform: translateX(43px);
  box-shadow:
    0 1px 3px rgba(177, 126, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.68),
    inset 0 -1px 0 rgba(150, 104, 0, 0.14);
}

.reference-editor-mode-switch button {
  position: relative;
  z-index: 1;
  width: 43px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #77777c;
  font-family: inherit;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  transition: color 160ms ease, opacity 160ms ease, transform 140ms cubic-bezier(0.23, 1, 0.32, 1);
}

.reference-editor-mode-switch button.active { color: #3a2b00; }
.reference-editor-mode-switch button:hover:not(:disabled) { color: #343438; }
.reference-editor-mode-switch button:active:not(:disabled) { transform: scale(0.94); }

.reference-editor-mode-switch button:focus-visible {
  outline: 2px solid #d99f00;
  outline-offset: 2px;
}

.reference-editor-mode-switch button:disabled { cursor: default; }

.reference-editor-switch-spinner {
  position: absolute;
  z-index: 2;
  left: 20px;
  top: 9px;
  width: 10px;
  height: 10px;
  box-sizing: border-box;
  border: 1.5px solid rgba(58, 43, 0, 0.22);
  border-top-color: #3a2b00;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  animation: sb-canvas-crop-spin 0.72s linear infinite;
}

.reference-editor-mode-switch[data-active-mode="annotate"] .reference-editor-switch-spinner { left: 63px; }
.reference-editor-mode-switch.is-loading .reference-editor-switch-spinner { opacity: 1; }
.reference-editor-mode-switch.is-loading button.active { opacity: 0.15; }

.reference-editor-mode-switch.has-error {
  animation: reference-editor-switch-error 260ms ease;
}

@keyframes reference-editor-switch-error {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-3px); }
  70% { transform: translateX(3px); }
}

html.theme-dark .reference-editor-mode-switch {
  background: rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.13),
    inset 0 2px 2px rgba(0, 0, 0, 0.32),
    inset 0 -1px 0 rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

html.theme-dark .reference-editor-mode-switch button { color: #d2d2d7; }
html.theme-dark .reference-editor-mode-switch button.active { color: #332600; }
html.theme-dark .reference-editor-mode-switch button:not(.active):hover:not(:disabled) {
  color: #fff;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .reference-editor-mode-thumb { transition: none; }
  .reference-editor-mode-switch button:active:not(:disabled) { transform: none; }
  .reference-editor-content-ghost.is-controls-exiting [data-reference-editor-control="exit"],
  .tool-modal-content.is-controls-entering [data-reference-editor-control="enter"] {
    animation: none;
  }
}

.sb-canvas-crop {
  display: grid;
  grid-template-rows: var(--reference-editor-topbar-height) minmax(0, 1fr) var(--reference-editor-footer-height);
  gap: 6px;
  height: 100%;
  min-height: 0;
  padding: 8px 0 0;
  box-sizing: border-box;
  color: var(--text);
  position: relative;
}

.sb-canvas-crop-ratios {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  height: var(--reference-editor-topbar-height);
  padding: 2px 0;
  box-sizing: border-box;
  overflow-x: auto;
  scrollbar-width: none;
}

.sb-canvas-crop-ratios::-webkit-scrollbar {
  display: none;
}

.sb-canvas-crop-ratio {
  flex: 0 0 auto;
  width: 54px;
  height: 50px;
  padding: 5px 3px 4px;
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, var(--soft));
  color: var(--muted);
  font: inherit;
  display: inline-grid;
  grid-template-rows: 20px 12px;
  place-items: center;
  align-content: center;
  row-gap: 3px;
  cursor: pointer;
  transform-origin: center;
  transition: transform 0.15s ease, background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.sb-canvas-crop-ratio svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-canvas-crop-ratio-graphic {
  display: block;
  flex: 0 0 auto;
  box-sizing: border-box;
  border: 1.8px solid currentColor;
  border-radius: 2px;
}

.sb-canvas-crop-ratio > span,
.sb-canvas-crop-button-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  line-height: 12px;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
}

.sb-canvas-crop-ratio > span {
  width: 100%;
  height: 12px;
  text-align: center;
}

.sb-canvas-crop-ratio:hover {
  color: var(--text);
  transform: scale(1.025);
}

.sb-canvas-crop-ratio:active {
  transform: scale(0.96);
}

.sb-canvas-crop-ratio.active {
  color: #1d1d1f;
  background: color-mix(in srgb, #ffc106 20%, #fff);
  border-color: #e0aa00;
}

html.theme-dark .sb-canvas-crop-ratio.active {
  color: #fff;
  background: color-mix(in srgb, #ffc106 28%, #2c2c2e);
  border-color: #ffc106;
}

.sb-canvas-crop-stage {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: auto;
  padding: 6px 12px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--soft) 88%, var(--surface));
}

html.theme-dark .sb-canvas-crop-stage {
  background: #171717;
  border-color: rgba(255, 255, 255, 0.08);
}

.sb-canvas-crop-frame {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  transition: width 0.22s ease, height 0.22s ease;
}

.sb-canvas-crop-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.sb-canvas-crop-canvas.dragging {
  cursor: grabbing;
}

.sb-canvas-crop-outline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(29, 29, 31, 0.72);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.sb-canvas-crop-outline i {
  position: absolute;
  width: 17px;
  height: 17px;
  border-color: #1d1d1f;
  border-style: solid;
}

.sb-canvas-crop-outline i:nth-child(1) {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
  border-radius: 6px 0 0;
}

.sb-canvas-crop-outline i:nth-child(2) {
  top: -1px;
  right: -1px;
  border-width: 2px 2px 0 0;
  border-radius: 0 6px 0 0;
}

.sb-canvas-crop-outline i:nth-child(3) {
  right: -1px;
  bottom: -1px;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 6px;
}

.sb-canvas-crop-outline i:nth-child(4) {
  bottom: -1px;
  left: -1px;
  border-width: 0 0 2px 2px;
  border-radius: 0 0 0 6px;
}

.sb-canvas-crop-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #6e6e73;
  background: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sb-canvas-crop-loading.show {
  display: flex;
}

.sb-canvas-crop-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(29, 29, 31, 0.16);
  border-top-color: #c89b28;
  border-radius: 50%;
  animation: sb-canvas-crop-spin 0.75s linear infinite;
}

@keyframes sb-canvas-crop-spin {
  to { transform: rotate(360deg); }
}

.sb-canvas-crop-footer {
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--reference-editor-footer-height);
  padding: 6px 8px 8px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.sb-canvas-crop-footer::-webkit-scrollbar {
  display: none;
}

.sb-canvas-crop-zoom,
.sb-canvas-crop-transform-actions,
.sb-canvas-crop-main-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 6px;
}

.sb-canvas-crop-main-actions {
  justify-content: flex-end;
}

.sb-canvas-crop-percent {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.sb-canvas-crop-percent {
  width: 35px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sb-canvas-crop-slider {
  width: 110px;
  flex: 0 0 110px;
}

.sb-canvas-crop-slider,
.annotate-control input[type="range"] {
  --image-tool-range-accent: #ffd54a;
  --image-tool-range-track: #dedee3;
  height: 30px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  outline: 0;
  background: transparent;
  cursor: grab;
  touch-action: pan-y;
}

html.theme-dark .sb-canvas-crop-slider,
html.theme-dark .annotate-control input[type="range"] {
  --image-tool-range-track: #74757b;
}

.sb-canvas-crop-slider:active,
.annotate-control input[type="range"]:active {
  cursor: grabbing;
}

.sb-canvas-crop-slider::-webkit-slider-runnable-track,
.annotate-control input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--image-tool-range-track);
}

.sb-canvas-crop-slider::-webkit-slider-thumb,
.annotate-control input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8px;
  appearance: none;
  -webkit-appearance: none;
  border: 5px solid var(--image-tool-range-accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(35, 35, 38, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
  transition: transform 100ms ease-out, box-shadow 100ms ease-out;
}

.sb-canvas-crop-slider:hover::-webkit-slider-thumb,
.annotate-control input[type="range"]:hover::-webkit-slider-thumb {
  box-shadow: 0 2px 8px rgba(35, 35, 38, 0.2), 0 0 0 4px color-mix(in srgb, var(--image-tool-range-accent) 16%, transparent);
}

.sb-canvas-crop-slider:active::-webkit-slider-thumb,
.annotate-control input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.1);
  box-shadow: 0 2px 9px rgba(35, 35, 38, 0.22), 0 0 0 6px color-mix(in srgb, var(--image-tool-range-accent) 18%, transparent);
}

.sb-canvas-crop-slider::-moz-range-track,
.annotate-control input[type="range"]::-moz-range-track,
.sb-canvas-crop-slider::-moz-range-progress,
.annotate-control input[type="range"]::-moz-range-progress {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--image-tool-range-track);
}

.sb-canvas-crop-slider::-moz-range-thumb,
.annotate-control input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 5px solid var(--image-tool-range-accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(35, 35, 38, 0.18);
  transition: transform 100ms ease-out, box-shadow 100ms ease-out;
}

.annotate-control input[type="range"]::-webkit-slider-thumb {
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-width: 4px;
}

.annotate-control input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border-width: 4px;
}

.sb-canvas-crop-slider:focus-visible::-webkit-slider-thumb,
.annotate-control input[type="range"]:focus-visible::-webkit-slider-thumb,
.sb-canvas-crop-slider:focus-visible::-moz-range-thumb,
.annotate-control input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--image-tool-range-accent) 20%, transparent), 0 0 0 6px rgba(80, 80, 86, 0.16);
}

.sb-canvas-crop-icon-btn,
.sb-canvas-crop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, var(--soft));
  color: var(--text);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
  transform: scale(1);
  transform-origin: center;
  transition: transform 0.15s ease, background-color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.sb-canvas-crop-icon-btn {
  width: 48px;
  flex: 0 0 48px;
  padding: 4px 3px 3px;
  flex-direction: column;
  gap: 3px;
}

.sb-canvas-crop-btn {
  width: 56px;
  flex: 0 0 56px;
  padding: 4px 3px 3px;
  flex-direction: column;
  gap: 3px;
  white-space: nowrap;
}

.sb-canvas-crop-icon-btn svg,
.sb-canvas-crop-btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sb-canvas-crop-icon-btn:hover:not(:disabled),
.sb-canvas-crop-btn:hover:not(:disabled) {
  transform: scale(1.04);
  background: color-mix(in srgb, var(--surface) 78%, var(--soft));
}

.sb-canvas-crop-icon-btn:active:not(:disabled),
.sb-canvas-crop-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.sb-canvas-crop-icon-btn:disabled,
.sb-canvas-crop-btn:disabled,
.sb-canvas-crop-ratio:disabled {
  opacity: 0.36;
  cursor: default;
}

.sb-canvas-crop-btn.primary {
  width: 70px;
  flex-basis: 70px;
  color: #332600 !important;
  background: linear-gradient(180deg, #ffe477 0%, #ffd13f 52%, #f0b900 100%) !important;
  border-color: #e1ac00 !important;
  box-shadow: none;
}

.sb-canvas-crop-btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe477 0%, #ffd13f 52%, #f0b900 100%) !important;
  box-shadow: none;
}

.sb-canvas-crop-btn.primary .sb-canvas-crop-button-label {
  font-size: 10px;
  font-weight: 700;
}

.sb-canvas-crop-btn.primary.loading svg {
  border: 2px solid rgba(29, 29, 31, 0.2);
  border-top-color: #1d1d1f;
  border-radius: 50%;
  stroke: none;
  animation: sb-canvas-crop-spin 0.75s linear infinite;
}

.sb-canvas-crop > .sb-canvas-crop-status {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: calc(var(--reference-editor-footer-height) + 10px);
  left: 16px;
  pointer-events: none;
}

.sb-canvas-crop-status {
  min-height: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  text-align: right;
}

.sb-canvas-crop-status:empty {
  display: none;
}

.sb-canvas-crop-status.error {
  color: #d64545;
}

@media (max-width: 760px) {
  .tool-modal-card.canvas-crop-modal-card,
  .tool-modal-card.reference-annotate-modal-card {
    --reference-editor-topbar-height: 66px;
    width: min(100%, calc(100vw - 20px));
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    padding: 12px;
  }

  .sb-canvas-crop {
    gap: 6px;
  }

  .sb-canvas-crop-ratios {
    justify-content: flex-start;
  }

  .sb-canvas-crop-stage {
    min-height: 0;
    height: auto;
    padding: 5px 8px;
  }

  .sb-canvas-crop-footer {
    justify-content: flex-start;
    gap: 6px;
  }

  .sb-canvas-crop-zoom {
    min-width: 0;
    justify-content: flex-start;
  }

  .sb-canvas-crop-main-actions {
    justify-content: flex-start;
  }

  .sb-canvas-crop-transform-actions {
    justify-content: flex-start;
  }

  .sb-canvas-crop-btn {
    padding: 5px 3px 4px;
  }
}

.crop-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crop-btn {
  height: 36px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  background: #fff;
  color: #3a3a3c;
  font: inherit;
  font-size: 13px;
  padding: 0 12px;
  cursor: pointer;
  transform: scale(1);
  transform-origin: center;
  transition:
    transform 0.16s ease,
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.crop-btn.active {
  background: var(--blue);
  border-color: transparent;
  color: #1d1d1f;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

html.theme-dark .crop-btn.active {
  background: var(--blue);
  border-color: transparent;
  color: #1d1d1f;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}

.crop-btn:hover {
  transform: scale(1.025);
}

.crop-btn:active {
  transform: scale(0.97);
}

.annotate-toolbar .crop-btn.active {
  background: color-mix(in srgb, #ffc106 20%, #fff);
  border-color: #e0aa00;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.36) inset,
    0 3px 10px rgba(141, 103, 0, 0.16);
}

.annotate-toolbar .crop-btn.annotate-selection-pulse {
  animation: annotate-option-selected 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.theme-dark .annotate-toolbar .crop-btn.active {
  background: color-mix(in srgb, #ffc106 28%, #2c2c2e);
  border-color: #ffc106;
  color: #fff;
}

.annotate-toolbar .crop-btn:hover {
  transform: scale(1.025);
}

.annotate-toolbar .crop-btn:active {
  transform: scale(0.95);
  transition-duration: 80ms;
}

.annotate-toolbar .crop-btn:focus-visible {
  outline: 2px solid #ffc106;
  outline-offset: 2px;
}

.annotate-toolbar .crop-btn.active:focus-visible {
  outline: none;
}

@keyframes annotate-option-selected {
  0% { transform: scale(0.96); }
  70% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

.annotate-editor {
  display: grid;
  grid-template-rows: var(--reference-editor-topbar-height) minmax(0, 1fr) var(--reference-editor-footer-height);
  gap: 6px;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  padding: 8px 0 0;
  position: relative;
}

.annotate-topbar {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  height: var(--reference-editor-topbar-height);
  padding: 6px 0;
  box-sizing: border-box;
  overflow: visible;
  scrollbar-width: none;
}

.annotate-topbar::-webkit-scrollbar {
  display: none;
}

.annotate-toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.annotate-toolbar .annotate-tool-btn {
  width: 54px;
  height: 50px;
  padding: 5px 3px 4px;
  border-radius: 12px;
  display: inline-flex;
  flex: 0 0 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
}

.annotate-tool-btn .annotate-tool-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  stroke-width: 1.85;
}

.annotate-tool-btn .annotate-tool-icon-mosaic rect:nth-child(2),
.annotate-tool-btn .annotate-tool-icon-mosaic rect:nth-child(3) {
  fill: currentColor;
  stroke: currentColor;
  opacity: 0.3;
}

.annotate-tool-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  line-height: 12px;
  white-space: nowrap;
  letter-spacing: 0;
  pointer-events: none;
}

.annotate-controls {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: max-content max-content;
  grid-template-rows: 24px 24px;
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
  justify-content: start;
  min-width: 0;
}

.annotate-controls > .annotate-control:first-child {
  grid-column: 1;
  grid-row: 1 / 3;
}

.annotate-controls > .annotate-control:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.annotate-controls > .annotate-control:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.annotate-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #3a3a3c;
  font-size: 12px;
}

.annotate-control-label {
  width: 42px;
  flex: 0 0 42px;
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}

html.theme-dark .annotate-control {
  color: #d8d8dc;
}

.annotate-color-palette {
  display: inline-grid;
  grid-template-columns: repeat(3, 26px);
  grid-template-rows: repeat(2, 24px);
  align-items: center;
  gap: 0;
  min-height: 48px;
}

.annotate-color-btn {
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 26px;
}

.annotate-color-dot {
  display: block;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: var(--annotate-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.48);
  opacity: 0.52;
  transform: scale(0.84);
  transform-origin: center;
  transition:
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 150ms ease-out,
    box-shadow 150ms ease-out;
  pointer-events: none;
}

.annotate-color-btn.active .annotate-color-dot {
  opacity: 1;
  transform: scale(1.12);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.55),
    0 1px 4px rgba(0, 0, 0, 0.2);
}

.annotate-color-btn.annotate-selection-pulse .annotate-color-dot {
  animation: annotate-color-selected 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.annotate-color-palette:has(.annotate-color-btn:hover) .annotate-color-btn.active:not(:hover) .annotate-color-dot {
  opacity: 0.52;
  transform: scale(0.84);
}

.annotate-color-btn:hover {
  z-index: 2;
}

.annotate-color-btn:hover .annotate-color-dot,
.annotate-color-btn.active:hover .annotate-color-dot {
  opacity: 1;
  transform: scale(1.16);
}

.annotate-color-btn:active .annotate-color-dot,
.annotate-color-btn.active:active .annotate-color-dot {
  opacity: 0.82;
  transform: scale(0.9);
  transition-duration: 70ms;
}

.annotate-color-btn:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.32);
  outline-offset: 0;
}

@keyframes annotate-color-selected {
  0% { transform: scale(0.84); }
  70% { transform: scale(1.18); }
  100% { transform: scale(1.12); }
}

.annotate-control input[type="range"] {
  width: 104px;
}

.annotate-topbar .annotate-control input[type="range"] {
  height: 34px;
}

@media (max-width: 760px) {
  .annotate-topbar {
    padding: 8px 0;
    overflow-x: auto;
    overflow-y: hidden;
  }
}

.annotate-tool-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.annotate-canvas-wrap {
  grid-row: 2;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 6px 12px;
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--soft) 88%, var(--surface));
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.annotate-editor.is-space-pan .annotate-canvas-wrap {
  cursor: grab;
}

.annotate-editor.is-panning .annotate-canvas-wrap {
  cursor: grabbing;
}

.tool-modal-card.reference-annotate-modal-card .tool-modal-content {
  overflow: hidden;
}

.tool-modal-card.reference-annotate-modal-card .annotate-canvas-wrap {
  margin: 0;
}

html.theme-dark .tool-modal-card.reference-annotate-modal-card .annotate-canvas-wrap {
  background: #171717;
  border-color: rgba(255, 255, 255, 0.08);
}

.tool-modal-card.reference-annotate-modal-card .annotate-canvas {
  max-width: none;
  max-height: none;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.annotate-style-preview {
  position: absolute;
  z-index: 2;
  width: 132px;
  height: 72px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transform-origin: center;
  transition: opacity 140ms ease, transform 180ms ease;
  will-change: opacity, transform;
}

.annotate-style-preview.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.annotate-style-preview-canvas {
  display: block;
  width: 132px;
  height: 72px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.48));
}

.annotate-style-preview-value {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.9),
    0 0 5px rgba(0, 0, 0, 0.62);
}

.annotate-zoom-tip {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 2;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(28, 28, 30, 0.74);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -4px) scale(0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 120ms ease-out, transform 150ms ease-out;
}

.annotate-zoom-tip.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .annotate-style-preview,
  .annotate-zoom-tip {
    transition: opacity 100ms linear;
  }

  .annotate-toolbar .crop-btn.annotate-selection-pulse,
  .annotate-color-btn.annotate-selection-pulse .annotate-color-dot {
    animation: none;
  }

  .annotate-color-dot {
    transition: none;
  }
}

.annotate-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: rgba(15, 15, 18, 0.72);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  z-index: 3;
}

.annotate-loading.show {
  display: flex;
}

.annotate-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: annotate-loading-spin 0.72s linear infinite;
}

@keyframes annotate-loading-spin {
  to { transform: rotate(360deg); }
}

.annotate-editor > .annotate-status {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: calc(var(--reference-editor-footer-height) + 10px);
  left: 16px;
  pointer-events: none;
}

.annotate-status {
  min-height: 18px;
  color: #636366;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.annotate-status:empty {
  display: none;
}

.annotate-status.error {
  color: #d92d20;
}

.annotate-canvas {
  max-width: 100%;
  max-height: 58vh;
  display: block;
  touch-action: none;
  cursor: crosshair;
  transform-origin: center;
  will-change: transform;
}

.annotate-text-input {
  position: absolute;
  min-width: 120px;
  max-width: 260px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: rgba(255, 255, 255, 0.96);
  color: #1d1d1f;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 6px 8px;
  outline: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  z-index: 2;
}

.annotate-footer {
  grid-row: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  height: var(--reference-editor-footer-height);
  padding: 6px 10px 8px;
  box-sizing: border-box;
}

.annotate-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.annotate-removal-option {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin-left: 2px;
  padding: 0 4px;
  color: color-mix(in srgb, var(--text) 78%, transparent);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transform-origin: center;
  transition: color 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.annotate-removal-option:hover {
  color: var(--text);
  transform: scale(1.025);
}

.annotate-removal-option:active {
  transform: scale(0.98);
}

.annotate-removal-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.annotate-removal-check {
  position: relative;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 1px solid color-mix(in srgb, var(--text) 24%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface) 90%, var(--soft));
  box-sizing: border-box;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.annotate-removal-check::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #332600;
  border-width: 0 2px 2px 0;
  opacity: 0;
  transform: rotate(45deg) scale(0.65);
  transform-origin: center;
  transition: opacity 130ms ease, transform 160ms cubic-bezier(0.2, 0.85, 0.22, 1);
}

.annotate-removal-option input:checked + .annotate-removal-check {
  border-color: #d7a900;
  background: #ffd54a;
}

.annotate-removal-option input:checked + .annotate-removal-check::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.annotate-removal-option input:focus-visible + .annotate-removal-check {
  box-shadow: 0 0 0 3px color-mix(in srgb, #ffd54a 30%, transparent);
}

.annotate-removal-option:has(input:disabled) {
  cursor: default;
  opacity: 0.38;
  transform: none;
}

.annotate-actions .annotate-action-btn {
  width: 68px;
  height: 50px;
  padding: 5px 3px 4px;
  border-radius: 12px;
  display: inline-flex;
  flex: 0 0 68px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
}

.annotate-actions .annotate-action-btn[data-annotate-apply] {
  width: 84px;
  flex-basis: 84px;
  border-color: #e1ac00 !important;
  background: linear-gradient(180deg, #ffe477 0%, #ffd13f 52%, #f0b900 100%) !important;
  color: #332600 !important;
  box-shadow: none;
}

.annotate-actions .annotate-action-btn[data-annotate-apply] .annotate-action-label {
  font-size: 11px;
  font-weight: 700;
}

.annotate-actions .annotate-action-btn[data-annotate-apply]:hover:not(:disabled) {
  box-shadow: none;
}

.annotate-action-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.annotate-action-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  line-height: 12px;
  white-space: nowrap;
  letter-spacing: 0;
  pointer-events: none;
}

.annotate-actions .annotate-action-btn:disabled {
  cursor: default;
  opacity: 0.38;
  transform: none;
  box-shadow: none;
}

.annotate-actions .annotate-action-btn:disabled:hover,
.annotate-actions .annotate-action-btn:disabled:active {
  transform: none;
}
