/* NikoPDF editor v4 — iLovePDF/Acrobat-style: toolbar, page thumbnails, page stage, properties panel. */
.ed-body { min-height: 100vh; }
.ed-body .site-footer, .ed-body .ad-region { display: none; }
.ed-start { padding-top: 5rem; }
body.ed-open .ed-start { display: none; }
.ed[hidden] { display: none !important; }

.ed { --tb: 56px; display: flex; flex-direction: column; height: calc(100vh - 62px); height: calc(100dvh - 62px); }
.ed-toolbar { height: var(--tb); flex: none; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0 0.75rem; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.ed-tools, .ed-actions { display: flex; align-items: center; gap: 0.15rem; }
.ed-tools { overflow-x: auto; scrollbar-width: none; flex: 1; justify-content: center; }
.ed-tools::-webkit-scrollbar { display: none; }
.ed-toolbar button { flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 52px; height: 46px; padding: 0 0.45rem; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: 600 0.68rem 'Outfit', sans-serif; cursor: pointer; transition: background 0.12s, color 0.12s; }
.ed-toolbar button:hover { background: var(--bg-input); }
.ed-toolbar button.active { background: var(--accent-soft); color: var(--accent); }
.ed-toolbar button:disabled { opacity: 0.35; cursor: default; background: transparent; }
.ed-toolbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ed-actions button { min-width: 38px; font-size: 1.1rem; }
.ed-actions .ed-zoom { min-width: 58px; font-size: 0.8rem; }
.ed-sep { width: 1px; height: 28px; background: var(--border); margin: 0 0.3rem; }

.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px 1fr 290px; }
.ed-pages { background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.ed-pages-head { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 1rem; font-size: 0.85rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.ed-pages-head b { color: var(--text); }
.ed-thumbs { flex: 1; overflow-y: auto; padding: 0.9rem 0.8rem; display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.ed-thumb { position: relative; width: 132px; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; cursor: pointer; border-radius: 8px; padding: 6px; border: 2px solid transparent; }
.ed-thumb.current { border-color: var(--accent); background: var(--accent-soft); }
.ed-thumb.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.ed-thumb.dragging { opacity: 0.35; }
.ed-thumb canvas { max-width: 116px; max-height: 150px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); display: block; }
.ed-thumb .ph { width: 100px; height: 130px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.ed-thumb-num { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.ed-thumb-tools { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; opacity: 0; transition: opacity 0.12s; }
.ed-thumb:hover .ed-thumb-tools, .ed-thumb.current .ed-thumb-tools { opacity: 1; }
@media (hover: none) { .ed-thumb-tools { opacity: 1; } }
.ed-thumb-tools button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg-card); font-size: 0.8rem; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.ed-thumb-tools button:hover { background: var(--accent); color: #fff; }
.ed-pages-foot { padding: 0.7rem; border-top: 1px solid var(--border); display: grid; gap: 0.4rem; }
.ed-btn-ghost { font: 600 0.82rem 'Outfit', sans-serif; padding: 0.55rem 0.8rem; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer; }
.ed-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.ed-stage { overflow: auto; background: var(--preview-stage); position: relative; outline: none; }
.ed-doc { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 26px 20px 120px; min-width: min-content; }
.ed-page { position: relative; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18); flex: none; }
.ed-page > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ed-page-label { position: absolute; top: -20px; left: 0; font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.ed-layer { position: absolute; inset: 0; overflow: hidden; touch-action: pan-x pan-y; }
.ed-layer.drawing { touch-action: none; cursor: crosshair; }
.tool-text .ed-layer { cursor: text; }
.tool-image .ed-layer, .tool-sign .ed-layer { cursor: copy; }

.ed-obj { position: absolute; box-sizing: border-box; user-select: none; -webkit-user-select: none; }
.tool-select .ed-obj { cursor: move; }
.ed-obj.sel { outline: 1.5px solid #2e6fd8; outline-offset: 1px; }
.ed-obj .ed-h { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid #2e6fd8; border-radius: 50%; display: none; z-index: 2; touch-action: none; }
.ed-obj.sel .ed-h { display: block; }
.ed-h.nw { left: -7px; top: -7px; cursor: nwse-resize; } .ed-h.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.ed-h.sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .ed-h.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.ed-obj.t-line .ed-h.ne, .ed-obj.t-line .ed-h.sw, .ed-obj.t-line .ed-h.nw, .ed-obj.t-line .ed-h.se { display: none; }
.ed-obj .ed-h.p1, .ed-obj .ed-h.p2 { display: none; cursor: move; }
.ed-obj.t-line.sel .ed-h.p1, .ed-obj.t-line.sel .ed-h.p2 { display: block; }
.ed-obj .ed-txt { width: 100%; min-height: 1em; white-space: pre-wrap; word-break: break-word; outline: none; line-height: 1.2; font-family: Helvetica, Arial, sans-serif; }
.ed-obj .ed-txt[contenteditable="true"] { cursor: text; user-select: text; -webkit-user-select: text; background: rgba(46, 111, 216, 0.06); }
.ed-obj.t-text.sel:not(.editing) .ed-txt:empty::before { content: 'Type here'; opacity: .4; }
.ed-obj img { width: 100%; height: 100%; display: block; pointer-events: none; }
.ed-obj svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ed-obj.t-whiteout { background: #fff; }
.ed-obj.t-whiteout.sel, .ed-layer:hover .ed-obj.t-whiteout { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.ed-ghost { position: absolute; border: 1.5px dashed #2e6fd8; background: rgba(46, 111, 216, 0.08); pointer-events: none; }

.ed-side { background: var(--bg-card); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.ed-props { flex: 1; overflow-y: auto; padding: 1.1rem 1.2rem; }
.ed-props h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 0.25rem; }
.ed-props .hint { font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 1rem; }
.ed-props .row { margin-bottom: 0.95rem; }
.ed-props .row > label { display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem; }
.ed-props select, .ed-props input[type="number"] { width: 100%; padding: 0.55rem 0.6rem; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font: 500 0.9rem 'Outfit', sans-serif; }
.ed-props input[type="range"] { width: 100%; accent-color: var(--accent); }
.ed-props .inline { display: flex; gap: 0.4rem; align-items: center; }
.ed-props .inline > * { flex: 1; }
.ed-toggle { font: 700 0.9rem 'Outfit', sans-serif; padding: 0.5rem; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer; }
.ed-toggle.on { background: var(--text); color: var(--bg-card); border-color: var(--text); }
.ed-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ed-swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg-card); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.ed-swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.ed-swatches input[type="color"] { width: 26px; height: 26px; border: 0; padding: 0; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); border-radius: 50%; cursor: pointer; overflow: hidden; }
.ed-swatches input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.ed-swatches input[type="color"]::-moz-color-swatch { opacity: 0; }
.ed-props .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin-top: 1.1rem; }
.ed-props .actions .danger:hover { border-color: var(--error); color: var(--error); }
.ed-props .tip { font-size: 0.8rem; color: var(--text-muted); background: var(--bg-input); border-radius: 9px; padding: 0.7rem 0.8rem; line-height: 1.45; margin-top: 1rem; }
.ed-props kbd { font: 600 0.72rem 'Outfit', sans-serif; padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); }
.ed-side-foot { padding: 1rem 1.2rem 1.2rem; border-top: 1px solid var(--border); display: grid; gap: 0.5rem; }
.ed-export { width: 100%; font-size: 1.1rem; padding: 0.95rem; margin: 0; display: flex; justify-content: center; gap: 0.5rem; }
.ed-export::after { content: '⬇'; }
.ed-side-foot .status { text-align: center; margin: 0; }

.ed-modal { position: fixed; inset: 0; z-index: 600; background: rgba(15, 15, 25, 0.55); display: grid; place-items: center; padding: 1rem; }
.ed-modal[hidden] { display: none; }
.ed-dialog { width: min(620px, 100%); background: var(--bg-card); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.9rem; }
.ed-dialog-head { display: flex; justify-content: space-between; align-items: center; }
.ed-dialog-head h3 { font-size: 1.2rem; color: var(--text); }
.ed-x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--bg-input); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.ed-seg { display: flex; background: var(--bg-input); border-radius: 10px; padding: 3px; }
.ed-seg button { flex: 1; border: 0; background: none; padding: 0.5rem; border-radius: 8px; font: 600 0.9rem 'Outfit', sans-serif; color: var(--text-muted); cursor: pointer; }
.ed-seg button.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow); }
#sigPad { width: 100%; height: auto; aspect-ratio: 560 / 200; background: #fff; border: 1.5px dashed var(--border); border-radius: 12px; touch-action: none; cursor: crosshair; }
.sig-row { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.sig-row .ed-btn-ghost { margin-left: auto; }
#sigName { width: 100%; padding: 0.75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-size: 1rem; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.6rem; }
.sig-fonts button { height: 70px; border-radius: 10px; border: 1.5px solid var(--border); background: #fff; color: #1a1a2e; font-size: 1.8rem; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 0.5rem; }
.sig-fonts button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ed-upload-sig { display: grid; place-items: center; text-align: center; min-height: 140px; border: 1.5px dashed var(--border); border-radius: 12px; color: var(--text-muted); cursor: pointer; padding: 1rem; font-size: 0.9rem; }
.ed-upload-sig.has img { max-height: 120px; max-width: 100%; }
.ed-dialog-foot { display: flex; justify-content: flex-end; gap: 0.5rem; }
.ed-dialog-foot .btn-primary { margin: 0; width: auto; padding: 0.7rem 1.3rem; }

.ed-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; background: var(--text); color: var(--bg-card); padding: 0.7rem 1.1rem; border-radius: 10px; font-size: 0.9rem; z-index: 700; transition: all 0.2s; pointer-events: none; max-width: 90vw; text-align: center; }
.ed-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ed-toolbar .ed-mobile-pages { display: none; }
.ed-props .actions .danger { color: var(--error); }

@media (max-width: 1100px) { .ed-main { grid-template-columns: 170px 1fr 250px; } .ed-thumb { width: 116px; } .ed-thumb canvas { max-width: 100px; max-height: 130px; } }
@media (max-width: 860px) {
  .ed-body .site-header { padding: 0.6rem 1rem; }
  .ed { height: calc(100dvh - 62px); }
  .ed-toolbar { height: auto; flex-wrap: wrap; padding: 0.2rem 0.4rem; gap: 0; }
  .ed-tools { order: 2; flex-basis: 100%; justify-content: flex-start; }
  .ed-actions { order: 1; width: 100%; justify-content: space-between; }
  .ed-toolbar button { min-width: 50px; height: 44px; }
  .ed-actions button { height: 38px; }
  .ed-main { display: flex; flex-direction: column; }
  .ed-pages { position: fixed; left: 0; top: 0; bottom: 0; width: 190px; z-index: 300; transform: translateX(-105%); transition: transform 0.2s; box-shadow: var(--shadow-lg); }
  body.ed-pages-open .ed-pages { transform: none; }
  .ed-stage { flex: 1; min-height: 0; }
  .ed-doc { padding: 22px 10px 30px; }
  .ed-side { flex: none; max-height: 42%; border-left: 0; border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0,0,0,.08); }
  .ed-props { padding: 0.7rem 1rem 0.4rem; }
  .ed-props .hint, .ed-props .tip { display: none; }
  .ed-props h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
  .ed-props .row { margin-bottom: 0.6rem; }
  .ed-props .actions { grid-template-columns: repeat(4, 1fr); margin-top: 0.5rem; }
  .ed-props .actions .ed-btn-ghost { padding: 0.5rem 0.2rem; font-size: 0.72rem; }
  .ed-side-foot { padding: 0.6rem 1rem 0.8rem; grid-template-columns: 1fr auto; align-items: center; }
  .ed-export { font-size: 1rem; padding: 0.8rem; }
  .ed-new { padding: 0.75rem 0.7rem; font-size: 0.75rem; }
  .ed-side-foot .status { grid-column: 1 / -1; }
  .ed-side-foot .status:empty { display: none; }
  .ed-toolbar .ed-mobile-pages { display: inline-flex; align-items: center; min-width: 58px !important; font-size: 0.8rem !important; }
  body.ed-pages-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 290; }
  .ed-toast { bottom: 140px; }
}

.ed-thumb-tools .touch-only { display: none; }
@media (hover: none) { .ed-thumb-tools .touch-only { display: grid; } }

/* touch: objects grab the finger instead of scrolling the page; bigger corner handles */
.ed-obj { touch-action: none; }
@media (pointer: coarse) {
  .ed-obj .ed-h { width: 20px; height: 20px; border-width: 3px; }
  .ed-h.nw { left: -12px; top: -12px; } .ed-h.ne { right: -12px; top: -12px; }
  .ed-h.sw { left: -12px; bottom: -12px; } .ed-h.se { right: -12px; bottom: -12px; }
  .ed-obj .ed-h::after { content: ''; position: absolute; inset: -10px; }
  .ed-obj.sel { outline-width: 2px; }
}

/* Edit text tool: outlines of the PDF's own text lines */
.ed-tline { position: absolute; border-radius: 2px; cursor: text; outline: 1px dashed rgba(46, 111, 216, 0.45); background: rgba(46, 111, 216, 0.05); }
.ed-tline:hover { outline: 1.5px solid #2e6fd8; background: rgba(46, 111, 216, 0.12); }
.ed-cover { position: absolute; pointer-events: none; }
.tool-edittext .ed-layer { cursor: default; }
@media (pointer: coarse) { .ed-tline::after { content: ''; position: absolute; inset: -5px -2px; } }
