.tool__body [hidden] { display: none !important; }
.pe-loading { margin-top: 12px; }

.pe-create { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.pe-create-title { margin: 0 0 12px; color: var(--text); font-weight: 650; }
.pe-create .field { margin-bottom: 0; }
.pe-create .row > .field { flex: 1 1 150px; }
.pe-create .row > .pe-create-count { flex: 0 1 130px; }
.pe-create .btn { flex: 1 1 200px; }

.pe-editor { display: grid; grid-template-columns: minmax(0, 1fr) 290px; grid-template-areas: "tools tools" "stage side"; gap: 14px 20px; }
.pe-toolbar { grid-area: tools; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.pe-group { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); }
.pe-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 42px; height: 42px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.pe-btn.pe-icon { padding: 0; }
.pe-btn svg { flex: none; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pe-btn b, .pe-btn i { font-size: 1.05rem; font-family: Georgia, serif; }
.pe-btn:hover:not(:disabled, [aria-pressed="true"]) { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.pe-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }
.pe-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pe-btn:disabled { opacity: .35; cursor: default; }
.pe-zoom-value { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-size: .9rem; }
.pe-page-no { padding: 0 8px 0 6px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pe-stage { grid-area: stage; position: relative; height: min(78vh, 1100px); min-height: 380px; overflow: auto; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--border) 45%, var(--bg)); overscroll-behavior: contain; }
.pe-stage.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.pe-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; width: max-content; min-width: 100%; }
.pe-page { position: relative; flex: none; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .28); }
.pe-page:not(.is-ready)::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, #fff 0 12px, #f3f4f6 12px 24px); }
.pe-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pe-layer { position: absolute; inset: 0; overflow: hidden; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; }
.pe-editor[data-tool="text"] .pe-layer { cursor: text; }
.pe-editor[data-tool="whiteout"] .pe-layer { cursor: crosshair; touch-action: none; }
.pe-editor[data-tool="edit"] .pe-page.is-text .pe-layer { cursor: text; }

.pe-cover { position: absolute; pointer-events: none; }
.pe-hover { position: absolute; z-index: 3; pointer-events: none; border-radius: 2px; outline: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pe-item { position: absolute; z-index: 1; cursor: move; touch-action: none; }
.pe-item > canvas { position: absolute; pointer-events: none; }
.pe-item > img { display: block; width: 100%; height: 100%; pointer-events: none; }
.pe-item:hover { outline: 1px dashed color-mix(in srgb, var(--accent) 70%, transparent); }
.pe-item.is-selected { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.pe-item.is-empty { outline: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); }
.pe-item.is-editing { visibility: hidden; }
.pe-rect { box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.pe-handle { position: absolute; right: -9px; bottom: -9px; width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .35); cursor: nwse-resize; }
@media (hover: none) { .pe-handle { right: -13px; bottom: -13px; width: 24px; height: 24px; } }
.pe-ta { position: absolute; z-index: 5; min-width: 1em; margin: 0; padding: 0; overflow: hidden; border: 0; outline: 1.5px dashed var(--accent); outline-offset: 2px; background: transparent; resize: none; white-space: pre; font-kerning: none; font-variant-ligatures: normal; caret-color: var(--accent); }

.pe-side { grid-area: side; display: flex; flex-direction: column; gap: 14px; align-self: start; position: sticky; top: 12px; }
.pe-side .field { margin-bottom: 0; }
.pe-hint { margin: 0; }
.pe-label { color: var(--text); font-size: .88rem; font-weight: 650; }
.pe-row { display: flex; align-items: flex-end; gap: 12px; }
.pe-styles { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); }
.pe-size { flex: 1 1 auto; }
.pe-note { margin: 0; color: #b45309; }
.pe-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.pe-swatch { width: 30px; height: 30px; padding: 0; border: 1px solid color-mix(in srgb, var(--text) 22%, transparent); border-radius: 50%; background: var(--c); cursor: pointer; }
.pe-swatch.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.pe-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.pe-color { width: 38px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.pe-order { margin-top: 0; }
.pe-order .btn { flex: 1 1 auto; padding-inline: 12px; }
.pe-danger:hover { border-color: #e6454f; color: #e6454f; }
.pe-save { padding-top: 14px; border-top: 1px solid var(--border); }
.pe-save .hint { margin-top: 0; }
.pe-save .btn--primary { flex: 1 1 100%; }

.pe-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.pe-dialog::backdrop { background: rgba(10, 15, 30, .45); }
.pe-dialog-body { padding: 20px; }
.pe-dialog-title { margin: 0 0 14px; font-size: 1.1rem; }
.pe-dialog .tabs { margin-bottom: 14px; }
.pe-pad { display: block; width: 100%; height: 190px; background: #fff; border: 1px dashed var(--border); border-radius: 10px; touch-action: none; cursor: crosshair; }
.pe-sign-color { margin-top: 12px; max-width: 220px; }
.pe-sign-preview { display: flex; align-items: center; min-height: 64px; margin: 10px 0 14px; }
.pe-sign-preview img { max-height: 64px; max-width: 100%; padding: 4px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }

@media (max-width: 960px) {
    .pe-editor { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tools" "side" "stage"; }
    .pe-side { position: static; flex-flow: row wrap; align-items: flex-end; gap: 12px 20px; }
    .pe-side > .field { flex: 1 1 200px; }
    .pe-hint, .pe-note, .pe-save { flex-basis: 100%; }
    .pe-stage { height: 72vh; }
}

@media (max-width: 620px) {
    .pe-btn:not(.pe-icon) span { display: none; }
    .pe-btn:not(.pe-icon) { padding: 0; }
    .pe-toolbar { justify-content: flex-start; }
    .pe-stage { padding: 10px; min-height: 300px; }
    .pe-pages { gap: 10px; }
}
