/* ============================================================
   FreeToolzHub PDF Editor — stylesheet
   One design system: gradient primary, glass secondary, red danger
   ============================================================ */
.pdfe{position:relative;--pdfe-h:74vh}
.pdfe [hidden]{display:none !important}
.pdfe *:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px}

/* ---------- buttons (single system) ---------- */
.pe-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;cursor:pointer;
  font-family:var(--font-body);font-weight:600;border-radius:var(--radius-full);
  transition:transform var(--dur-base) var(--ease-out),box-shadow var(--dur-base),background var(--dur-base),color var(--dur-base)}
.pe-btn svg{width:16px;height:16px;flex:none}
.pe-btn:disabled{opacity:.38;cursor:not-allowed;pointer-events:none;background:var(--surface-2);color:var(--text-muted);box-shadow:none}
.pe-btn--primary{padding:11px 22px;font-weight:700;font-size:.93rem;background:var(--gradient-brand);color:var(--text-on-brand);box-shadow:var(--shadow-brand-soft)}
.pe-btn--primary:hover{transform:translateY(-2px) scale(1.015);box-shadow:var(--shadow-brand)}
.pe-btn--secondary{padding:9px 16px;font-size:.87rem;background:var(--glass-bg,rgba(255,255,255,.7));backdrop-filter:var(--blur-md,blur(8px));border:1px solid var(--border-color);color:var(--text-body)}
.pe-btn--secondary:hover{transform:translateY(-2px);border-color:var(--color-primary);color:var(--color-primary);box-shadow:var(--shadow-sm)}
.pe-btn--danger{padding:9px 16px;font-size:.87rem;background:var(--red-500,#ef4444);color:#fff}
.pe-btn--danger:hover{transform:translateY(-2px);box-shadow:0 8px 20px -6px rgba(239,68,68,.55)}
.pe-btn--full{width:100%}
.pe-ico{width:32px;height:32px;padding:0;border-radius:50%;background:var(--surface-1);color:var(--text-body);box-shadow:var(--shadow-xs);font-size:15px;font-weight:700;line-height:1}
.pe-ico:hover:not(:disabled){background:var(--gradient-brand);color:var(--text-on-brand);transform:translateY(-1px);box-shadow:var(--shadow-brand-soft)}
.pe-ico svg{width:15px;height:15px}

/* ---------- toolbar (grouped) ---------- */
.pe-tb{border:1px solid var(--border-color);border-radius:var(--radius-xl);background:var(--surface-1);box-shadow:var(--shadow-sm);padding:8px 10px}
.pe-tb-rows{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.pe-grp{display:flex;align-items:center;gap:3px;padding:4px;border-radius:var(--radius-full);background:var(--surface-2);border:1px solid var(--border-color)}
.pe-grp-lb{font-size:.62rem;font-weight:800;letter-spacing:.1em;text-transform:uppercase;color:var(--text-faint,var(--text-muted));padding:0 6px 0 4px}
.pe-t{display:inline-flex;align-items:center;gap:6px;padding:7px 11px;border:0;border-radius:var(--radius-full);background:transparent;
  color:var(--text-muted);font-family:var(--font-body);font-weight:600;font-size:.8rem;cursor:pointer;transition:all var(--dur-base) var(--ease-out)}
.pe-t svg{width:15px;height:15px;transition:transform var(--dur-base) var(--ease-spring)}
.pe-t:hover:not(:disabled){color:var(--text-strong);background:var(--surface-1)}
.pe-t:hover:not(:disabled) svg{transform:scale(1.16)}
.pe-t.on{background:var(--gradient-brand);color:var(--text-on-brand);box-shadow:var(--shadow-brand-soft)}
.pe-t:disabled{opacity:.35;cursor:not-allowed}
.pe-tb-r{margin-left:auto;display:flex;align-items:center;gap:10px}
.pe-zoom{min-width:46px;text-align:center;font-weight:600;font-size:.82rem;color:var(--text-body);font-variant-numeric:tabular-nums}
.pe-status{display:inline-flex;align-items:center;gap:6px;font-size:.78rem;font-weight:600;color:var(--text-muted)}
.pe-status i{width:8px;height:8px;border-radius:50%;background:var(--green-500,#22c55e)}
.pe-status.dirty i{background:var(--amber-500,#f59e0b)}
.pe-status.err i{background:var(--red-500,#ef4444)}

/* ---------- workspace ---------- */
.pe-work{display:grid;grid-template-columns:152px 1fr 244px;gap:12px;margin-top:12px}
.pe-side{border:1px solid var(--border-color);border-radius:var(--radius-lg);background:var(--surface-1);overflow:hidden;display:flex;flex-direction:column;max-height:var(--pdfe-h)}
.pe-side-h{padding:10px 12px;font-family:var(--font-heading);font-weight:700;font-size:.72rem;letter-spacing:.09em;text-transform:uppercase;
  color:var(--text-muted);border-bottom:1px solid var(--border-color);background:var(--surface-2)}
.pe-stage{overflow:auto;max-height:var(--pdfe-h);padding:20px;border-radius:var(--radius-lg);background:var(--surface-2);
  border:1px solid var(--border-color);display:flex;justify-content:center;align-items:flex-start}
.pe-page{position:relative;flex:none;box-shadow:var(--shadow-lg);background:#fff;border-radius:3px;overflow:hidden}
.pe-page canvas{display:block}
.pe-layer{position:absolute;inset:0}
.pe-layer[data-cursor="cross"]{cursor:crosshair}
.pe-layer[data-cursor="copy"]{cursor:copy}
.pe-layer[data-cursor="text"]{cursor:text}
.pe-layer:not([data-cursor="text"]) .pe-txt{pointer-events:none}

/* ---------- thumbnails ---------- */
.pe-thumbs{overflow-y:auto;padding:10px;display:flex;flex-direction:column;gap:10px}
.pe-th{position:relative;border:2px solid transparent;border-radius:var(--radius-md);overflow:hidden;cursor:pointer;
  background:#fff;box-shadow:var(--shadow-xs);transition:all var(--dur-base) var(--ease-out)}
.pe-th:hover{transform:translateY(-2px);box-shadow:var(--shadow-md)}
.pe-th.on{border-color:var(--color-primary);box-shadow:var(--shadow-brand-soft)}
.pe-th img{display:block;width:100%}
.pe-th-n{position:absolute;top:4px;left:4px;z-index:2;min-width:18px;height:18px;padding:0 5px;display:grid;place-items:center;
  border-radius:5px;background:rgba(15,23,42,.78);color:#fff;font-size:10px;font-weight:700}
.pe-th-a{position:absolute;inset:auto 0 0 0;display:flex;justify-content:center;gap:2px;padding:4px;
  background:linear-gradient(transparent,rgba(15,23,42,.86));opacity:0;transition:opacity var(--dur-base)}
.pe-th:hover .pe-th-a,.pe-th:focus-within .pe-th-a{opacity:1}
.pe-th-a button{width:20px;height:20px;display:grid;place-items:center;border:0;border-radius:4px;background:rgba(255,255,255,.92);color:#0f172a;font-size:10px;cursor:pointer}
.pe-th-a button svg{width:11px;height:11px}
.pe-th-a button:hover{background:var(--color-primary);color:#fff}

/* ---------- text runs ---------- */
.pe-txt{position:absolute;white-space:pre;color:transparent;background:transparent;border-radius:3px;outline:0;
  transition:background var(--dur-fast) var(--ease-out),box-shadow var(--dur-fast)}
.pe-layer[data-cursor="text"] .pe-txt{cursor:text}
.pe-layer[data-cursor="text"] .pe-txt:hover{background:rgba(37,99,235,.12);box-shadow:0 0 0 1.5px rgba(37,99,235,.45)}
.pe-txt.on,.pe-txt.ed{color:var(--tc,#111827) !important;background:#fff}
.pe-txt.on{box-shadow:0 0 0 2px var(--color-primary),var(--shadow-md);z-index:30;padding:0 2px}
.pe-txt.ed{box-shadow:0 0 0 1.5px rgba(20,184,166,.55)}

/* ---------- objects + handles ---------- */
.pe-obj{position:absolute;z-index:15;touch-action:none;cursor:move}
.pe-obj img{width:100%;height:100%;object-fit:contain;pointer-events:none;display:block}
.pe-obj svg{width:100%;height:100%;display:block;pointer-events:none;overflow:visible}
.pe-obj.locked{cursor:not-allowed}
.pe-obj-box{position:absolute;inset:0;border-radius:inherit}
.pe-obj:hover .pe-sel-ring{opacity:.55}
.pe-sel-ring{position:absolute;inset:-2px;border:2px solid var(--color-primary);border-radius:3px;opacity:0;
  transition:opacity var(--dur-base);pointer-events:none}
.pe-obj.sel .pe-sel-ring{opacity:1}
.pe-h{position:absolute;width:11px;height:11px;background:#fff;border:2px solid var(--color-primary);border-radius:2px;
  opacity:0;transition:opacity var(--dur-base);z-index:4}
.pe-obj.sel .pe-h{opacity:1}
.pe-h[data-h="nw"]{left:-6px;top:-6px;cursor:nwse-resize}
.pe-h[data-h="n"]{left:50%;margin-left:-5.5px;top:-6px;cursor:ns-resize}
.pe-h[data-h="ne"]{right:-6px;top:-6px;cursor:nesw-resize}
.pe-h[data-h="e"]{right:-6px;top:50%;margin-top:-5.5px;cursor:ew-resize}
.pe-h[data-h="se"]{right:-6px;bottom:-6px;cursor:nwse-resize}
.pe-h[data-h="s"]{left:50%;margin-left:-5.5px;bottom:-6px;cursor:ns-resize}
.pe-h[data-h="sw"]{left:-6px;bottom:-6px;cursor:nesw-resize}
.pe-h[data-h="w"]{left:-6px;top:50%;margin-top:-5.5px;cursor:ew-resize}
.pe-rot{position:absolute;left:50%;margin-left:-9px;top:-32px;width:18px;height:18px;border-radius:50%;
  background:var(--gradient-brand);border:2px solid #fff;box-shadow:var(--shadow-sm);cursor:grab;opacity:0;
  transition:opacity var(--dur-base);z-index:4}
.pe-rot::after{content:"";position:absolute;left:50%;top:100%;width:2px;height:14px;margin-left:-1px;background:var(--color-primary)}
.pe-obj.sel .pe-rot{opacity:1}
.pe-del{position:absolute;top:-10px;right:-30px;width:22px;height:22px;border-radius:50%;border:2px solid var(--surface-1);
  background:var(--red-500,#ef4444);color:#fff;font-size:11px;line-height:1;cursor:pointer;opacity:0;
  transition:opacity var(--dur-base);display:grid;place-items:center;z-index:5}
.pe-obj.sel .pe-del{opacity:1}
.pe-tbox{width:100%;height:100%;outline:0;white-space:pre-wrap;overflow:hidden}
.pe-marquee{position:absolute;background:rgba(37,99,235,.14);border:1.5px dashed var(--color-primary);border-radius:3px;pointer-events:none;z-index:40}

/* ---------- properties ---------- */
.pe-props{overflow-y:auto;padding:12px}
.pe-empty{margin:0;font-size:.81rem;color:var(--text-muted);line-height:1.55}
.pe-pg{display:flex;flex-direction:column;gap:10px}
.pe-pg-t{display:flex;align-items:center;gap:7px;font-family:var(--font-heading);font-weight:700;font-size:.85rem;color:var(--text-strong);text-transform:capitalize}
.pe-pg-t svg{width:15px;height:15px;color:var(--color-primary)}
.pe-f{display:flex;flex-direction:column;gap:4px;font-size:.72rem;font-weight:600;color:var(--text-muted)}
.pe-f input,.pe-f select{border:1px solid var(--border-color);border-radius:var(--radius-md);padding:7px 9px;
  font-family:var(--font-body);font-size:.81rem;background:var(--surface-1);color:var(--text-body);width:100%}
.pe-f input[type="color"]{height:32px;padding:2px;cursor:pointer}
.pe-f input[type="range"]{padding:0}
.pe-r{display:flex;gap:8px}
.pe-r>.pe-f{flex:1}
.pe-tg{width:34px;height:32px;display:grid;place-items:center;border:1px solid var(--border-color);border-radius:var(--radius-md);
  background:var(--surface-1);color:var(--text-body);cursor:pointer;font-size:.84rem}
.pe-tg.on{background:var(--gradient-brand);color:var(--text-on-brand);border-color:transparent}
.pe-chk{display:flex;align-items:center;gap:8px;font-size:.79rem;font-weight:600;color:var(--text-body);cursor:pointer}
.pe-chk input{width:auto}
.pe-note{margin:0;padding:9px 11px;border-radius:var(--radius-md);background:var(--gradient-hero);border:1px solid var(--border-color);
  font-size:.74rem;line-height:1.5;color:var(--text-body)}
.pe-note b{color:var(--color-primary)}
.pe-swatches{display:flex;gap:6px;flex-wrap:wrap}
.pe-sw{width:26px;height:26px;border-radius:7px;border:2px solid var(--border-color);cursor:pointer;padding:0}
.pe-sw.on{border-color:var(--color-primary);transform:scale(1.1)}

/* ---------- hint ---------- */
.pe-hint{display:flex;align-items:center;gap:10px;margin-top:12px;padding:11px 15px;border-radius:var(--radius-lg);
  background:var(--gradient-hero);border:1px solid var(--border-color);font-size:.86rem;color:var(--text-body)}
.pe-hint b{color:var(--color-primary)}
.pe-hint svg{width:16px;height:16px;flex:none;color:var(--color-primary)}

/* ---------- dialogs ---------- */
.pe-ov{position:fixed;inset:0;z-index:220;display:grid;place-items:center;padding:20px;
  background:rgba(8,15,30,.55);backdrop-filter:blur(6px);animation:peFade .18s var(--ease-out)}
@keyframes peFade{from{opacity:0}to{opacity:1}}
.pe-dlg{width:100%;max-width:min(560px,94vw);max-height:92vh;overflow-y:auto;padding:24px;border-radius:var(--radius-xl);
  background:var(--surface-1);border:1px solid var(--border-color);box-shadow:var(--shadow-lg);text-align:center;
  animation:peUp .22s var(--ease-out)}
@keyframes peUp{from{opacity:0;transform:translateY(14px) scale(.98)}to{opacity:1;transform:none}}
.pe-dlg-h{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:6px;text-align:left}
.pe-dlg-h h3{font-family:var(--font-heading);font-size:1.15rem;margin:0;color:var(--text-strong)}
.pe-x{width:30px;height:30px;flex:none;display:grid;place-items:center;border:0;border-radius:50%;background:var(--surface-2);
  color:var(--text-muted);cursor:pointer;font-size:15px}
.pe-x:hover{background:var(--red-500,#ef4444);color:#fff}
.pe-dlg-s{margin:0 0 16px;font-size:.85rem;color:var(--text-muted);text-align:left}
.pe-dlg-a{display:flex;gap:10px;justify-content:flex-end;margin-top:18px;flex-wrap:wrap}
.pe-segs{display:inline-flex;gap:4px;padding:4px;border-radius:var(--radius-full);background:var(--surface-2);border:1px solid var(--border-color);margin-bottom:14px}
.pe-segs button{padding:8px 18px;border:0;border-radius:var(--radius-full);background:transparent;color:var(--text-muted);
  font-family:var(--font-body);font-weight:600;font-size:.85rem;cursor:pointer}
.pe-segs button.on{background:var(--gradient-brand);color:var(--text-on-brand)}
.pe-pad{width:100%;max-width:500px;height:180px;border:2px dashed var(--border-color);border-radius:var(--radius-lg);
  background:#fff;cursor:crosshair;touch-action:none;display:block;margin:0 auto}
.pe-tin{width:100%;max-width:400px;padding:12px 16px;border:1px solid var(--border-color);border-radius:var(--radius-md);
  font-family:var(--font-body);font-size:1rem;background:var(--surface-1);color:var(--text-body)}
.pe-prev{margin-top:12px;min-height:72px;display:grid;place-items:center;border:1px dashed var(--border-color);border-radius:var(--radius-lg);background:#fff}
.pe-prev img{max-height:80px;max-width:100%}
.pe-saved{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.pe-saved-t{width:100%;font-size:.7rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted);text-align:left}
.pe-ss{position:relative;width:92px;height:42px;padding:4px;border:1px solid var(--border-color);border-radius:var(--radius-md);
  background:#fff;cursor:pointer;display:grid;place-items:center}
.pe-ss:hover{border-color:var(--color-primary)}
.pe-ss img{max-width:100%;max-height:100%}
.pe-ss-x{position:absolute;top:-7px;right:-7px;width:18px;height:18px;border-radius:50%;background:var(--red-500,#ef4444);
  color:#fff;font-size:10px;display:grid;place-items:center;border:0;cursor:pointer}
.pe-dlg .pe-f{text-align:left;margin-bottom:12px}
.pe-dlg .pe-chk{margin:8px 0;text-align:left}
.pe-bar{height:8px;border-radius:99px;background:var(--surface-2);overflow:hidden;margin:14px 0}
.pe-bar i{display:block;height:100%;width:0;background:var(--gradient-brand);transition:width .3s var(--ease-out)}
.pe-kbd{display:grid;grid-template-columns:1fr 1fr;gap:8px 18px;text-align:left;font-size:.84rem}
.pe-kbd div{display:flex;justify-content:space-between;gap:10px;padding:5px 0;border-bottom:1px solid var(--border-color);color:var(--text-body)}
.pe-kbd kbd{font-family:var(--font-mono,monospace);font-size:.74rem;font-weight:700;padding:2px 7px;border-radius:5px;
  background:var(--surface-2);border:1px solid var(--border-color);color:var(--text-strong)}

/* ---------- mobile ---------- */
.pe-fab{display:none;position:fixed;right:18px;bottom:22px;z-index:120;width:54px;height:54px;border-radius:50%;border:0;
  background:var(--gradient-brand);color:var(--text-on-brand);box-shadow:var(--shadow-brand);cursor:pointer;place-items:center}
.pe-fab svg{width:22px;height:22px}
.pe-more{display:none}
@media(max-width:1080px){
  .pe-work{grid-template-columns:1fr}
  .pe-side{max-height:none}
  .pe-thumbs{flex-direction:row;overflow-x:auto}
  .pe-th{flex:none;width:104px}
}
@media(max-width:760px){
  .pdfe{--pdfe-h:60vh}
  .pe-t span{display:none}
  .pe-grp-lb{display:none}
  .pe-tb-r{margin-left:0;width:100%}
  .pe-tb-r .pe-btn--primary{flex:1}
  .pe-stage{padding:12px}
  .pe-fab{display:grid}
  .pe-tb[data-collapsed="1"] .pe-grp:not(.pe-grp--keep){display:none}
  .pe-more{display:inline-flex}
  .pe-dlg{max-width:100%;border-radius:var(--radius-xl) var(--radius-xl) 0 0;align-self:end;max-height:80vh}
  .pe-ov{place-items:end center;padding:0}
}
@media(prefers-reduced-motion:reduce){.pe-btn,.pe-t,.pe-th,.pe-dlg,.pe-ov{transition:none;animation:none}}
@media(prefers-contrast:more){.pe-sel-ring,.pe-h{border-width:3px}.pe-txt.ed{box-shadow:0 0 0 2px #0f172a}}
