:root {
  --toolbar-height: 45px;
  --secondary-toolbar-height: 40px;
}

/* styles.css forces `body:has(#pdfEditorApp) * { font-family: inherit }`
   (system-ui) on every element — its ID-in-:has specificity beats plain
   class selectors, so display headlines lost their serif. Opt the mock's
   display type (hero, section headings, drop-zone headline, modal titles,
   the invoice demo) back into the serif face. Toolbar/labels stay sans. */
body:has(#pdfEditorApp) .editor-seo-title,
body:has(#pdfEditorApp) .editor-seo-section h2,
body:has(#pdfEditorApp) .dz-headline,
body:has(#pdfEditorApp) .config-header h3 {
  font-family: var(--ed-serif) !important;
}

/* ===================================================================
   PDF Editor design tokens — mirrors the "PDF Editor" Claude Design
   mock palette, mapped onto the site's warm-red brand. Self-contained
   so the editor themes independently of the (page-scoped) --pdf-* vars.
   =================================================================== */
.pdf-editor-page {
  --ed-bg: #fbf5f2;
  --ed-surface: #fcf8f6;
  --ed-canvas: #f4ece8;
  --ed-panel: #ffffff;
  --ed-ink: #1c1512;
  --ed-sub: #7a6c66;
  --ed-line: rgba(28, 21, 18, 0.1);
  --ed-line-strong: rgba(28, 21, 18, 0.16);
  --ed-seg: #f2e4df;
  --ed-hover: #f3e6e1;
  --ed-thumb: #ffffff;
  --ed-thumb-border: rgba(255, 255, 255, 0.7);
  --ed-accent: #d62828;
  --ed-accent-ink: #a31621;
  --ed-accent-soft: #fbe7e3;
  --ed-accent-rgb: 214, 40, 40;
  --ed-danger: #c0392b;
  --ed-danger-soft: #fbe7e3;
  --ed-radius: 10px;
  --ed-radius-sm: 8px;
  --ed-radius-lg: 14px;
  --ed-shadow-accent: 0 2px 10px rgba(var(--ed-accent-rgb), 0.28);
  --ed-shadow-card: 0 14px 30px -18px rgba(28, 21, 18, 0.28);
  --ed-serif: 'Fredoka', system-ui, sans-serif;
}

body.theme-dark .pdf-editor-page {
  --ed-bg: #160f0c;
  --ed-surface: #211812;
  --ed-canvas: #100b08;
  --ed-panel: #271c16;
  --ed-ink: #f4ece8;
  --ed-sub: #ae9f97;
  --ed-line: rgba(255, 255, 255, 0.12);
  --ed-line-strong: rgba(255, 255, 255, 0.2);
  --ed-seg: #342720;
  --ed-hover: rgba(255, 255, 255, 0.09);
  --ed-thumb: rgba(255, 255, 255, 0.13);
  --ed-thumb-border: rgba(255, 255, 255, 0.18);
  --ed-accent: #ff6b61;
  --ed-accent-ink: #ff8e86;
  --ed-accent-soft: rgba(255, 107, 97, 0.16);
  --ed-accent-rgb: 255, 107, 97;
  --ed-danger: #ff8e86;
  --ed-danger-soft: rgba(255, 107, 97, 0.16);
  --ed-shadow-card: 0 16px 34px -18px rgba(0, 0, 0, 0.55);
}

html,
body {
  height: 100%;
}

body:has(#pdfEditorApp) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* better on mobile — overrides if supported */
}

body:has(#pdfEditorApp) footer {
  display: none;
}

body:has(#pdfEditorApp) main.container-fullwidth {
  flex: 1;
  min-height: 0;
  height: auto;
}

/* Scoped reset for editor so global site styles don't leak in */
.pdf-editor-page,
.pdf-editor-page * {
  /* Reset previous style to apply only editor one */
  box-sizing: border-box;
}

.pdf-editor-page {
  font-family:
    'Fredoka',
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  color: var(--ed-ink);
  /* Match secondary toolbar strip so no background flash when it fades in */
  background: linear-gradient(
    180deg,
    var(--ed-surface) 0,
    var(--ed-surface)
      calc(var(--toolbar-height) + var(--secondary-toolbar-height)),
    var(--ed-canvas)
      calc(var(--toolbar-height) + var(--secondary-toolbar-height))
  );
  overflow-y: hidden; /* Keep vertical overflow hidden */
  overflow-x: hidden; /* Prevent horizontal scrollbar from sidebar toggle */
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 0;
}

body:has(#pdfEditorApp) {
  background: var(--ed-canvas);
}

/* Editor page only: full-width main so editor fills the viewport */
body:has(#pdfEditorApp) main.container-fullwidth {
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  background: var(--ed-canvas);
}

.pdf-editor-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
}

.pdf-editor-page
  :where(h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, blockquote) {
  margin: 0;
  padding: 0;
}

.pdf-editor-page :where(ul, ol) {
  list-style: none;
}

.pdf-editor-page :where(a) {
  color: inherit;
  text-decoration: none;
}

.pdf-editor-page :where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
  margin: 0;
  border-radius: 0;
  outline: none;
}

.pdf-editor-page :where(button) {
  background: none;
  border: none;
}

.pdf-editor-page
  :where(.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands) {
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  line-height: 1;
}

.pdf-editor-page
  :where(.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands)::before {
  content: '';
  display: inline-block;
  width: 1em;
  height: 1em;
  line-height: 1;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

/* Word-like Toolbar */
.editor-toolbar {
  background: var(--ed-surface);
  border-bottom: 1px solid var(--ed-line);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: none;
  z-index: 1000;
  flex-wrap: wrap;
  flex-shrink: 0; /* Prevent toolbar from shrinking */
}

/* The secondary toolbar is position:relative; z-index:999, which forms a
   stacking context above the shared navbar (z-index:100) and would hide the
   navbar's "All PDF tools" mega-menu (and the mobile drawer) behind the toolbar
   when it drops down over the editor. Lift the navbar above the editor toolbars,
   but keep it below editor modals (e.g. .draw-signature-modal at z-index:2000).
   editor.css only loads on the editor page, so this stays scoped there. */
.nb-root,
.nb-drawer {
  z-index: 1050;
}

.toolbar-group {
  display: flex;
  gap: 2px;
  padding: 0 4px;
  align-items: center;
}

.toolbar-separator {
  display: inline-block;
  width: 1px;
  height: 34px;
  background: var(--ed-line);
  flex: 0 0 auto;
}

/* Formatting/draw/shapes strips keep their inline separators subtle */
.editor-secondary-toolbar .toolbar-separator {
  height: 24px;
}

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

.toolbar-control-group input {
  height: 32px;
}

.toolbar-label-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: #555;
  cursor: default;
  border-radius: 4px;
  transition: background-color 0.2s;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  pointer-events: none;
}

.toolbar-label-icon:hover {
  background-color: #f0f0f0;
}

.toolbar-label-icon i {
  font-size: 14px;
}

.toolbar-select,
.toolbar-input {
  padding: 6px 8px;
  border: 1px solid var(--ed-line);
  border-radius: 7px;
  font-size: 13px;
  background: var(--ed-panel);
  color: var(--ed-ink);
  min-width: 120px;
  height: 32px;
  font-family: inherit;
}

.toolbar-select:focus,
.toolbar-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 2px rgba(var(--link-rgb), 0.1);
}

.toolbar-input {
  width: 44px;
  min-width: 44px;
}

.toolbar-input-narrow {
  width: 38px;
  min-width: 38px;
  text-align: center;
}

.toolbar-color-input {
  width: 40px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--ed-line);
  border-radius: 7px;
  cursor: pointer;
  background: var(--ed-panel);
}

.toolbar-color-input:hover {
  border-color: var(--ed-accent);
}

.toolbar-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.toolbar-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ed-ink);
  display: flex;
  align-items: center;
  gap: 6px;
  transition:
    background 0.15s,
    color 0.15s;
}

/* Disable transition on mode buttons for instant updates */
.toolbar-btn.mode-btn {
  transition: none;
  transform: none;
}

.toolbar-btn:hover:not(:disabled) {
  background: var(--ed-hover);
  transform: none;
}

.toolbar-btn.mode-btn:hover:not(:disabled) {
  transform: none;
}

.toolbar-btn {
  transform: none;
}

.toolbar-btn:hover:not(:disabled) {
  transform: none;
}

.toolbar-btn:disabled,
.toolbar-btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.toolbar-group.mode-group .toolbar-btn.mode-btn:disabled,
.toolbar-group.mode-group .toolbar-btn.mode-btn[aria-disabled='true'] {
  opacity: 1;
  background: var(--item-bg) !important;
  color: var(--muted-text) !important;
  border-color: var(--border-color) !important;
  box-shadow: none !important;
  transform: none !important;
  font-weight: 500;
  opacity: 0.6;
}

.toolbar-btn.active:not(.mode-btn) {
  background: var(--ed-accent-soft) !important;
  box-shadow: none !important;
  border-color: transparent !important;
  color: var(--ed-accent) !important;
}

.toolbar-caret {
  margin-left: 6px;
  font-size: 10px;
}

.toolbar-dropdown {
  position: relative;
}

.toolbar-btn.icon-only {
  min-width: 32px;
  padding: 5px 6px;
  gap: 4px;
  justify-content: center;
  border: none !important;
}

.format-group {
  gap: 4px;
  position: relative;
}

.toolbar-group.file-menu {
  border: none;
  padding: 0;
  background: transparent;
  gap: 2px;
}

.toolbar-group.add-tools-group,
.toolbar-group.tool-group,
.toolbar-group.zoom-control {
  border: 1px solid var(--ed-line);
  border-radius: 9px;
  padding: 3px 6px;
  background: transparent;
  gap: 2px;
}

.toolbar-group.add-tools-group {
  display: flex;
  flex-wrap: wrap;
}

.toolbar-btn.add-tool-btn {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 10px;
  min-width: 48px;
  min-height: 44px;
  border: none !important;
  border-radius: 4px;
}

/* Mobile: keep the toolbars on a single horizontally-scrollable row instead
   of wrapping/stacking buttons (which destroyed the layout on phones). */
@media (max-width: 768px) {
  .editor-toolbar,
  .editor-secondary-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .editor-toolbar::-webkit-scrollbar,
  .editor-secondary-toolbar::-webkit-scrollbar {
    display: none;
  }

  .editor-toolbar .toolbar-group,
  .editor-secondary-toolbar .toolbar-group {
    flex: 0 0 auto;
  }

  .toolbar-group.add-tools-group {
    flex-wrap: nowrap;
  }

  .toolbar-btn.add-tool-btn {
    min-width: 44px;
    padding: 5px 8px;
  }
}

.toolbar-btn.add-tool-btn .fa,
.toolbar-btn.add-tool-btn .fas,
.toolbar-btn.add-tool-btn .far {
  margin: 0;
  font-size: 14px;
  line-height: 1;
}

.toolbar-btn-label {
  font-size: 9.5px;
  line-height: 1;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ed-sub);
}

.toolbar-btn.add-tool-btn:hover:not(:disabled) {
  background: var(--ed-hover);
  border: 1px solid transparent !important;
}

.toolbar-btn.add-tool-btn.active {
  background: var(--ed-accent-soft) !important;
  box-shadow: none !important;
  border: 1px solid transparent !important;
  color: var(--ed-accent) !important;
}

.toolbar-btn.add-tool-btn.active .toolbar-btn-label {
  color: var(--ed-accent) !important;
}

/* Flex spacer pushes the Download button to the far right */
.toolbar-flex-spacer {
  flex: 1 1 12px;
  min-width: 12px;
}

.toolbar-group.download-group {
  border: none;
  padding: 0;
  background: transparent;
  margin-left: auto;
}

/* Fallback colours (#d62828 / #fff) so the download button is ALWAYS a solid red
   pill with a visible white label - even if --ed-accent fails to resolve in some
   state (which was rendering the button white, hiding the white "Download" text). */
.toolbar-btn.toolbar-btn-download {
  flex-direction: row;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--ed-radius);
  border: none !important;
  background: var(--ed-accent, #d62828) !important;
  color: #fff !important;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--ed-shadow-accent);
}

.toolbar-btn.toolbar-btn-download i {
  font-size: 14px;
  color: #fff !important;
}

.toolbar-btn-download-label {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #fff !important;
  display: inline !important;
}

.toolbar-btn.toolbar-btn-download:hover:not(:disabled) {
  background: var(--ed-accent-ink, #a31621) !important;
  color: #fff !important;
}

.toolbar-btn.toolbar-btn-download:disabled,
.toolbar-btn.toolbar-btn-download[aria-disabled='true'] {
  box-shadow: none;
}

@media (max-width: 768px) {
  .toolbar-flex-spacer {
    display: none;
  }
  .toolbar-btn.toolbar-btn-download {
    padding: 9px 14px;
  }
}

/* Mode group: segmented pill with a sliding thumb (mock aesthetic) */
.toolbar-group.mode-group {
  position: relative;
  border: 1px solid transparent !important;
  border-radius: 12px !important;
  padding: 4px;
  background: var(--ed-seg) !important;
  gap: 0;
  overflow: hidden;
  margin: 0;
  flex: 0 0 auto;
  box-shadow: none !important;
}

/* Sliding pill indicator — positioned/animated by JS */
.mode-indicator {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  background: var(--ed-thumb);
  border: 1px solid var(--ed-thumb-border);
  box-shadow: 0 2px 8px rgba(28, 21, 18, 0.16);
  border-radius: 9px;
  transition:
    transform 0.34s cubic-bezier(0.34, 1.4, 0.5, 1),
    width 0.34s cubic-bezier(0.34, 1.4, 0.5, 1);
  pointer-events: none;
  z-index: 0;
}

body.theme-dark .mode-indicator {
  background: var(--ed-thumb);
  border-color: var(--ed-thumb-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.toolbar-btn.mode-btn {
  position: relative;
  z-index: 1;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
  color: var(--ed-sub) !important;
  font-weight: 600;
  flex: 0 0 auto;
  flex-direction: column; /* stack icon above label, same as add-tool-btn */
  gap: 3px;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 5px 14px;
  border-radius: 3px;
  transition: color 0.18s ease;
  transform: none !important;
  margin: 0;
}

.toolbar-btn.mode-btn i {
  font-size: 14px;
  line-height: 1;
}

.toolbar-btn.mode-btn:hover:not(:disabled) {
  color: var(--ed-ink) !important;
  background: transparent !important;
  transform: none !important;
}

.toolbar-group.mode-group .toolbar-btn.mode-btn[aria-pressed='true'],
.toolbar-group.mode-group .toolbar-btn.mode-btn.active {
  /* Active: accent text on the white sliding pill */
  color: var(--ed-accent) !important;
  font-weight: 600;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  pointer-events: none;
  cursor: default;
}

.toolbar-group.mode-group .toolbar-btn.mode-btn[aria-pressed='true'] i,
.toolbar-group.mode-group .toolbar-btn.mode-btn.active i {
  color: inherit;
}

.toolbar-group.mode-group
  .toolbar-btn.mode-btn[aria-pressed='true']
  .toolbar-btn-label,
.toolbar-group.mode-group .toolbar-btn.mode-btn.active .toolbar-btn-label {
  color: inherit;
}

body.theme-dark .toolbar-btn.mode-btn {
  color: var(--ed-sub) !important;
}

body.theme-dark .toolbar-btn.mode-btn:hover:not(:disabled) {
  color: var(--ed-ink) !important;
}

body.theme-dark
  .toolbar-group.mode-group
  .toolbar-btn.mode-btn[aria-pressed='true'],
body.theme-dark .toolbar-group.mode-group .toolbar-btn.mode-btn.active {
  /* Dark theme: accent text on the sliding pill */
  color: var(--ed-accent) !important;
  font-weight: 600;
}

/* Disabled state: entire group fades */
.toolbar-group.mode-group:has(.toolbar-btn.mode-btn:disabled) {
  opacity: 0.5;
  pointer-events: none;
}

/* Edit mode text blocks */
.text-block-edit {
  position: absolute;
  border: 1px dashed transparent;
  background: transparent;
  cursor: move;
  pointer-events: all;
  z-index: 10;
  opacity: 0;
  transition:
    opacity 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

/* Disable pointer events for edited blocks - they use pdf-element instead */
.text-block-edit--edited {
  pointer-events: none !important;
}

.text-block-edit--visible,
.text-block-edit--edited {
  opacity: 1;
}

.text-block-edit--visible,
.text-block-edit--selected {
  border-color: var(--primary-blue);
  background: transparent;
}

.text-block-edit--selected {
  border-style: dashed;
  box-shadow: 0 0 0 2px rgba(var(--link-rgb), 0.2);
  background: #fff;
}

/* Show the overlay text content when selected so user can see what they're editing */
.text-block-edit--selected .text-block-edit__content {
  opacity: 1;
}

.text-block-edit--edited:not(.text-block-edit--selected):not(
    .text-block-edit--hover
  ) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.text-block-edit__content {
  width: 100%;
  height: 100%;
  padding: 2px;
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
  font: inherit;
  pointer-events: none;
  opacity: 0;
  /* Match the canvas rasterization weight (see .pdf-element-layer-text). */
  -webkit-font-smoothing: auto;
}

/* When overlay is visible (hover/selected), receive clicks on content so one click selects the block */
.text-block-edit--visible .text-block-edit__content,
.text-block-edit--selected .text-block-edit__content,
.text-block-edit--hover .text-block-edit__content {
  pointer-events: auto;
}

.text-block-edit--edited .text-block-edit__content {
  opacity: 1;
}

.text-block-edit__controls {
  position: absolute;
  top: -32px;
  right: 0;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: #ffffff;
  border: 1px solid var(--primary-blue);
  border-radius: 6px 6px 0 0;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.15s ease;
  transform: translateY(4px);
  z-index: 12;
  user-select: none;
}

.text-block-edit--selected .text-block-edit__controls,
.text-block-edit--hover .text-block-edit__controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.text-block-edit__btn {
  border: 1px solid transparent !important;
  background: #ffffff !important;
  color: #333 !important;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
  user-select: none;
  font-size: 12px;
  padding: 12px 12px;
}

.text-block-edit__btn:hover:not(:disabled) {
  background: #eef5ff !important;
  border-color: var(--primary-blue) !important;
  color: var(--primary-blue) !important;
}

.text-block-edit__btn:disabled,
.text-block-edit__btn[aria-disabled='true'] {
  opacity: 0.4;
  cursor: not-allowed;
}

.text-block-edit__handle {
  position: absolute;
  width: 12px;
  height: 12px;
  right: -6px;
  bottom: -6px;
  border-radius: 3px;
  border: 2px solid var(--primary-blue);
  background: #fff;
  cursor: nwse-resize;
  display: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

.text-block-edit--selected .text-block-edit__handle {
  display: block;
}

.text-block-edit--visible:hover,
.text-block-edit--hover {
  background: rgba(var(--link-rgb), 0.05);
  border-color: var(--primary-blue);
}

/* Inline editor - appears directly in place of text; size matches element box exactly */
.inline-editor {
  position: absolute;
  z-index: 1000;
  background-color: transparent;
  border: 1px solid var(--primary-blue);
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

.inline-editor-content {
  outline: none;
  border: none;
  width: 100%;
  min-height: 1em;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  resize: none;
  overflow: visible;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Element text box editor: content must not be constrained so line-height and height apply correctly */
.inline-editor[data-element-id] .inline-editor-content {
  min-height: 0;
  white-space: pre-line;
}

/* Save / cancel bar attached to the open inline editor */
.inline-editor-actions {
  position: absolute;
  top: -24px;
  right: -1px;
  display: flex;
  gap: 2px;
  padding: 2px;
  margin: 0;
  font-size: 11px;
  line-height: 1;
  background: #ffffff;
  border: 1px solid var(--primary-blue);
  border-radius: 4px 4px 0 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  z-index: 30;
}

.inline-editor-action {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  margin: 0;
  border-radius: 3px;
  border: 1px solid transparent;
  background: #ffffff;
  color: #333;
  font-size: 10px;
  line-height: 1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.inline-editor-action--save:hover {
  background: #e8f7ed;
  border-color: #2e7d32;
  color: #2e7d32;
}

.inline-editor-action--cancel:hover {
  background: #fdeaea;
  border-color: #c62828;
  color: #c62828;
}

.inline-editor-confirm {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--primary-blue);
  background: #fff;
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.inline-editor-confirm:hover {
  background: #e6f2fb;
}

.element-controls .confirm-btn {
  background: #fff;
  color: var(--primary-blue);
  border: 1px solid var(--primary-blue);
}

.element-controls .confirm-btn:hover {
  background: #e6f2fb;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.panel-section:last-child {
  margin-bottom: 0;
}

.panel-section label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.panel-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-section select,
.panel-section input[type='number'],
.panel-section input[type='color'] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  font-size: 13px;
}

.panel-section input[type='color'] {
  padding: 0;
  height: 34px;
}

.unit-label {
  font-size: 12px;
  color: #666;
}

.toolbar-btn i {
  font-size: 14px;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-slider-inline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.zoom-slider-inline {
  width: 88px;
  height: 5px;
  margin: 0 4px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 999px;
  background: var(--ed-seg);
  outline: none;
}

.zoom-slider-inline::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ed-panel);
  border: 2px solid var(--ed-accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(28, 21, 18, 0.25);
}

.zoom-slider-inline::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ed-panel);
  border: 2px solid var(--ed-accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(28, 21, 18, 0.25);
}

.zoom-percent-wrap {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.zoom-percentage-inline {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
}

.zoom-percent-wrap:has(.zoom-percent-input:disabled) {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Flat zoom % input — no border, just editable text */
.zoom-percent-wrap .zoom-percent-input {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ed-ink);
  outline: none;
  box-sizing: border-box;
}

.zoom-percent-suffix {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ed-ink);
  user-select: none;
}

body.theme-dark .zoom-percent-suffix {
  color: var(--ed-ink);
}

.zoom-dropdown {
  position: relative;
}

.zoom-toggle {
  padding: 6px;
  justify-content: center;
}

.zoom-panel,
.more-panel,
.toolbar-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 12px;
  min-width: 260px;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
  background-clip: padding-box;
  z-index: 1100;
}

.zoom-panel {
  right: 0;
}

.more-panel {
  left: 0;
}

.toolbar-dropdown-panel {
  left: 0;
  min-width: 200px;
}

.dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 4px;
  color: #333;
  transition: background 0.15s ease;
  margin-bottom: 4px;
}

.dropdown-item:last-child {
  margin-bottom: 0;
}

.dropdown-item + .dropdown-item {
  margin-top: 4px;
}

.dropdown-item i {
  width: 14px;
  text-align: center;
}

.dropdown-item:hover:not(:disabled) {
  background: #eef5fb;
}

.dropdown-item:disabled,
.dropdown-item[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 6px 0;
}

.file-menu input[type='file'] {
  display: none;
}

.zoom-dropdown.open .zoom-panel,
.format-group.open .more-panel,
.toolbar-dropdown.open .toolbar-dropdown-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.zoom-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-step-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #c7c7c7;
  border-radius: 4px;
  background: #fff;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.zoom-step-btn:hover {
  background: #e8f4ff;
  border-color: #7ab6ff;
}

#zoomSlider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-blue), #ff8a5b);
  outline: none;
}

#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary-blue);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

#zoomSlider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary-blue);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.zoom-panel-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.zoom-percentage {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.zoom-reset-btn {
  border: none;
  background: var(--primary-blue);
  color: #fff;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.zoom-reset-btn:hover {
  background: var(--primary-blue);
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: #d0d0d0;
  margin: 0 4px;
}

/* Secondary Toolbar - transition matches show/hide animation so page resizing is smooth */
.editor-secondary-toolbar {
  background: var(--ed-surface);
  border-bottom: 1px solid var(--ed-line);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
  z-index: 999;
  position: relative;
  flex-shrink: 0;
  max-height: 80px;
  overflow: hidden;
  transition:
    max-height 0.28s cubic-bezier(0.33, 1, 0.68, 1),
    padding 0.28s cubic-bezier(0.33, 1, 0.68, 1),
    border-bottom-width 0.28s ease,
    box-shadow 0.28s ease;
  contain: layout style;
}

@keyframes secondary-toolbar-fade-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes secondary-toolbar-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.editor-secondary-toolbar.secondary-toolbar-visible {
  animation: secondary-toolbar-fade-in 0.28s cubic-bezier(0.33, 1, 0.68, 1)
    forwards;
}

.editor-secondary-toolbar.secondary-toolbar-hiding {
  animation: secondary-toolbar-fade-out 0.26s cubic-bezier(0.32, 0.72, 0.46, 1)
    forwards;
}

/* Collapsed state: smooth height transition so page resizing matches toolbar show/hide */
.editor-secondary-toolbar.secondary-toolbar-collapsed {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-bottom-width: 0 !important;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
  transition:
    max-height 0.26s cubic-bezier(0.32, 0.72, 0.46, 1),
    padding 0.26s cubic-bezier(0.32, 0.72, 0.46, 1),
    border-bottom-width 0.26s ease,
    box-shadow 0.26s ease;
}

/* When using [hidden] (e.g. initial load), keep same collapsed appearance */
.editor-secondary-toolbar[hidden] {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-bottom-width: 0 !important;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

.secondary-toolbar-panel[hidden] {
  display: none !important;
}

.secondary-toolbar-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-text-input-group {
  min-width: 140px;
}

.toolbar-text-input-group .toolbar-label-text {
  white-space: nowrap;
  margin-right: 4px;
  font-size: 13px;
  color: #555;
}

.toolbar-text-input {
  min-width: 120px;
  max-width: 200px;
}

.toolbar-signature-draw-group[hidden] {
  display: none !important;
}

/* Draw Signature Modal */
.draw-signature-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 16px;
}

.draw-signature-modal[hidden] {
  display: none !important;
}

.draw-signature-modal-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 560px;
  width: 100%;
  overflow: hidden;
}

.draw-signature-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
}

.draw-signature-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.draw-signature-modal-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #666;
  border-radius: 4px;
}

.draw-signature-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.draw-signature-modal-body {
  padding: 16px;
}

.draw-signature-canvas-wrapper {
  border: 1px solid var(--border-color, #d0d0d0);
  border-radius: var(--radius-medium, 6px);
  background-color: var(--input-bg, #fff);
  background-image:
    linear-gradient(45deg, var(--card-bg, #f5f5f5) 25%, transparent 25%),
    linear-gradient(-45deg, var(--card-bg, #f5f5f5) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--card-bg, #f5f5f5) 75%),
    linear-gradient(-45deg, transparent 75%, var(--card-bg, #f5f5f5) 75%);
  background-size: 12px 12px;
  background-position:
    0 0,
    0 6px,
    6px -6px,
    -6px 0px;
  margin-bottom: 12px;
  overflow: hidden;
}

.draw-signature-canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
  background: transparent;
}

.draw-signature-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.draw-signature-stroke-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.draw-signature-stroke-label {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

.draw-signature-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.draw-signature-stroke-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.draw-signature-stroke-slider {
  width: 180px;
  height: 24px;
  accent-color: var(--primary-blue, var(--primary-blue));
}

.draw-signature-stroke-preview {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color, #d0d0d0);
  border-radius: 50%;
  background: var(--input-bg, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.draw-signature-stroke-preview canvas {
  display: block;
  width: 32px;
  height: 32px;
}

.draw-signature-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  background: var(--card-bg, #f8f8f8);
}

.editor-secondary-toolbar .toolbar-group {
  padding-right: 8px;
  margin-right: 4px;
}

.toolbar-btn-add-another {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-left: 4px;
  color: var(--ed-accent) !important;
  background: var(--ed-accent-soft) !important;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.toolbar-btn-add-another:hover {
  background: var(--ed-accent-soft) !important;
  color: var(--ed-accent-ink) !important;
  border-color: var(--ed-accent);
}

.toolbar-btn-add-another .toolbar-btn-add-another-label {
  white-space: nowrap;
}

.editor-secondary-toolbar .toolbar-separator {
  height: 20px;
  margin: 0 4px;
}

.draw-settings-inline,
.draw-settings {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.draw-settings[hidden] {
  display: none !important;
}

.draw-settings-inline label,
.draw-settings label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.draw-settings-inline input,
.draw-settings input {
  pointer-events: auto;
}

.draw-settings-inline i,
.draw-settings i {
  color: var(--ed-sub);
  pointer-events: none;
}

.toolbar-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--ed-accent);
}

.secondary-toolbar-shapes .shapes-settings,
.secondary-toolbar-panel.secondary-toolbar-shapes {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.shape-type-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.shape-type-buttons .shape-type-btn {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
  font-size: 18px;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
}

.shape-type-buttons .shape-type-btn:hover {
  border-radius: 999px;
}

.shape-type-buttons .shape-type-btn.active {
  border-radius: 999px;
  background: var(--ed-accent-soft) !important;
  color: var(--ed-accent) !important;
}

.shape-type-buttons .shape-type-btn.active:hover {
  background: var(--ed-accent-soft) !important;
}

.secondary-toolbar-emoji .emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  align-content: flex-start;
}

.emoji-btn {
  flex: 1 1 auto;
  min-width: 2em;
  max-width: 2.5em;
  height: 2em;
  font-size: 18px;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.emoji-btn:hover {
  border-radius: 999px;
}

.text-box-controls .text-box-btn.rotate {
  display: inline-flex;
}

.draw-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.draw-item-controls input[type='range'] {
  width: 100px;
}

/* Main Editor Area */
.editor-container {
  display: flex;
  min-height: 0;
  flex: 1;
  height: auto;
  overflow: hidden; /* Prevent horizontal scrollbar from sidebar toggle */
  position: relative; /* Ensure absolute children are positioned relative to this */
  max-height: none;
  background: #e5e5e5;
}

/* Dark theme support */
/* ── Dark mode: most surfaces/text derive from --ed-* tokens (which swap
   automatically under body.theme-dark .pdf-editor-page). Only the rules the
   token base rules don't already cover are kept here. ── */
body.theme-dark .editor-container {
  background: var(--ed-canvas);
}

body.theme-dark .editor-toolbar,
body.theme-dark .editor-secondary-toolbar {
  box-shadow: none;
}

body.theme-dark .toolbar-btn:disabled,
body.theme-dark .toolbar-btn[aria-disabled='true'] {
  opacity: 0.35;
}

body.theme-dark .zoom-percent-wrap:has(.zoom-percent-input:disabled),
body.theme-dark .zoom-slider-inline:disabled {
  opacity: 0.35;
}

body.theme-dark .toolbar-label-icon {
  color: var(--ed-sub);
}

body.theme-dark .toolbar-label-icon:hover {
  background: var(--ed-hover);
}

body.theme-dark .toolbar-select:focus,
body.theme-dark .toolbar-input:focus {
  border-color: var(--ed-accent);
  box-shadow: 0 0 0 2px rgba(var(--ed-accent-rgb), 0.2);
}

body.theme-dark .toolbar-dropdown-panel {
  background: var(--ed-panel);
  border-color: var(--ed-line);
}

body.theme-dark .dropdown-item {
  color: var(--ed-ink);
}

body.theme-dark .dropdown-item:hover:not(:disabled) {
  background: var(--ed-hover);
}

body.theme-dark .text-box-thumbnail,
body.theme-dark .text-box-item .text-box-thumbnail {
  color: var(--ed-ink) !important;
}

.editor-sidebar {
  width: 320px; /* Increased base width */
  min-width: 0;
  background: var(--ed-surface);
  border-right: 1px solid var(--ed-line);
  padding: 16px;
  position: relative;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: visible; /* Allow toggle button to be visible outside sidebar */
  z-index: 10; /* Ensure sidebar is above editor-main but toggle button can overflow */
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -6px;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
}

/* Full-height edge line */
.sidebar-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  left: 5px;
  width: 2px;
  height: 100%;
  background: rgba(150, 150, 150, 0.3);
  transition: background 0.15s;
  pointer-events: none;
}

/* Two-bar grip icon centered on the handle */
.sidebar-resize-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 24px;
  border-left: 2px solid rgba(120, 120, 120, 0.55);
  border-right: 2px solid rgba(120, 120, 120, 0.55);
  border-radius: 1px;
  pointer-events: none;
  transition: border-color 0.15s;
}

.sidebar-resize-handle:hover::after {
  background: var(--primary-blue);
}

.sidebar-resize-handle:hover::before {
  border-color: var(--primary-blue);
}

body.theme-dark .sidebar-resize-handle::after {
  background: rgba(200, 200, 200, 0.2);
}

body.theme-dark .sidebar-resize-handle::before {
  border-color: rgba(200, 200, 200, 0.45);
}

body.theme-dark .sidebar-resize-handle:hover::after {
  background: var(--primary-blue, var(--primary-blue));
}

body.theme-dark .sidebar-resize-handle:hover::before {
  border-color: var(--primary-blue, var(--primary-blue));
}

.editor-sidebar.collapsed .sidebar-resize-handle {
  display: none;
}

.editor-sidebar.collapsed {
  width: 0 !important; /* Force width to 0 when collapsed, override any dynamic width */
  min-width: 0 !important; /* Remove min-width when collapsed */
  padding: 0;
  overflow: visible; /* Allow toggle button to be visible */
}

/* Only the content section should scroll, not the sidebar itself */
.editor-sidebar .sidebar-section {
  overflow-x: hidden; /* Allow rotated content to extend horizontally */
  overflow-y: auto; /* Only the content section should scroll vertically */
  flex: 1;
  min-height: 0;
  /* Ensure section doesn't clip toggle button */
  clip-path: none;
  -webkit-clip-path: none;
}

.editor-sidebar.collapsed .sidebar-section {
  display: none;
}

.sidebar-toggle {
  position: absolute;
  right: -15px; /* Position 15px to the right of sidebar edge - half button extends outside */
  top: 8px;
  transform: none;
  width: 30px;
  height: 30px;
  background: var(--ed-panel) !important;
  color: var(--ed-sub) !important;
  border: 1px solid var(--ed-line) !important;
  border-radius: 50%;
  cursor: pointer;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 1001; /* Higher z-index to ensure visibility */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
  pointer-events: auto; /* Ensure it's clickable */
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow: visible; /* Ensure button is fully visible */
  min-width: 30px; /* Prevent clipping */
  min-height: 30px;
}

.sidebar-toggle.visible {
  display: flex; /* Show when visible class is added */
}

.sidebar-toggle:hover {
  background: var(--ed-panel) !important;
  border-color: var(--ed-accent) !important;
  color: var(--ed-accent) !important;
}

.editor-sidebar.collapsed .sidebar-toggle {
  right: -15px; /* When collapsed, position outside the zero-width sidebar */
  /* Keep button visible when sidebar is collapsed */
}

/* When sidebar is not collapsed, ensure toggle button is fully visible */
.editor-sidebar:not(.collapsed) .sidebar-toggle {
  right: -15px;
  /* Button should extend 15px to the right of sidebar */
}

.sidebar-toggle i {
  font-size: 12px;
  transition: none;
  pointer-events: none; /* Prevent icon from blocking clicks */
}

.editor-sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

/* Right Sidebar (Text Boxes) */
.editor-sidebar-right {
  border-right: none;
  border-left: 1px solid var(--ed-line);
  order: 3;
  overflow: visible;
}

.sidebar-toggle-right {
  left: -15px;
  right: auto;
}

.editor-sidebar-right.collapsed .sidebar-toggle-right {
  left: -15px;
}

/* Text Boxes Sidebar Content */
.text-box-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  margin-bottom: 9px;
  background: var(--ed-panel);
  border: 1px solid var(--ed-line);
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.text-box-item:hover {
  border-color: var(--ed-accent);
}

.text-box-item.active {
  background: var(--ed-accent-soft);
  border-color: var(--ed-accent);
}

.text-box-type {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--ed-seg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ed-sub);
  flex-shrink: 0;
}

.text-box-item.active .text-box-type {
  background: var(--ed-accent);
  color: #fff;
}

.text-box-thumbnail {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px;
  max-width: 180px;
}

.text-box-controls {
  display: flex;
  gap: 1px;
  margin-left: auto;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #cfd8e3;
  padding: 1px;
}

.text-box-btn {
  width: 18px;
  height: 18px;
  border: 1px solid transparent !important;
  background: #ffffff !important;
  color: #4a4a4a !important;
  cursor: pointer;
  border-radius: 3px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
  font-size: 11px;
  padding: 14px 12px;
}

.text-box-btn:hover {
  background: var(--ed-accent-soft);
  border-color: var(--ed-accent);
  color: var(--ed-accent);
}

.text-box-btn.remove:hover {
  background: var(--ed-danger-soft);
  border-color: var(--ed-danger);
  color: var(--ed-danger);
}

.text-boxes-empty {
  margin-top: 6px;
  padding: 14px;
  text-align: center;
  color: var(--ed-sub);
  font-size: 12px;
  line-height: 1.5;
  border: 1.5px dashed var(--ed-line-strong);
  border-radius: 11px;
}

/* Page thumbnail loading state */
.page-thumbnail.loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.page-thumbnail.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-blue);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* No document: main area fills space and centers empty state. Has document: fills remaining space and scrolls. */
.editor-main {
  flex: 0 0 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  background-color: var(--ed-canvas);
  padding: 20px;
  padding-right: 12px; /* Add space for scrollbar */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  min-width: 0;
  position: relative;
  box-sizing: border-box;
  overflow-anchor: none;
  z-index: 1;
  width: 100%;
  align-self: stretch;
}

/* No document: grow to fill space and scroll SEO content from the top */
.pdf-editor-page:not(.has-document) .editor-main {
  flex: 1;
  min-height: 0;
  justify-content: flex-start;
  align-items: center;
}

.pdf-editor-page.has-document .editor-main {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  background-image: radial-gradient(var(--ed-line) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* Ensure scrollbar is accessible and visible */
.editor-main::-webkit-scrollbar {
  width: 12px;
}

.editor-main::-webkit-scrollbar-track {
  background: transparent;
  margin-right: 0;
}

.editor-main::-webkit-scrollbar-thumb {
  background: rgba(28, 21, 18, 0.18);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.editor-main::-webkit-scrollbar-thumb:hover {
  background: rgba(28, 21, 18, 0.3);
  background-clip: padding-box;
}

body.theme-dark .editor-main::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  background-clip: padding-box;
}

#editorPages {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: auto; /* Don't force 100% height */
  flex: 1;
}

.editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 180px;
  color: var(--ed-sub);
  text-align: center;
  padding: 0 16px 48px;
}

/* Inner drop zone keeps the dashed border */
.editor-drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0; /* never let the flex parent squash the panel + clip content */
  width: min(100%, 920px);
  min-height: 520px;
  padding: 48px 40px;
  border: 1px solid var(--ed-line);
  border-radius: 20px;
  background: var(--ed-panel);
  box-shadow:
    0 30px 70px -30px rgba(28, 21, 18, 0.35),
    0 4px 14px rgba(28, 21, 18, 0.06);
  overflow: hidden;
  transition:
    border-color 0.2s,
    background-color 0.2s;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

/* Dotted grid + radial accent tint behind the drop-zone content */
.editor-drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--ed-line) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.editor-drop-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    120% 90% at 50% 0%,
    rgba(var(--ed-accent-rgb), 0.06),
    transparent 60%
  );
  pointer-events: none;
}

/* Drag-over visual applied to inner drop zone */
.editor-empty--drag-over .editor-drop-zone {
  border: 1.5px dashed var(--ed-accent);
  background: var(--ed-accent-soft);
}

body.theme-dark .editor-empty--drag-over .editor-drop-zone {
  border-color: var(--ed-accent);
  background: var(--ed-accent-soft);
}

/* dz-content: centered column. Top row = loo + text; badges + privacy
   span the full width, centered below. */
.dz-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Top row split into two equal halves — loo | upload — each centered
   within its own area. */
.dz-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 32px;
  width: 100%;
}

.dz-pdf-icon {
  flex-shrink: 0;
  justify-self: center;
  margin-top: 64px;
}

.dz-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  text-align: center;
  max-width: 420px;
}

.dz-text .dz-cta-row {
  justify-content: center;
}

@media (max-width: 700px) {
  .dz-top {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Floating PDF icon */
@keyframes dz-pdf-float {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-13px) rotate(3deg);
  }
}

.dz-pdf-icon {
  animation: dz-pdf-float 3s ease-in-out infinite;
  margin-bottom: 16px;
}

.dz-pdf-icon i {
  font-size: 64px;
  color: #ccc;
  display: block;
}

/* ── loo, the loopdf mascot, in the editor drop zone ── */
@keyframes dz-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.dz-loo-wrap {
  position: relative;
  display: inline-block;
  animation: dz-bob 4s ease-in-out infinite;
}

.dz-loo {
  object-fit: contain;
  width: 132px;
  height: auto;
  display: block;
  pointer-events: none;
  user-select: none;
  overflow: visible;
}

/* The mascot is a raster asset now (assets/img/loo-wave.webp), so the wink
   that used to cross-fade two SVG eye shapes is gone with it. The wrapper's
   bob is the only motion left. */
@media (prefers-reduced-motion: reduce) {
  .dz-loo-wrap {
    animation: none;
  }
}

.dz-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

/* Typewriter text inside bubble — animation driven by JS */
.dz-bubble {
  overflow: hidden;
}

.dz-bubble-text {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
  border-right: 1.5px solid transparent;
}

/* Tail pointing down toward loo */
.dz-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.08));
}

.dz-bubble::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.1);
  margin-top: 1px;
}

body.theme-dark .dz-bubble {
  background: #2d3748;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f0f0f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.theme-dark .dz-bubble::after {
  border-top-color: #2d3748;
}

body.theme-dark .dz-bubble::before {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.editor-drop-zone h2 {
  margin-bottom: 8px;
  color: var(--ed-ink);
}

.dz-headline {
  font-family: var(--ed-serif);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.1;
  color: var(--ed-ink);
  margin-top: 4px;
}

.dz-subcopy {
  margin: 10px 0 0;
  max-width: 400px;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ed-sub);
}

.dz-cta-row {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.dz-or {
  font-size: 13.5px;
  color: var(--ed-sub);
}

.dz-badges {
  margin-top: 30px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.dz-badge {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--ed-accent-soft);
  border: 1px solid color-mix(in srgb, var(--ed-accent) 22%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--ed-accent-ink);
  cursor: pointer;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.4, 0.5, 1),
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.dz-badge:hover {
  transform: translateY(-3px);
  background: var(--ed-accent);
  color: #fff;
  border-color: var(--ed-accent);
  box-shadow: 0 6px 14px rgba(var(--ed-accent-rgb), 0.32);
}

.dz-privacy {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 100px;
  background: var(--ed-surface);
  border: 1px solid var(--ed-line);
  font-size: 12.5px;
  color: var(--ed-sub);
}

.dz-privacy i {
  color: #3a8f4a;
  font-size: 12px;
}

body.theme-dark .dz-privacy i {
  color: #5fbf72;
}

body.theme-dark .editor-drop-zone h2 {
  color: var(--ed-ink);
}

body.theme-dark .editor-drop-zone i {
  color: inherit;
}

/* Debug PDF picker (only when app.settings.app.debug) */
.editor-debug-picker {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 480px;
}

body.theme-dark .editor-debug-picker {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.editor-debug-picker-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body.theme-dark .editor-debug-picker-label {
  color: var(--muted-text);
}

.editor-debug-picker-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.editor-debug-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  min-width: 120px;
}

.editor-debug-picker-card:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 2px 8px rgba(var(--link-rgb), 0.2);
}

body.theme-dark .editor-debug-picker-card {
  background: var(--panel-bg, #2d2d2d);
  border-color: rgba(255, 255, 255, 0.2);
}

body.theme-dark .editor-debug-picker-card:hover {
  border-color: #4da3ff;
  box-shadow: 0 2px 8px rgba(77, 163, 255, 0.25);
}

.editor-debug-picker-preview {
  display: block;
  width: 120px;
  height: auto;
  max-height: 155px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  margin-bottom: 8px;
}

body.theme-dark .editor-debug-picker-preview {
  background: #1e1e1e;
}

.editor-debug-picker-name {
  font-size: 12px;
  color: #333;
  word-break: break-all;
  text-align: center;
}

body.theme-dark .editor-debug-picker-name {
  color: var(--text-primary, #fff);
}

.editor-debug-picker-load {
  margin-top: 0;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--ed-accent);
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  margin-top: 0;
  box-shadow: 0 6px 18px rgba(var(--ed-accent-rgb), 0.34);
  transition: background 0.2s;
}

.btn-primary i {
  font-size: 15px;
}

.btn-primary:hover {
  background: var(--ed-accent-ink);
}

.btn-primary:disabled {
  background: var(--ed-line-strong);
  box-shadow: none;
  cursor: not-allowed;
}

/* PDF Page */
.pdf-page {
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  margin: 0 auto 20px;
  position: relative;
  border: 1px solid #ddd;
}

.pdf-page canvas {
  display: block;
  width: 100%;
  height: auto;
}

.pdf-analysis-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.pdf-analysis-overlay--active {
  opacity: 1;
  pointer-events: auto;
}

.pdf-analysis-overlay__card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
  font-size: 14px;
  font-weight: 600;
  color: #1f2933;
}

.pdf-analysis-overlay__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(31, 41, 51, 0.2);
  border-top-color: rgba(31, 41, 51, 0.8);
  border-radius: 50%;
  animation: pdf-analysis-spin 0.9s linear infinite;
}

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

/* Full-viewport overlay shown while entering Edit mode */
.editor-mode-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(229, 229, 229, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  /* No transition on base state: fade-out is applied via inline style when hiding */
}

.editor-mode-loading-overlay--active {
  opacity: 1;
  pointer-events: auto;
  /* transition:none ensures the overlay appears instantly (no fade-in) */
  transition: none;
}

/* Preparation progress: centered on current pdf-page, pill style */
.editor-prepare-progress {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
}

.editor-prepare-progress[hidden] {
  display: none;
}

.editor-prepare-progress__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.editor-prepare-progress__spinner {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  animation: pdf-analysis-spin 0.9s linear infinite;
}

.editor-prepare-progress__label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  min-width: 0;
}

.editor-prepare-progress__bar {
  flex-shrink: 0;
  width: 100px;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.editor-prepare-progress__fill {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* Editable Elements */
.draw-layer {
  touch-action: none;
}

.pdf-element {
  position: absolute;
  cursor: move;
  /* Let finger drag/resize the element instead of scrolling the page. */
  touch-action: none;
  border: 1px dashed rgba(0, 0, 0, 0.15);
  transition:
    border-color 0.15s,
    background-color 0.15s,
    box-shadow 0.15s;
  user-select: none;
  min-width: 24px;
  min-height: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px;
  text-align: left;
  /* Disable transitions for position changes - instant movement */
  will-change: left, top;
  z-index: 15; /* Higher than text-block-edit (z-index: 10) to ensure controls are clickable */
}

/* Layer text (original PDF text blocks in Edit mode): no border — outline is used for hover/select
   so that box-sizing: border-box does not steal width from the tightly-sized content area. */
.pdf-element.pdf-element-layer-text {
  border-width: 0;
  /* Contain horizontally (no bleeding into same-row neighbours) while
     letting glyph descenders ("p", "g", "y") extend below the tight block
     box instead of being cut off. */
  overflow: visible;
  clip-path: inset(0 0 -0.4em 0);
  /* Match the canvas rasterization weight — the global `antialiased`
     smoothing renders text noticeably thinner than the PDF canvas. */
  -webkit-font-smoothing: auto;
}

.pdf-element.pdf-element-layer-text:hover {
  outline: 1px dashed var(--primary-blue);
  background: rgba(var(--link-rgb), 0.05);
  border-width: 0;
}

.pdf-element.pdf-element-layer-text.selected {
  outline: 1px dashed var(--primary-blue);
  background: rgba(var(--link-rgb), 0.1);
  box-shadow: 0 0 0 2px rgba(var(--link-rgb), 0.2);
  border-width: 0;
}

/* Annotate-mode added text: above original PDF text (Edit mode layer text) */
.pdf-element.pdf-element-annotation-added {
  z-index: 25;
}

/* Image mask (white cover for erased image): match page background; below overlays; capture hover for default cursor */
.pdf-element.pdf-image-mask {
  z-index: 5;
  pointer-events: auto;
  cursor: default;
  background: #ffffff !important;
}

.pdf-element.pdf-emoji {
  min-width: 20px;
  min-height: 20px;
  padding: 0;
}

.pdf-element.dragging {
  transition: none;
}

.pdf-element.pdf-image {
  padding: 2px;
  box-sizing: border-box;
}

.pdf-element.pdf-element-original-image {
  background: transparent !important;
}

.pdf-element.pdf-image img,
.pdf-dragging-element.pdf-image-element img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  display: block;
}

.pdf-element:hover {
  background: rgba(var(--link-rgb), 0.05);
  border: 1px dashed var(--primary-blue);
}

.pdf-element.selected {
  background: rgba(var(--link-rgb), 0.1);
  box-shadow: 0 0 0 2px rgba(var(--link-rgb), 0.2);
  border: 1px dashed var(--primary-blue);
  z-index: 500; /* Above other .pdf-elements so the control bar is clickable when another box is behind it */
}

/* When inline editor is open: raise element so resize handle and controls render on top; hide element text/box so only edit zone + handle + controls show (no double text) */
.pdf-element.inline-editing-active {
  z-index: 1001;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  visibility: hidden;
}
.pdf-element.inline-editing-active .resize-handle,
.pdf-element.inline-editing-active .element-controls {
  visibility: visible;
  opacity: 1;
}

/* View/Annotate mode: hide original PDF editing only; added elements keep borders/hover/controls */
.pdf-view-mode .text-block-edit {
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.pdf-view-mode .text-block-edit__controls {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.pdf-element.dragging {
  opacity: 0.7;
  z-index: 1000;
}

.pdf-element.resizing {
  cursor: nwse-resize;
  user-select: none;
}

.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  bottom: -6px;
  right: -6px;
  border: 2px solid var(--primary-blue);
  background: #fff;
  border-radius: 3px;
  cursor: nwse-resize;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 1100;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none; /* Only active when element is selected */
}

.pdf-element.selected .resize-handle {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* Controls appear above the selected element only (not on hover) */
.element-controls {
  position: absolute;
  top: -29px;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--primary-blue);
  border-radius: 6px 6px 0 0;
  padding: 2px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 20;
  pointer-events: none;
}

.pdf-element.selected .element-controls {
  opacity: 1;
}

.element-controls button {
  pointer-events: auto;
  background: #ffffff !important;
  border: 1px solid transparent !important;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #333 !important;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
  padding: 0;
}

.element-controls button:hover {
  background: #eef5ff !important;
  border-color: var(--primary-blue) !important;
  color: var(--primary-blue) !important;
}

/* Signature/Initials Styles */
.pdf-signature,
.pdf-initials {
  font-family: 'Dancing Script', 'Pacifico', 'Satisfy', cursive;
  white-space: nowrap;
}

.pdf-text {
  font-family: Arial, sans-serif;
  word-wrap: break-word;
  white-space: pre-wrap;
  pointer-events: auto;
}

/* Text wrapper so content wraps and respects box width (flex item needs min-width: 0 to shrink) */
.pdf-element.pdf-text .pdf-element-text {
  display: block;
  min-width: 0;
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow: hidden;
  box-sizing: border-box;
}

/* Layer text from PDF: distinctive style (original/unmodified) */
/* Layer text in Edit mode: use exact bbox size, no large min */
.pdf-element.pdf-element-layer {
  min-width: 0 !important;
  min-height: 0 !important;
}

.pdf-element.pdf-element-layer.pdf-element-original {
  border: 1px dashed rgba(var(--link-rgb), 0.4);
  background: rgba(248, 249, 250, 0.6);
}
body.theme-dark .pdf-element.pdf-element-layer.pdf-element-original {
  border-color: rgba(100, 180, 255, 0.35);
  background: rgba(30, 35, 45, 0.5);
}

/* Original layer text/image in annotate mode: no visible box, plain text look */
.pdf-element.pdf-element-readonly-annotate {
  cursor: default;
  pointer-events: auto;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
}
.pdf-element.pdf-element-readonly-annotate:hover {
  background: transparent !important;
  border: none !important;
}

/* User-added elements in Edit mode: read-only (only original texts/images are editable) */
.pdf-element.pdf-element-readonly-edit {
  cursor: default;
  pointer-events: auto;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
}
.pdf-element.pdf-element-readonly-edit:hover {
  background: transparent !important;
  border: none !important;
}

/* Dragging element (follows mouse) */
.pdf-dragging-element {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.85;
  transform: translate(-50%, -50%);
  border: 1px dashed var(--primary-blue);
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 12px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: crosshair;
  max-width: 300px;
  word-wrap: break-word;
  /* Disable transitions for instant movement */
  transition: none;
  will-change: left, top;
}

.pdf-dragging-element.pdf-image-element {
  padding: 4px;
  border-style: solid;
  background: rgba(255, 255, 255, 0.95);
  max-width: none;
}

/* Right-Click Context Menu */
.context-menu {
  position: fixed;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  min-width: 180px;
  padding: 4px 0;
}

.context-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #333;
  transition: background 0.15s;
}

.context-menu-item:hover {
  background: #f0f0f0;
}

.context-menu-item i {
  width: 18px;
  text-align: center;
  color: #666;
}

/* Configuration Modal */
.config-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.config-modal.active {
  display: flex;
}

.config-content {
  background: var(--ed-panel);
  color: var(--ed-ink);
  border: 1px solid var(--ed-line);
  border-radius: var(--ed-radius-lg, 14px);
  box-shadow: 0 24px 60px -20px rgba(28, 21, 18, 0.5);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.config-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--ed-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-header h3 {
  margin: 0;
  font-family: var(--ed-serif);
  font-weight: 600;
  font-size: 19px;
  color: var(--ed-ink);
}

.config-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted-text, #666);
  padding: 4px 8px;
}

.config-close:hover {
  color: var(--text-color, #333);
}

.config-body {
  padding: 20px;
  flex: 1;
}

/* Config Tabs */
.config-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.config-tab {
  background: transparent;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted-text, #666);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  flex: 1 1 0;
  justify-content: center;
}

.config-tab:hover {
  color: var(--text-color, #333);
  background: var(--item-hover-bg, #f5f5f5);
}

.config-tab.active {
  color: var(--primary-blue, var(--primary-blue));
  border-bottom-color: var(--primary-blue, var(--primary-blue));
  font-weight: 500;
}

.config-tab-content {
  display: none;
}

.config-tab-content.active {
  display: block;
}

.config-preview {
  background: var(--card-bg, #f9f9f9);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: var(--radius-small, 4px);
  padding: 16px;
  margin-bottom: 20px;
}

.config-preview-label {
  font-size: 12px;
  color: var(--muted-text, #666);
  margin-bottom: 8px;
}

.config-preview-box {
  background: var(--input-bg, #fff);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: var(--radius-small, 4px);
  padding: 20px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-color, #333);
}

body.theme-dark .config-preview-label {
  color: var(--muted-text, #b8b8b8) !important;
}

body.theme-dark .config-preview-box {
  background: #f0f0f0 !important;
  /* No !important on color — Add Signature / Add Initials set preview color via JS */
  color: #333;
}

/* Add Signature / Add Initials modal tabs — segmented pill (mock aesthetic) */
.add-signature-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border-bottom: none;
  border-radius: 10px;
  background: var(--ed-seg);
}

.add-signature-tab {
  background: transparent;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ed-sub);
  border-radius: 7px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  flex: 1 1 0;
  justify-content: center;
}

.add-signature-tab:hover {
  color: var(--ed-ink) !important;
  background: transparent !important;
}

.add-signature-tab.active {
  color: var(--ed-accent) !important;
  background: var(--ed-panel) !important;
  box-shadow: 0 1px 3px rgba(28, 21, 18, 0.08) !important;
  font-weight: 600 !important;
}

body.theme-dark .add-signature-tab.active {
  color: var(--ed-accent) !important;
  background: var(--ed-panel) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
  font-weight: 600 !important;
}

.add-signature-tab-content {
  display: none;
}

.add-signature-tab-content.active {
  display: block;
}

.sig-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px dashed var(--border-color, #ccc);
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--item-bg, #f9f9f9);
  transition:
    border-color 0.2s,
    background 0.2s;
}

.sig-upload-dropzone.drag-over {
  border-color: var(--primary-color, var(--primary-blue));
  background: color-mix(
    in srgb,
    var(--primary-color, var(--primary-blue)) 8%,
    transparent
  );
}

.sig-upload-dropzone > i {
  font-size: 28px;
  color: var(--muted-text, #888);
}

.sig-upload-dropzone p {
  margin: 0;
  color: var(--muted-text, #888);
  font-size: 13px;
}

.sig-upload-or {
  font-size: 12px;
  color: var(--muted-text, #888);
}

.sig-upload-hint {
  font-size: 11px;
  opacity: 0.7;
}

.sig-upload-label {
  cursor: pointer;
}

.sig-upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 8px;
  background: var(--item-bg, #f9f9f9);
}

.sig-upload-preview img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 4px;
}

.add-signature-modal .config-content,
.add-initials-modal .config-content {
  max-width: 420px;
  overflow: visible;
}

.signature-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.signature-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.signature-mode-btn.active {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
}

.signature-draw-options {
  border: 1px dashed #c7d3e3;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 16px;
  background: #f8fbff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signature-draw-options[hidden] {
  display: none;
}

.signature-canvas-wrapper {
  border: 1px solid #d0dcea;
  border-radius: 6px;
  overflow: hidden;
  background-image:
    linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
}

#signatureCanvas {
  width: 100%;
  height: 220px;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: transparent;
}

.signature-draw-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.signature-draw-toolbar label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #333;
}

#signatureStrokeWidth {
  width: 180px;
}

.signature-clear-btn {
  border-color: #d93025;
  color: #d93025;
}

.signature-clear-btn:hover {
  background: rgba(217, 48, 37, 0.1);
}

.signature-help {
  font-size: 12px;
  color: var(--muted-text, #666);
}

.config-option {
  margin-bottom: 16px;
}

.config-option label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--heading-color, #333);
  margin-bottom: 6px;
}

.config-option input,
.config-option select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color, #d0d0d0);
  border-radius: var(--radius-small, 3px);
  font-size: 14px;
  background: var(--input-bg, #fff);
  color: var(--text-color, #333);
}

.config-option input[type='color'] {
  height: 40px;
  cursor: pointer;
}

.config-font-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.config-font-row select {
  flex: 1;
  min-width: 0;
}

.config-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-color, #d0d0d0);
  background: var(--container-bg, #fff);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-color, #333);
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.config-checkbox-label:hover {
  background: var(--item-hover-bg, #f0f0f0);
  border-color: var(--primary-blue, var(--primary-blue));
}

.config-checkbox-label:has(input:checked) {
  background: var(--primary-blue, var(--primary-blue));
  border-color: var(--primary-blue, var(--primary-blue));
  color: #fff;
}

.config-checkbox-label input[type='checkbox'] {
  display: none;
}

.config-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  background: var(--card-bg, transparent);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.config-footer-actions {
  display: flex;
  gap: 8px;
}

/* Editor confirm modal (reusable confirm/alert style) */
.editor-confirm-modal .editor-confirm-content {
  max-width: 400px;
}
.editor-confirm-message {
  margin: 0;
  font-size: 15px;
  color: var(--text-color, #333);
  line-height: 1.5;
}

/* Editor password modal (password-protected PDFs) */
.editor-password-modal .editor-password-content {
  max-width: 400px;
}
.editor-password-message {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--text-color, #333);
  line-height: 1.5;
}
.editor-password-error {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--error-color, #c00);
  line-height: 1.4;
}

/* Editor Download & Protect modal */
.editor-download-protect-modal .editor-download-protect-content {
  max-width: 420px;
}
.editor-download-protect-message {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--text-color, #333);
  line-height: 1.5;
}
.editor-protect-permissions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.editor-protect-permission {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.editor-protect-spoiler {
  margin-top: 12px;
}
.editor-protect-spoiler-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 0;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-color, #333);
  cursor: pointer;
  text-align: left;
}
.editor-protect-spoiler-toggle:hover {
  color: var(--ed-accent);
}
.editor-protect-spoiler-icon {
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.editor-protect-spoiler-toggle[aria-expanded='true']
  .editor-protect-spoiler-icon {
  transform: rotate(180deg);
}
.editor-protect-spoiler-content {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color, #e0e0e0);
}

.btn {
  padding: 10px 16px;
  border: 1px solid var(--ed-line);
  border-radius: var(--ed-radius, 10px);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--ed-panel);
  color: var(--ed-ink);
  transition: all 0.2s;
}

.btn:hover {
  background: var(--ed-hover);
}

.btn-primary-modal {
  background: var(--ed-accent) !important;
  color: #fff !important;
  border: 1px solid transparent !important;
  box-shadow: var(--ed-shadow-accent);
}

.btn-primary-modal:hover {
  background: var(--ed-accent-ink) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Protect-modal permission rows rendered as pill toggle switches (mock) */
.editor-protect-permissions {
  flex-direction: column;
  gap: 11px;
}

.editor-protect-permission {
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--ed-ink);
}

.editor-protect-permission input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  order: 2;
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 100px;
  background: var(--ed-line-strong);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  transition: background 0.18s ease;
}

.editor-protect-permission input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ed-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.editor-protect-permission input[type='checkbox']:checked {
  background: var(--ed-accent);
}

.editor-protect-permission input[type='checkbox']:checked::after {
  transform: translateX(16px);
}

.btn-undo-signature,
.btn-clear-signature {
  background: var(--container-bg, #fff) !important;
  border: 1px solid var(--border-color, #d0d0d0) !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
}

.btn-undo-signature {
  color: var(--text-color, #333) !important;
}

.btn-undo-signature:hover {
  background: var(--item-hover-bg, #f5f5f5) !important;
  border-color: var(--primary-blue, var(--primary-blue)) !important;
  color: var(--primary-blue, var(--primary-blue)) !important;
}

.btn-clear-signature {
  color: #c62828 !important;
}

.btn-clear-signature:hover {
  background: #fdf0f0 !important;
  border-color: #c62828 !important;
}

.signature-mode-footer-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100%;
  color: #666;
}

.loading-title {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  text-align: center;
}

.loading-subtext {
  margin-top: 6px;
  font-size: 12px;
  color: #555;
  text-align: center;
}

.editor-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(229, 229, 229, 0.92);
  z-index: 20;
  padding: 24px;
}

.editor-loading[hidden] {
  display: none;
}

.loading-progress {
  width: 240px;
  height: 10px;
  background: #dfe6ef;
  border-radius: 999px;
  margin-top: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid #c5d0df;
}

.loading-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-blue), #ff8a5b);
  transition: width 0.2s ease;
}

.loading-progress.loading-progress--indeterminate .loading-progress-fill {
  width: 40%;
  animation: loading-progress-indeterminate 1.2s linear infinite;
}

@keyframes loading-progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(250%);
  }
}

.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary-blue);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Sidebar - Page Selector */
.sidebar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  overflow-x: hidden;
  position: relative; /* Ensure proper stacking context */
}

.sidebar-section h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ed-ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 0 4px;
}

.sidebar-pages-heading .sidebar-page-count {
  font-weight: 700;
  font-size: 11px;
  color: var(--ed-sub);
  text-transform: none;
  letter-spacing: normal;
}

/* Extract page modal (thumbnails → ⋮ → Extract page) — theme-aware text */
.extract-page-modal-body {
  text-align: center;
  padding: 30px 20px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.extract-page-modal-prompt {
  margin: 0;
  font-size: 15px;
  color: var(--text-color, #333);
}

.page-thumbnail {
  padding: 0;
  background: transparent;
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  user-select: none;
  overflow: visible;
  cursor: pointer;
}

/* Buttons should have normal cursor */
.page-thumbnail-buttons {
  cursor: default; /* Normal cursor for buttons */
}

/* Hover and active states are now on the wrapper */

.page-thumbnail.dragging .page-thumbnail-wrapper {
  opacity: 0.5;
}

.page-thumbnail.drop-before::before,
.page-thumbnail.drop-after::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  background: var(--ed-accent);
  border-radius: 2px;
  z-index: 10;
  pointer-events: none;
}

.page-thumbnail.drop-before::before {
  top: -5px;
}

.page-thumbnail.drop-after::after {
  bottom: -5px;
}

.page-thumbnail-wrapper {
  position: relative;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  background: var(--ed-panel);
  border: 2px solid var(--ed-line);
  padding: 6px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
  box-sizing: border-box;
}

.page-thumbnail:hover .page-thumbnail-wrapper {
  border-color: var(--ed-line-strong);
}

.page-thumbnail.active .page-thumbnail-wrapper {
  border-color: var(--ed-accent);
  box-shadow: 0 8px 18px -8px rgba(var(--ed-accent-rgb), 0.45);
}

.page-thumbnail.active .page-thumbnail-label {
  color: var(--ed-accent);
  border-color: color-mix(in srgb, var(--ed-accent) 30%, transparent);
  font-weight: 600;
}

.page-thumbnail-wrapper canvas,
.page-thumbnail canvas {
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer !important;
}

/* Adjust wrapper for rotated pages (90 or 270 degrees) */
.page-thumbnail.rotated-landscape .page-thumbnail-wrapper {
  /* When rotated 90/270, the canvas dimensions are swapped */
  /* The viewport already accounts for rotation, so canvas will fit */
}

.page-thumbnail-buttons {
  display: flex;
  flex-direction: row; /* Buttons in a row below the page box */
  gap: 6px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition:
    opacity 0.2s ease,
    max-height 0.2s ease;
  flex-shrink: 0; /* Don't shrink */
  justify-content: center; /* Center the buttons */
  align-items: center;
  padding: 0;
  margin: 0;
  transform: none;
}

/* Show buttons only when page is active/selected — mock's floating white pill */
.page-thumbnail.active .page-thumbnail-buttons {
  opacity: 1;
  max-height: 48px; /* Enough height for button + padding */
  gap: 3px;
  padding: 4px;
  background: var(--ed-panel);
  border: 1px solid var(--ed-line);
  border-radius: 11px;
  box-shadow: 0 2px 8px rgba(28, 21, 18, 0.07);
}

.page-thumbnail-btn {
  width: 30px;
  height: 30px;
  border: none !important;
  background: transparent !important;
  color: var(--ed-ink) !important;
  margin: 0 !important;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  padding: 0;
  flex-shrink: 0;
  transform: none;
  box-shadow: none !important;
}

.page-thumbnail-btn svg {
  fill: currentColor !important;
}

.page-thumbnail-btn:hover {
  background: var(--ed-hover) !important;
  color: var(--ed-accent) !important;
  border-color: transparent !important;
  box-shadow: none !important;
  transform: none;
}

.page-thumbnail-btn.page-thumbnail-remove:hover {
  background: var(--ed-danger-soft) !important;
  color: var(--ed-danger) !important;
}

.pdf-editor-page button {
  transform: none;
}

.pdf-editor-page button:hover {
  transform: none;
}

.page-thumbnail-btn i,
.page-thumbnail-btn svg {
  pointer-events: none;
  display: block;
}

/* Context menu button is now in the buttons container, no special styling needed */

.page-thumbnail-label {
  text-align: center;
  font-size: 13px;
  color: var(--ed-sub);
  margin-top: 8px;
  font-weight: 600;
  border-top: none;
  padding-top: 2px;
  width: 100%; /* Full width of wrapper */
  background: transparent;
}

#pageThumbnailsContainer {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 16px 12px;
  align-content: flex-start;
}

/* Page Context Menu - visible by default, animate only on hide */
.page-context-menu {
  position: fixed;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  min-width: 200px;
  padding: 4px 0;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.page-context-menu.is-hidden {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
}

.page-context-menu-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #333;
  transition: background 0.15s;
}

.page-context-menu-item:hover {
  background: #f0f0f0;
}

.page-context-menu-item.danger {
  color: #c00;
}

.page-context-menu-item.danger:hover {
  background: #fee;
}

.page-context-menu-item i {
  width: 16px;
  text-align: center;
}

.page-context-menu-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

body.theme-dark .page-context-menu {
  background: var(--container-bg, #1e1e1e);
  border-color: var(--border-color, #444);
  box-shadow: var(--shadow-medium, 0 4px 12px rgba(0, 0, 0, 0.45));
}

body.theme-dark .page-context-menu-item {
  color: var(--text-color, #e8e8e8);
}

body.theme-dark .page-context-menu-item:hover {
  background: var(--item-hover-bg, rgba(255, 255, 255, 0.08));
}

body.theme-dark .page-context-menu-item.danger {
  color: #ff8a80;
}

body.theme-dark .page-context-menu-item.danger:hover {
  background: rgba(229, 57, 53, 0.22);
}

body.theme-dark .page-context-menu-separator {
  background: var(--border-color, #444);
}

/* Form field elements detected from PDF annotations */
.pdf-element.pdf-element-form-field {
  background: rgba(120, 170, 255, 0.25);
  border: 2px solid rgba(70, 120, 230, 0.85);
  border-radius: 2px;
  cursor: text;
}
.pdf-element.pdf-element-form-field:hover {
  background: rgba(120, 170, 255, 0.4);
  border-color: rgba(50, 100, 220, 1);
}
.pdf-element.pdf-element-form-field.selected {
  background: rgba(120, 170, 255, 0.45);
  border-color: rgba(50, 100, 220, 1);
}

/* Checkbox form field — invisible until hovered or checked */
.pdf-element.pdf-element-form-checkbox {
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdf-element.pdf-element-form-checkbox:hover {
  background: rgba(120, 170, 255, 0.2);
  border: 1px dashed rgba(70, 120, 230, 0.7);
}
.pdf-element.pdf-element-form-checkbox.checked {
  background: transparent;
  border: 1px dashed rgba(70, 120, 230, 0.4);
}
/* Native checkbox rendering — no custom glyph or theming so it matches a
   normal PDF viewer's checkbox. */
.pdf-element.pdf-element-form-checkbox .form-checkbox-mark {
  appearance: auto;
  -webkit-appearance: checkbox;
  /* The checkbox sits on the white PDF page, so keep it light even when the
     app is in dark mode (native controls follow the page color-scheme). */
  color-scheme: light;
  margin: 0;
  padding: 0;
  pointer-events: none;
  user-select: none;
}

input[type='file'] {
  display: none;
}

/* ─── SEO Content Sections ─────────────────────────────────────────────── */

/* Header */
.editor-seo-header {
  width: 100%;
  max-width: 760px;
  text-align: center;
  padding: 16px 16px 12px;
}

.editor-seo-eyebrow {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ed-accent-ink);
  margin-bottom: 18px;
}

body.theme-dark .editor-seo-eyebrow {
  color: var(--ed-accent);
}

.editor-seo-title {
  font-family: var(--ed-serif);
  font-size: 52px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.04;
  color: var(--ed-ink);
  margin: 0 0 18px !important;
}

body.theme-dark .editor-seo-title {
  color: var(--ed-ink);
}

.editor-seo-desc {
  font-size: 17px;
  color: var(--ed-sub);
  line-height: 1.55;
  margin: 0 auto !important;
  max-width: 720px;
}

body.theme-dark .editor-seo-desc {
  color: var(--ed-sub);
}

/* Footer wrapper */
.editor-seo-footer a {
  color: var(--ed-accent);
  text-decoration: none;
}

.editor-seo-footer {
  width: 100%;
  max-width: 960px;
  text-align: left;
  padding: 44px 16px 56px;
}

/* Section scaffold */
.editor-seo-section {
  margin-bottom: 56px !important;
  padding: 0 !important;
}

.editor-seo-section-last {
  margin-bottom: 0 !important;
  padding-top: 24px !important;
}

.editor-seo-overline {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ed-accent-ink);
  margin-bottom: 10px;
}

body.theme-dark .editor-seo-overline {
  color: var(--ed-accent);
}

.editor-seo-section h2 {
  font-family: var(--ed-serif);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ed-ink);
  margin: 0 0 28px !important;
  padding: 0 !important;
}

body.theme-dark .editor-seo-section h2 {
  color: var(--ed-ink);
}

/* ── Section 1: Capabilities — card grid (mock aesthetic) ── */
.editor-seo-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  border-top: none;
  margin: 0 !important;
  padding: 0 !important;
}

.editor-seo-feature {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 24px;
  border: 1px solid var(--ed-line);
  border-radius: 16px;
  background: var(--ed-panel);
  box-shadow: 0 1px 3px rgba(28, 21, 18, 0.04);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.editor-seo-feature:hover {
  border-color: color-mix(in srgb, var(--ed-accent) 40%, transparent);
  box-shadow: 0 14px 30px -18px rgba(28, 21, 18, 0.28);
}

.editor-seo-feature dt {
  font-size: 17px;
  font-weight: 700;
  color: var(--ed-ink);
  letter-spacing: -0.01em;
  padding: 0;
  margin: 0;
}

.editor-seo-feature dt a {
  color: var(--ed-accent) !important;
  font-weight: inherit !important;
  text-decoration: none !important;
}

.editor-seo-feature dd {
  font-size: 14px;
  color: var(--ed-sub);
  line-height: 1.55;
  margin: 0;
  padding: 0;
}

.editor-seo-feature dd a {
  color: var(--ed-accent) !important;
}

@media (max-width: 900px) {
  .editor-seo-features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .editor-seo-features {
    grid-template-columns: 1fr;
  }
}

/* ── Section 2: How it works — dark workflow panel with red badges ── */
.editor-seo-section:has(.editor-seo-steps) {
  background: #1c1512;
  border-radius: 22px;
  padding: 44px 44px 40px !important;
  position: relative;
  overflow: hidden;
}

.editor-seo-section:has(.editor-seo-steps)::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -40px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(var(--ed-accent-rgb), 0.32),
    transparent 70%
  );
  pointer-events: none;
}

.editor-seo-section:has(.editor-seo-steps) > * {
  position: relative;
}

.editor-seo-section:has(.editor-seo-steps) .editor-seo-overline {
  color: #f2988c;
}

.editor-seo-section:has(.editor-seo-steps) h2 {
  color: #fbf5f2;
}

.editor-seo-steps {
  list-style: none !important;
  counter-reset: loo-step;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin: 0 !important;
  padding: 0 !important;
  border-top: none;
}

.editor-seo-steps li {
  counter-increment: loo-step;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-bottom: none;
}

.editor-seo-steps li::before {
  content: counter(loo-step);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ed-accent);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
}

.editor-seo-step-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 0;
}

.editor-seo-step-body strong {
  font-size: 16px;
  font-weight: 700;
  color: #fbf5f2;
  letter-spacing: -0.01em;
}

.editor-seo-step-body span {
  font-size: 13.5px;
  color: #b7a8a1;
  line-height: 1.55;
}

@media (max-width: 860px) {
  .editor-seo-steps {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .editor-seo-steps {
    grid-template-columns: 1fr;
  }
  .editor-seo-section:has(.editor-seo-steps) {
    padding: 32px 24px !important;
  }
}

/* ── Section 3: Philosophy — 4-col, no chrome ── */
.editor-seo-why {
  list-style: none !important;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 32px !important;
  margin: 0 !important;
  padding: 0 !important;
}

.editor-seo-why li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: none;
  position: relative;
}

.editor-seo-why li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 3px;
  border-radius: 3px;
  background: var(--ed-accent);
}

.editor-seo-why li strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ed-ink);
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.editor-seo-why li span {
  font-size: 13.5px;
  color: var(--ed-sub);
  line-height: 1.55;
}

/* Why section: student copy on the left, campus photo on the right */
.editor-seo-why-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 48px;
  align-items: center;
}

.editor-seo-why-grid .editor-seo-why {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 26px 32px !important;
  margin-top: 26px !important;
}

.editor-seo-why-media {
  width: 100%;
}

.editor-seo-why-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  object-fit: cover;
  display: block;
}

.editor-seo-why-photo--placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1.5px dashed var(--ed-line-strong);
  background:
    radial-gradient(
      120% 120% at 50% 0%,
      var(--ed-accent-soft),
      transparent 62%
    ),
    var(--ed-surface);
  color: var(--ed-sub);
}

.editor-seo-why-photo--placeholder svg {
  color: var(--ed-accent);
  opacity: 0.75;
}

.editor-seo-why-photo--placeholder span {
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 820px) {
  .editor-seo-why-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .editor-seo-why-media {
    order: -1;
  }
}

@media (max-width: 520px) {
  .editor-seo-why-grid .editor-seo-why {
    grid-template-columns: 1fr !important;
  }
}

/* ── Section 4: FAQ — rounded accordion cards (mock aesthetic) ── */
.editor-seo-footer .collapse-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* The FAQ cards here are now styled by the unified `.collapse-faq` skin in
   styles.css (reworked design, shared across the whole site). The editor-scoped
   skin was removed so the editor FAQ stays in sync with the rest. */

/* Responsive */
@media (max-width: 720px) {
  .editor-seo-title {
    font-size: 36px;
  }
  .editor-seo-why {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px 32px !important;
  }
}

@media (max-width: 480px) {
  .editor-seo-title {
    font-size: 30px;
    letter-spacing: -0.02em;
  }
  .editor-seo-why {
    grid-template-columns: 1fr !important;
  }
}
