/* Load after the shared website styles. The editor owns no upload or auth state. */
.permutis-photo-editor {
  box-sizing: border-box;
  width: min(580px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .4);
}
.permutis-photo-editor::backdrop { background: rgba(0, 0, 0, .72); }
.permutis-photo-editor__content { padding: 24px; }
.permutis-photo-editor h2 { margin: 0 0 12px; color: var(--text); font-size: 1.5rem; }
.permutis-photo-editor__hint,
.permutis-photo-editor__status { color: var(--text); font-size: .9375rem; line-height: 1.5; margin: 8px 0 12px; }
.permutis-photo-editor__status:empty { display: none; }
.permutis-photo-editor__stage { width: min(100%, 420px); margin-inline: auto; }
.permutis-photo-editor__preview {
  display: block;
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  background: white;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
}
.permutis-photo-editor__preview:active { cursor: grabbing; }
.permutis-photo-editor__controls { display: grid; gap: 14px; margin-block: 16px; }
.permutis-photo-editor__slider { display: grid; gap: 8px; color: var(--text); }
.permutis-photo-editor__slider-heading { display: flex; justify-content: space-between; gap: 12px; font-size: 1rem; font-weight: 600; }
.permutis-photo-editor output { font-variant-numeric: tabular-nums; color: var(--text); }
.permutis-photo-editor input[type="range"] { width: 100%; min-height: 28px; margin: 0; accent-color: var(--violet-600); cursor: pointer; }
.permutis-photo-editor__tools { display: flex; flex-wrap: wrap; gap: 8px; }
.permutis-photo-editor__button {
  appearance: none;
  min-height: 44px;
  max-width: 100%;
  padding: 10px 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  white-space: normal;
  cursor: pointer;
}
.permutis-photo-editor__button:hover { color: var(--text); background: var(--surface); border-color: var(--text); }
.permutis-photo-editor__button--primary,
.permutis-photo-editor__button--primary:hover { background: var(--violet-600); color: var(--text-on-dark); border-color: var(--violet-600); }
.permutis-photo-editor__button:disabled { cursor: wait; }
.permutis-photo-editor :is(button, input, canvas):focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.permutis-photo-editor__footer { display: flex; justify-content: flex-end; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border-strong); }
@media (min-width: 900px) {
  .permutis-photo-editor { width: min(900px, calc(100vw - 32px)); }
  .permutis-photo-editor__content { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px 24px; align-items: start; }
  .permutis-photo-editor__content > :is(h2, .permutis-photo-editor__hint, .permutis-photo-editor__status, .permutis-photo-editor__footer) { grid-column: 1 / -1; margin: 0; }
  .permutis-photo-editor__stage { grid-column: 1; grid-row: 3; width: min(100%, 420px, calc(100dvh - 380px)); align-self: center; }
  .permutis-photo-editor__controls { grid-column: 2; grid-row: 3; margin: 0; }
}

#offer-image-preview,
.offer-step-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 12px;
  align-items: start;
}
#offer-image-preview .offer-image-card,
.offer-step-gallery-grid .offer-step-gallery-card {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  height: auto;
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
#offer-image-preview .offer-image-card img,
.offer-step-gallery-grid .offer-step-gallery-card img { display: block; width: 100%; min-height: 0; height: 100%; aspect-ratio: 1; object-fit: contain; background: white; }
#offer-image-preview .offer-image-card :is(button, .offer-image-badge),
.offer-step-gallery-grid :is(button, .offer-image-badge) { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
#offer-image-preview .offer-image-card > :is(span, small),
.offer-step-gallery-grid .offer-step-gallery-badge {
  max-width: calc(100% - 16px);
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: .75rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
#offer-image-preview .offer-image-card > span { bottom: 58px; }
#offer-image-preview .offer-image-card > button {
  top: auto;
  bottom: 6px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}
#offer-image-preview .offer-image-card .offer-image-main-btn { left: 6px; right: auto !important; color: var(--text) !important; }
#offer-image-preview .offer-image-card .offer-image-edit-btn { left: 50%; right: auto; transform: translateX(-50%); }
#offer-image-preview .offer-image-card .offer-image-remove-btn { right: 6px; }
.offer-step-gallery-grid .offer-step-gallery-actions { left: 6px; right: 6px; bottom: 6px; justify-content: space-between; gap: 4px; }
.offer-step-gallery-grid .offer-step-gallery-actions button { width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--border-strong); }
.offer-step-gallery-grid .offer-step-gallery-actions button:hover { background: var(--surface-2); color: var(--text); }
#offer-image-preview .offer-image-card > .offer-image-retry,
.offer-step-gallery-grid .offer-step-gallery-card > .offer-image-retry {
  position: absolute;
  top: auto;
  left: 6px;
  right: 6px;
  bottom: 56px;
  width: calc(100% - 12px);
  min-height: 44px;
  height: auto;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-size: .75rem;
  line-height: 1.3;
  white-space: normal;
}
#offer-image-preview .offer-image-card:has(> .offer-image-retry) > span { top: 34px; bottom: auto; }
#offer-image-preview .offer-image-empty,
.offer-step-gallery-grid .offer-step-gallery-empty { aspect-ratio: auto; color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
#offer-image-preview .offer-image-card button:focus-visible,
.offer-step-gallery-grid button:focus-visible { outline: 3px solid var(--text); outline-offset: -4px; }
@media (max-width: 640px) {
  .permutis-photo-editor { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .permutis-photo-editor__content { padding: 16px; }
  .permutis-photo-editor__footer > button { flex: 1; }
  #offer-image-preview,
  .offer-step-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 10px; }
}
