/* =========================================================
   Booklet Builder - style.css
   Fixes + additions:
   - Page orientation (portrait/landscape)
   - 4x6 image grid (Real Photos) + pager styling support
   - PDF background layer visibility/stacking
   - Per-page audio controls styling
   - Overlay SVG styling
   - Text box highlight (border/background) friendly for overlays
   ========================================================= */

body {
  background-color: #f8f9fa;
  font-family: Arial, sans-serif;
  margin-bottom: 4rem;
}

.top-menu {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 1rem;
}

#page-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  margin-bottom: 2rem;
}

/* ===================== Page base ===================== */
.page {
  background: #ffffff;
  border: 2px solid #ddd;
  position: relative;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Orientation sizes */
.page.landscape {
  width: 800px;
  height: 600px;
}

.page.portrait {
  width: 600px;
  height: 800px;
}

/* ===================== Custom page grid layer ===================== */
.page-grid{
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.page-grid svg{
  width: 100%;
  height: 100%;
  display: block;
}

/* ===================== PDF background layer ===================== */
.page-background {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.page-background img,
.page-background canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* ===================== Grid overlay ===================== */
.page.show-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 50;
}

/* ===================== Page controls ===================== */
.page-controls {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  z-index: 120;
}

.page-number {
  position: absolute;
  bottom: 5px;
  right: 10px;
  font-weight: bold;
  font-size: 14px;
  z-index: 120;
}

/* ===================== Page audio controls ===================== */
.page-audio-controls {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(6px);
}

.page-audio-controls button {
  padding: 2px 8px;
  font-size: 12px;
}

.page-audio-controls .audio-status {
  font-size: 12px;
  color: #555;
}


/* ===================== EPUB audio control marker ===================== */
/* This marker lets you choose where the EPUB <audio controls> appears per-page. */
.epub-audio-marker {
  position: absolute;
  z-index: 121;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: grab;
}

/* When a page has audio saved, show a small green dot */
.epub-audio-marker.has-audio::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -2px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #2ecc71;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* Inline audio popover (opened by clicking the 🔊 marker) */
.audio-popover {
  position: absolute;
  z-index: 125;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  padding: 8px;
  display: none;
  gap: 6px;
  align-items: center;
  user-select: none;
  backdrop-filter: blur(6px);
}

.audio-popover.open {
  display: flex;
}

.audio-popover .audio-status,
.audio-popover .audio-popover-status {
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  margin-left: 4px;
}

.epub-audio-marker:active {
  cursor: grabbing;
}

/* ===================== Drag box shell ===================== */
.drag-box {
  position: absolute;
  border: none;                 /* boundary chrome only shows when selected */
  outline: none;
  background-color: transparent;
  box-shadow: none;
  overflow: visible;
  z-index: 110; /* above background */
  box-sizing: border-box;
}

/* Show boundary + handles only when selected */
.drag-box.selected {
  outline: 2px solid rgba(59, 130, 246, 0.95); /* blue selection */
  outline-offset: 0px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

/* 8-point resize handles */
.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.45);
  border-radius: 3px;
  z-index: 140;
  display: none; /* hidden unless selected */
}

.drag-box.selected .resize-handle {
  display: block;
}

/* Handle placement */
.resize-handle[data-dir="nw"] { left: -6px; top: -6px; cursor: nwse-resize; }
.resize-handle[data-dir="n"]  { left: 50%; top: -6px; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle[data-dir="ne"] { right: -6px; top: -6px; cursor: nesw-resize; }

.resize-handle[data-dir="w"]  { left: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.resize-handle[data-dir="e"]  { right: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.resize-handle[data-dir="sw"] { left: -6px; bottom: -6px; cursor: nesw-resize; }
.resize-handle[data-dir="s"]  { left: 50%; bottom: -6px; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle[data-dir="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }

/* Custom context menu */
.box-context-menu {
  position: fixed;
  z-index: 10000;
  display: none;
  flex-direction: column;
  min-width: 160px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(0,0,0,0.16);
  box-shadow: 0 14px 34px rgba(0,0,0,0.24);
  user-select: none;
}

.box-context-menu.open {
  display: flex;
}

.box-context-menu button {
  all: unset;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.box-context-menu button:hover {
  background: rgba(0,0,0,0.06);
}

.box-context-menu button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.box-context-menu .sep {
  height: 1px;
  margin: 6px 4px;
  background: rgba(0,0,0,0.12);
}


/* ===================== Text box ===================== */
.symbolated-text {
  width: 100%;
  height: 100%;
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  cursor: default;
  background: transparent;
  border-radius: 8px;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}


/* Cursor + selection behavior:
   - Editable text boxes show I-beam and allow selecting text.
   - Non-editable (modal-only) text boxes never show a typing cursor and don't allow direct typing. */
.symbolated-text[contenteditable="true"]{
  cursor: text;
  user-select: text;
}
.symbolated-text[contenteditable="false"]{
  cursor: pointer;
  user-select: none;
}
.symbolated-text.symbolated-locked {
  cursor: pointer;
  user-select: none;
}

/* Word + symbol containers */
.symbol-container {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 5px;
}


/* Punctuation containers: tighter margins so punctuation sits with the text line */
.symbol-container.punct {
  margin: 5px 2px;
}

.symbol-container.punct .word-label{
  line-height: 1;
}

/* Hide blank placeholder symbol but keep click area */
.symbol-container img[src^="data:image/gif;base64,R0lGODlhAQABAPAAAP8AAP///yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="] {
  opacity: 0 !important;
  pointer-events: auto !important;
}

/* Cover tweak (optional) */
.page.cover .symbolated-text {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.2;
  padding: 5px;
}

/* ===================== Image region ===================== */
.image-region-inner {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.image-region-inner img {
  display: block;
  object-fit: contain;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  will-change: transform;
}

/* Cut-out / sticker dashed outline overlay */
.image-region-inner .image-cutout-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.image-region-inner .image-cutout-outline path {
  fill: none;
  stroke: #000;
  stroke-width: 2;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Image editor modal */
.image-editor-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
}

.image-editor-preview .inner {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.image-editor-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
}

.image-editor-preview svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ===================== Overlay region ===================== */
.overlay-region-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-svg-wrap{
  width: 100%;
  height: 100%;
  padding: 6px;
  box-sizing: border-box;
}

.overlay-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
/* ===================== Rich Text Toolbar ===================== */
.rich-text-toolbar {
  position: fixed;
  background: #fff;
  border: 1px solid #ccc;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  z-index: 9999;
  visibility: hidden;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.rich-text-toolbar button {
  cursor: pointer;
}

/* ===================== Spinner ===================== */
.spinner {
  width: 24px;
  height: 24px;
  border: 4px solid #ccc;
  border-top: 4px solid #555;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

/* ===================== Guides ===================== */
#guides-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}


.alignment-guide {
  position: absolute;
  background: red;
  opacity: 0.5;
  z-index: 9999;
}


.vertical-guide {
  width: 1px;
}

.horizontal-guide {
  height: 1px;
}

/* ===================== PDF export hides UI ===================== */
body.pdf-export {
  background-color: #fff !important;
}

body.pdf-export .drag-box {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.pdf-export .drag-handle,
body.pdf-export .corner-handle,
body.pdf-export .page-controls,
body.pdf-export .page-audio-controls,
body.pdf-export .epub-audio-marker,
body.pdf-export .audio-popover,
body.pdf-export .resize-handle,
body.pdf-export .box-delete,
body.pdf-export #boxContextMenu,
body.pdf-export .box-context-menu,
body.pdf-export .box-copy {
  display: none !important;
}

/* ===================== Image grid 4x6 ===================== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 80px;
  gap: 10px;
  justify-items: center;
  align-items: center;
  min-height: calc(4 * 80px + 3 * 10px);
}

.image-grid img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.image-grid img:hover {
  border-color: rgba(0, 0, 0, 0.35);
}

/* ===================== Symbol selection modal results ===================== */
#symbolSelectionResults img,
#symbolImageResults img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

#symbolSelectionResults img:hover,
#symbolImageResults img:hover {
  border-color: rgba(0, 0, 0, 0.35);
}

/* ===================== Paste preview ===================== */
#pastedImagePreview {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}



/* ===== Workspace background / centering ===== */
body {
  background: #f2f2f2;
}

#workspace {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center; /* keeps pages centered */
  padding: 0 16px 48px;
}

/* Keep pages white for contrast */
.page, .page-inner, .page-background {
  background: #ffffff;
}

/* Compact top toolbar */
.top-menu.compact-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Preview mode: hide editing chrome */
body.preview-mode body.preview-mode .page-toolbar,
body.preview-mode #richTextToolbar,
body.preview-mode .corner-handle,
body.preview-mode .resize-handle,
body.preview-mode .delete-btn,
body.preview-mode .drag-handle,
body.preview-mode #guides-layer {
  display: none !important;
}

body.preview-mode .draggable,
body.preview-mode .photo-box,
body.preview-mode .overlay-box,
body.preview-mode .text-box {
  outline: none !important;
}

/* ===================== Preview mode extra UI hiding ===================== */
body.preview-mode .drag-box {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
}

body.preview-mode .box-delete,
body.preview-mode .box-copy {
  display: none !important;
}

body.preview-mode .audio-popover {
  display: none !important;
}

/* ===================== Toolbar layout (Undo/Redo left, Add/Import center, Mode/Export/Settings right) ===================== */
.workspace-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px;
}

.workspace-toolbar 

/* App branding in the fixed header */
.app-brand{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}
.app-logo{
  height: 34px; /* compact header */
  width: auto;
  display: block;
}
@media (max-width: 480px){
  .app-logo{ height: 30px; }
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.workspace-toolbar .toolbar-group.left {
  justify-content: flex-start;
}

.workspace-toolbar .toolbar-group.center {
  justify-content: center;
}

.workspace-toolbar .toolbar-group.right {
  justify-content: flex-end;
}

/* ===================== Present mode (fullscreen, one page at a time) ===================== */
body.present-mode {
  background: #000 !important;
  overflow: hidden !important;
  margin: 0 !important;
}

body.present-mode .top-menu {
  display: none !important;
}

body.present-mode #workspace {
  padding: 0 !important;
}

body.present-mode #page-container {
  width: 100vw;
  height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.present-mode #page-container .page-wrapper {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

body.present-mode #page-container .page-wrapper.present-active {
  display: flex;
  position: relative;
}

body.present-mode .page {
  box-shadow: none !important;
  border: none !important;
  position: absolute;
  left: 50%;
  top: 50%;
}

body.present-mode #guides-layer {
  display: none !important;
}


/* ===================== Page wrapper + toolbar layout ===================== */
.page-wrapper{
  display: inline-block;
  margin: 18px auto;
}

#page-container{
  text-align: center;
}

.page-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px; /* spacing between toolbar and page */
}

.page-toolbar-left,
.page-toolbar-right{
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-toolbar-right{
  justify-content: flex-end;
}





/* ===== Brand + SVG icons ===== */
.bb-icon{
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  vertical-align: -0.12em;
  color: var(--brand);
  fill: currentColor;
  flex: none;
}

.btn-brand{
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: var(--brand-contrast) !important;
}
.btn-brand .bb-icon{ color: var(--brand-contrast); }

.btn-brand:hover,
.btn-brand:focus{
  filter: brightness(0.95);
}

.icon-text-toggle.dropdown-toggle::after,
.icon-split-toggle.dropdown-toggle-split::after{
  display: none !important;
}

/* Make icon-only buttons feel clickable but minimal */
.icon-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== Page toolbar icon-only buttons ===== */
.page-icon-btn{
  border: none;
  background: transparent;
  color: var(--brand);
  padding: 2px 4px;
  line-height: 1;
}
.page-icon-btn:hover{
  background: rgba(84,48,141,0.10);
  border-radius: 6px;
}
.page-icon-btn:focus{
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(84,48,141,0.18);
  border-radius: 6px;
}
.page-icon-btn .bb-icon{
  width: 18px;
  height: 18px;
}

/* ===== Overlay shape picker ===== */
.overlay-shape-grid{
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.overlay-shape-btn{
  border: 1px solid rgba(0,0,0,0.15);
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
}
.overlay-shape-btn:hover{
  border-color: rgba(84,48,141,0.55);
  box-shadow: 0 0 0 0.2rem rgba(84,48,141,0.12);
}
.overlay-shape-btn.active{
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(84,48,141,0.18);
}

/* ===== Zoom controls smaller ===== */
.zoom-controls .btn{
  padding: 2px 6px !important;
  font-size: 0.8rem !important;
}
.zoom-controls .bb-icon{
  width: 16px;
  height: 16px;
}
.zoom-slider{
  width: 140px !important;
  accent-color: #54308d;

  /* Remove tinted background behind the slider; show neutral track + purple fill */
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  outline: none;
  --zoom-fill: 50%;
  background: linear-gradient(
    to right,
    #54308d 0%,
    #54308d var(--zoom-fill),
    #d9d9df var(--zoom-fill),
    #d9d9df 100%
  );
}



/* Zoom slider (magnify) styling */
.zoom-slider::-webkit-slider-runnable-track{
  background: transparent;
  height: 8px;
  border-radius: 999px;
}
.zoom-slider::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: #54308d;
  margin-top: -5px; /* center the thumb over the 8px track */
}
.zoom-slider::-moz-range-thumb{
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #54308d;
  border: none;
}
.zoom-slider::-moz-range-track{
  background: #d9d9df;
  height: 8px;
  border-radius: 999px;
}
.zoom-slider::-moz-range-progress{
  background: #54308d;
  height: 8px;
  border-radius: 999px;
}
.zoom-label{
  font-size: 0.85rem;
}

/* ===== Toolbar icons ===== */
.icon-btn .toolbar-icon{
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  vertical-align: -0.15em;
}
.icon-btn .toolbar-icon path,
.icon-btn .toolbar-icon circle,
.icon-btn .toolbar-icon line,
.icon-btn .toolbar-icon polyline,
.icon-btn .toolbar-icon rect{
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Settings rows ===== */
.settings-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== Page numbers toggle ===== */
.hide-page-numbers .page-number{
  display:none !important;
}
.page-number{
  position:absolute;
  right: 10px;
  bottom: 8px;
  font-size: 14px;
  color: rgba(0,0,0,0.55);
  background: rgba(255,255,255,0.6);
  padding: 2px 6px;
  border-radius: 6px;
  pointer-events:none;
}

/* Placeholder text for empty editable boxes */
.symbolated-text[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.symbolated-text:focus:empty::before {
  content: "";
}


/* Keep symbolated content inside its box when resized narrower */
.symbol-container {
  max-width: 100%;
}

.symbol-container .word-label {
  max-width: 100%;
  text-align: center;
  word-break: break-word;
  overflow-wrap: anywhere;
}

img.symbol-img {
  width: var(--sym-size);
  height: var(--sym-size);
  display: block;
  object-fit: contain;
}


/* Inner regions should always fill the drag shell */
.drag-box > .image-region-inner,
.drag-box > .overlay-region-inner,
.drag-box > .symbolated-text {
  width: 100%;
  height: 100%;
}


/* ===================== Multi-select toolbar ===================== */
.multi-select-toolbar{
  position: fixed;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.14);
  box-shadow: 0 14px 34px rgba(0,0,0,0.18);
  backdrop-filter: blur(8px);
  user-select: none;
}

.multi-select-toolbar.open{
  display: flex;
}

.multi-select-toolbar .mst-group{
  display: flex;
  align-items: center;
  gap: 6px;
}

.multi-select-toolbar .mst-sep{
  display: inline-block;
  width: 1px;
  height: 22px;
  margin: 0 6px;
  background: rgba(0,0,0,0.14);
}

/* Selected audio marker outline */
.epub-audio-marker.selected{
  outline: 2px solid rgba(59, 130, 246, 0.95);
  outline-offset: 2px;
}

/* ===================== Marquee selection ===================== */
.marquee-rect{
  position: absolute;
  z-index: 200;
  border: 1px dashed rgba(59,130,246,0.95);
  /* Keep the marquee selection visible without adding a translucent overlay */
  background: transparent;
  pointer-events: none;
}

/* ===== Group boundary (single outline around grouped items) ===== */
.group-boundary{
  position: absolute;
  border: 2px solid #1e6cff;
  border-radius: 10px;
  background: transparent;
  box-sizing: border-box;
  z-index: 40;
}
.group-boundary .resize-handle{
  position: absolute;
  width: 10px;
  height: 10px;
  background: #1e6cff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-sizing: border-box;
}
.group-boundary .resize-handle[data-dir="nw"]{ left:-6px; top:-6px; cursor:nwse-resize;}
.group-boundary .resize-handle[data-dir="n"]{ left:50%; top:-6px; transform:translateX(-50%); cursor:ns-resize;}
.group-boundary .resize-handle[data-dir="ne"]{ right:-6px; top:-6px; cursor:nesw-resize;}
.group-boundary .resize-handle[data-dir="w"]{ left:-6px; top:50%; transform:translateY(-50%); cursor:ew-resize;}
.group-boundary .resize-handle[data-dir="e"]{ right:-6px; top:50%; transform:translateY(-50%); cursor:ew-resize;}
.group-boundary .resize-handle[data-dir="sw"]{ left:-6px; bottom:-6px; cursor:nesw-resize;}
.group-boundary .resize-handle[data-dir="s"]{ left:50%; bottom:-6px; transform:translateX(-50%); cursor:ns-resize;}
.group-boundary .resize-handle[data-dir="se"]{ right:-6px; bottom:-6px; cursor:nwse-resize;}
/* Hide individual blue outlines when a whole group is selected */
.drag-box.in-group-selection.selected{
  outline: none !important;
  box-shadow: none !important;
}


/* Blank symbols (when a pictogram can't be found) should still be easy to click */
.symbol-container[data-blank="true"] .symbol-img{
  outline: 1px dashed #bbb;
  outline-offset: -2px;
  background: rgba(0,0,0,0.03);
}
.symbol-container{
  cursor: pointer;
}

/* Symbolated text: place word labels above/below symbols */
.symbolated-text[data-text-position="above"] .symbol-container { flex-direction: column-reverse; }
.symbolated-text[data-text-position="below"] .symbol-container { flex-direction: column; }


/* Modal-only text boxes (e.g., cover title) */
.drag-box.modal-edit-only .symbolated-text,
.drag-box[data-modal-edit-only="true"] .symbolated-text {
  cursor: default !important;
}

/* ===================== Fixed top + bottom toolbars ===================== */
:root{
  --topbar-height: 54px;
  --bottombar-height: 48px;
  --brand: #54308d;
  --brand-contrast: #ffffff;

  /* Bootstrap/link color overrides */
  --bs-primary: #54308d;
  --bs-primary-rgb: 84, 48, 141;
  --bs-link-color: #54308d;
  --bs-link-hover-color: #54308d;
}


/* Brand-colored primary buttons (Bootstrap defaults are blue) */
.btn-primary{
  background-color: var(--brand) !important;
  border-color: var(--brand) !important;
  color: var(--brand-contrast) !important;
}
.btn-primary:hover,
.btn-primary:focus{
  filter: brightness(0.92);
  color: var(--brand-contrast) !important;
}
.btn-primary:active{
  filter: brightness(0.88);
}

/* Make "primary" text/link utilities match brand */
.text-primary,
.link-primary{
  color: var(--brand) !important;
}
a:not(.btn){
  color: var(--brand);
}

/* Make room for fixed toolbars */
body{
  padding-top: var(--topbar-height);
  padding-bottom: var(--bottombar-height);
  margin-bottom: 0;
}

/* Fixed top shell (keeps the existing Bootstrap container centered) */
.top-toolbar-fixed{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 11000;
  background: rgba(255,255,255,0.98);
  border-bottom: 1px solid rgba(0,0,0,0.10);
  backdrop-filter: blur(8px);
}

/* The existing toolbar element */
.top-toolbar-fixed .top-menu{
  margin-bottom: 0; /* remove old spacing */
}

/* Fixed bottom toolbar */
.bottom-toolbar-fixed{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 11000;
  background: rgba(255,255,255,0.98);
  border-top: 1px solid rgba(0,0,0,0.10);
  backdrop-filter: blur(8px);
}

.bottom-toolbar{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 4px 10px;
}

.bottom-toolbar-left{
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-label{
  min-width: 54px;
  text-align: center;
  font-weight: 600;
  color: rgba(0,0,0,0.70);
}

/* Zoom slider controls (bottom toolbar) */
.zoom-controls{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto; /* keep on the right */
}

.zoom-slider{
  width: 180px;
  max-width: 40vw;
}

/* Hide fixed toolbars in present mode */
body.present-mode .top-toolbar-fixed,
body.present-mode .bottom-toolbar-fixed{
  display: none !important;
}

/* Present mode shouldn't reserve space for hidden bars */
body.present-mode{
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}


/* Make fixed toolbars more compact */
.top-toolbar-fixed .workspace-toolbar{
  padding: 2px 4px;
  gap: 8px;
}

.top-toolbar-fixed .toolbar-icon{
  width: 16px;
  height: 16px;
}

.top-toolbar-fixed .btn,
.bottom-toolbar-fixed .btn{
  padding: 0.16rem 0.40rem;
  font-size: 0.90rem;
  line-height: 1.1;
}

.top-toolbar-fixed .form-select,
.top-toolbar-fixed .form-control{
  padding: 0.18rem 0.50rem;
  font-size: 0.90rem;
  line-height: 1.15;
}

.top-toolbar-fixed .container{
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
}

.bottom-toolbar-fixed .container-fluid{
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
}



/* Keep modals from overwhelming the workspace */
.modal-dialog{
  max-width: 75vw;
  max-height: 75vh;
}

.modal-content{
  max-height: 75vh;
}

.modal-body{
  overflow: auto;
}

/* Smaller modals (about half size) */
#imageLibraryModal .modal-dialog{
  max-width: clamp(380px, 50vw, 760px);
}

#symbolSelectionModal .modal-dialog,
#pasteImageModal .modal-dialog{
  max-width: clamp(340px, 45vw, 560px);
}

#imageLibraryModal .modal-header,
#symbolSelectionModal .modal-header,
#pasteImageModal .modal-header{
  padding: 0.5rem 0.75rem;
}

#imageLibraryModal .modal-body,
#symbolSelectionModal .modal-body,
#pasteImageModal .modal-body{
  padding: 0.75rem;
}

/* ===================== v4: Bottom zoom controls alignment + modal typography ===================== */

/* Right-align bottom toolbar contents */
.bottom-toolbar-fixed .bottom-toolbar{
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.bottom-toolbar-fixed .zoom-controls{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.zoom-slider{
  width: 180px;
  max-width: 30vw;
}

/* Modal typography (image library / symbol selection / paste image) */
#imageLibraryModal .modal-content,
#symbolSelectionModal .modal-content,
#pasteImageModal .modal-content{
  font-size: 0.9rem;
}

#imageLibraryModal .modal-title,
#symbolSelectionModal .modal-title,
#pasteImageModal .modal-title{
  font-size: 1rem;
}

#imageLibraryModal .form-label,
#symbolSelectionModal .form-label,
#pasteImageModal .form-label{
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

#imageLibraryModal .btn,
#symbolSelectionModal .btn,
#pasteImageModal .btn,
#imageLibraryModal input,
#symbolSelectionModal input,
#pasteImageModal input,
#imageLibraryModal select,
#symbolSelectionModal select,
#pasteImageModal select{
  font-size: 0.85rem;
}

#imageLibraryModal .btn,
#symbolSelectionModal .btn,
#pasteImageModal .btn{
  padding: 0.25rem 0.5rem;
}

/* Slightly tighter modal body spacing */
#imageLibraryModal .modal-body,
#symbolSelectionModal .modal-body,
#pasteImageModal .modal-body{
  line-height: 1.25;
}


/* Centered pager below results */
.results-nav{
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}


/* Extra breathing room for search controls on very narrow screens */
@media (max-width: 480px){
  #symbolSearchInput{ margin-bottom: 8px; }
}


/* Cut-out outline inside the image editor modal */
.image-editor-preview .image-cutout-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.image-editor-preview .image-cutout-outline path {
  fill: none;
  stroke: #000;
  stroke-width: 2;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Cut-out outline inside the image editor modal */
.image-editor-preview .image-cutout-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.image-editor-preview .image-cutout-outline path {
  fill: none;
  stroke: #000;
  stroke-width: 2;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
