/* Toolszu Photo Editor — every rule is scoped to #tzpe so nothing leaks into the site (Tailwind safe) */
#tzpe {
  --pe-blue: #2563eb; --pe-blue-d: #1d4ed8; --pe-blue-l: #eff6ff; --pe-blue-m: #dbeafe;
  --pe-ink: #0f172a; --pe-ink2: #334155; --pe-mute: #64748b; --pe-line: #e2e8f0; --pe-line2: #cbd5e1;
  --pe-bg: #f8fafc; --pe-stage: #e8edf4; --pe-danger: #dc2626; --pe-radius: 18px;
  --pe-top: 56px; --pe-rail: 78px; --pe-panel: 332px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--pe-ink); position: relative; max-width: 1400px; margin: 0 auto; -webkit-tap-highlight-color: transparent;
}
#tzpe *, #tzpe *::before, #tzpe *::after { box-sizing: border-box; }
#tzpe button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; margin: 0; }
#tzpe button:disabled { cursor: not-allowed; opacity: .4; }
#tzpe [hidden] { display: none !important; }
#tzpe a { color: var(--pe-blue); font-weight: 600; }
#tzpe :focus-visible { outline: 2px solid var(--pe-blue); outline-offset: 2px; }

/* ---------- upload screen ---------- */
#tzpe .tzpe-drop {
  border: 2px dashed #93c5fd; border-radius: 24px; background:
    radial-gradient(1200px 300px at 50% -40%, #dbeafe 0%, transparent 70%), #fff;
  min-height: 380px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 40px 20px; cursor: pointer; transition: border-color .2s, background-color .2s, transform .2s; box-shadow: 0 10px 30px -18px rgba(37, 99, 235, .45);
}
#tzpe .tzpe-drop:hover, #tzpe.tzpe-dragover .tzpe-drop { border-color: var(--pe-blue); background-color: #f8fbff; }
#tzpe.tzpe-dragover .tzpe-drop { transform: scale(1.01); }
#tzpe .tzpe-drop-icon { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4); color: #fff; font-size: 32px; box-shadow: 0 12px 24px -10px rgba(37, 99, 235, .7); }
#tzpe .tzpe-drop-title { font-size: 22px; font-weight: 800; margin: 0 0 6px; color: var(--pe-ink); line-height: 1.3; }
#tzpe .tzpe-drop-sub { color: var(--pe-mute); margin: 0 0 14px; font-size: 14px; }
#tzpe .tzpe-drop-note { color: var(--pe-mute); font-size: 12.5px; margin: 16px 0 6px; }
#tzpe .tzpe-drop-privacy { color: #047857; font-size: 13px; font-weight: 600; margin: 0; }
#tzpe .tzpe-drop-error { color: var(--pe-danger); font-size: 14px; font-weight: 600; margin: 12px 0 0; }
#tzpe .tzpe-link { display: block; margin: 14px auto 0; color: var(--pe-blue); font-weight: 600; font-size: 14px; }
#tzpe .tzpe-link:hover { text-decoration: underline; }
#tzpe .tzpe-drop.tzpe-loading { pointer-events: none; opacity: .7; }

/* ---------- buttons ---------- */
#tzpe .tzpe-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 11px; border: 1px solid var(--pe-line2) !important; background: #fff; font-weight: 600; font-size: 14px; color: var(--pe-ink2);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; white-space: nowrap; }
#tzpe .tzpe-btn:hover { background: var(--pe-bg); border-color: #94a3b8 !important; }
#tzpe .tzpe-btn:active { transform: translateY(1px); }
#tzpe .tzpe-btn-primary { background: var(--pe-blue); border-color: var(--pe-blue) !important; color: #fff; box-shadow: 0 6px 14px -8px rgba(37, 99, 235, .9); }
#tzpe .tzpe-btn-primary:hover { background: var(--pe-blue-d); border-color: var(--pe-blue-d) !important; }
#tzpe .tzpe-btn-soft { background: var(--pe-blue-l); border-color: var(--pe-blue-m) !important; color: var(--pe-blue-d); }
#tzpe .tzpe-btn-soft:hover { background: var(--pe-blue-m); }
#tzpe .tzpe-btn-lg { height: 48px; padding: 0 22px; font-size: 16px; border-radius: 13px; }
#tzpe .tzpe-btn-block { width: 100%; }
#tzpe .tzpe-ib { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--pe-ink2); font-size: 15px; transition: background .15s, color .15s; flex: 0 0 auto; }
#tzpe .tzpe-ib:hover:not(:disabled) { background: #f1f5f9; color: var(--pe-ink); }
#tzpe .tzpe-ib.on { background: var(--pe-blue-l); color: var(--pe-blue); }
#tzpe .tzpe-danger { color: var(--pe-danger) !important; }
#tzpe .tzpe-sep { width: 1px; height: 22px; background: var(--pe-line); margin: 0 4px; }

/* ---------- editor shell ---------- */
#tzpe .tzpe-app { background: #fff; border: 1px solid var(--pe-line); border-radius: var(--pe-radius); overflow: hidden;
  box-shadow: 0 20px 40px -24px rgba(15, 23, 42, .35); height: clamp(600px, calc(100vh - 120px), 920px); display: flex; flex-direction: column; }
#tzpe .tzpe-top { height: var(--pe-top); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px;
  border-bottom: 1px solid var(--pe-line); background: #fff; flex: 0 0 auto; position: relative; z-index: 3; }
#tzpe .tzpe-top-l, #tzpe .tzpe-top-c, #tzpe .tzpe-top-r { display: flex; align-items: center; gap: 2px; }
#tzpe .tzpe-top-r { gap: 6px; }
#tzpe .tzpe-zoom { min-width: 58px; height: 32px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--pe-ink2); background: #f1f5f9; }
#tzpe .tzpe-zoom:hover { background: #e2e8f0; }
#tzpe [data-act="compare"].on { background: var(--pe-ink); color: #fff; }
#tzpe .tzpe-only-fs { display: none; }
#tzpe .tzpe-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: var(--pe-rail) 1fr var(--pe-panel); }

/* tool rail */
#tzpe .tzpe-rail { border-right: 1px solid var(--pe-line); background: #fff; overflow-y: auto; padding: 8px 6px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: none; }
#tzpe .tzpe-rail::-webkit-scrollbar { display: none; }
#tzpe .tzpe-rail button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 2px 8px; border-radius: 12px; color: var(--pe-mute); font-size: 11px; font-weight: 600; transition: background .15s, color .15s; }
#tzpe .tzpe-rail button i { font-size: 18px; width: 22px; text-align: center; }
#tzpe .tzpe-rail button:hover { background: #f1f5f9; color: var(--pe-ink); }
#tzpe .tzpe-rail button.on { background: var(--pe-blue-l); color: var(--pe-blue); }

/* stage */
#tzpe .tzpe-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  background-color: var(--pe-stage); background-image: radial-gradient(rgba(100, 116, 139, .18) 1px, transparent 1px); background-size: 18px 18px; }
#tzpe .tzpe-stage canvas { position: absolute; inset: 0; display: block; touch-action: none; }
#tzpe .tzpe-float { position: absolute; left: 0; top: 0; z-index: 4; display: flex; gap: 2px; padding: 4px; background: #fff; border-radius: 12px;
  box-shadow: 0 8px 24px -8px rgba(15, 23, 42, .35), 0 0 0 1px rgba(15, 23, 42, .06); will-change: transform; }
#tzpe .tzpe-float button { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; color: var(--pe-ink2); }
#tzpe .tzpe-float button:hover { background: #f1f5f9; }
#tzpe .tzpe-toast { position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 6;
  background: rgba(15, 23, 42, .92); color: #fff; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 12px; max-width: calc(100% - 24px); text-align: center; transition: opacity .2s, transform .2s; }
#tzpe .tzpe-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#tzpe .tzpe-toast.err { background: #b91c1c; }
#tzpe .tzpe-toast a { color: #fff; text-decoration: underline; }
#tzpe .tzpe-busy { position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center; gap: 10px; background: rgba(248, 250, 252, .7); font-weight: 700; color: var(--pe-ink2); backdrop-filter: blur(2px); }
#tzpe .tzpe-spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--pe-blue-m); border-top-color: var(--pe-blue); animation: tzpe-spin .8s linear infinite; display: inline-block; vertical-align: -4px; }
@keyframes tzpe-spin { to { transform: rotate(360deg); } }

/* panel */
#tzpe .tzpe-panel { border-left: 1px solid var(--pe-line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
#tzpe .tzpe-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px 16px; flex: 0 0 auto; }
#tzpe .tzpe-panel-head h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--pe-ink); }
#tzpe .tzpe-panel-toggle { display: none; }
#tzpe .tzpe-panel-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 20px; overscroll-behavior: contain; scrollbar-width: thin; }
#tzpe .tzpe-group { margin-top: 14px; }
#tzpe .tzpe-group h4, #tzpe .tzpe-sel-props h4 { margin: 0 0 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--pe-mute); }
#tzpe .tzpe-sel-props { margin-top: 14px; padding: 12px; border: 1px solid var(--pe-blue-m); background: #f8fbff; border-radius: 14px; }
#tzpe .tzpe-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--pe-ink2); margin: 14px 0 7px; }
#tzpe .tzpe-m0 { margin: 0 !important; }
#tzpe .tzpe-mt { margin-top: 14px; }
#tzpe .tzpe-mt0 { margin-top: 0 !important; }
#tzpe .tzpe-muted { color: var(--pe-mute); font-weight: 500; }
#tzpe .tzpe-warn { color: #b45309; font-weight: 600; }
#tzpe .tzpe-hint { font-size: 12.5px; line-height: 1.55; color: var(--pe-mute); margin: 14px 0 0; }
#tzpe .tzpe-hint b { color: var(--pe-ink2); }
#tzpe .tzpe-empty { text-align: center; color: var(--pe-mute); font-size: 13.5px; line-height: 1.6; padding: 28px 8px; }
#tzpe .tzpe-empty i { font-size: 26px; color: var(--pe-line2); margin-bottom: 8px; }
#tzpe .tzpe-row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#tzpe .tzpe-row-gap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#tzpe .tzpe-actions { display: flex; gap: 8px; margin-top: 16px; }
#tzpe .tzpe-actions .tzpe-btn { flex: 1; }
#tzpe .tzpe-actions-top { margin-top: 4px; }
#tzpe .tzpe-sep-h { height: 1px; background: var(--pe-line); margin: 16px 0 2px; }

/* sliders */
#tzpe .tzpe-sl { margin-top: 10px; }
#tzpe .tzpe-sl label { font-size: 13px; font-weight: 600; color: var(--pe-ink2); }
#tzpe .tzpe-sl output { font-size: 12px; font-weight: 700; color: var(--pe-mute); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
#tzpe .tzpe-range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 2px 0 0; background: transparent; cursor: pointer; --a: 0%; --b: 50%; display: block; }
#tzpe .tzpe-range::-webkit-slider-runnable-track { height: 5px; border-radius: 5px; background: linear-gradient(to right, #e2e8f0 var(--a), var(--pe-blue) var(--a), var(--pe-blue) var(--b), #e2e8f0 var(--b)); }
#tzpe .tzpe-range::-moz-range-track { height: 5px; border-radius: 5px; background: linear-gradient(to right, #e2e8f0 var(--a), var(--pe-blue) var(--a), var(--pe-blue) var(--b), #e2e8f0 var(--b)); }
#tzpe .tzpe-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--pe-blue); margin-top: -6.5px; box-shadow: 0 1px 4px rgba(15, 23, 42, .25); }
#tzpe .tzpe-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--pe-blue); box-shadow: 0 1px 4px rgba(15, 23, 42, .25); }

/* inputs */
#tzpe .tzpe-input, #tzpe .tzpe-select { width: 100%; height: 40px; border: 1px solid var(--pe-line2); border-radius: 11px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--pe-ink); background: #fff; }
#tzpe .tzpe-select { appearance: auto; }
#tzpe .tzpe-input:focus, #tzpe .tzpe-select:focus { outline: none; border-color: var(--pe-blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
#tzpe .tzpe-textarea { height: auto; min-height: 64px; padding: 10px 12px; resize: vertical; line-height: 1.45; font-size: 15px; }
#tzpe .tzpe-wh { display: grid; grid-template-columns: 1fr 40px 1fr; gap: 8px; align-items: end; margin-top: 12px; }
#tzpe .tzpe-wh label { font-size: 12.5px; font-weight: 700; color: var(--pe-ink2); display: flex; flex-direction: column; gap: 6px; }
#tzpe .tzpe-wh .tzpe-ib { height: 40px; width: 40px; }

/* chips, segments, tiles */
#tzpe .tzpe-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
#tzpe .tzpe-chips button { height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--pe-line2) !important; background: #fff; font-size: 12.5px; font-weight: 600; color: var(--pe-ink2); }
#tzpe .tzpe-chips button:hover { border-color: var(--pe-blue) !important; color: var(--pe-blue); }
#tzpe .tzpe-chips button.on { background: var(--pe-blue); border-color: var(--pe-blue) !important; color: #fff; }
#tzpe .tzpe-kb { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--pe-mute); }
#tzpe .tzpe-kb input { width: 84px; height: 32px; border: 1px solid var(--pe-line2); border-radius: 999px; padding: 0 10px; font: inherit; font-size: 12.5px; }
#tzpe .tzpe-seg { display: inline-flex; background: #f1f5f9; border-radius: 11px; padding: 3px; gap: 2px; }
#tzpe .tzpe-seg button { min-width: 36px; height: 32px; padding: 0 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--pe-mute); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#tzpe .tzpe-seg button.on { background: #fff; color: var(--pe-blue); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
#tzpe .tzpe-sel-props .tzpe-seg { margin: 4px 6px 4px 0; }
#tzpe .tzpe-grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
#tzpe .tzpe-grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 4px; }
#tzpe .tzpe-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 66px; padding: 8px 4px; border-radius: 13px; border: 1px solid var(--pe-line) !important; background: #fff; font-size: 11.5px; font-weight: 600; color: var(--pe-ink2); transition: border-color .15s, background .15s; }
#tzpe .tzpe-tile i { font-size: 19px; color: var(--pe-ink2); }
#tzpe .tzpe-tile:hover { border-color: var(--pe-blue) !important; background: #f8fbff; }
#tzpe .tzpe-tile.on { border-color: var(--pe-blue) !important; background: var(--pe-blue-l); color: var(--pe-blue); }
#tzpe .tzpe-tile.on i { color: var(--pe-blue); }
#tzpe .tzpe-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 16px -16px 0; padding: 0 16px 6px; scrollbar-width: none; }
#tzpe .tzpe-tabs::-webkit-scrollbar { display: none; }
#tzpe .tzpe-tabs button { flex: 0 0 auto; height: 30px; padding: 0 12px; border-radius: 999px; background: #f1f5f9; font-size: 12.5px; font-weight: 600; color: var(--pe-mute); }
#tzpe .tzpe-tabs button.on { background: var(--pe-ink); color: #fff; }
#tzpe .tzpe-emoji { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin-top: 8px; }
#tzpe .tzpe-emoji button { height: 44px; border-radius: 10px; font-size: 26px; line-height: 1; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; transition: background .12s, transform .12s; }
#tzpe .tzpe-emoji button:hover { background: #f1f5f9; transform: scale(1.12); }
#tzpe .tzpe-tpresets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 10px; }
#tzpe .tzpe-tpresets button { height: 44px; border-radius: 12px; background: #0f172a; color: #fff; font-size: 16px; padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#tzpe .tzpe-tpresets button:nth-child(4n+2) { background: linear-gradient(135deg, #1e3a8a, #0891b2); }
#tzpe .tzpe-tpresets button:nth-child(4n+3) { background: linear-gradient(135deg, #7c2d12, #db2777); }
#tzpe .tzpe-tpresets button:nth-child(4n+4) { background: linear-gradient(135deg, #14532d, #0d9488); }
#tzpe .tzpe-tpresets button:hover { filter: brightness(1.15); }

/* colour swatches */
#tzpe .tzpe-sws { display: flex; flex-wrap: wrap; gap: 6px; }
#tzpe .tzpe-sw { width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .15); position: relative; transition: transform .12s; }
#tzpe .tzpe-sw:hover { transform: scale(1.1); }
#tzpe .tzpe-sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pe-blue); }
#tzpe .tzpe-sw-none { background: #fff; overflow: hidden; }
#tzpe .tzpe-sw-none::after { content: ''; position: absolute; left: 50%; top: 2px; bottom: 2px; width: 2px; background: var(--pe-danger); transform: translateX(-50%) rotate(45deg); }
#tzpe .tzpe-sw-pick { display: grid; place-items: center; background: conic-gradient(#ef4444, #facc15, #22c55e, #06b6d4, #6366f1, #ec4899, #ef4444); cursor: pointer; overflow: hidden; }
#tzpe .tzpe-sw-pick i { color: #fff; font-size: 11px; text-shadow: 0 0 3px rgba(0, 0, 0, .6); pointer-events: none; }
#tzpe .tzpe-sw-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

/* switch */
#tzpe .tzpe-switch { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s; flex: 0 0 auto; }
#tzpe .tzpe-switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
#tzpe .tzpe-switch.on { background: var(--pe-blue); }
#tzpe .tzpe-switch.on span { transform: translateX(18px); }

/* details */
#tzpe .tzpe-more { margin-top: 16px; border: 1px solid var(--pe-line); border-radius: 14px; padding: 0 12px 12px; }
#tzpe .tzpe-more summary { cursor: pointer; list-style: none; font-size: 13px; font-weight: 700; color: var(--pe-ink2); padding: 12px 0 2px; }
#tzpe .tzpe-more summary::-webkit-details-marker { display: none; }
#tzpe .tzpe-more summary::after { content: '\25BE'; float: right; color: var(--pe-mute); }
#tzpe .tzpe-more[open] summary::after { content: '\25B4'; }
#tzpe .tzpe-more .tzpe-sws { margin-top: 8px; }

/* filters */
#tzpe .tzpe-filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
#tzpe .tzpe-fl { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 4px; border-radius: 13px; font-size: 12px; font-weight: 600; color: var(--pe-ink2); border: 2px solid transparent !important; }
#tzpe .tzpe-fl canvas { width: 100%; aspect-ratio: 1; border-radius: 10px; display: block; background: #e2e8f0; }
#tzpe .tzpe-fl:hover { background: #f8fafc; }
#tzpe .tzpe-fl.on { border-color: var(--pe-blue) !important; color: var(--pe-blue); background: var(--pe-blue-l); }

/* layers */
#tzpe .tzpe-layers { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
#tzpe .tzpe-layer { display: flex; align-items: center; gap: 0; border: 1px solid var(--pe-line); border-radius: 12px; padding: 2px 2px 2px 4px; background: #fff; }
#tzpe .tzpe-layer.on { border-color: var(--pe-blue); background: var(--pe-blue-l); }
#tzpe .tzpe-layer .tzpe-ib { width: 30px; height: 30px; font-size: 12.5px; }
#tzpe .tzpe-layer-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 6px; text-align: left; font-size: 13px; font-weight: 600; }
#tzpe .tzpe-layer-main i { width: 18px; text-align: center; color: var(--pe-mute); }
#tzpe .tzpe-layer-main span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- download dialog ---------- */
#tzpe .tzpe-modal { position: fixed; inset: 0; z-index: 99995; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
#tzpe .tzpe-dialog { background: #fff; border-radius: 20px; width: min(880px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .5); }
#tzpe .tzpe-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--pe-line); }
#tzpe .tzpe-dialog-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
#tzpe .tzpe-dialog-head h3 i { color: var(--pe-blue); margin-right: 6px; }
#tzpe .tzpe-dialog-body { display: grid; grid-template-columns: 1.1fr 1fr; grid-auto-rows: max-content; align-items: start; gap: 20px; padding: 16px 20px 20px; overflow-y: auto; }
#tzpe .tzpe-ex-preview { min-width: 0; background: #eef2f7 repeating-conic-gradient(#e2e8f0 0 25%, #f8fafc 0 50%) 0 0 / 20px 20px; border-radius: 14px; display: flex; align-items: center; justify-content: center; padding: 14px; min-height: 240px; }
#tzpe .tzpe-ex-preview canvas { display: block; flex: 0 0 auto; border-radius: 6px; box-shadow: 0 8px 20px -10px rgba(15, 23, 42, .45); }
#tzpe .tzpe-ex-opts .tzpe-label:first-child { margin-top: 0; }
#tzpe .tzpe-ex-info { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: #f1f5f9; font-size: 13.5px; color: var(--pe-ink2); line-height: 1.5; }
#tzpe .tzpe-ex-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
#tzpe .tzpe-ex-actions .tzpe-btn-primary { flex: 1 1 100%; }
#tzpe .tzpe-ex-actions .tzpe-btn:not(.tzpe-btn-primary) { flex: 1; }

/* ---------- full screen (phones, or the expand button) ---------- */
html.tzpe-noscroll, html.tzpe-noscroll body { overflow: hidden !important; overscroll-behavior: none; }
/* hide the site's floating chat / install widgets while the editor is full screen */
html.tzpe-noscroll [id*="askzu" i]:not(#tzpe *), html.tzpe-noscroll [class*="askzu" i]:not(#tzpe *), html.tzpe-noscroll [id*="pwa" i]:not(#tzpe *) { display: none !important; }
#tzpe.tzpe-fs { position: fixed; inset: 0; z-index: 99990; max-width: none; margin: 0; background: #fff; }
#tzpe.tzpe-fs .tzpe-app { height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
#tzpe.tzpe-fs .tzpe-only-fs { display: inline-grid; }

/* ---------- tablets & phones ---------- */
@media (max-width: 1100px) { #tzpe { --pe-panel: 300px; --pe-rail: 72px; } }
@media (max-width: 900px) {
  #tzpe { --pe-top: 52px; }
  #tzpe .tzpe-app { height: auto; min-height: 560px; }
  #tzpe.tzpe-fs .tzpe-app { height: 100vh; height: 100dvh; }
  #tzpe .tzpe-body { display: flex; flex-direction: column; }
  #tzpe .tzpe-stage { flex: 1 1 auto; min-height: 260px; order: 1; }
  #tzpe .tzpe-panel { order: 2; border-left: 0; border-top: 1px solid var(--pe-line); flex: 0 0 auto; max-height: 40%; transition: max-height .25s ease; box-shadow: 0 -8px 20px -16px rgba(15, 23, 42, .4); }
  #tzpe:not(.tzpe-fs) .tzpe-panel { max-height: 340px; }
  #tzpe:not(.tzpe-fs) .tzpe-stage { min-height: 380px; }
  #tzpe .tzpe-panel-head { padding: 8px 10px 4px 16px; }
  #tzpe .tzpe-panel-head h3 { font-size: 14px; }
  #tzpe .tzpe-panel-toggle { display: inline-grid; transition: transform .25s; }
  #tzpe.tzpe-panel-min .tzpe-panel { max-height: 44px !important; overflow: hidden; }
  #tzpe.tzpe-panel-min .tzpe-panel-toggle { transform: rotate(180deg); }
  #tzpe .tzpe-panel-body { padding: 0 14px 14px; }
  #tzpe .tzpe-rail { order: 3; flex-direction: row; border-right: 0; border-top: 1px solid var(--pe-line); overflow-x: auto; overflow-y: hidden; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 0; flex: 0 0 auto; }
  #tzpe .tzpe-rail button { flex: 0 0 64px; padding: 7px 2px 6px; font-size: 10.5px; }
  #tzpe .tzpe-rail button i { font-size: 17px; }
  #tzpe .tzpe-filters { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  #tzpe .tzpe-dialog-body { grid-template-columns: 1fr; gap: 14px; padding: 14px 16px 16px; }
  #tzpe .tzpe-ex-preview { min-height: 140px; }
  #tzpe .tzpe-ex-actions { position: sticky; bottom: -16px; margin: 12px -16px -16px; padding: 10px 16px 16px; background: #fff; box-shadow: 0 -12px 14px -12px rgba(15, 23, 42, .25); z-index: 1; }
  #tzpe .tzpe-drop { min-height: 320px; }
  #tzpe .tzpe-drop-title { font-size: 19px; }
}
@media (max-width: 520px) {
  #tzpe .tzpe-hide-xs { display: none !important; }
  #tzpe .tzpe-top { padding: 0 6px; }
  #tzpe .tzpe-top-r .tzpe-btn span { display: none; }
  #tzpe .tzpe-top-r .tzpe-btn { width: 40px; padding: 0; }
  #tzpe .tzpe-grid4 { grid-template-columns: repeat(4, 1fr); }
  #tzpe .tzpe-tile { min-height: 60px; font-size: 10.5px; }
  #tzpe .tzpe-dialog { border-radius: 18px; }
  #tzpe .tzpe-modal { padding: 8px; align-items: flex-end; }
}
@media (hover: none) { #tzpe .tzpe-emoji button:hover { transform: none; } }

/* v1.0.1: upload box same width as the other tools (editor stays wide after upload) */
#tzpe .tzpe-drop { max-width: 1024px; margin: 0 auto; min-height: 340px; }

/* v1.0.2: "Add image" button in the top bar */
#tzpe .tzpe-addimg { height: 34px; padding: 0 12px; margin-left: 4px; font-size: 13px; }
@media (max-width: 700px) { #tzpe .tzpe-addimg span { display: none; } #tzpe .tzpe-addimg { width: 36px; padding: 0; margin-left: 2px; } }

/* v1.0.3: Recent edits, saved badge, "open a new photo?" dialog */
#tzpe .tzpe-recent { max-width: 1024px; margin: 18px auto 0; }
#tzpe .tzpe-recent-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
#tzpe .tzpe-recent-head h3 { margin: 0; font-size: 15px; font-weight: 800; color: var(--pe-ink); }
#tzpe .tzpe-recent-head h3 i { color: var(--pe-blue); margin-right: 6px; }
#tzpe .tzpe-recent-head .tzpe-link { margin: 0; font-size: 13px; color: var(--pe-mute); }
#tzpe .tzpe-recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
#tzpe .tzpe-rc { position: relative; }
#tzpe .tzpe-rc-open { width: 100%; display: flex; flex-direction: column; text-align: left; background: #fff; border: 1px solid var(--pe-line) !important; border-radius: 14px; overflow: hidden; transition: box-shadow .2s, transform .2s, border-color .2s; }
#tzpe .tzpe-rc-open:hover { border-color: #93c5fd !important; box-shadow: 0 10px 22px -14px rgba(37, 99, 235, .55); transform: translateY(-2px); }
#tzpe .tzpe-rc-img { display: grid; place-items: center; aspect-ratio: 4 / 3; background: #eef2f7; overflow: hidden; color: var(--pe-line2); font-size: 26px; }
#tzpe .tzpe-rc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
#tzpe .tzpe-rc-name { padding: 9px 11px 0; font-size: 13px; font-weight: 700; color: var(--pe-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tzpe .tzpe-rc-meta { padding: 2px 11px 0; font-size: 11.5px; color: var(--pe-mute); }
#tzpe .tzpe-rc-go { margin: 8px 11px 11px; font-size: 12.5px; font-weight: 700; color: var(--pe-blue); }
#tzpe .tzpe-rc-go i { font-size: 11px; margin-right: 3px; }
#tzpe .tzpe-rc-del { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(15, 23, 42, .6); color: #fff; display: grid; place-items: center; font-size: 12px; opacity: .85; }
#tzpe .tzpe-rc-del:hover { background: var(--pe-danger); opacity: 1; }
#tzpe .tzpe-recent-note { margin: 10px 0 0; font-size: 12px; color: var(--pe-mute); text-align: center; }
#tzpe .tzpe-recent-note i { color: #059669; margin-right: 4px; }
#tzpe .tzpe-saved { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; font-size: 12px; font-weight: 700; color: #059669; opacity: 0; transition: opacity .4s; white-space: nowrap; }
#tzpe .tzpe-saved.show { opacity: 1; }
#tzpe .tzpe-dialog-sm { width: min(460px, 100%); padding: 26px 24px 20px; text-align: center; }
#tzpe .tzpe-dialog-sm h3 { margin: 10px 0 8px; font-size: 19px; font-weight: 800; color: var(--pe-ink); }
#tzpe .tzpe-dialog-sm p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--pe-ink2); }
#tzpe .tzpe-cf-icon { width: 54px; height: 54px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center; font-size: 22px; color: var(--pe-blue); background: var(--pe-blue-l); }
#tzpe .tzpe-cf-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
#tzpe .tzpe-cf-actions .tzpe-btn { flex: 1 1 auto; height: 42px; }
#tzpe .tzpe-cf-actions .tzpe-btn-primary { flex-basis: 100%; order: -1; }
#tzpe .tzpe-dialog-sm .tzpe-cf-tip { margin-top: 16px; padding: 10px 12px; border-radius: 12px; background: #f8fafc; font-size: 12.5px; color: var(--pe-mute); }
#tzpe .tzpe-cf-tip i { color: #f59e0b; margin-right: 4px; }
@media (max-width: 520px) {
  #tzpe .tzpe-saved span { display: none; }
  #tzpe .tzpe-recent-list { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  #tzpe #tzpeConfirm { align-items: center; }
}
