/* Workspace, page stack, canvas/text/markup layers, selection visuals. */

.bb-workspace {
  flex: 1; min-height: 0; position: relative; background: var(--bb-canvas);
  display: flex;
}
.bb-viewpane {
  flex: 1; min-width: 0; min-height: 0; position: relative; overflow: auto;
  outline: none;
}
.bb-viewpane + .bb-viewpane { border-left: 2px solid var(--bb-border); }
.bb-pagestack {
  position: relative; margin: 0 auto; padding: 14px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: max-content; min-width: 100%;
}
.bb-page {
  position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.55);
  flex-shrink: 0; isolation: isolate;
}
.bb-page > canvas.bb-raster { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.bb-page .bb-page-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #999; font-size: 14px; background: #fdfdfd;
}

/* text layer (pdf.js) */
.bb-textlayer {
  position: absolute; inset: 0; overflow: hidden; line-height: 1; z-index: 2;
  opacity: 1; pointer-events: none;
}
.bb-textlayer span {
  color: transparent; position: absolute; white-space: pre; cursor: text;
  transform-origin: 0 0;
}
.bb-textlayer ::selection { background: rgba(0, 131, 219, 0.35); }
.bb-viewpane.bb-mode-text .bb-textlayer { pointer-events: auto; user-select: text; -webkit-user-select: text; }
.bb-viewpane.bb-mode-text .bb-markuplayer { pointer-events: none !important; }

/* markup overlay */
svg.bb-markuplayer {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; overflow: visible;
}
svg.bb-markuplayer .bb-markup { cursor: move; }
svg.bb-markuplayer .bb-markup.bb-locked { cursor: default; }
svg.bb-markuplayer .bb-markup.bb-filtered { opacity: 0.18 !important; }
svg.bb-markuplayer .bb-markup.bb-hidden { display: none; }
svg.bb-markuplayer .bb-markup.bb-inline-edit-source { visibility: hidden; }
svg.bb-markuplayer text { user-select: none; }

/* form layer */
.bb-formlayer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.bb-formlayer > * { pointer-events: auto; position: absolute; }
.bb-formlayer input, .bb-formlayer select, .bb-formlayer textarea {
  background: rgba(173, 216, 255, 0.25); border: 1px solid rgba(0,90,175,0.55);
  color: #000; font-family: Helvetica, Arial, sans-serif; padding: 0 2px; border-radius: 0;
}
.bb-designed-field { box-sizing: border-box; }
.bb-designed-field:hover, .bb-designed-field.bb-selected {
  outline: 2px solid var(--bb-accent); outline-offset: 2px;
}
.bb-viewpane.bb-cursor-pan .bb-designed-field.bb-selected { cursor: move; }
.bb-viewpane:not(.bb-cursor-pan):not(.bb-cursor-cross) .bb-designed-field.bb-selected { cursor: move; }
.bb-designed-field > input, .bb-designed-field > select, .bb-designed-field > button:not(.bb-field-grip):not(.bb-field-resize),
.bb-designed-field > div {
  width: 100%; height: 100%; box-sizing: border-box; font-size: inherit; margin: 0;
}
.bb-designed-field .bb-field-grip, .bb-designed-field .bb-field-resize {
  position: absolute; z-index: 1; padding: 0; border: 1px solid #176099;
  background: #d9efff; color: #154c75; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  touch-action: none; user-select: none;
}
.bb-designed-field .bb-field-grip {
  left: 0; top: -17px; width: 24px; height: 17px; font-size: 13px; line-height: 13px; cursor: move;
}
.bb-designed-field .bb-field-resize {
  right: -5px; bottom: -5px; width: 11px; height: 11px; cursor: nwse-resize;
}
.bb-forms-hint { padding: 8px 10px; line-height: 1.4; }
.bb-form-item-selected { background: var(--bb-accent-dim); }

/* interaction layer (screen space, spans the viewpane) */
svg.bb-interact {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 50;
  pointer-events: none; overflow: visible;
}
svg.bb-interact .bb-handle { pointer-events: auto; cursor: pointer; }
.bb-handle-resize { fill: var(--bb-handle-yellow); stroke: #7a6400; stroke-width: 1; }
.bb-handle-rotate { fill: var(--bb-handle-orange); stroke: #7a4400; stroke-width: 1; }
.bb-handle-vertex { fill: var(--bb-handle-yellow); stroke: #7a6400; stroke-width: 1; }
.bb-handle-scale  { fill: var(--bb-handle-purple); stroke: #5a2d80; stroke-width: 1; }
.bb-handle-locked { fill: #9a9a9a; stroke: #555; }
.bb-select-outline { fill: none; stroke: var(--bb-accent-hover); stroke-width: 1; stroke-dasharray: 4 3; }
.bb-marquee { fill: rgba(0,131,219,0.12); stroke: var(--bb-accent); stroke-width: 1; stroke-dasharray: 5 3; }
.bb-marquee-crossing { fill: rgba(76,175,80,0.10); stroke: var(--bb-handle-green); }
.bb-lasso-path { fill: rgba(0,131,219,0.10); stroke: var(--bb-accent); stroke-width: 1; stroke-dasharray: 4 3; }
.bb-snapguide { stroke: #ff40ff; stroke-width: 1; stroke-dasharray: 3 3; }
svg.bb-interact .bb-snap-indicator { pointer-events: none; }
svg.bb-interact .bb-snap-indicator path { filter: drop-shadow(0 0 1px rgba(0,0,0,0.6)); }
.bb-draw-preview { pointer-events: none; }

/* grid overlay */
.bb-gridlayer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* cursor modes on the viewpane — custom SVG cursors with black-on-white double
   outline so they stay visible over white paper AND the dark workspace */
.bb-viewpane.bb-cursor-pan {
  /* no `*` override: markups keep their move/resize cursors so Pan-mode editing is discoverable */
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M9 11V5.5a1.5 1.5 0 0 1 3 0V11m0-4.5a1.5 1.5 0 0 1 3 0V11m0-3a1.5 1.5 0 0 1 3 0v6c0 4-2.5 7-6.5 7S6 18 5.5 15L4.3 10.8a1.4 1.4 0 0 1 2.6-.9L9 13' fill='white' stroke='white' stroke-width='4' stroke-linejoin='round'/%3E%3Cpath d='M9 11V5.5a1.5 1.5 0 0 1 3 0V11m0-4.5a1.5 1.5 0 0 1 3 0V11m0-3a1.5 1.5 0 0 1 3 0v6c0 4-2.5 7-6.5 7S6 18 5.5 15L4.3 10.8a1.4 1.4 0 0 1 2.6-.9L9 13' fill='white' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E") 13 13, grab;
}
.bb-viewpane.bb-cursor-panning, .bb-viewpane.bb-cursor-panning * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M8 13v-2a1.5 1.5 0 0 1 3-.5V10a1.5 1.5 0 0 1 3 0v.5a1.5 1.5 0 0 1 3 .5v1a1.5 1.5 0 0 1 3 1v3c0 4-2.5 6-6.5 6S7 19 6.5 16l-.7-2.2A1.4 1.4 0 0 1 8 13' fill='white' stroke='white' stroke-width='4' stroke-linejoin='round'/%3E%3Cpath d='M8 13v-2a1.5 1.5 0 0 1 3-.5V10a1.5 1.5 0 0 1 3 0v.5a1.5 1.5 0 0 1 3 .5v1a1.5 1.5 0 0 1 3 1v3c0 4-2.5 6-6.5 6S7 19 6.5 16l-.7-2.2A1.4 1.4 0 0 1 8 13' fill='white' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E") 13 13, grabbing !important;
}
.bb-viewpane.bb-cursor-cross, .bb-viewpane.bb-cursor-cross * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='25' height='25' viewBox='0 0 25 25'%3E%3Cpath d='M12.5 1v23M1 12.5h23' stroke='white' stroke-width='4'/%3E%3Cpath d='M12.5 1v23M1 12.5h23' stroke='black' stroke-width='1.5'/%3E%3Ccircle cx='12.5' cy='12.5' r='2.2' fill='none' stroke='white' stroke-width='2.4'/%3E%3Ccircle cx='12.5' cy='12.5' r='2.2' fill='none' stroke='black' stroke-width='1'/%3E%3C/svg%3E") 12 12, crosshair !important;
}
.bb-viewpane.bb-cursor-zoom, .bb-viewpane.bb-cursor-zoom * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6.5' fill='none' stroke='white' stroke-width='4.5'/%3E%3Cpath d='M15 15l6 6' stroke='white' stroke-width='5'/%3E%3Ccircle cx='10' cy='10' r='6.5' fill='rgba(255,255,255,0.3)' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M15 15l6 6' stroke='black' stroke-width='2.4'/%3E%3Cpath d='M7.5 10h5M10 7.5v5' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E") 10 10, zoom-in !important;
}
.bb-viewpane.bb-cursor-text { cursor: text; }

/* in-place text editing */
.bb-inline-editor {
  position: absolute; z-index: 60; background: transparent; border: 1px dashed var(--bb-accent);
  outline: none; resize: none; overflow: hidden; box-sizing: border-box;
  font-family: Helvetica, Arial, sans-serif; white-space: pre-wrap; word-break: break-word;
}

/* popup note */
.bb-popup-note {
  position: absolute; z-index: 70; width: 220px; min-height: 120px;
  background: #fdf6c9; border: 1px solid #b7a63e; box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; color: #333;
}
.bb-popup-note-head {
  display: flex; align-items: center; padding: 3px 6px; font-size: 11px;
  border-bottom: 1px solid #d6c973; cursor: move; gap: 6px;
}
.bb-popup-note-head .bb-popup-close { margin-left: auto; cursor: pointer; padding: 0 4px; }
.bb-popup-note textarea {
  flex: 1; background: transparent; border: none; color: #222; resize: none; padding: 6px;
  font-size: 12px;
}
