/* ---------- Инструменты для изображений (поверх pdf.css) ---------- */
.ws-body canvas { max-width: 100%; }
.checker { background: repeating-conic-gradient(#e6ebf2 0 25%, #fff 0 50%) 0 0 / 20px 20px; }

/* Общая сцена: картинка целиком на экране */
.pe-stage, .ic-stage, .ib-stage, .bg-stage, .wm-stage {
  background: repeating-conic-gradient(#eef2f7 0 25%, #f6f8fb 0 50%) 0 0 / 22px 22px;
  border-radius: 12px; padding: 14px; display: grid; place-items: center; min-height: 340px; overflow: hidden;
}
.pe-stage.loading { opacity: .5; }
.pe-wrap, .ic-wrap, .ib-wrap, .bg-wrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.pe-canvas, .ic-canvas, .ib-canvas, .bg-canvas, .wm-canvas { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; box-shadow: 0 2px 10px rgba(16, 35, 53, .16); }
@media (max-width: 980px) { .pe-canvas, .ic-canvas, .ib-canvas, .bg-canvas, .wm-canvas { max-height: 60vh; } }

/* ---- Фоторедактор */
.pe-layer { position: absolute; left: 0; top: 0; overflow: hidden; line-height: normal; }
.pe-obj { position: absolute; transform: translate(-50%, -50%); cursor: move; touch-action: none; user-select: none; white-space: pre; text-align: center; outline: none; }
.pe-txt { display: block; paint-order: stroke fill; }
.pe-obj.sel { outline: 2px dashed var(--accent); outline-offset: 3px; }
.pe-obj:not(.sel):hover { outline: 1px dashed rgba(255, 255, 255, .9); outline-offset: 3px; }
.pe-hnd { position: absolute; right: -11px; bottom: -11px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: nwse-resize; }
.pe-del { position: absolute; right: -14px; top: -16px; width: 26px; height: 26px; }
.pe-obj:not(.sel) .pe-hnd, .pe-obj:not(.sel) .pe-del, .ib-reg:not(.sel) .pe-del { display: none; }
@media (pointer: coarse) { .pe-hnd { width: 24px; height: 24px; right: -15px; bottom: -15px; } }

.pe-panel { display: grid; gap: 14px; }
.pe-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.pe-tabs button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 11px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.pe-tabs button[aria-selected=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pe-body, .pe-objp { display: grid; gap: 14px; }
.pe-objp { padding-top: 6px; border-top: 1px solid var(--line); }
.pe-panel textarea, .pe-panel select { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; background: var(--surface); font: 15px/1.35 var(--font); }
.pe-panel input[type=range] { width: 100%; accent-color: var(--accent); }
.pe-panel input[type=color] { width: 44px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; padding: 2px; background: var(--surface); cursor: pointer; }
.pe-row { display: flex; gap: 6px; align-items: flex-end; }
.pe-grow { flex: 1; min-width: 0; }
.pe-row .ed-b { height: 40px; width: 40px; }
.pe-i { font-style: italic; }
.pe-u { font-size: 12px; }
.pe-filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pe-filter { border: 2px solid transparent; background: var(--bg); border-radius: 10px; padding: 4px 4px 6px; display: grid; gap: 4px; justify-items: center; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.pe-filter canvas { width: 100%; height: 62px; object-fit: cover; border-radius: 6px; }
.pe-filter[aria-pressed=true] { border-color: var(--accent); background: var(--accent-wash); }
.pe-stickers { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pe-stickers button { border: 0; background: var(--bg); border-radius: 8px; font-size: 22px; line-height: 1; padding: 6px 0; cursor: pointer; }
.pe-stickers button:hover { background: var(--accent-wash); }
.pe-frames { grid-template-columns: 1fr 1fr; }
.pe-frames .ocard { padding: 9px 12px; }
.pe-turn { display: grid; gap: 8px; }
.pe-turn .btn { justify-content: flex-start; }
.pe-reset { justify-self: start; color: var(--muted); font-size: 13px; }

/* ---- Обрезка */
.ic-box { position: absolute; box-shadow: 0 0 0 9999px rgba(16, 35, 53, .55); outline: 2px solid #fff; cursor: move; touch-action: none; }
.ic-wrap { touch-action: none; cursor: crosshair; }
.ic-grid { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255, 255, 255, .55) 0, rgba(255, 255, 255, .55) calc(33.33% + .5px), transparent 0, transparent calc(66.66% - .5px), rgba(255, 255, 255, .55) 0, rgba(255, 255, 255, .55) calc(66.66% + .5px), transparent 0),
              linear-gradient(transparent calc(33.33% - .5px), rgba(255, 255, 255, .55) 0, rgba(255, 255, 255, .55) calc(33.33% + .5px), transparent 0, transparent calc(66.66% - .5px), rgba(255, 255, 255, .55) 0, rgba(255, 255, 255, .55) calc(66.66% + .5px), transparent 0); }
.ic-h { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--accent); border-radius: 3px; margin: -7px 0 0 -7px; }
@media (pointer: coarse) { .ic-h { width: 24px; height: 24px; margin: -12px 0 0 -12px; } }
.ic-nw { left: 0; top: 0; cursor: nwse-resize; } .ic-n { left: 50%; top: 0; cursor: ns-resize; } .ic-ne { left: 100%; top: 0; cursor: nesw-resize; }
.ic-e { left: 100%; top: 50%; cursor: ew-resize; } .ic-se { left: 100%; top: 100%; cursor: nwse-resize; } .ic-s { left: 50%; top: 100%; cursor: ns-resize; }
.ic-sw { left: 0; top: 100%; cursor: nesw-resize; } .ic-w { left: 0; top: 50%; cursor: ew-resize; }
.ic-info { text-align: center; color: var(--muted); font-size: 14px; margin-top: 10px; font-variant-numeric: tabular-nums; }

/* ---- Размытие областей */
.ib-hint { margin-bottom: 10px; }
.ib-layer { position: absolute; inset: 0; cursor: crosshair; touch-action: none; line-height: normal; }
.ib-reg { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(16, 35, 53, .6), inset 0 0 0 1px rgba(16, 35, 53, .4); cursor: move; touch-action: none; }
.ib-reg.ellipse { border-radius: 50%; }
.ib-reg.sel { border-color: var(--accent); }
.ib-reg .pe-hnd { right: -9px; bottom: -9px; }
.ib-reg.ellipse .pe-hnd { right: 6%; bottom: 6%; }
.ib-reg:not(.sel) .pe-hnd { opacity: .7; }

/* ---- Удаление фона */
.bg-stage[data-bg=color] { background: var(--bgc, #fff); }
.bg-wrap { cursor: crosshair; touch-action: none; overflow: hidden; }
.bg-cursor { position: absolute; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
.bg-wrap:not(:hover) .bg-cursor { display: none; }

/* ---- Водяной знак: превью */
.wm-stage + .ed-hint { margin-top: 10px; text-align: center; }

/* Положение 3×3 */
.ogrid { display: grid; grid-template-columns: repeat(3, 38px); gap: 5px; }
.ogrid button { height: 32px; border: 1.5px solid var(--line-2); border-radius: 8px; background: var(--surface); cursor: pointer; display: grid; place-items: center; padding: 0; }
.ogrid button i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.ogrid button[aria-pressed=true] { border-color: var(--accent); background: var(--accent-wash); }
.ogrid button[aria-pressed=true] i { background: var(--accent); }

.dlg-code { width: min(640px, 80vw); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: 13px/1.4 ui-monospace, Consolas, monospace; resize: vertical; }
.dz-alt .btn-ghost { background: var(--surface); }
