/* PDF editor: toolbar, page stack, overlay objects. */
.editor-page { background: var(--bg-elev); }
.editor-page #editor-hero { padding: 54px 16px 42px; }
.editor-page #editor-hero h1 { font-size: clamp(30px, 4vw, 40px); margin-bottom: 6px; }
.editor-page #editor-hero p { font-size: clamp(18px, 2.4vw, 24px); }
.editor-entry-shell { max-width: none; background: var(--bg-sunken); padding: 44px 20px 24px; border-radius: 50% 50% 0 0 / 36px 36px 0 0; }
.editor-entry-shell .workspace { margin: 0 auto; }
.editor-entry-shell .dropzone { border: 2px solid transparent; background: transparent; padding: 36px 12px 22px; }
.editor-entry-shell .dropzone.drag { border-color: #008f6b; }
.blank-document-link { display: block; margin: 12px auto 0; border: 0; background: none; color: #008f6b; cursor: pointer; font-size: 17px; padding: 8px; text-decoration: underline; text-underline-offset: 4px; }
.editor-privacy { color: var(--ink-3); margin-top: 30px; font-size: 14px; }
.editor-privacy p { margin: 5px 0; }
.editor-privacy a { color: inherit; text-decoration: underline; }
.editor { position: relative; display: flex; flex-direction: column; min-height: calc(100vh - 62px); background: var(--bg-sunken); }
.editing #editor-hero, .editing .site-footer, .editing .steps, .editing .related, .editing .recent { display: none; }
.editor-page.editing #editor-hero { display: block; padding: 20px 16px 24px; }
.editor-page.editing #editor-hero h1 { font-size: 30px; }
.editor-page.editing #editor-hero p { font-size: 18px; }
.editing .editor-entry-shell { padding: 0; border-radius: 0; }
.ed-bar {
  position: sticky; top: 62px; z-index: 30; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px; align-items: center;
  padding: 8px 12px; background: var(--bg-elev); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.ed-group { display: flex; flex: 0 0 auto; gap: 2px; padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--line); }
.ed-group:last-child { border-right: 0; }
.ed-right { margin-left: auto; align-items: center; }
.ed-bar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 48px; padding: 6px 5px 5px; border: 0; border-radius: 9px; flex: none;
  background: none; color: var(--ink-2); cursor: pointer; font-size: 11.5px; font-weight: 550;
}
.ed-bar button:hover { background: var(--bg-sunken); color: var(--ink); }
.ed-bar button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); }
.ed-bar button .icon { width: 19px; height: 19px; }
@media (min-width: 761px) {
  .ed-bar { flex-wrap: wrap; justify-content: center; gap: 6px; padding: 12px 18px; background: var(--bg-sunken); box-shadow: none; }
  .ed-group { gap: 0; padding-right: 0; border-right: 0; }
  .ed-bar button { flex-direction: row; gap: 6px; min-height: 42px; border: 1px solid #1586d7; border-radius: 0; color: #0878bd; background: var(--bg-elev); padding: 8px 10px; font-size: 13px; }
  .ed-group button + button { border-left: 0; }
  .ed-group button:first-child { border-radius: 4px 0 0 4px; }
  .ed-group button:last-child { border-radius: 0 4px 4px 0; }
  .ed-bar button[aria-pressed="true"] { color: #006caa; background: #dcefff; }
}
.ed-right button[data-action^="zoom"] { min-width: 30px; font-size: 18px; }
.ed-zoom { font-size: 12.5px; color: var(--ink-3); min-width: 44px; text-align: center; }
@media (max-width: 760px) {
  /* Keep names discoverable on touchscreens; the strip scrolls horizontally. */
  .ed-bar { touch-action: pan-x; min-height: 72px; }
  .ed-bar button { min-width: 64px; width: 64px; min-height: 54px; }
  .ed-bar button span { font-size: 10px; line-height: 1.1; min-height: 22px; max-width: 54px; white-space: normal; }
}

.ed-props {
  position: sticky; top: var(--editor-props-top, 128px); z-index: 29; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  padding: 7px 12px; background: var(--bg-elev); border-bottom: 1px solid var(--line); font-size: 13px;
}
.ed-props label { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.ed-props select, .ed-props input[type="number"] { padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-elev); }
.ed-props input[type="number"] { width: 64px; }
.ed-props input[type="color"] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: none; }
.ed-props .tog { min-width: 30px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg-elev); cursor: pointer; font-weight: 700; }
.ed-props .tog[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

.ed-pages { flex: 1; overflow: auto; padding: 24px 12px 120px; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.ed-pagewrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ed-page { position: relative; background: #fff; box-shadow: var(--shadow); user-select: none; touch-action: pan-x pan-y; }
/* drag tools need every touch move; otherwise a finger can still scroll the document */
.ed-pages.drag-tool .ed-page, .obj { touch-action: none; }
.ed-page canvas.pdf { display: block; width: 100%; height: 100%; }
.ed-page .layer { position: absolute; inset: 0; }
/* the stacked layers must not swallow clicks meant for the form fields underneath */
.ed-page .layer { pointer-events: none; }
.ed-page .layer > * { pointer-events: auto; }
.ed-pagebar { display: flex; gap: 6px; align-items: center; color: var(--ink-3); font-size: 12.5px; }
.ed-pagebar button { border: 1px solid var(--line); background: var(--bg-elev); border-radius: 7px; height: 28px; padding: 0 8px; cursor: pointer; color: var(--ink-2); display: flex; align-items: center; gap: 4px; font-size: 12px; }
.ed-pagebar button:hover { color: var(--brand); border-color: var(--brand); }
.ed-pagebar .icon { width: 15px; height: 15px; }
.ed-insert { opacity: .0; transition: opacity .15s; }
.ed-pagewrap:hover .ed-insert, .ed-insert:focus { opacity: 1; }

/* overlay objects */
.obj { position: absolute; box-sizing: border-box; }
.obj.sel { outline: 1.5px dashed var(--brand); outline-offset: 2px; }
.obj .h { position: absolute; width: 11px; height: 11px; right: -7px; bottom: -7px; background: var(--brand); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; display: none; }
.obj.sel .h { display: block; }
.obj .x { position: absolute; top: -24px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--err); color: #fff; font-size: 13px; line-height: 22px; text-align: center; cursor: pointer; display: none; padding: 0; }
.obj.sel .x { display: block; }
.obj.text { min-width: 20px; padding: 0; white-space: pre; outline-offset: 3px; cursor: move; line-height: 1.2; color: #000; }
.obj.text [contenteditable] { outline: none; cursor: text; min-width: 8px; display: block; white-space: pre; }
.obj.image img { width: 100%; height: 100%; display: block; pointer-events: none; }
.obj.shape { cursor: move; }
.obj.mark { cursor: move; }
.obj.link { border: 1.5px dashed #2f6fed; background: rgba(47, 111, 237, .08); cursor: move; }
.obj.link .tag { position: absolute; left: 0; top: -18px; font-size: 11px; color: #2f6fed; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.obj.field { border: 1.5px solid #7b61ff; background: rgba(123, 97, 255, .1); cursor: move; font-size: 11px; color: #5b47d6; padding: 1px 3px; overflow: hidden; }
.obj > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.obj.svgobj { cursor: move; }
.edit-span { position: absolute; color: transparent; white-space: pre; cursor: text; border-radius: 2px; transform-origin: 0 0; }
.edit-span:hover { background: rgba(75, 63, 224, .14); outline: 1px solid rgba(75, 63, 224, .5); }
.formfield { position: absolute; border: 1px solid rgba(75, 63, 224, .55); background: rgba(75, 63, 224, .07); font: inherit; padding: 0 3px; color: #000; }
.formfield:focus { outline: 2px solid var(--brand); background: #fff; }
textarea.formfield { resize: none; }
input[type="checkbox"].formfield { margin: 0; accent-color: var(--brand); }
.ed-draft { position: absolute; border: 1.5px dashed var(--brand); background: rgba(75, 63, 224, .08); pointer-events: none; }
.ed-footer {
  position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 12px; justify-content: flex-end;
  padding: 10px 16px; background: var(--bg-elev); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px -12px rgba(0,0,0,.25);
}
.ed-footer #ed-status { margin-right: auto; }
@media (min-width: 761px) {
  .ed-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .ed-footer #ed-status { grid-column: 1; grid-row: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ed-footer [data-action="save"] { grid-column: 2; grid-row: 1; }
  .ed-footer [data-action="close"] { grid-column: 3; grid-row: 1; justify-self: end; }
  .ed-footer #flatten-wrap { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
}
@media (max-width: 760px) {
  .ed-props { top: var(--editor-props-top, 134px); flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; gap: 8px; }
  .ed-props label { flex: none; }
  .ed-footer { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .ed-footer #ed-status { flex: 1 1 100%; margin: 0; }
  .ed-footer .btn-lg { padding-left: 16px; padding-right: 16px; }
  .ed-pages { padding: 16px 8px 100px; }
  .ed-pagebar button { min-height: 44px; }
  .obj.sel .h { width: 20px; height: 20px; right: -10px; bottom: -10px; }
  .obj.sel .x { width: 32px; height: 32px; line-height: 32px; top: -34px; }
}

/* Signature library and creation dialog. */
.signature-menu { position: fixed; z-index: 75; width: min(310px, calc(100vw - 16px)); max-height: min(440px, calc(100dvh - 16px)); overflow: auto; padding: 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--bg-elev); box-shadow: var(--shadow-lg); }
.signature-menu-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.signature-reuse { flex: 1; min-width: 0; border: 0; background: #fff; padding: 10px; cursor: pointer; }
.signature-reuse img { max-width: 100%; height: 60px; object-fit: contain; }
.signature-remove { border: 0; background: none; color: var(--ink-3); font-size: 26px; padding: 10px; cursor: pointer; }
.signature-new { display: block; margin: 12px auto 2px; color: #0878bd; border-color: #1586d7; }
.signature-back { padding: 20px; }
.signature-modal { width: min(1000px, 100%); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-lg); border-radius: 5px; overflow: hidden; }
.signature-modal header { display: flex; justify-content: space-between; align-items: center; padding: 18px 26px; background: var(--bg-sunken); }
.signature-modal h2 { font-size: 20px; font-weight: 500; margin: 0; }
.signature-modal [data-close] { background: none; border: 0; color: var(--ink-3); font-size: 32px; cursor: pointer; }
.signature-tabs { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 26px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.signature-tabs [role="tablist"] { display: flex; flex-wrap: wrap; }
.signature-tabs [role="tab"] { border: 1px solid transparent; border-bottom: 0; background: none; color: #008f6b; font-size: 17px; padding: 12px 18px; cursor: pointer; }
.signature-tabs [aria-selected="true"] { border-color: var(--line-strong); border-radius: 5px 5px 0 0; background: var(--bg-sunken); color: var(--ink-2); }
.signature-tabs .check { white-space: nowrap; padding: 10px 0; }
.signature-content { overflow: auto; padding: 28px; min-height: 0; overscroll-behavior: contain; }
.signature-content [role="tabpanel"] { min-height: 310px; text-align: center; }
.signature-content .sig-type { display: block; width: min(500px, 100%); margin: 10px auto 20px; font-family: var(--font); font-size: 20px; }
.signature-colors { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 8px; margin-bottom: 18px; }
.signature-colors button { width: 26px; height: 26px; padding: 0; border: 2px solid #fff; border-radius: 50%; cursor: pointer; }
.signature-colors button[aria-pressed="true"] { outline: 2px solid var(--line-strong); outline-offset: 2px; }
.sig-fonts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sig-fonts button { min-height: 76px; min-width: 0; padding: 8px; border: 1px solid transparent; border-radius: 7px; background: #fff; font-size: 31px; overflow-wrap: anywhere; cursor: pointer; }
.sig-fonts button[aria-pressed="true"] { background: #edf8fc; border-color: #b4dbe9; }
.sig-pad { width: 100%; height: 210px; display: block; border: 1px dashed var(--line-strong); border-radius: 5px; background: #fff; touch-action: none; cursor: crosshair; }
.signature-draw-actions, .signature-camera-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.signature-draw-actions { color: var(--ink-3); font-size: 13px; }
.signature-draw-actions label { display: flex; gap: 8px; align-items: center; }
.signature-draw-actions input { width: 90px; }
.signature-versions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.signature-versions h3 { grid-column: 1 / -1; font-size: 16px; }
.signature-versions button { display: flex; flex-direction: column; gap: 12px; align-items: center; min-width: 0; padding: 10px; border: 2px solid transparent; border-radius: 6px; background: none; color: var(--ink-2); cursor: pointer; }
.signature-versions button[aria-pressed="true"] { border-color: #008f6b; background: var(--bg-sunken); }
.signature-versions img { width: 100%; height: 210px; object-fit: contain; background-color: #fff; background-image: conic-gradient(#eee 25%, #fff 0 50%, #eee 0 75%, #fff 0); background-size: 18px 18px; }
.signature-video { max-width: 100%; max-height: 240px; margin: 16px auto 0; background: #111; }
.signature-error { color: var(--err); margin: 14px 0 0; }
.signature-modal footer { text-align: center; padding: 14px 24px 20px; border-top: 1px solid var(--line); }
.signature-modal footer p { color: var(--ink-3); font-size: 13px; margin: 0 0 12px; }
.signature-modal footer .btn { min-width: 130px; }
.signature-object-actions { width: max-content; z-index: 3; display: none; position: absolute; left: 0; top: -40px; background: var(--bg-elev); border: 1px solid #1586d7; border-radius: 4px; overflow: hidden; box-shadow: var(--shadow-sm); }
.signature-object.sel .signature-object-actions { display: flex; }
.signature-object-actions button { flex: 0 0 40px; padding: 0; min-width: 40px; height: 36px; display: grid; place-items: center; color: #0878bd; border: 0; border-right: 1px solid var(--line); background: var(--bg-elev); cursor: pointer; }
.signature-object-actions .icon { position: static; width: 20px; height: 20px; }
.signature-object-actions button:hover, .signature-object-actions button:focus-visible { background: #dcefff; }
.signature-object > .x { display: none !important; }
@media (max-width: 600px) {
  .signature-back { padding: 8px; }
  .signature-modal { max-height: calc(100dvh - 16px); }
  .signature-modal header { padding: 10px 14px; }
  .signature-tabs { padding: 10px 12px 0; gap: 0; }
  .signature-tabs [role="tab"] { padding: 10px; font-size: 14px; min-height: 44px; }
  .signature-content { padding: 16px; }
  .sig-fonts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .sig-fonts button { font-size: 25px; min-height: 68px; }
  .signature-versions { grid-template-columns: 1fr; }
  .signature-versions img { height: 150px; }
  .signature-modal footer { padding: 10px 16px; }
  .signature-object-actions { top: -48px; }
  .signature-object-actions button { min-width: 44px; height: 44px; }
}

/* Signature follows the mouse/pen before its single placement. Never intercept input. */
.signature-placement-preview { position: fixed; z-index: 28; pointer-events: none; transform: translate(-50%, -50%); outline: 1px dashed #1586d7; }
.signature-placement-preview[hidden] { display: none; }
.signature-placement-preview img { display: block; width: 100%; height: 100%; }
