body.is-editor {
  height: auto;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

.ed-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.65rem 1rem;
  margin: 0.75rem 1rem 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.ed-header .btn-secondary { text-decoration: none; white-space: nowrap; }
.ed-title { min-width: 0; flex: 1; }
.ed-title h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ed-sub { margin: 0; font-size: 0.8rem; color: var(--muted); }
.ed-dirty { font-size: 0.78rem; font-weight: 600; color: var(--danger); }

.ed-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: 0.75rem;
  padding: 0.75rem 1rem 1rem;
  height: calc(100dvh - 4.6rem);
  min-height: 560px;
}

.ed-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  overflow-y: auto;
  min-width: 0;
}

.ed-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.8rem; padding: 0.25rem; background: var(--paper); border-radius: 12px; }
.ed-tab {
  flex: 1;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  border: none;
  border-radius: 9px;
  padding: 0.5rem 0.4rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.ed-tab.is-active { background: var(--brand); color: #fff; }

.ed-group { margin-bottom: 1.05rem; }
.ed-group:last-child { margin-bottom: 0; }
.ed-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.ed-panel .form-hint { color: var(--muted); margin-top: 0.4rem; }

.ed-row {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 0.5rem;
  align-items: center;
  margin: 0.4rem 0;
  font-size: 0.82rem;
}
.ed-row label { font-weight: 600; }
.ed-row output { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.6em; text-align: right; }
.ed-row input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--brand); margin: 0.1rem 0 0; min-height: 28px; }
.ed-row.is-changed label { color: var(--brand); }
.ed-row .ed-grad { grid-column: 1 / -1; height: 4px; border-radius: 3px; margin-top: 0.15rem; }
.ed-row .ed-grad + input { margin-top: -0.2rem; }

.ed-seg { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.5rem; }
.ed-seg button, .ed-chip {
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.42rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 34px;
}
.ed-seg button.is-active, .ed-chip.is-active { background: rgba(0, 61, 255, 0.1); border-color: rgba(0, 61, 255, 0.4); color: var(--brand); }
.ed-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.ed-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; margin-bottom: 0.5rem; }

.ed-btnrow { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0; }
.ed-btnrow--end { justify-content: flex-end; margin-top: 1rem; }
.ed-btnrow .btn-secondary { flex: 1 1 auto; min-height: 34px; }
.ed-wide { width: 100%; margin-top: 0.4rem; min-height: 38px; }
.ed-center { display: block; text-align: center; text-decoration: none; padding: 0.55rem 0.65rem; }
.btn-secondary.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.ed-check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; margin: 0.35rem 0; cursor: pointer; }
.ed-radios { display: grid; gap: 0.3rem; font-size: 0.86rem; margin-bottom: 0.4rem; }
.ed-radios label { display: flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.ed-radios label { align-items: flex-start; }
.ed-radios label input { margin-top: 0.2rem; }
.ed-opt { display: inline-flex; align-items: center; }
.ed-opt b { font-weight: 600; color: var(--ink); }
.ed-more { margin-top: 0.2rem; display: grid; gap: 0.3rem; }
.ed-more > summary { cursor: pointer; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }
.ed-more > label { margin-top: 0.3rem; }
.ed-radios label.is-disabled { opacity: 0.45; cursor: not-allowed; }
.ed-select {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
}

.ed-swatches { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.ed-swatches button {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; background: var(--c);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.ed-swatches button.is-active { box-shadow: 0 0 0 2px var(--brand); }
.ed-swatches--hsl { margin-bottom: 0.4rem; }

.ed-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 0.5rem; position: relative; }
.ed-topbar { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.ed-spacer { flex: 1; }
.ed-zoom { font-size: 0.82rem; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 3.4em; text-align: center; }
.ed-topbar .btn-secondary { min-height: 34px; }

.ed-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background-color: var(--paper-deep);
  background-image:
    linear-gradient(45deg, rgba(0,0,0,.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.05) 75%),
    linear-gradient(45deg, rgba(0,0,0,.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.05) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.ed-stack { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.ed-stack canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
#cv-img { image-rendering: auto; box-shadow: 0 6px 30px rgba(15, 23, 42, 0.25); }
#cv-mask { pointer-events: none; }
/* Отключаем жесты только на холсте, оставляя прокрутку страницы. */
#cv-cursor { touch-action: none; cursor: crosshair; }
#cv-cursor.is-pan { cursor: grab; }
#cv-cursor.is-panning { cursor: grabbing; }
.ed-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(232, 236, 243, 0.8); font-weight: 600; color: var(--muted);
}
.ed-loading[hidden] { display: none; }

.ed-toast {
  position: absolute; left: 50%; bottom: 1rem; transform: translateX(-50%);
  max-width: 90%; padding: 0.55rem 0.9rem; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 0.85rem; box-shadow: var(--shadow-brand);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.ed-toast.is-on { opacity: 1; }
.ed-toast.is-error { background: var(--danger); }

#hist { width: 100%; height: 72px; background: #fff; border: 1px solid var(--line); border-radius: 10px; display: block; }

.ed-edits { display: grid; gap: 0.5rem; }
.ed-edit { display: grid; grid-template-columns: 64px 1fr; gap: 0.5rem; padding: 0.45rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ed-edit.is-current { border-color: rgba(0, 61, 255, 0.45); }
.ed-edit img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--paper); }
.ed-edit-meta { font-size: 0.76rem; color: var(--muted); min-width: 0; }
.ed-edit-meta strong { color: var(--ink); display: block; font-size: 0.82rem; }
.ed-edit-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.ed-edit-actions .btn-secondary, .ed-edit-actions .btn-download { font-size: 0.74rem; padding: 0.28rem 0.5rem; text-decoration: none; }
.ed-empty { font-size: 0.82rem; color: var(--muted); }

.ed-dialog { max-width: min(440px, calc(100vw - 2rem)); }

@media (max-width: 1100px) {
  .ed-shell { grid-template-columns: minmax(0, 1fr); height: auto; padding: 0.6rem 1rem 1rem; }
  .ed-main { order: -1; }
  .ed-stage { flex: none; height: 62dvh; min-height: 320px; }
  .ed-panel { overflow: visible; }
  .ed-header { flex-wrap: wrap; margin: 0.6rem 1rem 0; }
}
@media (max-width: 520px) {
  .ed-header { margin: 0.5rem 16px 0; padding: 0.55rem 0.7rem; }
  .ed-shell { padding-left: 16px; padding-right: 16px; }
  .ed-chips { grid-template-columns: 1fr 1fr; }
}

#btn-preview {
  position: sticky;
  bottom: 0;
  z-index: 3;
  box-shadow: 0 -0.6rem 0.9rem var(--card);
}

#flux-box { margin-bottom: 0.4rem; }
#flux-box input[type="text"] { width: 100%; box-sizing: border-box; padding: 0.4rem 0.55rem; font: inherit; font-size: 0.86rem; border: 1px solid var(--border, #d0d5dd); border-radius: 6px; }

.ed-split { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 5; }
.ed-split[hidden] { display: none; }
.ed-split-line {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 24px; margin-left: -12px;
  pointer-events: auto; cursor: ew-resize; touch-action: none;
}
.ed-split-line::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 11px; width: 2px;
  background: rgba(255, 255, 255, 0.92); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.ed-split-handle {
  position: absolute; top: 50%; left: 50%; width: 2.1rem; height: 2.1rem;
  transform: translate(-50%, -50%); border-radius: 999px; background: #fff;
  border: 2px solid var(--brand, #2563eb); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  touch-action: none; cursor: ew-resize;
}
.ed-split-handle::before, .ed-split-handle::after {
  content: ""; position: absolute; top: 50%; width: 0; height: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent; transform: translateY(-50%);
}
.ed-split-handle::before { left: 0.35rem; border-right: 6px solid var(--brand, #2563eb); }
.ed-split-handle::after { right: 0.35rem; border-left: 6px solid var(--brand, #2563eb); }
.ed-split-lbl {
  position: absolute; top: 8px; padding: 0.15rem 0.55rem; border-radius: 999px;
  background: rgba(15, 23, 42, 0.72); color: #fff; font-size: 0.75rem; font-weight: 600;
  white-space: nowrap; pointer-events: none;
}
.ed-split-lbl--l { left: 8px; }
.ed-split-lbl--r { right: 8px; }

.ed-step .ed-label { display: flex; align-items: center; gap: 0.45rem; }
.ed-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 0.7rem; letter-spacing: 0;
}
.ed-label--sub { margin-top: 0.75rem; }
.ed-how { margin: 0 0 0.5rem; font-size: 0.82rem; line-height: 1.35; color: var(--ink); }
.ed-more .ed-row { margin-top: 0.35rem; }
.ed-more > .form-hint { margin-top: 0.1rem; }

.ed-layers { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.ed-layer {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.2rem;
  padding: 0.2rem 0.2rem 0.2rem 0.55rem;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: 0.8rem; font-weight: 600;
}
.ed-layer button {
  width: 28px; height: 28px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--brand);
  font: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
}
.ed-layer button:hover { background: rgba(0, 61, 255, 0.1); border-color: rgba(0, 61, 255, 0.4); }
.ed-layer.is-disabled { opacity: 0.4; }
.ed-layer button:disabled { cursor: not-allowed; }
.ed-maskview { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; }
.ed-maskview .ed-check { margin: 0; }

.ed-feedback form { display: grid; gap: 0.8rem; }
.ed-feedback .stars { padding: 0.15rem 0; }
.ed-feedback textarea { resize: vertical; display: block; }
.ed-fb-ok { color: var(--muted); }

.ed-label--row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ed-mini { font-size: 0.74rem; padding: 0.25rem 0.6rem; text-transform: none; letter-spacing: 0; }
.ed-lrows { display: flex; flex-direction: column; gap: 0.3rem; }
.ed-lrow {
  display: flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.4rem 0.4rem 0.5rem;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer;
}
.ed-lrow:hover { border-color: rgba(var(--brand-rgb), 0.3); }
.ed-lrow:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.ed-lrow.is-active { border-color: rgba(var(--brand-rgb), 0.55); background: rgba(var(--brand-rgb), 0.06); box-shadow: inset 3px 0 0 var(--brand); }
.ed-lrow.is-hidden .ed-lrow-main, .ed-lrow.is-hidden .ed-lrow-sw { opacity: 0.4; }
.ed-lrow--all { background: var(--paper); }
.ed-lrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.05rem; }
.ed-lrow-main strong { font-size: 0.82rem; font-weight: 600; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.ed-lrow-main small { font-size: 0.72rem; line-height: 1.25; color: var(--muted); }
.ed-lrow-main small.is-pending { color: #b45309; font-weight: 600; }
.ed-lrow-sw { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.ed-lrow .ed-lrow-eye, .ed-lrow .ed-lrow-del {
  flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 0.9rem; line-height: 1; cursor: pointer;
}
.ed-lrow .ed-lrow-eye:hover, .ed-lrow .ed-lrow-del:hover { background: var(--paper-deep); color: var(--ink); }
.ed-lrow .ed-lrow-del:hover { color: var(--danger); }
.ed-target-line { font-weight: 600; font-size: 0.88rem; padding-left: 0.5rem; border-left: 4px solid var(--c, var(--line)); }
#btn-preview.is-pending { box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.35); }

.ed-pick.is-active { background: rgba(var(--brand-rgb), 0.12); border-color: rgba(var(--brand-rgb), 0.5); color: var(--brand); }
.ed-pick-box { display: flex; align-items: center; gap: 0.35rem; margin: 0.4rem 0 0.2rem; font-size: 0.8rem; color: var(--muted); }
#btn-pick { margin-bottom: 1rem; }
#pick-box:not([hidden]) { margin-bottom: 1rem; }
.ed-pick-box span { flex: 1; }
#cv-cursor.is-pick { cursor: crosshair; }
#cv-cursor.is-busy { cursor: progress; }

.ed-tip {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 16px; height: 16px; margin-left: 6px; border-radius: 50%; vertical-align: middle;
  background: var(--paper-deep); color: var(--muted); cursor: help;
  font-size: 11px; font-weight: 700; line-height: 1; text-transform: none; letter-spacing: 0;
}
.ed-tip::before { content: "?"; }
.ed-tip:hover, .ed-tip:focus-visible, .ed-tip.is-open { background: var(--brand); color: #fff; outline: none; }
.ed-tip-text { display: none; }
.ed-tip:has(.ed-tip-text:empty) { display: none; }
.ed-tiprow { display: flex; align-items: center; gap: 0.2rem; }
.ed-tiprow > :first-child { flex: 1; min-width: 0; }
.ed-tipbox {
  position: fixed; z-index: 1000; max-width: 340px; padding: 0.55rem 0.7rem;
  background: var(--ink); color: #fff; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 0.8rem; line-height: 1.4; pointer-events: none; white-space: pre-line;
}

[hidden] { display: none !important; }
.ed-tipbox p { margin: 0; }
.ed-tipbox p + p { margin-top: 0.35rem; }
.ed-tipbox b { font-weight: 700; }

.ed-jobbtn { text-align: left; cursor: pointer; width: 100%; white-space: normal; }
.ed-jobs[open] {
  width: min(1100px, calc(100vw - 1rem)); height: min(900px, calc(100dvh - 1rem));
  max-width: none; max-height: none; padding: 0; border: 0; border-radius: 14px;
  background: var(--card, #fff); color: var(--ink);
}
.ed-jobs::backdrop { background: rgba(8, 10, 16, 0.78); }
.ed-jobs-inner { display: flex; flex-direction: column; height: 100%; }
.ed-jobs-head { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line, rgba(0, 0, 0, 0.1)); }
.ed-jobs-head h3 { margin: 0; flex: 1; font-size: 1.05rem; }
.ed-jobs-x { border: 0; background: none; font-size: 1.9rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 0.3rem; }
.ed-jobs-scroll { flex: 1; overflow: auto; padding: 0.8rem 0.9rem 1rem; }
.ed-jgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.7rem; margin-top: 0.7rem; }
.ed-jgrid--photos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ed-jcard, .ed-jphoto {
  display: flex; flex-direction: column; gap: 0.35rem; padding: 0.4rem; text-align: left; cursor: pointer;
  border: 2px solid transparent; border-radius: 12px; background: var(--paper, #f4f4f6); color: inherit; font: inherit;
}
.ed-jcard:hover, .ed-jphoto:hover { border-color: rgba(0, 61, 255, 0.35); }
.ed-jcard.is-current, .ed-jphoto.is-current { border-color: rgba(0, 61, 255, 0.8); }
.ed-jthumb { aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: rgba(128, 128, 128, 0.18); }
.ed-jthumb img, .ed-jphoto img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; }
.ed-jphoto img { aspect-ratio: 3 / 2; height: auto; background: rgba(128, 128, 128, 0.18); }
.ed-jcap { display: flex; flex-direction: column; font-size: 0.78rem; color: var(--muted); }
.ed-jcap strong { color: var(--ink); font-size: 0.88rem; }
.ed-jphoto span { font-size: 0.74rem; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .ed-jobs[open] { width: 100vw; height: 100dvh; border-radius: 0; }
  .ed-jgrid { grid-template-columns: repeat(2, 1fr); }
}

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ed-hasic { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; }
.ed-hasic .bt { min-width: 0; }
.ed-ibtn, .ed-seg button.ed-ibtn { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 36px; padding: 0.3rem 0.5rem; }
.ed-btnrow .btn-secondary.ed-ibtn { flex: 0 0 auto; }
.ed-ibtn--sm { min-width: 32px; min-height: 30px; padding: 0.2rem 0.4rem; }
.ed-ibtn--sm .ic { width: 16px; height: 16px; }
.ed-ibtn.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.ed-seg button.ed-ibtn.is-active { background: rgba(0, 61, 255, 0.1); color: var(--brand); border-color: rgba(0, 61, 255, 0.4); }
.ed-opt .ed-mic { margin-right: 0.4rem; color: var(--muted); }
.ed-radios label:has(input:checked) .ed-mic { color: var(--brand); }
.ed-layer button { display: inline-flex; align-items: center; justify-content: center; }
.ed-layer button .ic { width: 15px; height: 15px; }
.ed-lrow .ed-lrow-eye, .ed-lrow .ed-lrow-del { display: inline-flex; align-items: center; justify-content: center; }
.ed-lrow .ic { width: 16px; height: 16px; }
.ed-jobs-x { display: inline-flex; }
.ed-jobs-x .ic { width: 22px; height: 22px; }
.star .ic { width: 22px; height: 22px; fill: currentColor; stroke-width: 1.5; }
.ed-tt {
  position: fixed; z-index: 1100; max-width: min(280px, calc(100vw - 16px)); padding: 0.35rem 0.6rem;
  background: var(--ink); color: #fff; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 0.78rem; line-height: 1.35; pointer-events: none;
}

.ed-glnote { margin: 0 0 0.6rem; padding: 0.5rem 0.65rem; border-radius: 10px; background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.4); font-size: 0.78rem; line-height: 1.4; color: var(--ink); }
.ed-calc { font-size: 0.78rem; color: var(--muted); padding: 0 0.3rem; }
.ed-calc.is-err { color: var(--danger, #b42318); }
