/* Toolszu PDF Editor v0.5 — every rule is scoped to #tz-editor so it lives safely beside Tailwind */
#tz-editor {
  --tz-primary: #0066cc; --tz-primary-dark: #0052a3; --tz-primary-soft: #e8f2ff; --tz-primary-line: #bfdbfe;
  --tz-ink: #1e293b; --tz-ink-2: #334155; --tz-muted: #64748b; --tz-faint: #94a3b8;
  --tz-line: #e2e8f0; --tz-bg: #f8fafc; --tz-canvas: #eef2f7;
  --tz-danger: #dc2626; --tz-ok: #10b981; --tz-ok-dark: #059669;
  --tz-radius: 14px; --tz-shadow: 0 4px 20px rgba(15, 23, 42, .08); --tz-shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  position: relative; max-width: 1600px; margin: 0 auto; padding: 24px 20px;
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--tz-ink); text-align: left; -webkit-tap-highlight-color: transparent;
}
#tz-editor *, #tz-editor *::before, #tz-editor *::after { box-sizing: border-box; }
/* UI icons (Tailwind preflight makes svg display:block — keep them inline and sized) */
#tz-editor svg { display: inline-block; vertical-align: middle; width: 18px; height: 18px; max-width: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#tz-editor button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; text-transform: none; }
#tz-editor button:disabled { cursor: default; }
#tz-editor input, #tz-editor select { font: inherit; color: var(--tz-ink); margin: 0; }
#tz-editor h2, #tz-editor p, #tz-editor ul { margin: 0; padding: 0; }
#tz-editor ul { list-style: none; }
#tz-editor [hidden] { display: none !important; }
#tz-editor :focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

/* ===================================================================== screens */
#tz-editor .tz-app { display: none; }
#tz-editor[data-screen="editor"] .tz-upload { display: none; }
#tz-editor[data-screen="editor"] .tz-app { display: block; }

/* ===================================================================== buttons */
#tz-editor .tz-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px;
  border: 1.5px solid var(--tz-line); border-radius: 10px; background: #fff; color: var(--tz-ink-2); font-size: 13px; font-weight: 600;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
#tz-editor .tz-btn svg { width: 16px; height: 16px; }
#tz-editor .tz-btn:hover:not(:disabled) { border-color: var(--tz-primary-line); background: var(--tz-primary-soft); color: var(--tz-primary); }
#tz-editor .tz-btn:disabled { opacity: .45; }
#tz-editor .tz-btn.tz-primary { background: var(--tz-primary); border-color: var(--tz-primary); color: #fff; }
#tz-editor .tz-btn.tz-primary:hover:not(:disabled) { background: var(--tz-primary-dark); border-color: var(--tz-primary-dark); color: #fff; }
#tz-editor .tz-btn.tz-success { background: var(--tz-ok); border-color: var(--tz-ok); color: #fff; box-shadow: 0 4px 12px rgba(16, 185, 129, .3); }
#tz-editor .tz-btn.tz-success:hover:not(:disabled) { background: var(--tz-ok-dark); border-color: var(--tz-ok-dark); color: #fff; }
#tz-editor .tz-btn.tz-danger { color: var(--tz-danger); }
#tz-editor .tz-btn.tz-danger:hover:not(:disabled) { background: #fef2f2; border-color: #fecaca; color: var(--tz-danger); }
#tz-editor .tz-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px;
  color: var(--tz-muted); transition: background .15s, color .15s; flex: none; }
#tz-editor .tz-icon-btn:hover:not(:disabled) { background: var(--tz-primary-soft); color: var(--tz-primary); }

/* segmented control (undo/redo, zoom, B/I, alignment) */
#tz-editor .tz-seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: #f1f5f9; border-radius: 11px; flex: none; }
#tz-editor .tz-seg button { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: 8px; color: var(--tz-ink-2); transition: background .15s, color .15s, box-shadow .15s; }
#tz-editor .tz-seg button svg { width: 16px; height: 16px; }
#tz-editor .tz-seg button:hover:not(:disabled) { background: #fff; color: var(--tz-primary); }
#tz-editor .tz-seg button:disabled { opacity: .35; }
#tz-editor .tz-seg button.on { background: #fff; color: var(--tz-primary); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
#tz-editor .tz-seg-full { display: flex; width: 100%; }
#tz-editor .tz-seg-full button { flex: 1; }

/* ===================================================================== upload */
#tz-editor[data-screen="upload"] { padding: 24px; }
#tz-editor .tz-upload { padding: 0; }
#tz-editor .tz-drop { max-width: 1152px; margin: 0 auto; padding: 4rem 2rem; text-align: center; background: #fff;
  border: 3px dashed #c7d9f0; border-radius: var(--tz-radius); cursor: pointer; transition: border-color .25s, background .25s, box-shadow .25s; }
#tz-editor .tz-drop:hover, #tz-editor .tz-drop.over { border-color: var(--tz-primary); background: var(--tz-primary-soft); }
#tz-editor .tz-drop.over { box-shadow: 0 0 0 6px rgba(0, 102, 204, .12); }
#tz-editor .tz-drop-icon { display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; transition: transform .25s; }
#tz-editor .tz-drop:hover .tz-drop-icon { transform: translateY(-3px); }
#tz-editor .tz-drop-icon svg { display: block; width: 56px; height: 56px; margin: 0 auto; stroke: none; }
#tz-editor .tz-drop h2 { font-size: 1.4rem; line-height: 1.3; font-weight: 700; color: var(--tz-ink); margin-bottom: .5rem; }
#tz-editor .tz-drop p { color: var(--tz-muted); font-size: .95rem; margin-bottom: 1.5rem; }
#tz-editor .tz-upload-btn { display: inline-flex; align-items: center; gap: 8px; padding: .85rem 2.2rem; border-radius: 10px;
  background: var(--tz-primary); color: #fff; font-size: 1rem; font-weight: 600; transition: background .2s, transform .2s; }
#tz-editor .tz-upload-btn:hover { background: var(--tz-primary-dark); transform: translateY(-1px); }
#tz-editor .tz-upload-btn svg { width: 18px; height: 18px; }
#tz-editor .tz-file-limit { margin-top: .75rem; font-size: .8rem; color: var(--tz-muted); }
#tz-editor .tz-secure { display: block; margin-top: 1rem; text-align: center; font-size: 12px; font-weight: 600; color: var(--tz-faint); }
#tz-editor .tz-secure svg { width: 14px; height: 14px; margin: -2px 5px 0 0; color: var(--tz-ok); }
#tz-editor .tz-turnstile { display: flex; justify-content: center; margin-top: 12px; }

/* ===================================================================== editor layout (desktop) */
#tz-editor .tz-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr) 330px; gap: 16px; align-items: stretch;
  height: calc(100vh - 40px); height: calc(100dvh - 40px); min-height: 640px; max-height: 1100px; }
#tz-editor .tz-card { background: #fff; border: 1px solid var(--tz-line); border-radius: var(--tz-radius); box-shadow: var(--tz-shadow);
  display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
#tz-editor .tz-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 8px 10px 8px 16px;
  border-bottom: 1px solid var(--tz-line); flex: none; }
#tz-editor .tz-card-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: #0f172a; font-size: 14px; }
#tz-editor .tz-card-title svg { color: var(--tz-primary); }
#tz-editor .tz-only-compact { display: none !important; }
#tz-editor .tz-only-wide { display: inline-flex; }
#tz-editor .tz-backdrop { display: none; }

/* ---------- left: pages */
#tz-editor .tz-tabs { display: flex; gap: 2px; margin: 10px 10px 0; padding: 3px; background: #f1f5f9; border-radius: 11px; flex: none; }
#tz-editor .tz-tabs button { flex: 1; height: 30px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--tz-muted); transition: background .15s, color .15s; }
#tz-editor .tz-tabs button.on { background: #fff; color: var(--tz-primary); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
#tz-editor .tz-thumbs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
#tz-editor .tz-thumb { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border: 2px solid transparent; border-radius: 10px;
  background: var(--tz-bg); font-size: 12px; font-weight: 600; color: var(--tz-muted); overflow: hidden; transition: border-color .15s, background .15s; flex: none; }
#tz-editor .tz-thumb:hover { border-color: var(--tz-primary-line); }
#tz-editor .tz-thumb canvas { display: block; max-width: none; box-shadow: 0 1px 4px rgba(15, 23, 42, .18); background: #fff; transition: transform .2s; }
#tz-editor .tz-thumb.on { border-color: var(--tz-primary); background: var(--tz-primary-soft); color: var(--tz-primary); }
#tz-editor .tz-thumb.is-deleted { opacity: .35; }
#tz-editor .tz-manage-wrap { display: none; flex: 1; overflow-y: auto; padding: 12px; }
#tz-editor .tz-sidebar[data-tab="manage"] .tz-thumbs { display: none; }
#tz-editor .tz-sidebar[data-tab="manage"] .tz-manage-wrap { display: block; }
#tz-editor .tz-manage-hint { font-size: 11px; color: var(--tz-muted); margin-bottom: 10px; }
#tz-editor .tz-mrow { display: flex; align-items: center; gap: 6px; padding: 8px; border: 1.5px solid var(--tz-line); border-radius: 10px; margin-bottom: 8px;
  background: #fff; font-size: 12px; cursor: grab; }
#tz-editor .tz-mrow.is-dragging { opacity: .4; }
#tz-editor .tz-mrow.is-deleted .tz-mlabel { text-decoration: line-through; color: var(--tz-muted); }
#tz-editor .tz-mgrip { color: var(--tz-faint); }
#tz-editor .tz-mnum { font-weight: 800; color: var(--tz-primary); min-width: 14px; }
#tz-editor .tz-mlabel { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tz-editor .tz-mbtn { width: 26px; height: 26px; border: 1.5px solid var(--tz-line); border-radius: 7px; background: #fff; font-size: 12px; line-height: 1; color: var(--tz-ink); }
#tz-editor .tz-mbtn:hover { background: var(--tz-primary-soft); border-color: var(--tz-primary-line); }
#tz-editor .tz-mbtn.is-del:hover { background: #fef2f2; border-color: #fecaca; color: var(--tz-danger); }

/* ---------- centre: workspace */
#tz-editor .tz-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--tz-line); flex: none; min-height: 56px; }
#tz-editor .tz-bar-left, #tz-editor .tz-bar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
#tz-editor .tz-file-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
#tz-editor .tz-file-badge { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px;
  background: #fee2e2; color: #dc2626; font-size: 10px; font-weight: 800; letter-spacing: .03em; }
#tz-editor .tz-file-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
#tz-editor .tz-filename { font-weight: 700; color: #0f172a; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
#tz-editor .tz-file-meta { font-size: 12px; color: var(--tz-muted); }

#tz-editor .tz-toolbar-wrap { flex: none; min-width: 0; border-bottom: 1px solid var(--tz-line); background: #fff; }
#tz-editor .tz-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: #fff;
  overflow-x: auto; flex: none; scrollbar-width: none; overscroll-behavior-x: contain; }
#tz-editor .tz-toolbar::-webkit-scrollbar { display: none; }
#tz-editor .tz-tgroup { display: flex; gap: 2px; padding: 4px; background: #f1f5f9; border-radius: 12px; flex: none; }
#tz-editor .tz-tb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 50px; height: 50px; padding: 4px 5px;
  border-radius: 9px; color: #475569; font-size: 11px; font-weight: 600; flex: none; transition: background .15s, color .15s, box-shadow .15s; }
#tz-editor .tz-tb svg { width: 19px; height: 19px; }
#tz-editor .tz-tb:hover:not(:disabled) { background: rgba(255, 255, 255, .8); color: var(--tz-primary); }
#tz-editor .tz-tb.on { background: #fff; color: var(--tz-primary); box-shadow: 0 1px 4px rgba(15, 23, 42, .14); }
#tz-editor .tz-tb:disabled { opacity: .35; }

#tz-editor .tz-findbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--tz-line); background: #fafcff; flex-wrap: wrap; flex: none; }
#tz-editor .tz-find-fields { display: flex; gap: 8px; flex: 1 1 320px; min-width: 0; }
#tz-editor .tz-find-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#tz-editor .tz-findbar input[type=search], #tz-editor .tz-findbar input[type=text] { flex: 1; min-width: 0; height: 38px; padding: 0 12px;
  border: 1.5px solid var(--tz-line); border-radius: 10px; background: #fff; }
#tz-editor .tz-findbar input:focus { outline: none; border-color: var(--tz-primary); box-shadow: 0 0 0 3px rgba(0, 102, 204, .12); }
#tz-editor .tz-find-count { font-size: 12px; color: var(--tz-muted); min-width: 64px; text-align: center; }
#tz-editor .tz-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--tz-muted); cursor: pointer; white-space: nowrap; }
#tz-editor .tz-check input { width: 15px; height: 15px; accent-color: var(--tz-primary); }

#tz-editor .tz-scroll { flex: 1; min-height: 0; overflow: auto; background: var(--tz-canvas); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#tz-editor .tz-pages { display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 28px 24px; width: max-content; min-width: 100%; }
#tz-editor .tz-page { position: relative; background: #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, .08), 0 12px 32px rgba(15, 23, 42, .12); flex: none; }
#tz-editor .tz-canvas { position: absolute; inset: 0; display: block; max-width: none; }
#tz-editor .tz-overlay { position: absolute; inset: 0; overflow: visible; }
#tz-editor .tz-page-label { position: absolute; top: -21px; left: 0; font-size: 11px; font-weight: 600; color: var(--tz-muted); }
#tz-editor.tool-text .tz-overlay { cursor: crosshair; }

#tz-editor .tz-viewbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--tz-line); flex: none; }
#tz-editor .tz-zoom-val { min-width: 48px; text-align: center; font-size: 12px; font-weight: 700; color: var(--tz-ink-2); font-variant-numeric: tabular-nums; }
#tz-editor .tz-page-num { min-width: 86px; text-align: center; font-size: 12px; font-weight: 700; color: var(--tz-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- right: properties */
/* side panels pass the wheel on to the page when they have nothing (more) to scroll */
#tz-editor .tz-panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
#tz-editor .tz-panel .tz-panel-body { display: none; }
#tz-editor .tz-panel:not(.is-empty)[data-mode="text"] .tz-text-props,
#tz-editor .tz-panel:not(.is-empty)[data-mode="object"] .tz-obj-props { display: block; }
#tz-editor .tz-panel:not(.is-empty) .tz-panel-empty { display: none; }
#tz-editor .tz-sheet-close { visibility: hidden; }
#tz-editor .tz-panel:not(.is-empty) .tz-sheet-close { visibility: visible; }
#tz-editor .tz-panel-empty { text-align: center; padding: 18px 6px; color: var(--tz-muted); font-size: 13px; }
#tz-editor .tz-empty-icon { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--tz-primary-soft); color: var(--tz-primary); }
#tz-editor .tz-empty-icon svg { width: 24px; height: 24px; }
#tz-editor .tz-panel-empty strong { display: block; color: #0f172a; font-size: 15px; margin-bottom: 6px; }
#tz-editor .tz-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; font-size: 12px; }
#tz-editor .tz-keys li { padding: 5px 9px; border-radius: 8px; background: var(--tz-bg); border: 1px solid var(--tz-line); }
#tz-editor kbd { display: inline-block; padding: 0 5px; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 5px; background: #fff;
  font: 600 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tz-ink-2); }

#tz-editor .tz-kind { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; padding: 5px 10px; border-radius: 999px;
  background: var(--tz-primary-soft); color: var(--tz-primary); font-size: 12px; font-weight: 700; }
#tz-editor .tz-kind::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
#tz-editor .tz-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
#tz-editor .tz-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tz-muted); }
#tz-editor .tz-field select, #tz-editor .tz-field input[type=number], #tz-editor .tz-color input[type=text] {
  width: 100%; height: 40px; padding: 0 10px; border: 1.5px solid var(--tz-line); border-radius: 10px; background: #fff; font-size: 14px; }
#tz-editor .tz-field select { appearance: auto; }
#tz-editor .tz-field select:focus, #tz-editor .tz-field input:focus { outline: none; border-color: var(--tz-primary); box-shadow: 0 0 0 3px rgba(0, 102, 204, .12); }
#tz-editor .tz-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#tz-editor .tz-grid2 > .tz-field { margin-bottom: 16px; }
#tz-editor .tz-text-props .tz-seg { height: 40px; }
#tz-editor .tz-text-props .tz-seg button { height: 34px; }
#tz-editor .tz-color { display: flex; align-items: center; gap: 8px; }
#tz-editor .tz-color input[type=color] { width: 44px; height: 40px; padding: 3px; border: 1.5px solid var(--tz-line); border-radius: 10px; background: #fff; flex: none; cursor: pointer; }
#tz-editor .tz-color input[type=text] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
#tz-editor .tz-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
#tz-editor .tz-swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; transition: transform .12s, box-shadow .12s; }
#tz-editor .tz-swatches button:hover { transform: scale(1.12); box-shadow: 0 0 0 2px var(--tz-primary); }
#tz-editor .tz-field input[type=range] { width: 100%; accent-color: var(--tz-primary); height: 24px; }
#tz-editor .tz-val { float: right; text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--tz-ink); }
#tz-editor .tz-hint { font-size: 12px; color: var(--tz-muted); margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: #fffbeb; border: 1px solid #fde68a; }
#tz-editor .tz-hint:empty { display: none; }
#tz-editor .tz-actions { margin-top: 4px; }
#tz-editor .tz-actions .tz-btn { width: 100%; }
#tz-editor .tz-actions .tz-layer-btn { padding: 0 8px; gap: 6px; font-size: 12.5px; }
#tz-editor .tz-actions .tz-layer-btn[aria-disabled="true"] { opacity: .4; cursor: help; }
#tz-editor .tz-actions .tz-layer-btn[aria-disabled="true"]:hover { background: #fff; border-color: var(--tz-line); color: var(--tz-ink-2); }

#tz-editor .tz-action { flex: none; padding: 14px 16px 16px; border-top: 1px solid var(--tz-line); background: #fff; }
#tz-editor .tz-download { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; height: 50px; border-radius: 12px;
  background: var(--tz-ok); color: #fff; font-size: 16px; font-weight: 700; box-shadow: 0 8px 20px rgba(16, 185, 129, .3); transition: background .2s, transform .2s; }
#tz-editor .tz-download:hover { background: var(--tz-ok-dark); transform: translateY(-1px); }
#tz-editor .tz-download svg { width: 20px; height: 20px; }
#tz-editor .tz-action p { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--tz-muted); }
#tz-editor .tz-action p svg { width: 14px; height: 14px; color: var(--tz-ok-dark); }

/* ===================================================================== text items (core — keep) */
#tz-editor .tz-item { position: absolute; white-space: pre; margin: 0; padding: 0; cursor: text; transform-origin: 0 0;
  outline: 1px solid transparent; outline-offset: 1px; border-radius: 1px; user-select: none; -webkit-user-select: none;
  font-weight: normal; font-style: normal; font-kerning: none; min-width: 4px; line-height: normal; }
#tz-editor .tz-item:hover { outline-color: rgba(0, 102, 204, .55); background: rgba(0, 102, 204, .06); }
#tz-editor .tz-item.is-changed:hover { background: rgba(250, 204, 21, .18); }
#tz-editor .tz-item.is-selected { outline: 1.5px dashed var(--tz-primary); background: rgba(0, 102, 204, .05); cursor: move; touch-action: none; }
#tz-editor .tz-item.is-editing { outline: 2px solid var(--tz-primary); cursor: text; user-select: text; -webkit-user-select: text; caret-color: var(--tz-primary); touch-action: auto; }
#tz-editor .tz-item.is-match { background: rgba(250, 204, 21, .45); }
#tz-editor .tz-item.is-current { background: rgba(249, 115, 22, .55); outline: 2px solid #f97316; }

/* pages: removed / rotated */
#tz-editor .tz-page.is-deleted .tz-canvas, #tz-editor .tz-page.is-deleted .tz-overlay { opacity: .25; }
#tz-editor .tz-page-badge { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--tz-ink); color: #fff;
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; pointer-events: none; }
#tz-editor .tz-page.is-deleted .tz-page-badge { background: var(--tz-danger); }

/* objects (core — keep) */
#tz-editor .tz-obj { position: absolute; box-sizing: border-box; cursor: move; }
#tz-editor .tz-obj svg { display: block; position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; overflow: visible; pointer-events: none; fill: none; stroke: none; stroke-width: 0; }
#tz-editor .tz-obj img { width: 100%; height: 100%; max-width: none; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
#tz-editor .tz-obj-highlight { mix-blend-mode: multiply; }
#tz-editor .tz-obj-highlight, #tz-editor .tz-obj-underline, #tz-editor .tz-obj-strike { pointer-events: none; }
#tz-editor .tz-obj-highlight.is-selected, #tz-editor .tz-obj-underline.is-selected, #tz-editor .tz-obj-strike.is-selected { pointer-events: auto; }
#tz-editor .tz-obj-whiteout:hover, #tz-editor .tz-obj-whiteout.is-selected { box-shadow: 0 0 0 1px rgba(148, 163, 184, .7) inset; }
#tz-editor .tz-obj:hover { outline: 1px solid rgba(0, 102, 204, .5); }
#tz-editor .tz-obj.is-selected { outline: 1.5px dashed var(--tz-primary); outline-offset: 1px; touch-action: none; }
#tz-editor .tz-h { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #fff; border: 1.5px solid var(--tz-primary); border-radius: 2px; z-index: 2; touch-action: none; }
#tz-editor .tz-h-nw { left: 0; top: 0; cursor: nwse-resize; } #tz-editor .tz-h-n { left: 50%; top: 0; cursor: ns-resize; }
#tz-editor .tz-h-ne { left: 100%; top: 0; cursor: nesw-resize; } #tz-editor .tz-h-e { left: 100%; top: 50%; cursor: ew-resize; }
#tz-editor .tz-h-se { left: 100%; top: 100%; cursor: nwse-resize; } #tz-editor .tz-h-s { left: 50%; top: 100%; cursor: ns-resize; }
#tz-editor .tz-h-sw { left: 0; top: 100%; cursor: nesw-resize; } #tz-editor .tz-h-w { left: 0; top: 50%; cursor: ew-resize; }
#tz-editor .tz-h-p0, #tz-editor .tz-h-p1 { border-radius: 50%; cursor: crosshair; }
#tz-editor.tool-shape .tz-overlay { cursor: crosshair; }
#tz-editor.tool-shape .tz-item { pointer-events: none; }
/* while drawing or placing text, a finger draws instead of scrolling */
#tz-editor.tool-shape .tz-overlay, #tz-editor.tool-text .tz-overlay { touch-action: none; }

/* text move handle + smart guides */
#tz-editor .tz-grip { position: absolute; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: var(--tz-primary); color: #fff;
  border-radius: 7px; cursor: move; z-index: 900; box-shadow: 0 2px 8px rgba(0, 102, 204, .4); touch-action: none; }
#tz-editor .tz-grip svg { width: 15px; height: 15px; }
#tz-editor .tz-guide { position: absolute; z-index: 950; pointer-events: none; background: #ec4899; }
#tz-editor .tz-guide-v { top: 0; bottom: 0; width: 1px; }
#tz-editor .tz-guide-h { left: 0; right: 0; height: 1px; }
#tz-editor .tz-guide.is-center { background: #8b5cf6; }

/* bigger touch targets on touch screens */
@media (pointer: coarse) {
  #tz-editor .tz-h { width: 18px; height: 18px; margin: -9px 0 0 -9px; border-width: 2px; border-radius: 4px; }
  #tz-editor .tz-h-p0, #tz-editor .tz-h-p1 { border-radius: 50%; }
  #tz-editor .tz-grip { width: 32px; height: 32px; border-radius: 9px; }
  #tz-editor .tz-grip svg { width: 18px; height: 18px; }
}

/* ===================================================================== ready (after export) */
#tz-editor .tz-ready { position: fixed; inset: 0; z-index: 9990; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(15, 23, 42, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#tz-editor .tz-ready-card { display: flex; flex-direction: column; width: min(1040px, 100%); height: 100%; max-height: 1000px; background: #fff;
  border-radius: 18px; overflow: hidden; box-shadow: var(--tz-shadow-lg); animation: tz-pop .25s ease-out; }
@keyframes tz-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
#tz-editor .tz-ready-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--tz-line); flex-wrap: wrap; }
#tz-editor .tz-ready-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
#tz-editor .tz-ready-check { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: #d1fae5; color: var(--tz-ok-dark); flex: none; }
#tz-editor .tz-ready-check svg { width: 22px; height: 22px; stroke-width: 3; }
#tz-editor .tz-ready-title strong { display: block; font-size: 17px; color: #0f172a; }
#tz-editor .tz-ready-title span { font-size: 13px; color: var(--tz-muted); }
#tz-editor .tz-ready-actions { display: flex; gap: 8px; }
#tz-editor .tz-ready-actions .tz-btn { height: 44px; padding: 0 18px; font-size: 14px; }
#tz-editor .tz-ready-body { flex: 1; min-height: 0; display: flex; background: var(--tz-canvas); }
#tz-editor .tz-preview { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 24px 16px; -webkit-overflow-scrolling: touch; }
#tz-editor .tz-preview-page { background: #fff; box-shadow: 0 4px 18px rgba(15, 23, 42, .18); flex: none; max-width: 100%; }
#tz-editor .tz-preview-page canvas { display: block; max-width: 100%; height: auto; }
#tz-editor .tz-preview-msg { color: var(--tz-muted); margin: auto; }

/* ===================================================================== confirm popup */
#tz-editor .tz-modal { position: fixed; inset: 0; z-index: 9995; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: tz-fade .18s ease-out; }
#tz-editor .tz-modal-card { width: min(420px, 100%); padding: 28px 24px 18px; background: #fff; border-radius: 18px; text-align: center;
  box-shadow: var(--tz-shadow-lg); animation: tz-pop .22s ease-out; }
#tz-editor .tz-modal-icon { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%;
  background: #fef3c7; color: #d97706; }
#tz-editor .tz-modal-icon svg { width: 26px; height: 26px; }
#tz-editor .tz-modal h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; color: #0f172a; }
#tz-editor .tz-modal p { color: var(--tz-muted); font-size: 14px; line-height: 1.55; }
#tz-editor .tz-modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
#tz-editor .tz-modal-actions .tz-btn { height: 46px; font-size: 14px; }
#tz-editor .tz-modal-discard { margin-top: 12px; padding: 8px 12px; border-radius: 8px; color: var(--tz-danger); font-size: 13px; font-weight: 600; }
#tz-editor .tz-modal-discard:hover { background: #fef2f2; }
@keyframes tz-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 420px) { #tz-editor .tz-modal-actions { grid-template-columns: 1fr; } }

/* ===================================================================== tool options bar */
#tz-editor .tz-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* floats over the top of the page area, so choosing a tool never shifts the page under the cursor */
#tz-editor .tz-subbar { position: absolute; z-index: 30; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 20px); width: max-content;
  border: 1px solid var(--tz-line); border-radius: 14px; background: rgba(255, 255, 255, .97); overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14); animation: tz-fade .15s ease-out; }
#tz-editor .tz-sub-inner { display: flex; align-items: center; gap: 14px; padding: 7px 12px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
#tz-editor .tz-sub-inner::-webkit-scrollbar { display: none; }

/* soft fade at an edge that has more to scroll to (set by JS: --fl / --fr) — no scrollbar needed */
#tz-editor .tz-toolbar, #tz-editor .tz-sub-inner {
  --fl: 0px; --fr: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%); }
/* centre the tool groups when they fit (auto margins collapse to 0 when they don't, so nothing is cut off) */
#tz-editor .tz-toolbar > .tz-tgroup:first-child { margin-left: auto; }
#tz-editor .tz-toolbar > .tz-tgroup:last-child { margin-right: auto; }
#tz-editor .tz-sub-title { flex: none; font-size: 12px; font-weight: 800; color: var(--tz-primary); padding: 4px 10px; border-radius: 999px; background: var(--tz-primary-soft); }
#tz-editor .tz-sub-group { display: flex; align-items: center; gap: 8px; flex: none; }
#tz-editor .tz-sub-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--tz-muted); }
#tz-editor .tz-sub-swatches { display: flex; align-items: center; gap: 6px; }
#tz-editor .tz-sub-swatches button, #tz-editor .tz-ink-row button, #tz-editor .tz-stamp-colors button {
  width: 24px; height: 24px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; flex: none; transition: transform .12s, box-shadow .12s; }
#tz-editor .tz-sub-swatches button:hover, #tz-editor .tz-ink-row button:hover, #tz-editor .tz-stamp-colors button:hover { transform: scale(1.1); }
#tz-editor .tz-sub-swatches button.on, #tz-editor .tz-ink-row button.on, #tz-editor .tz-stamp-colors button.on { box-shadow: 0 0 0 2px var(--tz-primary); }
#tz-editor .tz-sw-none { background: linear-gradient(135deg, #fff 45%, #ef4444 45%, #ef4444 55%, #fff 55%) !important; }
#tz-editor .tz-sub-custom { position: relative; width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex: none; cursor: pointer;
  background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #6366f1, #ec4899, #ef4444); box-shadow: 0 0 0 1px #cbd5e1; }
#tz-editor .tz-sub-custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
#tz-editor .tz-sub-range input { width: 110px; accent-color: var(--tz-primary); }
#tz-editor .tz-sub-val { min-width: 34px; font-size: 12px; font-weight: 700; color: var(--tz-ink-2); font-variant-numeric: tabular-nums; }
#tz-editor .tz-sub-hint { font-size: 12px; color: var(--tz-muted); white-space: nowrap; }
#tz-editor .tz-sub-hint:empty { display: none; }
#tz-editor .tz-subbar .tz-seg button { padding: 0 10px; font-size: 12px; font-weight: 600; }
#tz-editor .tz-marks button { min-width: 38px; font-size: 16px; }
#tz-editor .tz-marks button[data-mark="date"] { font-size: 12px; }
#tz-editor.tool-mark .tz-overlay { cursor: crosshair; touch-action: none; }
#tz-editor.tool-mark .tz-item { pointer-events: none; }

/* ===================================================================== signature + stamp popups */
#tz-editor .tz-dialog { position: fixed; inset: 0; z-index: 9993; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: tz-fade .18s ease-out; }
#tz-editor .tz-dialog-card { display: flex; flex-direction: column; width: min(560px, 100%); max-height: calc(100dvh - 32px); background: #fff;
  border-radius: 18px; box-shadow: var(--tz-shadow-lg); overflow: hidden; animation: tz-pop .22s ease-out; }
#tz-editor .tz-dialog-wide { width: min(860px, 100%); }
#tz-editor .tz-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 14px 22px; border-bottom: 1px solid var(--tz-line); flex: none; }
#tz-editor .tz-dialog-head h3 { margin: 0; font-size: 17px; font-weight: 800; color: #0f172a; }
#tz-editor .tz-dialog-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; overscroll-behavior: contain; }
#tz-editor .tz-dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--tz-line);
  background: var(--tz-bg); flex: none; flex-wrap: wrap; }
#tz-editor .tz-dialog-btns { display: flex; gap: 8px; margin-left: auto; }
#tz-editor .tz-dialog-btns .tz-btn { height: 42px; padding: 0 18px; }
#tz-editor .tz-dialog-note { font-size: 12px; color: var(--tz-muted); }
#tz-editor .tz-dialog-msg { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #fef2f2; color: var(--tz-danger); font-size: 13px; font-weight: 600; }
#tz-editor .tz-dialog-tabs { margin: 0 0 14px; }
#tz-editor .tz-dialog-tabs button { height: 34px; font-size: 13px; }
#tz-editor .tz-input { width: 100%; height: 44px; padding: 0 12px; border: 1.5px solid var(--tz-line); border-radius: 10px; background: #fff; font-size: 15px; }
#tz-editor .tz-input:focus { outline: none; border-color: var(--tz-primary); box-shadow: 0 0 0 3px rgba(0, 102, 204, .12); }

#tz-editor .tz-saved { margin-bottom: 14px; }
#tz-editor .tz-saved-list { display: flex; gap: 10px; margin-top: 8px; overflow-x: auto; padding: 2px; }
#tz-editor .tz-saved-item { position: relative; flex: none; display: flex; align-items: center; justify-content: center; width: 130px; height: 64px; padding: 6px;
  border: 1.5px solid var(--tz-line); border-radius: 12px; background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
#tz-editor .tz-saved-item:hover { border-color: var(--tz-primary); box-shadow: 0 0 0 3px rgba(0, 102, 204, .1); }
#tz-editor .tz-saved-item img { max-width: 100%; max-height: 100%; }
#tz-editor .tz-saved-del { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 1.5px solid var(--tz-line);
  font-size: 14px; line-height: 1; color: var(--tz-muted); }
#tz-editor .tz-saved-del:hover { color: var(--tz-danger); border-color: #fecaca; }

#tz-editor .tz-sign-pad { position: relative; height: 200px; border: 1.5px dashed #c7d9f0; border-radius: 14px; background: #fcfdff; overflow: hidden; touch-action: none; }
#tz-editor .tz-sign-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; max-width: none; }
#tz-editor .tz-sign-line { position: absolute; left: 24px; right: 24px; bottom: 46px; border-bottom: 1.5px solid #cbd5e1; pointer-events: none; }
#tz-editor .tz-sign-ph { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 13px; color: var(--tz-faint); pointer-events: none; }
#tz-editor .tz-sign-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
#tz-editor .tz-sign-tools .tz-seg button { padding: 0 12px; font-size: 12px; font-weight: 600; }
#tz-editor .tz-sign-actions { display: flex; gap: 8px; }
#tz-editor .tz-sign-actions .tz-btn { height: 34px; }
#tz-editor .tz-font-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
#tz-editor .tz-font-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 78px; padding: 6px 10px;
  border: 1.5px solid var(--tz-line); border-radius: 12px; background: #fff; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
#tz-editor .tz-font-sample { font-size: 27px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 4px; }
#tz-editor .tz-font-card small { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--tz-faint); }
#tz-editor .tz-font-card.on small { color: var(--tz-primary); }
#tz-editor .tz-font-loading { grid-column: 1 / -1; padding: 22px 0; text-align: center; font-size: 13px; color: var(--tz-muted); }
#tz-editor .tz-font-card:hover { border-color: var(--tz-primary-line); }
#tz-editor .tz-font-card.on { border-color: var(--tz-primary); box-shadow: 0 0 0 3px rgba(0, 102, 204, .12); background: #f7fbff; }
#tz-editor .tz-sign-upload { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 160px; padding: 16px;
  border: 1.5px dashed #c7d9f0; border-radius: 14px; background: #fcfdff; margin-bottom: 12px; }
#tz-editor .tz-sign-pick { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; background: var(--tz-primary-soft); color: var(--tz-primary); font-weight: 700; font-size: 13px; }
#tz-editor .tz-sign-upload-preview canvas { display: block; max-width: 100%; max-height: 140px;
  background: repeating-conic-gradient(#f1f5f9 0 25%, #fff 0 50%) 0 0 / 14px 14px; border-radius: 8px; }
#tz-editor .tz-ink-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }

#tz-editor .tz-stamp-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
#tz-editor .tz-stamp-preview { position: sticky; top: 0; display: flex; align-items: center; justify-content: center; height: 220px; padding: 16px; border-radius: 14px;
  border: 1px solid var(--tz-line); background: #fff repeating-linear-gradient(0deg, transparent 0 23px, #f1f5f9 23px 24px); }
#tz-editor .tz-stamp-preview canvas { display: block; }
#tz-editor .tz-stamp-empty { color: var(--tz-faint); font-size: 13px; }
#tz-editor .tz-stamp-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
#tz-editor .tz-stamp-presets button { padding: 5px 9px; border: 2px solid var(--c); border-radius: 7px; color: var(--c); font-size: 11px; font-weight: 800; letter-spacing: .06em; background: #fff; transition: background .15s, color .15s; }
#tz-editor .tz-stamp-presets button:hover { background: color-mix(in srgb, var(--c) 8%, #fff); }
#tz-editor .tz-stamp-presets button.on { background: var(--c); color: #fff; }
#tz-editor .tz-stamp-colors { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#tz-editor .tz-stamp-controls .tz-seg button { font-size: 12px; font-weight: 600; padding: 0 4px; }
#tz-editor .tz-rot-quick { display: flex; gap: 6px; }
#tz-editor .tz-rot-quick button { flex: 1; height: 26px; border-radius: 7px; background: #f1f5f9; font-size: 11px; font-weight: 700; color: var(--tz-ink-2); }
#tz-editor .tz-rot-quick button:hover { background: var(--tz-primary-soft); color: var(--tz-primary); }
#tz-editor .tz-stamp-checks { display: flex; gap: 18px; flex-wrap: wrap; }

@media (max-width: 760px) {
  #tz-editor .tz-stamp-body { grid-template-columns: 1fr; }
  #tz-editor .tz-stamp-preview { position: static; height: 150px; }
}
@media (max-width: 639px) {
  #tz-editor .tz-dialog { padding: 0; align-items: flex-end; }
  #tz-editor .tz-dialog-card, #tz-editor .tz-dialog-wide { width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; }
  #tz-editor .tz-dialog-body { padding: 14px 16px; }
  #tz-editor .tz-dialog-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  #tz-editor .tz-dialog-btns { width: 100%; }
  #tz-editor .tz-dialog-btns .tz-btn { flex: 1; }
  #tz-editor .tz-font-list { grid-template-columns: 1fr 1fr; gap: 8px; }
  #tz-editor .tz-font-card { height: 70px; padding: 4px 6px; }
  #tz-editor .tz-font-sample { font-size: 22px; }
  #tz-editor .tz-stamp-controls .tz-grid2 { grid-template-columns: 1fr; gap: 0; }
  #tz-editor .tz-sign-pad { height: 180px; }
  #tz-editor .tz-subbar { top: 6px; border-radius: 12px; }
  #tz-editor .tz-sub-inner { gap: 10px; padding: 5px 8px; }
  #tz-editor .tz-sub-title { display: none; }
  #tz-editor .tz-sub-swatches { gap: 5px; }
  #tz-editor .tz-sub-swatches button, #tz-editor .tz-sub-custom { width: 22px; height: 22px; }
  #tz-editor .tz-subbar .tz-seg button { height: 28px; min-width: 30px; }
  #tz-editor .tz-sub-label { font-size: 10px; }
  #tz-editor .tz-sub-range input { width: 90px; }
}

/* ===================================================================== busy + toasts */
#tz-editor .tz-busy { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px); align-items: center; justify-content: center; padding: 16px; }
#tz-editor.is-busy .tz-busy { display: flex; }
#tz-editor .tz-busy-card { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 220px; padding: 26px 30px; background: #fff;
  border-radius: 16px; box-shadow: var(--tz-shadow-lg); }
#tz-editor .tz-spinner { width: 42px; height: 42px; border: 4px solid var(--tz-primary-soft); border-top-color: var(--tz-primary); border-radius: 50%; animation: tz-spin .8s linear infinite; }
#tz-editor .tz-busy-text { font-weight: 700; color: var(--tz-ink); font-variant-numeric: tabular-nums; }
@keyframes tz-spin { to { transform: rotate(360deg); } }
#tz-editor .tz-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; align-items: center;
  gap: 8px; width: max-content; max-width: min(460px, calc(100vw - 32px)); pointer-events: none; }
#tz-editor .tz-toast { padding: 12px 16px; border-radius: 12px; background: var(--tz-ink); color: #fff; font-weight: 500; box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
  transition: opacity .4s, transform .4s; pointer-events: auto; }
#tz-editor .tz-toast.tz-error { background: var(--tz-danger); }
#tz-editor .tz-toast.tz-ok { background: var(--tz-ok-dark); }
#tz-editor .tz-toast.out { opacity: 0; transform: translateY(8px); }

/* ===================================================================== medium desktop */
@media (max-width: 1535px) {
  #tz-editor .tz-layout { grid-template-columns: 168px minmax(0, 1fr) 292px; }
  #tz-editor .tz-tb { min-width: 44px; padding: 4px 3px; font-size: 10.5px; }
  #tz-editor .tz-toolbar { gap: 4px; }
  #tz-editor .tz-tgroup { padding: 3px; gap: 1px; }
}
@media (max-width: 1365px) {
  #tz-editor .tz-layout { grid-template-columns: 148px minmax(0, 1fr) 276px; gap: 12px; }
  #tz-editor { padding-left: 14px; padding-right: 14px; }
  #tz-editor .tz-tb { min-width: 41px; padding: 4px 2px; font-size: 10px; }
  #tz-editor .tz-sub-inner { gap: 10px; padding: 6px 10px; }
  #tz-editor .tz-sub-title { display: none; }
  #tz-editor .tz-sub-range input { width: 80px; }
  #tz-editor .tz-sub-swatches { gap: 5px; }
}
@media (max-width: 1279px) {
  #tz-editor { padding-left: 14px; padding-right: 14px; }
  #tz-editor .tz-layout { grid-template-columns: 144px minmax(0, 1fr) 276px; gap: 12px; }
  #tz-editor .tz-tb { min-width: 43px; padding: 4px 3px; font-size: 10.5px; }
  #tz-editor .tz-toolbar { gap: 4px; padding: 8px 8px; }
}

/* ===================================================================== tablet + phone */
@media (min-width: 1024px) {
  #tz-editor .tz-sub-inner { flex-wrap: wrap; justify-content: center; row-gap: 8px; overflow: visible; }
}
@media (min-width: 1024px) and (max-width: 1199px) {
  #tz-editor .tz-tb { height: 40px; min-width: 36px; padding: 4px; }
  #tz-editor .tz-toolbar { gap: 3px; }
  #tz-editor .tz-tb span { display: none; }
}
@media (max-width: 1023px) {
  #tz-editor .tz-only-compact { display: inline-flex !important; }
  #tz-editor .tz-only-wide { display: none !important; }
  #tz-editor .tz-layout { display: block; height: auto; min-height: 0; max-height: none; }
  #tz-editor .tz-work { height: calc(100vh - 64px); height: calc(100dvh - 64px); min-height: 440px; }
  /* at the end of the document a swipe carries on to the page, so the properties card is easy to reach */
  #tz-editor .tz-scroll, #tz-editor .tz-panel-scroll { overscroll-behavior: auto; }
  #tz-editor .tz-file-chip { display: none; }
  #tz-editor .tz-bar-right { margin-left: auto; }

  /* pages: slide-in drawer */
  #tz-editor .tz-sidebar { position: fixed; z-index: 1001; top: 0; bottom: 0; left: 0; width: min(260px, 80vw); border-radius: 0 var(--tz-radius) var(--tz-radius) 0;
    transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--tz-shadow-lg); }
  #tz-editor.show-sidebar .tz-sidebar { transform: none; }
  #tz-editor .tz-backdrop { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  #tz-editor.show-sidebar .tz-backdrop { opacity: 1; pointer-events: auto; }

  /* properties: a normal card under the editor (never covers the page); scroll down to reach it */
  #tz-editor .tz-panel { margin-top: 12px; }
  #tz-editor .tz-panel-scroll { overflow: visible; }
  #tz-editor .tz-panel-empty { padding: 8px 4px 4px; }
  #tz-editor .tz-panel-empty .tz-keys { display: none; }        /* keyboard tips are for desktop */
  #tz-editor .tz-panel-scroll { padding: 14px 16px 18px; }
  #tz-editor .tz-action { display: none; }
  #tz-editor .tz-panel-body { max-width: 640px; margin: 0 auto; }
  #tz-editor .tz-text-props .tz-grid2.tz-actions, #tz-editor .tz-obj-props .tz-grid2.tz-actions { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

  #tz-editor .tz-toolbar { padding: 6px 8px; gap: 6px; }
  #tz-editor .tz-tgroup { padding: 3px; }
  #tz-editor .tz-tb { min-width: 52px; height: 48px; }
  #tz-editor .tz-pages { padding: 24px 12px; gap: 26px; }
  #tz-editor .tz-toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 639px) {
  #tz-editor { padding: 14px 10px; }
  #tz-editor[data-screen="editor"] { padding: 8px 6px; }

  #tz-editor .tz-work { border-radius: 12px; }
  #tz-editor .tz-bar { padding: 6px 6px 6px 8px; min-height: 52px; gap: 6px; }
  #tz-editor .tz-bar .tz-btn { height: 40px; padding: 0 12px; }
  #tz-editor .tz-pdf-word { display: none; }
  #tz-editor .tz-history button { min-width: 34px; height: 34px; }
  #tz-editor .tz-tb { min-width: 50px; font-size: 10.5px; }
  #tz-editor .tz-viewbar { padding: 6px 8px; }
  #tz-editor .tz-page-num { min-width: 74px; }
  #tz-editor .tz-findbar { padding: 8px; }
  #tz-editor .tz-find-fields { flex-basis: 100%; }
  #tz-editor .tz-find-actions { width: 100%; justify-content: space-between; }

  #tz-editor .tz-ready { padding: 0; }
  #tz-editor .tz-ready-card { border-radius: 0; max-height: none; }
  #tz-editor .tz-ready-bar { padding: 12px; }
  #tz-editor .tz-ready-actions { width: 100%; }
  #tz-editor .tz-ready-actions .tz-btn { flex: 1; }
}
@media (max-width: 359px) {
  #tz-editor .tz-bar .tz-btn { padding: 0 9px; }
  #tz-editor .tz-history button { min-width: 30px; }
}
@media (prefers-reduced-motion: reduce) { #tz-editor * { transition: none !important; animation-duration: 0s !important; } }
