:root { --pe-muted:#66736b; --pe-line:rgba(57,74,64,.13); --pe-danger:#92594b; }
.pe-button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; padding: 6px 11px; font-size: 11px; font-weight: 650; cursor: pointer; }
.pe-button.pe-secondary { border: 1px solid rgba(69, 106, 84, .25); color: #3e654d; background: rgba(255, 255, 255, .66); }
.pe-button.pe-primary { border: 1px solid #456a54; color: white; background: #456a54; }
.pe-button.pe-danger { border: 1px solid var(--pe-danger); color: white; background: var(--pe-danger); }
.pe-button.pe-text-danger { border: 0; color: var(--pe-danger); background: transparent; }

.pe-editor-layer, .pe-confirm-layer { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 10px; background: rgba(38, 48, 42, .42); backdrop-filter: blur(7px); }
.pe-editor-dialog { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: min(740px, calc(100vw - 20px)); max-height: min(570px, calc(100dvh - 20px)); overflow: hidden; border: 1px solid rgba(55, 74, 63, .16); border-radius: 22px; background: #fffdf9; box-shadow: 0 24px 70px rgba(42, 44, 38, .22); }
.pe-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px 10px; }
.pe-editor-header p, .pe-preview-label { margin: 0 0 3px; color: #707870; font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.pe-editor-header h2 { margin: 0; font-size: 21px; line-height: 1.15; }
.pe-close-editor { width: 32px; height: 32px; flex: 0 0 32px; border: 1px solid rgba(69, 106, 84, .20); border-radius: 50%; color: #617068; background: rgba(255, 255, 255, .8); font-size: 21px; line-height: 1; cursor: pointer; }
.pe-editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 20px; min-height: 0; padding: 8px 18px 12px; }
.pe-crop-column { display: grid; align-content: center; justify-items: center; min-width: 0; min-height: 0; }
.pe-crop-source-bar { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; width: min(300px, 38vh, 42vw); margin-bottom: 8px; }
.pe-choose-photo-button { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(69, 106, 84, .25); border-radius: 9px; padding: 5px 10px; color: #3e654d; background: rgba(255, 255, 255, .76); font-size: 10px; font-weight: 650; cursor: pointer; }
.pe-choose-photo-button:hover { background: white; }
.pe-choose-photo-button:focus-within { outline: 3px solid rgba(77, 114, 90, .32); outline-offset: 3px; }
.pe-selected-file-name { min-width: 0; overflow: hidden; color: var(--pe-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.pe-crop-viewport { position: relative; width: min(300px, 38vh, 42vw); aspect-ratio: 1; overflow: hidden; border-radius: 20px; background: #e6e3db; box-shadow: inset 0 0 0 1px rgba(55, 74, 63, .14); touch-action: none; cursor: grab; user-select: none; }
.pe-crop-viewport.pe-is-dragging { cursor: grabbing; }
.pe-crop-viewport > img { position: absolute; top: 50%; left: 50%; max-width: none; pointer-events: none; user-select: none; will-change: transform; }
.pe-crop-viewport::after { position: absolute; inset: 0; border: clamp(16px, 2.6vw, 30px) solid rgba(39, 48, 43, .48); content: ""; pointer-events: none; }
.pe-crop-guide { position: absolute; z-index: 2; inset: clamp(16px, 2.6vw, 30px); border: 1px solid rgba(255, 255, 255, .94); border-radius: 50%; box-shadow: 0 0 0 999px rgba(39, 48, 43, .04); pointer-events: none; }
.pe-move-hint { margin: 7px 0 0; color: var(--pe-muted); font-size: 10px; text-align: center; }
.pe-preview-column { display: flex; flex-direction: column; justify-content: center; gap: 15px; }
#pe-preview-canvas { display: block; width: 108px; height: 108px; margin: 7px auto 0; border: 4px solid white; border-radius: 50%; background: #a77a5e; box-shadow: 0 7px 18px rgba(65, 59, 43, .16); }
.pe-zoom-controls { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 8px; }
.pe-zoom-controls button { width: 32px; height: 32px; border: 1px solid rgba(69, 106, 84, .24); border-radius: 50%; color: #3e654d; background: rgba(255, 255, 255, .78); font-size: 20px; line-height: 1; }
.pe-zoom-controls div { text-align: center; }
.pe-zoom-controls span, .pe-zoom-controls strong { display: block; }
.pe-zoom-controls span { color: var(--pe-muted); font-size: 9px; }
.pe-zoom-controls strong { margin-top: 2px; font-size: 11px; }
.pe-reset-button { min-height: 32px; border: 0; border-bottom: 1px solid rgba(72, 107, 84, .28); padding: 0; color: #4c6c58; background: transparent; font-size: 10px; font-weight: 600; }
.pe-editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px 15px; border-top: 1px solid var(--pe-line); }
.pe-editor-footer > div { display: flex; gap: 8px; }
.pe-editor-footer > div > button { white-space: nowrap; }

.pe-confirm-layer { z-index: 120; }
.pe-confirm-dialog { width: min(390px, calc(100vw - 24px)); padding: 22px; border-radius: 20px; background: #fffdf9; box-shadow: 0 24px 70px rgba(42, 44, 38, .24); text-align: center; }
.pe-confirm-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 11px; border-radius: 50%; color: var(--pe-danger); background: rgba(141, 85, 74, .10); font-size: 23px; }
.pe-confirm-dialog h2 { margin: 0; font-size: 20px; }
.pe-confirm-dialog p { margin: 8px 0 18px; color: var(--pe-muted); font-size: 12px; line-height: 1.5; }
.pe-confirm-dialog > div { display: flex; justify-content: center; gap: 8px; }


@media (max-width: 820px) {
  .pe-editor-dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); border-radius: 18px; }
  .pe-editor-header { padding: 10px 11px 6px; }
  .pe-editor-header h2 { font-size: 17px; }
  .pe-editor-body { grid-template-columns: minmax(0, 1fr) 108px; gap: 10px; padding: 4px 10px 7px; }
  .pe-crop-source-bar { width: min(48vw, 235px, 34vh); gap: 5px; margin-bottom: 5px; }
  .pe-choose-photo-button { min-height: 27px; padding: 4px 7px; font-size: 8px; }
  .pe-selected-file-name { font-size: 7px; }
  .pe-crop-viewport { width: min(48vw, 235px, 34vh); border-radius: 15px; }
  .pe-crop-viewport::after { border-width: clamp(12px, 4vw, 20px); }
  .pe-crop-guide { inset: clamp(12px, 4vw, 20px); }
  .pe-move-hint { max-width: 170px; font-size: 8px; line-height: 1.25; }
  .pe-preview-column { gap: 9px; }
  .pe-preview-label { font-size: 7px; line-height: 1.25; text-align: center; }
  #pe-preview-canvas { width: 70px; height: 70px; margin-top: 4px; border-width: 3px; }
  .pe-zoom-controls { grid-template-columns: 27px minmax(0, 1fr) 27px; gap: 4px; }
  .pe-zoom-controls button { width: 27px; height: 27px; font-size: 17px; }
  .pe-zoom-controls span { font-size: 7px; }
  .pe-zoom-controls strong { font-size: 9px; }
  .pe-reset-button { min-height: 26px; font-size: 8px; line-height: 1.2; }
  .pe-editor-footer { padding: 7px 10px 10px; }
  .pe-editor-footer { flex-wrap: wrap; gap: 4px; }
  .pe-editor-footer > div { width: 100%; gap: 5px; }
  .pe-editor-footer > div > button { flex: 1 1 auto; padding-inline: 5px; }
}


@media (max-width: 360px), (max-height: 590px) {
  .pe-editor-header { padding-top: 8px; }
  .pe-editor-header p { display: none; }
  .pe-editor-body { grid-template-columns: minmax(0, 1fr) 92px; gap: 7px; padding-block: 2px 5px; }
  .pe-crop-source-bar { grid-template-columns: 1fr; width: min(45vw, 27vh); }
  .pe-selected-file-name { display: none; }
  .pe-crop-viewport { width: min(45vw, 27vh); }
  #pe-preview-canvas { width: 58px; height: 58px; }
  .pe-move-hint { margin-top: 4px; }
  .pe-editor-footer { padding-block: 6px 8px; }
}

.pe-editor-dialog { margin:auto; padding:0; color:#2f3d35; font-family:Onest,Manrope,sans-serif; }
.pe-editor-dialog:not([open]) { display:none; }
.pe-editor-dialog::backdrop { background:rgba(38,48,42,.42); backdrop-filter:blur(7px); }
.pe-editor-dialog * { box-sizing:border-box; }
.pe-editor-dialog [hidden] { display:none !important; }
.pe-editor-dialog button { font-family:inherit; cursor:pointer; }
.pe-editor-dialog button:disabled { opacity:.45; cursor:default; }
.pe-editor-footer > div { margin-left:auto; }
.pe-editor-dialog button:focus-visible { outline:3px solid #9bae9e; outline-offset:2px; }
.pe-crop-source-bar { min-height:12px; }
.pe-editor-dialog .pe-error { display:block !important; color:#92594b; white-space:normal; }
.pe-confirm { position:absolute; inset:0; z-index:5; display:grid; place-items:center; background:rgba(255,253,249,.97); }
.pe-editor-dialog .pe-confirm-dialog { box-shadow:none; }
#pe-preview-canvas { background:#e6e3db; }
