/* Редактор изображения перед отправкой */
.zm-image-editor {
  position: fixed;
  inset: 0;
  z-index: 12050;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.zm-image-editor[hidden] {
  display: none !important;
}

body.zm-image-editor-open {
  overflow: hidden;
}

.zm-image-editor__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.zm-image-editor__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  background: var(--zm-bg-elevated, #fff);
  color: var(--zm-text, #111);
}

@media (min-width: 600px) {
  .zm-image-editor__panel {
    width: min(100%, 1024px);
    height: calc(100% - 16px);
    max-height: calc(100% - 16px);
    margin: 8px auto;
    border-radius: var(--zm-radius-md, 12px);
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }
}

.zm-image-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--zm-border, #e5e7eb);
  background: var(--zm-bg-surface, #f9fafb);
  flex-shrink: 0;
}

.zm-image-editor__tools,
.zm-image-editor__zoom,
.zm-image-editor__history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.zm-image-editor__zoom-label {
  min-width: 3.2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--zm-text-muted, #6b7280);
  font-variant-numeric: tabular-nums;
}

.zm-image-editor__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--zm-border, #e5e7eb);
  border-radius: 50%;
  background: var(--zm-bg-elevated, #fff);
  color: var(--zm-text, #111);
  cursor: pointer;
  flex-shrink: 0;
}

.zm-image-editor__icon-btn:focus-visible {
  outline: 2px solid var(--zm-accent, #2563eb);
  outline-offset: 2px;
}

.zm-image-editor__icon-btn--tool.zm-image-editor__icon-btn--active {
  border-color: var(--zm-accent, #2563eb);
  background: color-mix(in srgb, var(--zm-accent, #2563eb) 14%, transparent);
  color: var(--zm-accent, #2563eb);
}

.zm-image-editor__icon-btn--cancel {
  border-color: rgba(239, 68, 68, 0.35);
  color: #dc2626;
  background: rgba(239, 68, 68, 0.08);
}

.zm-image-editor__icon-btn--save {
  border-color: rgba(34, 197, 94, 0.4);
  color: #16a34a;
  background: rgba(34, 197, 94, 0.1);
}

.zm-image-editor__icon-btn--history:disabled {
  opacity: 0.38;
  cursor: default;
}

.zm-image-editor__hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--zm-text-muted, #6b7280);
}

@media (min-width: 720px) {
  .zm-image-editor__hint {
    flex: 1 1 220px;
    min-width: 0;
  }
}

.zm-image-editor__icon-svg {
  width: 20px;
  height: 20px;
  display: block;
}

.zm-image-editor__palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.zm-image-editor__swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.zm-image-editor__swatch--on {
  border-color: var(--zm-accent, #2563eb);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--zm-accent, #2563eb) 35%, transparent);
}

.zm-image-editor__toolbar-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

.zm-image-editor__stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #0f172a;
  overscroll-behavior: contain;
}

.zm-image-editor__stage-inner {
  position: relative;
  box-sizing: border-box;
  padding: 12px;
  min-width: 100%;
  min-height: 100%;
}

.zm-image-editor__stage--pan-tool {
  cursor: grab;
}

.zm-image-editor__stage--pan-ready {
  cursor: grab;
}

.zm-image-editor__stage--panning {
  cursor: grabbing;
  user-select: none;
}

.zm-image-editor__viewport {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-block;
  line-height: 0;
  flex-shrink: 0;
}

.zm-image-editor__viewport--pan,
.zm-image-editor__viewport--pan * {
  pointer-events: none !important;
}

.zm-image-editor__canvas {
  display: block;
}

.zm-image-editor__canvas--draw {
  position: absolute;
  left: 0;
  top: 0;
  touch-action: none;
}

.zm-image-editor__canvas--draw-tool {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") 2 22, crosshair;
}

.zm-image-editor__canvas--arrow-tool {
  cursor: crosshair;
}

.zm-image-editor__text-layer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}

.zm-image-editor__text-layer--active {
  pointer-events: auto;
  cursor: text;
}

.zm-image-editor__text-item {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
}

.zm-image-editor__text-scaled {
  display: inline-block;
  transform-origin: center center;
}

.zm-image-editor__text-frame-wrap {
  position: relative;
  display: inline-block;
}

.zm-image-editor__text-handles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.zm-image-editor__text-handles .zm-image-editor__text-handle {
  pointer-events: auto;
}

.zm-image-editor__text-frame {
  position: relative;
  display: inline-block;
  min-width: 40px;
  padding: 4px 8px;
}

.zm-image-editor__text-item--selected .zm-image-editor__text-frame {
  outline: 2px dashed rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
  border-radius: 2px;
}

.zm-image-editor__text-body {
  outline: none;
  font-weight: 600;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
  display: block;
  width: max-content;
  max-width: min(72vw, 320px);
  min-width: 1.5em;
  min-height: 1.25em;
  height: auto;
  line-height: 1.25;
  overflow: hidden;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  cursor: text;
}

.zm-image-editor__text-body:empty::before {
  content: 'Текст';
  opacity: 0.45;
  pointer-events: none;
}

.zm-image-editor__text-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--zm-accent, #2563eb);
  touch-action: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--zm-accent, #2563eb);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.zm-image-editor__handle-svg {
  width: 12px;
  height: 12px;
  display: block;
  pointer-events: none;
}

.zm-image-editor__text-handle--move {
  left: 50%;
  top: 0;
  margin-left: -11px;
  transform: translateY(calc(-100% - 6px)) scale(calc(1 / var(--zm-text-scale, 1)));
  transform-origin: 50% 100%;
  cursor: move;
}

.zm-image-editor__text-handle--rotate {
  right: 0;
  top: 0;
  transform: translate(50%, -50%) scale(calc(1 / var(--zm-text-scale, 1)));
  transform-origin: 100% 0%;
  cursor: grab;
}

.zm-image-editor__text-handle--rotate:active {
  cursor: grabbing;
}

.zm-image-editor__text-handle--scale {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%) scale(calc(1 / var(--zm-text-scale, 1)));
  transform-origin: 100% 100%;
  cursor: nwse-resize;
}

.zm-image-editor__text-handle--scale::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(1px, 1px);
  pointer-events: none;
}

.zm-image-editor__crop {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.zm-image-editor__crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px dashed #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}

.zm-image-editor__crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--zm-accent, #2563eb);
  border-radius: 2px;
}

.zm-image-editor__crop-handle--br {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.zm-attach-picker-item__edit,
.composer-staged-file__edit {
  flex-shrink: 0;
  font-size: 0.9rem;
}
