body.tms-image-viewer-open { overflow: hidden; }
.tms-image-viewer {
  position: fixed; inset: 0; margin: 0; padding: 0; border: 0; border-radius: 0;
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  background: #161a1ef5; color: #fff; overflow: hidden; box-sizing: border-box;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.tms-image-viewer[open] { display: flex; flex-direction: column; }
.tms-image-viewer::backdrop { background: #161a1eeb; }
.tms-image-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: 8px 12px; background: #242a30; flex: 0 0 auto;
}
.tms-image-viewer .lb-caption { flex: 1 1 180px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-image-controls { display: flex; align-items: center; gap: 6px; }
.tms-image-viewer button {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 36px; height: 36px; padding: 0; border: 1px solid #73808c; border-radius: 6px;
  background: #242a30; color: #fff; font: inherit; font-size: 23px; cursor: pointer;
}
.tms-image-viewer button:hover:not(:disabled) { background: #3a4652; }
.tms-image-viewer button:focus-visible, .tms-image-stage:focus-visible { outline: 2px solid #85baff; outline-offset: -2px; }
.tms-image-viewer button:disabled { opacity: .35; cursor: default; }
.tms-image-zoom { min-width: 44px; text-align: center; font-size: 12px; }
.tms-image-body { flex: 1; min-height: 0; position: relative; margin: 8px 52px; }
.tms-image-stage { position: absolute; inset: 0; overflow: auto; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-y pinch-zoom; }
/* Keep wheel/keyboard scrolling and drag-to-pan without scrollbar gutters
   changing the image viewport on Windows or browsers with classic scrollbars. */
.tms-image-stage::-webkit-scrollbar { display: none; width: 0; height: 0; }
.tms-image-canvas { position: relative; min-width: 100%; min-height: 100%; overflow: hidden; }
.tms-image-canvas img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; transform-origin: center; user-select: none; }
.tms-image-viewer [hidden] { display: none !important; }
.tms-image-stage.can-pan { cursor: grab; touch-action: none; }
.tms-image-stage.panning { cursor: grabbing; }
.tms-image-status { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.tms-image-status button { width: auto; padding: 0 12px; font-size: 14px; pointer-events: auto; }
.tms-image-viewer .lb-prev, .tms-image-viewer .lb-next { position: absolute; top: 50%; transform: translateY(-50%); height: 52px; font-size: 32px; }
.tms-image-viewer .lb-prev { left: -44px; }
.tms-image-viewer .lb-next { right: -44px; }
.tms-image-help { flex: 0 0 auto; padding: 5px 10px 9px; text-align: center; font-size: 12px; color: #c7d1da; }
.tms-image-workspace { display: flex; flex: 1; min-height: 0; min-width: 0; }
.tms-image-controls { flex-wrap: wrap; }
.tms-image-viewer .tms-image-text-button { width: auto; padding: 0 10px; font-size: 14px; }
.tms-image-ocr { display: flex; flex-direction: column; gap: 10px; flex: 0 0 32%; min-width: 240px; max-width: 440px; margin: 8px 12px 8px 0; padding: 14px; background: #242a30; border: 1px solid #536170; border-radius: 8px; overflow: auto; box-sizing: border-box; }
.tms-image-ocr-heading, .tms-image-ocr-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tms-image-ocr-status { margin: 0; color: #e0e9f2; }
.tms-image-ocr progress { width: 100%; flex-shrink: 0; accent-color: #85baff; }
.tms-image-ocr textarea { width: 100%; flex: 1; min-height: 100px; box-sizing: border-box; resize: none; padding: 10px; border: 1px solid #73808c; border-radius: 6px; background: #fff; color: #17212b; font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.tms-image-ocr textarea:focus-visible { outline: 2px solid #85baff; }
.tms-image-ocr small { color: #c7d1da; }
@media (max-width: 800px) {
  .tms-image-workspace { flex-direction: column; }
  .tms-image-ocr { flex: 0 1 45%; max-height: 45%; min-height: 180px; min-width: 0; max-width: none; margin: 4px 12px; padding: 10px; gap: 6px; }
  .tms-image-ocr textarea { min-height: 60px; }
}
@media (max-width: 600px) {
  .tms-image-toolbar { gap: 6px; padding: 8px; }
  .tms-image-viewer .lb-caption { flex-basis: 100%; }
  .tms-image-controls { width: 100%; justify-content: space-between; gap: 4px; }
  .tms-image-body { margin: 4px 44px; }
  .tms-image-viewer .lb-prev { left: -40px; }
  .tms-image-viewer .lb-next { right: -40px; }
}
.tms-image-text-layer { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; transform-origin: center; pointer-events: none; overflow: visible; }
.tms-image-text-layer .ocr-block { cursor: pointer; pointer-events: none; }
.tms-image-text-layer.ocr-selecting .ocr-block { pointer-events: auto; }
.tms-image-text-layer polygon { fill: #fff; fill-opacity: .9; stroke: #1677c8; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.tms-image-text-layer text { fill: #142535; font-family: Arial, sans-serif; user-select: none; }
.tms-image-text-layer .uncertain polygon { stroke: #ee8b15; }
.tms-image-text-layer .selected polygon, .tms-image-text-layer .ocr-block:focus polygon { fill: #b8dbff; stroke: #065cc2; stroke-width: 2.5; }
.tms-image-text-layer.ocr-hide-text text { display: none; }
.tms-image-text-layer.ocr-hide-text polygon { fill-opacity: .08; }
.tms-image-text-layer.ocr-hide-text .selected polygon { fill-opacity: .45; }
.tms-image-stage.ocr-cropping { cursor: crosshair; touch-action: none; }
.tms-image-text-layer .ocr-crop-rect { fill: #1677c8; fill-opacity: .15; stroke: #66b5ff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.tms-image-ocr-options { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tms-image-ocr-options label { display: flex; align-items: center; gap: 5px; }
.tms-image-viewer [aria-pressed="true"] { border-color: #85baff; }
