/* PDF редактор: шрифты текста (те же файлы встраиваются в PDF) */
@font-face { font-family: "PeSans"; src: url("fonts/PT_Sans-Web-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "PeSans"; src: url("fonts/PT_Sans-Web-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "PeSans"; src: url("fonts/PT_Sans-Web-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "PeSans"; src: url("fonts/PT_Sans-Web-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "PeSerif"; src: url("fonts/PT_Serif-Web-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "PeSerif"; src: url("fonts/PT_Serif-Web-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "PeSerif"; src: url("fonts/PT_Serif-Web-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "PeSerif"; src: url("fonts/PT_Serif-Web-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "PeMono"; src: url("fonts/PTM55FT.ttf") format("truetype"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "PeScript"; src: url("fonts/MarckScript-Regular.ttf") format("truetype"); font-weight: 400 700; font-style: normal; font-display: swap; }

/* ---------- Редактор ---------- */
html.pe-open, html.pe-open body { overflow: hidden; }
.pe-app {
  --pe-bg: #eceae6; --pe-panel: #ffffff; --pe-line: #dedad3; --pe-text: #1f1816; --pe-dim: #6c5f57; --pe-hover: #f1ede6; --pe-acc: var(--red, #b5121b); --pe-acc-text: var(--red-text, #b5121b); --pe-sel: #1a73e8;
  position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--pe-bg); color: var(--pe-text); font: 400 14px/1.4 var(--body, system-ui, sans-serif);
}
:root[data-theme="dark"] .pe-app { --pe-bg: #0f0c0d; --pe-panel: #1d181a; --pe-line: #3a3134; --pe-text: #f6f1ea; --pe-dim: #b4a9a2; --pe-hover: #2a2326; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pe-app { --pe-bg: #0f0c0d; --pe-panel: #1d181a; --pe-line: #3a3134; --pe-text: #f6f1ea; --pe-dim: #b4a9a2; --pe-hover: #2a2326; } }
.pe-app[hidden] { display: none; }
.pe-app button { font: inherit; color: inherit; }
.pe-ic { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; }
.pe-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.pe-top { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.7rem; background: var(--pe-panel); border-bottom: 1px solid var(--pe-line); min-width: 0; }
.pe-file { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pe-fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.pe-status { color: var(--pe-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 15px; }
.pe-busy .pe-status::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 2px solid var(--pe-acc); border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: pe-spin .7s linear infinite; }
@keyframes pe-spin { to { transform: rotate(360deg); } }
.pe-hist, .pe-zoom, .pe-actions { display: flex; align-items: center; gap: 2px; }
.pe-zval { min-width: 54px; height: 34px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.pe-zval:hover { background: var(--pe-hover); }

.pe-ibtn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.pe-ibtn:hover:not(:disabled) { background: var(--pe-hover); }
.pe-ibtn:disabled { opacity: 0.35; cursor: default; }
.pe-ibtn[aria-pressed="true"] { background: color-mix(in srgb, var(--pe-acc) 14%, transparent); color: var(--pe-acc-text); }
.pe-ibtn.pe-danger:hover { color: #d93025; }
.pe-btn { display: inline-flex; align-items: center; gap: 0.4rem; height: 34px; padding: 0 0.85rem; border: 1px solid var(--pe-line); border-radius: 6px; background: var(--pe-panel); cursor: pointer; white-space: nowrap; }
.pe-btn:hover { background: var(--pe-hover); }
.pe-btn-s { height: 30px; padding: 0 0.6rem; font-size: 13px; }
.pe-btn-s .pe-ic, .pe-btn-s .pe-ic svg { width: 17px; height: 17px; }
.pe-btn-main { background: var(--pe-acc); border-color: var(--pe-acc); color: #fff !important; font-weight: 600; }
.pe-btn-main:hover { background: color-mix(in srgb, var(--pe-acc) 85%, #000); }
.pe-app :focus-visible, .pe-modal :focus-visible { outline: 2px solid var(--pe-sel); outline-offset: 1px; }

.pe-tools { display: flex; gap: 2px; padding: 0.35rem 0.6rem; background: var(--pe-panel); border-bottom: 1px solid var(--pe-line); overflow-x: auto; scrollbar-width: thin; }
.pe-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: 0.3rem 0.45rem; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 12px !important; }
.pe-tool:hover { background: var(--pe-hover); }
.pe-tool[aria-pressed="true"] { background: color-mix(in srgb, var(--pe-acc) 13%, transparent); color: var(--pe-acc-text); }
.pe-tool-l { white-space: nowrap; }

/* панель настроек: поверх документа под инструментами, только когда есть что настроить */
.pe-props { position: absolute; z-index: 6; top: 0; left: 196px; right: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.75rem; min-height: 46px; padding: 0.35rem 0.8rem; background: var(--pe-panel); border-bottom: 1px solid var(--pe-line); box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.pe-props:empty { display: none; }
.pe-noside .pe-props { left: 0; }
.pe-pg { display: flex; align-items: center; gap: 4px; }
.pe-sp { flex: 1; }
.pe-hint { color: var(--pe-dim); font-size: 13px; }
.pe-lab { color: var(--pe-dim); font-size: 12px; margin-right: 2px; }
.pe-unit { color: var(--pe-dim); font-size: 12px; }
.pe-sel-in, .pe-num, .pe-input { height: 32px; border: 1px solid var(--pe-line); border-radius: 6px; background: var(--pe-panel); color: var(--pe-text); font: inherit; padding: 0 0.5rem; }
.pe-num { width: 64px; }
.pe-input { width: 100%; height: 38px; }
.pe-url { width: min(380px, 60vw); height: 32px; }
.pe-range { width: 90px; accent-color: var(--pe-acc); }
.pe-colors { display: flex; align-items: center; gap: 2px; }
.pe-sw { width: 19px; height: 19px; padding: 0; border: 1px solid rgba(0,0,0,.25); border-radius: 50%; cursor: pointer; }
.pe-sw.on { box-shadow: 0 0 0 2px var(--pe-panel), 0 0 0 4px var(--pe-sel); }
.pe-sw-none { background: linear-gradient(135deg, #fff 45%, #d93025 45%, #d93025 55%, #fff 55%) !important; }
.pe-sw-custom { width: 23px; height: 23px; padding: 0; border: 0; background: none; cursor: pointer; }
.pe-check-l { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }

.pe-body { position: relative; display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: 0; }
.pe-noside .pe-body { grid-template-columns: 0 minmax(0, 1fr); }
.pe-noside .pe-side { visibility: hidden; }
.pe-side { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; background: var(--pe-panel); border-right: 1px solid var(--pe-line); overflow: hidden; }
.pe-side-head { display: flex; justify-content: space-between; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--pe-line); }
.pe-count { color: var(--pe-dim); }
.pe-thumbs { overflow-y: auto; padding: 0.7rem 0.6rem; display: grid; align-content: start; gap: 0.9rem; }
.pe-side-foot { display: grid; gap: 0.4rem; padding: 0.6rem; border-top: 1px solid var(--pe-line); }
.pe-side-foot .pe-btn { justify-content: center; }
.pe-th { position: relative; display: grid; justify-items: center; gap: 4px; padding: 6px; border-radius: 8px; cursor: pointer; outline-offset: 0; }
.pe-th:hover { background: var(--pe-hover); }
.pe-th-cur { background: color-mix(in srgb, var(--pe-sel) 12%, transparent) !important; }
.pe-th-box { display: grid; place-items: center; width: 140px; height: 150px; }
.pe-th canvas { max-width: 124px; max-height: 140px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.pe-th-side canvas { max-width: 140px; max-height: 124px; }
.pe-th-n { font-size: 12px; color: var(--pe-dim); }
.pe-th-acts { position: absolute; top: 4px; right: 4px; display: none; flex-direction: column; gap: 2px; }
.pe-th:hover .pe-th-acts, .pe-th:focus-within .pe-th-acts { display: flex; }
.pe-th-b { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid var(--pe-line); border-radius: 5px; background: var(--pe-panel); cursor: pointer; }
.pe-th-b:hover { color: var(--pe-acc-text); }
.pe-th-b .pe-ic, .pe-th-b .pe-ic svg { width: 15px; height: 15px; }
.pe-dragging { opacity: 0.4; }
.pe-th-over::before { content: ""; position: absolute; left: 6px; right: 6px; top: -6px; height: 3px; background: var(--pe-sel); border-radius: 2px; }
.pe-th-over.pe-th-after::before { top: auto; bottom: -6px; }

.pe-viewer { position: relative; grid-column: 2; grid-row: 1; overflow: auto; min-height: 0; outline: none; }
.pe-drop .pe-viewer { box-shadow: inset 0 0 0 3px var(--pe-sel); }
.pe-pages { display: grid; justify-items: center; gap: 28px; padding: 24px 24px 80px; min-width: min-content; }
.pe-page { position: relative; flex: none; }
.pe-inner { position: absolute; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18), 0 4px 18px rgba(0,0,0,.08); transform-origin: center center; touch-action: pan-x pan-y pinch-zoom; }
[data-tool="whiteout"] .pe-inner, [data-tool="highlight"] .pe-inner, [data-tool="rect"] .pe-inner, [data-tool="ellipse"] .pe-inner, [data-tool="line"] .pe-inner, [data-tool="arrow"] .pe-inner, [data-tool="link"] .pe-inner, [data-tool="draw"] .pe-inner, .pe-o { touch-action: none; }
.pe-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pe-pnum { position: absolute; left: 0; right: 0; bottom: -22px; text-align: center; font-size: 12px; color: var(--pe-dim); pointer-events: none; }
.pe-tlayer, .pe-flayer, .pe-objs { position: absolute; inset: 0; }
.pe-tlayer { display: none; }
[data-tool="edit"] .pe-tlayer { display: block; }
.pe-tbox { position: absolute; cursor: text; border-radius: 2px; outline: 1px dashed rgba(26,115,232,.35); }
.pe-tbox:hover { background: rgba(26,115,232,.12); outline: 1px solid rgba(26,115,232,.8); }
.pe-tbox.pe-done { display: none; }
.pe-objs { pointer-events: none; }
.pe-o { position: absolute; pointer-events: auto; cursor: move; box-sizing: border-box; }
[data-tool="edit"] .pe-o:not(.pe-o-text), [data-tool="draw"] .pe-o { pointer-events: none; }
.pe-o-text { white-space: pre; padding: 0; margin: 0; min-width: 4px; outline: none; cursor: move; user-select: none; -webkit-user-select: none; }
.pe-o-text.pe-editing { cursor: text; user-select: text; -webkit-user-select: text; outline: 1px dashed var(--pe-sel); outline-offset: 1px; }
.pe-o-text.pe-empty::before { content: attr(data-ph); color: #9aa0a6; pointer-events: none; }
.pe-o-ellipse { border-radius: 50%; }
.pe-o-link { background: rgba(26,115,232,.1); outline: 1px dashed rgba(26,115,232,.8); }
.pe-o-image img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.pe-o-svg { pointer-events: none; overflow: visible; }
.pe-o-svg svg { position: absolute; inset: 0; overflow: visible; }
.pe-o-svg .pe-hit { pointer-events: stroke; cursor: move; }
[data-tool="draw"] .pe-o-svg .pe-hit, [data-tool="edit"] .pe-o-svg .pe-hit { pointer-events: none; }
.pe-selbox { position: absolute; border: 1.5px solid var(--pe-sel); pointer-events: none; margin: -1px; }
.pe-selline { border: 0; }
.pe-hd { position: absolute; width: 11px; height: 11px; margin: -6px 0 0 -6px; background: #fff; border: 1.5px solid var(--pe-sel); border-radius: 2px; pointer-events: auto; touch-action: none; }
.pe-hd-nw { left: 0; top: 0; cursor: nwse-resize; } .pe-hd-n { left: 50%; top: 0; cursor: ns-resize; } .pe-hd-ne { left: 100%; top: 0; cursor: nesw-resize; }
.pe-hd-e { left: 100%; top: 50%; cursor: ew-resize; } .pe-hd-se { left: 100%; top: 100%; cursor: nwse-resize; } .pe-hd-s { left: 50%; top: 100%; cursor: ns-resize; }
.pe-hd-sw { left: 0; top: 100%; cursor: nesw-resize; } .pe-hd-w { left: 0; top: 50%; cursor: ew-resize; }
.pe-selline .pe-hd { border-radius: 50%; cursor: move; }
.pe-field { position: absolute; box-sizing: border-box; margin: 0; padding: 0 3px; border: 1px solid rgba(26,115,232,.45); border-radius: 2px; background: rgba(214,232,255,.55); color: #000; font-family: "PeSans", Arial, sans-serif; resize: none; }
.pe-field:focus { background: #fff; outline: 2px solid var(--pe-sel); }
textarea.pe-field { padding: 2px 3px; line-height: 1.2; }
.pe-check { accent-color: var(--pe-sel); padding: 0; cursor: pointer; }
.pe-field:disabled { background: transparent; border-color: transparent; }

[data-tool="text"] .pe-inner { cursor: text; }
[data-tool="whiteout"] .pe-inner, [data-tool="highlight"] .pe-inner, [data-tool="rect"] .pe-inner, [data-tool="ellipse"] .pe-inner,
[data-tool="line"] .pe-inner, [data-tool="arrow"] .pe-inner, [data-tool="link"] .pe-inner, [data-tool="draw"] .pe-inner { cursor: crosshair; }

/* окна */
.pe-modal-bg { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 1rem; background: rgba(15,12,13,.5); }
.pe-modal { --pe-panel: #fff; --pe-line: #dedad3; --pe-text: #1f1816; --pe-dim: #6c5f57; --pe-hover: #f1ede6; --pe-acc: var(--red, #b5121b); --pe-sel: #1a73e8;
  width: min(560px, 100%); max-height: calc(100vh - 2rem); overflow: auto; background: var(--pe-panel); color: var(--pe-text); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.35); font: 400 14px/1.45 var(--body, system-ui, sans-serif); }
:root[data-theme="dark"] .pe-modal { --pe-panel: #1d181a; --pe-line: #3a3134; --pe-text: #f6f1ea; --pe-dim: #b4a9a2; --pe-hover: #2a2326; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pe-modal { --pe-panel: #1d181a; --pe-line: #3a3134; --pe-text: #f6f1ea; --pe-dim: #b4a9a2; --pe-hover: #2a2326; } }
.pe-modal button { font: inherit; color: inherit; }
.pe-modal-h { display: flex; justify-content: space-between; align-items: center; padding: 0.7rem 0.8rem 0.4rem 1.1rem; font-size: 16px; }
.pe-modal-b { padding: 0.4rem 1.1rem 0.8rem; display: grid; gap: 0.8rem; }
.pe-modal-b p { margin: 0; }
.pe-modal-f { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.7rem 1.1rem 1rem; }
.pe-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--pe-line); }
.pe-tab { padding: 0.5rem 0.9rem; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; color: var(--pe-dim) !important; }
.pe-tab[aria-selected="true"] { border-bottom-color: var(--pe-acc); color: var(--pe-text) !important; font-weight: 600; }
.pe-sign-pane { display: grid; gap: 0.6rem; }
.pe-sign-pane[hidden] { display: none; }
.pe-sign-pad { width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px solid var(--pe-line); border-radius: 8px; touch-action: none; cursor: crosshair; background-image: linear-gradient(transparent calc(75% - 1px), #d9d4cc calc(75% - 1px), #d9d4cc 75%, transparent 75%); }
.pe-sign-row { display: flex; justify-content: space-between; align-items: center; }
.pe-sign-colors { display: flex; gap: 6px; }
.pe-sign-type { height: 84px; font: 44px "PeScript", cursive; background: #fff; }
.pe-sign-up { display: grid; place-items: center; padding: 2rem; border: 1px dashed var(--pe-line); border-radius: 8px; }
.pe-sign-saved p { margin: 0 0 0.4rem; color: var(--pe-dim); font-size: 13px; }
.pe-sign-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pe-sign-item { position: relative; }
.pe-sign-use { display: grid; place-items: center; width: 150px; height: 60px; padding: 6px; background: #fff; border: 1px solid var(--pe-line); border-radius: 6px; cursor: pointer; }
.pe-sign-use:hover { border-color: var(--pe-sel); }
.pe-sign-use img { max-width: 100%; max-height: 100%; }
.pe-sign-del { position: absolute; top: -7px; right: -7px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 1px solid var(--pe-line); border-radius: 50%; background: var(--pe-panel); cursor: pointer; }
.pe-sign-del .pe-ic, .pe-sign-del svg { width: 13px; height: 13px; }

@media (max-width: 900px) {
  .pe-props, .pe-noside .pe-props { left: 0; }
  .pe-body { grid-template-columns: 0 minmax(0, 1fr); }
  .pe-side { visibility: hidden; position: absolute; z-index: 5; top: 0; bottom: 0; width: 196px; }
  .pe-noside .pe-side { visibility: visible; position: absolute; top: 0; bottom: 0; z-index: 7; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  .pe-noside .pe-body { grid-template-columns: 0 minmax(0, 1fr); }
  .pe-tool { min-width: 54px; }
  .pe-tool-l { font-size: 11px; }
  .pe-hist .pe-ibtn, .pe-zoom .pe-ibtn { width: 30px; }
  .pe-zval { min-width: 44px; }
}
@media (max-width: 560px) {
  .pe-actions .pe-btn span:last-child { display: none; }
  .pe-zoom .pe-ibtn { display: none; }
  .pe-pages { padding: 14px 10px 60px; gap: 22px; }
}

/* поверх общих стилей сайта для ползунков и полей */
.pe-app .pe-range { width: 80px; height: 22px; }
.pe-app .pe-range::-webkit-slider-runnable-track { height: 3px; background: var(--pe-line); }
.pe-app .pe-range::-moz-range-track { height: 3px; background: var(--pe-line); }
.pe-app .pe-range::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5.5px; background: var(--pe-acc); clip-path: none; border-radius: 50%; }
.pe-app .pe-range::-moz-range-thumb { width: 14px; height: 14px; background: var(--pe-acc); border-radius: 50%; }
.pe-field { color-scheme: light; }

/* место под полосу прокрутки сайта не нужно, пока открыт редактор */
html.pe-open { scrollbar-gutter: auto; }
/* объекты за краем страницы не раздувают прокрутку; ручки выделения у края видны */
.pe-inner { overflow: clip; overflow-clip-margin: 14px; }

/* кнопки страниц в боковой колонке и формы окон */
.pe-side-tools { display: flex; justify-content: space-between; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--pe-line); }
.pe-side-tools .pe-ibtn { width: 32px; height: 32px; }
.pe-side { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.pe-radio { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.pe-radio .pe-num { margin-left: 0.3rem; }
.pe-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr); align-items: center; gap: 0.7rem; }
.pe-row .pe-sel-in, .pe-row .pe-num { width: 100%; max-width: 260px; }
.pe-input.pe-bad { border-color: #d93025; outline: 2px solid rgba(217,48,37,.3); }
.pe-mode-hint { color: var(--pe-text); }
