/* Pimg.me editor. Everything is scoped under .pe (the #pimg-app element) and uses its own tokens,
   so it does not depend on the page's stylesheet. */
.pe {
  --pe-cream: #FFF9F4;
  --pe-ink: #2D2445;
  --pe-ink2: #625A78;
  --pe-pink: #FF5C8A;
  --pe-go: #D92D66;
  --pe-go-deep: #B8245A;
  --pe-pink-soft: #FFE3EA;
  --pe-line: #EFE6F4;
  --pe-fill: #F6F1FA;
  --pe-glass: rgba(255, 255, 255, .94);
  --pe-shadow: 0 10px 30px -12px rgba(76, 46, 110, .3);
  --pe-font: Nunito, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;

  position: absolute; inset: 0; overflow: hidden;
  color: var(--pe-ink); font: 600 14px/1.4 var(--pe-font);
  -webkit-user-select: none; user-select: none;
  background:
    radial-gradient(900px 520px at 0% 0%, rgba(255, 92, 138, .13), transparent 70%),
    radial-gradient(760px 520px at 100% 100%, rgba(126, 220, 196, .2), transparent 70%),
    radial-gradient(circle, rgba(45, 36, 69, .14) 1.1px, transparent 1.3px) 0 0 / 22px 22px,
    var(--pe-cream);
}
.pe *, .pe *::before, .pe *::after { box-sizing: border-box; }
/* resets are wrapped in :where() so they never outrank the component rules below */
.pe [hidden] { display: none !important; }
:where(.pe) :where(button, input, select) { font: inherit; color: inherit; }
:where(.pe) button { cursor: pointer; border: 0; background: none; padding: 0; }
:where(.pe) svg { display: block; flex: none; }
.pe kbd {
  display: inline-block; padding: 1px 7px; border: 1.5px solid var(--pe-line); border-bottom-width: 3px;
  border-radius: 7px; background: #fff; font: 800 12px/1.5 var(--pe-font);
}
.pe :focus-visible { outline: 3px solid var(--pe-pink); outline-offset: 2px; }

.pe-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* floating cards */
.pe-card {
  position: absolute; z-index: 3; background: var(--pe-glass); border: 1.5px solid var(--pe-line); border-radius: 20px;
  box-shadow: var(--pe-shadow); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.pe-btn {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; color: var(--pe-ink);
  transition: background .15s, transform .15s;
}
.pe-btn:hover { background: var(--pe-fill); }
.pe-btn:active { transform: scale(.92); }
.pe-btn:disabled { opacity: .32; cursor: default; background: none; }
.pe-btn.is-on { background: var(--pe-ink); color: #fff; }
.pe-btn--pink { background: var(--pe-pink); color: #fff; box-shadow: 0 6px 14px -6px rgba(255, 92, 138, .9); }
.pe-btn--pink:hover { background: var(--pe-go); }
.pe-sep { display: block; height: 1.5px; margin: 6px 8px; background: var(--pe-line); border-radius: 2px; }
.pe-sep--v { width: 1.5px; height: 24px; margin: 0 6px; }

.pe-rail { left: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; padding: 6px; }
.pe-top { right: 16px; top: 16px; display: flex; align-items: center; gap: 2px; padding: 6px; }
.pe-zoom { min-width: 58px; height: 34px; padding: 0 10px; border-radius: 12px; background: var(--pe-fill); font-weight: 700; font-size: 17px; }
.pe-zoom:hover { background: var(--pe-pink-soft); }

/* dock */
.pe-dock { left: 50%; bottom: 20px; transform: translateX(-50%); padding: 6px; max-width: calc(100% - 24px); }
.pe-dock:not(:has(.pe-grp:not([hidden]))) { display: none; }
.pe-grp { display: flex; align-items: center; gap: 4px; }
.pe-hint { padding: 0 10px 0 12px; color: var(--pe-ink2); font-size: 14px; white-space: nowrap; }
.pe-hint b { color: var(--pe-ink); }
.pe-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: 14px; background: var(--pe-fill); font-weight: 700; font-size: 16px; white-space: nowrap;
  transition: transform .15s, background .15s;
}
.pe-pill:hover { background: var(--pe-pink-soft); }
.pe-pill:active { transform: translateY(1px) scale(.98); }
.pe-pill--go { background: var(--pe-go); color: #fff; box-shadow: 0 4px 0 var(--pe-go-deep), 0 12px 20px -10px rgba(217, 45, 102, .8); }
.pe-pill--go:hover { background: #E23A72; }
.pe-pill--go:active { box-shadow: 0 2px 0 var(--pe-go-deep); transform: translateY(2px); }
.pe-lay {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 74px; height: 50px;
  padding: 0 10px; border-radius: 14px; font-weight: 800; font-size: 11.5px; white-space: nowrap;
}
.pe-lay:hover { background: var(--pe-fill); }
.pe-lay.is-on { background: var(--pe-pink-soft); color: var(--pe-go); }

/* empty canvas */
.pe-empty { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.pe-empty-card {
  pointer-events: auto; width: min(520px, 100%); padding: 34px 28px 30px; text-align: center; background: rgba(255, 255, 255, .86);
  border: 2px dashed #F6A9BE; border-radius: 32px; box-shadow: 0 30px 60px -30px rgba(255, 92, 138, .55);
}
.pe-empty-art { display: grid; place-items: center; margin-bottom: 6px; }
.pe-empty-t { margin: 0 0 8px; font-size: 28px; font-weight: 900; letter-spacing: -.01em; }
.pe-empty-s { margin: 0 0 20px; color: var(--pe-ink2); font-size: 15px; line-height: 1.9; font-weight: 600; }
.pe-empty-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.pe-empty-btns .pe-pill { height: 50px; padding: 0 22px; border-radius: 16px; font-size: 17px; }
.pe-empty-btns .pe-pill:not(.pe-pill--go) { background: #fff; border: 2px solid var(--pe-line); font-weight: 600; }
.pe-empty-note { margin: 20px 0 0; font-size: 13px; font-weight: 800; color: var(--pe-ink2); }

/* settings panel */
.pe-panel { right: 16px; top: 78px; width: 268px; max-height: calc(100% - 78px - 96px); overflow: auto; padding: 14px; overscroll-behavior: contain; }
.pe-sec:not([hidden]) ~ .pe-sec:not([hidden]) { margin-top: 14px; padding-top: 14px; border-top: 1.5px solid var(--pe-line); }
.pe-h { margin: 0 0 12px; font-size: 15px; font-weight: 900; }
.pe-count { margin-left: 4px; font-size: 13px; font-weight: 700; color: var(--pe-ink2); }
.pe-field { display: block; margin: 0 0 14px; }
.pe-field-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.pe-val { font-weight: 800; color: var(--pe-ink2); font-size: 13px; }
.pe-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 800; }
.pe-step { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; background: var(--pe-fill); }
.pe-step button { width: 26px; height: 26px; border-radius: 8px; background: #fff; font-weight: 900; }
.pe-step b { min-width: 24px; text-align: center; }
.pe-select { width: 100%; height: 38px; padding: 0 10px; border: 1.5px solid var(--pe-line); border-radius: 12px; background: #fff; font-weight: 700; font-size: 13px; }
.pe-seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--pe-fill); }
.pe-seg button { flex: 1; height: 32px; border-radius: 9px; font-weight: 800; font-size: 13px; }
.pe-seg button.is-on { background: #fff; color: var(--pe-go); box-shadow: 0 2px 6px -2px rgba(76, 46, 110, .35); }
.pe-range {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 22px; margin: 0; background: none; cursor: pointer; --fill: 0%;
}
.pe-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--pe-pink) var(--fill), #EFE4F2 var(--fill)); }
.pe-range::-moz-range-track { height: 6px; border-radius: 3px; background: #EFE4F2; }
.pe-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--pe-pink); }
.pe-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 3px solid var(--pe-pink); box-shadow: 0 2px 5px rgba(76, 46, 110, .25); }
.pe-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--pe-pink); }
.pe-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-sw {
  position: relative; width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 1.5px solid rgba(45, 36, 69, .14); cursor: pointer;
}
.pe-sw--none { background: repeating-conic-gradient(#E6DFEC 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.pe-sw--pick { background: conic-gradient(#FF8FA3, #FFD166, #7EDCC4, #8FB8FF, #C9A6FF, #FF8FA3); overflow: hidden; }
.pe-sw--pick input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }
.pe-sw.is-on { box-shadow: 0 0 0 2.5px #fff, 0 0 0 5px var(--pe-pink); }
.pe-wh { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.pe-wh label { flex: 1; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border: 1.5px solid var(--pe-line); border-radius: 12px; background: #fff; }
.pe-wh label span { font-size: 12px; font-weight: 800; color: var(--pe-ink2); }
.pe-wh input { width: 100%; min-width: 0; border: 0; outline: 0; background: none; font-weight: 800; font-size: 16px; -moz-appearance: textfield; }
.pe-wh input::-webkit-outer-spin-button, .pe-wh input::-webkit-inner-spin-button { -webkit-appearance: none; }
.pe-lock { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--pe-ink2); background: var(--pe-fill); }
.pe-lock.is-on { background: var(--pe-pink-soft); color: var(--pe-go); }
.pe-chips { display: flex; gap: 6px; margin-bottom: 10px; }
.pe-chip { flex: 1; height: 28px; border: 1.5px solid var(--pe-line); border-radius: 9px; background: #fff; font-size: 12px; font-weight: 700; }
.pe-chip:hover { border-color: var(--pe-pink); }
.pe-meta { margin: 0; font-size: 13px; font-weight: 700; color: var(--pe-ink2); }
.pe-out { padding: 10px 12px; margin: 0 0 12px; border-radius: 12px; background: var(--pe-fill); color: var(--pe-ink); font-weight: 800; }
.pe-sec--out .pe-seg { margin-bottom: 14px; }
.pe-acts { display: flex; gap: 8px; }
.pe-acts .pe-pill { flex: 1; padding: 0 10px; }

/* shortcuts */
.pe-help { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px; background: rgba(45, 36, 69, .28); }
.pe-help-card { position: relative; width: min(440px, 100%); padding: 22px; background: #fff; }
.pe-help-x, .pe-panel-x { position: absolute; right: 8px; top: 8px; }
.pe-help dl { margin: 0; }
.pe-help dl > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1.5px solid var(--pe-line); }
.pe-help dt { font-weight: 700; white-space: nowrap; }
.pe-help dd { margin: 0; color: var(--pe-ink2); text-align: right; }

/* drop target and toast */
.pe-drop { position: absolute; inset: 12px; z-index: 9; display: grid; place-items: center; border: 3px dashed var(--pe-pink); border-radius: 28px; background: rgba(255, 227, 234, .82); pointer-events: none; }
.pe-drop div { font-size: 26px; font-weight: 900; color: var(--pe-go); }
.pe-toast {
  position: absolute; left: 50%; bottom: 92px; z-index: 7; transform: translate(-50%, 12px); max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 14px; background: var(--pe-ink); color: #fff; font-weight: 700; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.pe-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* crop mode */
.pe-pill--flat { background: none; padding: 0 12px; font-size: 14px; font-weight: 800; }
.pe-chip2 { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 11px; background: var(--pe-fill); font-weight: 700; font-size: 15px; white-space: nowrap; }
.pe-chip2:hover { background: var(--pe-pink-soft); }
.pe-chip2.is-on { background: var(--pe-ink); color: #fff; }
.pe-chip2--sizes { background: var(--pe-pink-soft); color: var(--pe-go-deep); }
.pe-presets { left: 50%; bottom: 88px; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); max-height: min(420px, calc(100% - 190px)); display: flex; flex-direction: column; padding: 12px; background: #fff; z-index: 6; }
.pe-presets-h { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.pe-presets-h b { font-weight: 900; white-space: nowrap; }
.pe-psearch { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 2px solid var(--pe-pink); border-radius: 12px; outline: 0; font-weight: 600; }
.pe-plist { overflow: auto; overscroll-behavior: contain; }
.pe-pgroup { margin: 10px 2px 6px; font-size: 12px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; color: var(--pe-ink2); }
.pe-pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pe-preset { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1.5px solid var(--pe-line); border-radius: 12px; text-align: left; }
.pe-preset:hover { border-color: var(--pe-pink); background: #FFF7F9; }
.pe-preset i { flex: none; margin: 0 2px; border: 2px solid var(--pe-ink); border-radius: 3px; background: var(--pe-pink-soft); }
.pe-preset span { display: block; min-width: 0; }
.pe-preset b { display: block; font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-preset small { font-size: 12px; font-weight: 600; color: var(--pe-ink2); }

.pe-narrow { display: none; }

/* phones and narrow windows: the panel becomes a sheet, the rail shrinks, the top bar moves under the badge */
@media (max-width: 760px) {
  .pe-wide { display: none; }
  .pe-narrow { display: grid; }
  .pe-rail { display: none; }
  .pe-top { left: 12px; right: auto; top: 74px; }
  .pe-dock { bottom: 12px; width: calc(100% - 24px); }
  .pe-grp { justify-content: space-between; }
  .pe-hint { white-space: normal; font-size: 13px; }
  .pe-lay { min-width: 0; flex: 1; padding: 0 2px; }
  .pe-dock .pe-pill--go { padding: 0 14px; }
  .pe-dock .pe-pill--go span { display: none; }
  .pe-panel { left: 12px; right: 12px; top: auto; bottom: 84px; width: auto; max-height: 56%; display: none; padding-top: 40px; }
  .pe-panel-open .pe-panel { display: block; }
  .pe-toast { bottom: 150px; }
  .pe-grp { flex-wrap: wrap; row-gap: 6px; }
  .pe-chip2 { padding: 0 9px; font-size: 13px; }
  .pe-pgrid { grid-template-columns: 1fr; }
  .pe-presets { bottom: 120px; }
  .pe-empty-t { font-size: 24px; }
}
