.pdf-editor{max-width:1200px;margin:36px auto;padding:0 18px}.editor-actions,.editor-toolbar{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin:16px 0}.editor-actions button,.upload-button,.editor-toolbar button{border:1px solid #ccc;background:white;border-radius:8px;padding:10px 14px;cursor:pointer}.upload-button{background:#2563eb;color:white}.editor-actions button:disabled,.editor-toolbar button:disabled{opacity:.5;cursor:not-allowed}.editor-toolbar{padding:14px;background:#f3f5f9;border-radius:12px}.editor-toolbar label{display:flex;align-items:center;gap:5px;font-size:14px}.editor-toolbar input[type=number]{width:64px}.editor-toolbar input,.editor-toolbar select{padding:6px}.pdf-pages{background:#e6e9ee;padding:24px;min-height:180px;overflow:auto;border-radius:12px}.pdf-page{position:relative;margin:0 auto 25px;background:white;box-shadow:0 4px 16px #0002;max-width:100%}.pdf-page img{display:block;width:100%;height:100%;pointer-events:none}.text-element{position:absolute;box-sizing:border-box;border:1px solid transparent;cursor:pointer;white-space:nowrap;overflow:visible;font-family:Arial,sans-serif;line-height:1.1;padding:0;background:transparent;color:transparent}.text-element:hover{border:1px dashed #3b82f6;background:#3b82f612}.text-element.selected{border:2px solid #2563eb;background:#2563eb16}.text-element.new{color:#111;background:#fff8}.editor-note{color:#666;font-size:13px;margin-top:15px}#editor-status{min-height:22px;color:#a33;font-size:14px}

/* Inline text editing: make the active span visible and editable on the page. */
.text-element.selected{color:#111;background:#fff;border:1px solid #2563eb;outline:none;min-width:32px;min-height:1.2em;white-space:pre;overflow:visible;z-index:5;cursor:text;}
.text-element.selected:focus{outline:2px solid #2563eb;outline-offset:1px;}
.text-element.new{min-width:32px;}

/* Keep modified text visible after deselection. White backing covers the old preview text. */
.text-element.changed { color:#111; background:#fff; z-index:2; min-width:32px; min-height:1.2em; white-space:pre; }
.text-element.changed.selected { z-index:5; }

/* Drag by the move handle; typing in the text itself remains unchanged. */
.text-element { position:absolute; }
.text-move-handle {
  display:none; position:absolute; top:-24px; left:-1px;
  width:24px; height:22px; padding:0; border:1px solid #2563eb;
  border-radius:5px; background:#2563eb; color:#fff; font-size:16px;
  line-height:20px; text-align:center; cursor:grab; touch-action:none;
  user-select:none; z-index:12;
}
.text-element:hover .text-move-handle,
.text-element.selected .text-move-handle { display:block; }
.text-move-handle:active { cursor:grabbing; }
.text-element.dragging { z-index:20; }

/* Hide the source text at its original coordinates after a move.
   Keep the mask below edited text boxes and above the PDF preview. */
.original-text-mask {
  position:absolute; background:#fff; z-index:1; pointer-events:none;
}

/* Font preview for the font-family selector. */
#font-family option[value="Helvetica"]{font-family:Arial,Helvetica,sans-serif}
#font-family option[value="Times"]{font-family:"Times New Roman",Times,serif}
#font-family option[value="Courier"]{font-family:"Courier New",Courier,monospace}

/* Bundled fonts: same files used in PDF export */
@font-face{font-family:"MDF Arial";src:url("/static/fonts/Arimo-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Arial";src:url("/static/fonts/Arimo-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Arial";src:url("/static/fonts/Arimo-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Arial";src:url("/static/fonts/Arimo-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Calibri";src:url("/static/fonts/Carlito-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Calibri";src:url("/static/fonts/Carlito-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Calibri";src:url("/static/fonts/Carlito-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Calibri";src:url("/static/fonts/Carlito-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Roboto";src:url("/static/fonts/Roboto-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Roboto";src:url("/static/fonts/Roboto-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Roboto";src:url("/static/fonts/Roboto-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Roboto";src:url("/static/fonts/Roboto-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Open Sans";src:url("/static/fonts/OpenSans-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Open Sans";src:url("/static/fonts/OpenSans-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Open Sans";src:url("/static/fonts/OpenSans-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Open Sans";src:url("/static/fonts/OpenSans-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Montserrat";src:url("/static/fonts/Lato-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Montserrat";src:url("/static/fonts/Lato-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Montserrat";src:url("/static/fonts/Lato-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Montserrat";src:url("/static/fonts/Lato-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Lato";src:url("/static/fonts/Lato-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Lato";src:url("/static/fonts/Lato-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Lato";src:url("/static/fonts/Lato-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Lato";src:url("/static/fonts/Lato-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Verdana";src:url("/static/fonts/DejaVuSans-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Verdana";src:url("/static/fonts/DejaVuSans-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Verdana";src:url("/static/fonts/DejaVuSans-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Verdana";src:url("/static/fonts/DejaVuSans-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Helvetica";src:url("/static/fonts/Arimo-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Helvetica";src:url("/static/fonts/Arimo-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Helvetica";src:url("/static/fonts/Arimo-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Helvetica";src:url("/static/fonts/Arimo-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Times New Roman";src:url("/static/fonts/Tinos-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Times New Roman";src:url("/static/fonts/Tinos-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Times New Roman";src:url("/static/fonts/Tinos-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Times New Roman";src:url("/static/fonts/Tinos-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Georgia";src:url("/static/fonts/NotoSerif-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Georgia";src:url("/static/fonts/NotoSerif-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Georgia";src:url("/static/fonts/NotoSerif-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Georgia";src:url("/static/fonts/NotoSerif-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Garamond";src:url("/static/fonts/EBGaramond12-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Garamond";src:url("/static/fonts/EBGaramond12-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Garamond";src:url("/static/fonts/EBGaramond12-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Garamond";src:url("/static/fonts/EBGaramond12-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Merriweather";src:url("/static/fonts/NotoSerif-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Merriweather";src:url("/static/fonts/NotoSerif-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Merriweather";src:url("/static/fonts/NotoSerif-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Merriweather";src:url("/static/fonts/NotoSerif-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Playfair Display";src:url("/static/fonts/EBGaramond12-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Playfair Display";src:url("/static/fonts/EBGaramond12-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Playfair Display";src:url("/static/fonts/EBGaramond12-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Playfair Display";src:url("/static/fonts/EBGaramond12-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Courier New";src:url("/static/fonts/Cousine-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Courier New";src:url("/static/fonts/Cousine-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Courier New";src:url("/static/fonts/Cousine-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Courier New";src:url("/static/fonts/Cousine-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Source Code Pro";src:url("/static/fonts/DejaVuSansMono-0.ttf") format("truetype");font-style:normal;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Source Code Pro";src:url("/static/fonts/DejaVuSansMono-1.ttf") format("truetype");font-style:normal;font-weight:700;font-display:swap;}
@font-face{font-family:"MDF Source Code Pro";src:url("/static/fonts/DejaVuSansMono-2.ttf") format("truetype");font-style:italic;font-weight:400;font-display:swap;}
@font-face{font-family:"MDF Source Code Pro";src:url("/static/fonts/DejaVuSansMono-3.ttf") format("truetype");font-style:italic;font-weight:700;font-display:swap;}

/* Selected text boxes can be resized using the lower-right corner. */
.text-resize-handle{
  display:none;position:absolute;right:-7px;bottom:-7px;
  width:14px;height:14px;padding:0;border:2px solid #fff;
  border-radius:3px;background:#2563eb;box-shadow:0 0 0 1px #2563eb;
  cursor:nwse-resize;touch-action:none;user-select:none;z-index:15;
}
.text-element.selected .text-resize-handle,.text-element:hover .text-resize-handle{display:block;}
.text-element.resizing{z-index:20;}
/* Keep the box boundary visible while sizing, even when text extends beyond it. */
.text-element.resizing{outline:1px dashed #2563eb;}


/* Upload-first page and visible download action */
.pdf-editor [hidden]{display:none!important}
.editor-upload-stage{text-align:center;max-width:800px;margin:45px auto 65px}
.editor-upload-stage h1{margin-bottom:12px}
.editor-upload-stage>p{color:#64748b;line-height:1.6}
.editor-upload-card{border:2px dashed #b8c8e0;border-radius:18px;background:#f8faff;padding:48px 20px;margin-top:28px;display:flex;align-items:center;flex-direction:column;gap:14px}
.editor-upload-icon{font-size:44px;line-height:1}
.editor-primary-upload{display:inline-flex;align-items:center;justify-content:center;min-height:48px;background:#2563eb;color:#fff!important;padding:12px 28px;border-radius:10px;font-weight:700;cursor:pointer}
.editor-primary-upload:hover{background:#1d4ed8}
.editor-upload-card p{margin:0;color:#64748b;font-size:13px}
.editor-file-input{position:absolute;width:1px;height:1px;opacity:0;overflow:hidden;clip-path:inset(50%)}
.editor-file-input:focus-visible+.editor-primary-upload{outline:3px solid #93c5fd}
.editor-workspace-heading{display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap}
.editor-workspace-heading h1{margin:0}
.editor-file-name{color:#64748b;margin:6px 0 0;overflow-wrap:anywhere}
.editor-change-file{cursor:pointer;text-decoration:underline;color:#2563eb;font-weight:600}
.editor-help{font-size:14px;color:#64748b;margin:4px 0 14px}
.pdf-editor .editor-actions{position:sticky;top:0;z-index:30;background:#fff;padding:12px 0;border-bottom:1px solid #e2e8f0}
.pdf-editor .editor-actions .editor-download-button{margin-left:auto;display:inline-flex!important;visibility:visible!important;align-items:center;justify-content:center;min-height:44px;background:linear-gradient(135deg,#2563eb,#7c3aed)!important;border:1px solid #2563eb!important;border-radius:12px!important;color:#fff!important;font-weight:800!important;opacity:1;box-shadow:0 4px 12px rgba(37,99,235,.18)}
.pdf-editor .editor-actions .editor-download-button:hover:not(:disabled){background:linear-gradient(135deg,#1d4ed8,#6d28d9)!important}
.pdf-editor .editor-actions .editor-download-button:disabled{opacity:.55!important;cursor:wait}
#editor-status:not(:empty){margin:10px 0;color:#334155}
@media(max-width:640px){.editor-upload-card{padding:36px 16px}.pdf-editor .editor-actions .editor-download-button{width:100%;margin-left:0}.pdf-editor .editor-actions{position:static}}

/* Transparent editing boxes; only the fixed original-text mask is opaque. */
.pdf-editor .text-element,
.pdf-editor .text-element:hover,
.pdf-editor .text-element.selected,
.pdf-editor .text-element.changed,
.pdf-editor .text-element.new { background: transparent !important; }


/* Force transparent text boxes in all editing states */
.pdf-editor .text-element,
.pdf-editor .text-element:hover,
.pdf-editor .text-element.selected,
.pdf-editor .text-element.changed,
.pdf-editor .text-element.new,
.pdf-editor .text-element.dragging,
.pdf-editor .text-element.resizing {
    background: transparent !important;
}



/* Ensure editor button labels are visible */
.pdf-editor .editor-actions button:not(.editor-download-button),
.pdf-editor .editor-toolbar button {
    color: #0f172a !important;
    background: #ffffff;
    font-weight: 600;
}

/* Button hover state */
.pdf-editor .editor-actions button:not(.editor-download-button):hover:not(:disabled),
.pdf-editor .editor-toolbar button:hover:not(:disabled) {
    background: #eff6ff;
    border-color: #2563eb;
}

/* Disabled button state */
.pdf-editor .editor-actions button:disabled,
.pdf-editor .editor-toolbar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Add text icon and label */
.pdf-editor #add-text { display:inline-flex; align-items:center; justify-content:center; gap:8px; }
.pdf-editor #add-text .add-text-icon { color:#2563eb; flex-shrink:0; }
