/* TGM PDF Editor v1.0.0 — Travel Guide Masters */
.tgmpe-root, .tgmpe-hub, .tgmpe-modal, .tgmpe-menu, .tgmpe-toast {
  --tg-indigo: #4f55d0;
  --tg-indigo-d: #3e43b3;
  --tg-indigo-l: #eceefe;
  --tg-navy: #1b1f3b;
  --tg-ink: #1f2433;
  --tg-muted: #5b6275;
  --tg-line: #e3e6ef;
  --tg-slate: #f4f6fb;
  --tg-danger: #c62828;
  --tg-radius: 10px;
  --tg-shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 6px 20px rgba(20, 24, 50, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tg-ink);
  line-height: 1.5;
  box-sizing: border-box;
}
.tgmpe-root *, .tgmpe-hub *, .tgmpe-modal *, .tgmpe-menu * { box-sizing: border-box; }
.tgmpe-root [hidden], .tgmpe-modal [hidden] { display: none !important; }
.tgmpe-ic { flex: none; display: inline-block; vertical-align: middle; }

/* ---------- buttons ---------- */
.tgmpe-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 8px; padding: 10px 18px;
  font-weight: 600; font-size: 15px; line-height: 1.2; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.tgmpe-btn:focus-visible, .tgmpe-tool:focus-visible, .tgmpe-ibtn:focus-visible, .tgmpe-linkbtn:focus-visible { outline: 3px solid rgba(79, 85, 208, .45); outline-offset: 2px; }
.tgmpe-btn-primary { background: var(--tg-indigo); color: #fff !important; }
.tgmpe-btn-primary:hover { background: var(--tg-indigo-d); }
.tgmpe-btn-primary:disabled { opacity: .7; cursor: progress; }
.tgmpe-btn-ghost { background: #fff; color: var(--tg-ink); border-color: var(--tg-line); }
.tgmpe-btn-ghost:hover { border-color: #c7cbe0; background: var(--tg-slate); }
.tgmpe-btn-danger { background: #fff; color: var(--tg-danger); border-color: #f2c9c9; }
.tgmpe-btn-danger:hover { background: #fdecec; }
.tgmpe-btn-xl { font-size: 19px; padding: 16px 34px; border-radius: 10px; box-shadow: 0 6px 18px rgba(79, 85, 208, .3); }
.tgmpe-btn-sm { padding: 6px 10px; font-size: 13px; }
.tgmpe-linkbtn { background: none; border: 0; padding: 4px 6px; color: var(--tg-indigo); font-weight: 600; font-size: 14px; font-family: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tgmpe-linkbtn:hover { color: var(--tg-indigo-d); }
.tgmpe-ibtn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 0; border-radius: 7px; background: transparent; color: var(--tg-ink); cursor: pointer; padding: 0; font-weight: 600; font-size: 16px; font-family: inherit; text-decoration: none;
}
.tgmpe-ibtn:hover { background: var(--tg-indigo-l); color: var(--tg-indigo); }
.tgmpe-ibtn:disabled { opacity: .35; cursor: not-allowed; background: none; color: var(--tg-ink); }
.tgmpe-danger:hover { background: #fdecec; color: var(--tg-danger); }

/* ---------- landing (upload page) ---------- */
.tgmpe-landing { text-align: center; padding: 48px 16px 40px; }
.tgmpe-eyebrow { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tg-indigo); background: var(--tg-indigo-l); border-radius: 999px; padding: 4px 12px; margin-bottom: 14px; }
.tgmpe-h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.12; margin: 0 0 12px; color: var(--tg-navy); font-weight: 800; letter-spacing: -.02em; }
.tgmpe-lead { font-size: clamp(16px, 2.2vw, 19px); color: var(--tg-muted); max-width: 720px; margin: 0 auto 30px; }
.tgmpe-drop {
  position: relative; max-width: 760px; margin: 0 auto; padding: 44px 20px 30px;
  border: 2px dashed #c9cdf3; border-radius: 16px; background: linear-gradient(180deg, #fafbff, #f3f4fe);
  transition: border-color .15s, background .15s;
}
.tgmpe-drop.is-over { border-color: var(--tg-indigo); background: var(--tg-indigo-l); }
.tgmpe-drop.is-loading [data-tgmpe-upload] { opacity: .6; pointer-events: none; }
.tgmpe-drop-hint { margin-top: 14px; color: var(--tg-muted); font-size: 15px; }
.tgmpe-drop-status { margin-top: 12px; min-height: 1.5em; font-weight: 600; color: var(--tg-navy); }
.tgmpe-drop.is-loading .tgmpe-drop-status::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--tg-indigo); border-right-color: transparent; border-radius: 50%; animation: tgmpe-spin .7s linear infinite; }
.tgmpe-privacy { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px auto 0; font-size: 14px; color: var(--tg-muted); }
.tgmpe-privacy .tgmpe-ic { color: #16a34a; }
.tgmpe-sample-row { margin-top: 6px; }

/* ---------- SEO content ---------- */
.tgmpe-seo { max-width: 1060px; margin: 0 auto; padding: 8px 16px 56px; }
.tgmpe-is-editing .tgmpe-seo, html.tgmpe-editing .tgmpe-seo { display: none; }
.tgmpe-seo h2 { font-size: clamp(22px, 3vw, 30px); color: var(--tg-navy); margin: 48px 0 18px; text-align: center; letter-spacing: -.01em; }
.tgmpe-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; counter-reset: s; }
.tgmpe-steps li { counter-increment: s; background: #fff; border: 1px solid var(--tg-line); border-radius: var(--tg-radius); padding: 20px 18px 18px; position: relative; }
.tgmpe-steps li::before { content: counter(s); display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 50%; background: var(--tg-indigo); color: #fff; font-weight: 700; margin-bottom: 10px; }
.tgmpe-steps strong { display: block; color: var(--tg-navy); margin-bottom: 4px; }
.tgmpe-steps p, .tgmpe-feats p { margin: 0; color: var(--tg-muted); font-size: 15px; }
.tgmpe-feats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tgmpe-feat { background: var(--tg-slate); border-radius: var(--tg-radius); padding: 18px; }
.tgmpe-feat h3 { font-size: 16px; margin: 0 0 6px; color: var(--tg-navy); display: flex; gap: 8px; align-items: center; }
.tgmpe-feat h3 .tgmpe-ic { color: var(--tg-indigo); }
.tgmpe-faq { max-width: 820px; margin: 0 auto; }
.tgmpe-faq details { border: 1px solid var(--tg-line); border-radius: var(--tg-radius); background: #fff; margin-bottom: 10px; }
.tgmpe-faq summary { cursor: pointer; padding: 15px 18px; font-weight: 650; color: var(--tg-navy); list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.tgmpe-faq summary::-webkit-details-marker { display: none; }
.tgmpe-faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--tg-indigo); }
.tgmpe-faq details[open] summary::after { content: "−"; }
.tgmpe-faq details p { margin: 0; padding: 0 18px 16px; color: var(--tg-muted); }

/* ---------- tools hub (home) ---------- */
.tgmpe-hub { max-width: 1120px; margin: 0 auto; padding: 48px 16px 64px; }
.tgmpe-hub-hero { text-align: center; margin-bottom: 36px; }
.tgmpe-hub-hero .tgmpe-btn-xl { margin-top: 6px; }
.tgmpe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tgmpe-card {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; border: 1px solid var(--tg-line); border-radius: 12px;
  background: #fff; text-decoration: none !important; color: var(--tg-ink); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tgmpe-card:hover { transform: translateY(-2px); box-shadow: var(--tg-shadow); border-color: #c9cdf3; }
.tgmpe-card-ic { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--tg-indigo-l); color: var(--tg-indigo); margin-bottom: 6px; }
.tgmpe-card strong { font-size: 17px; color: var(--tg-navy); }
.tgmpe-card span { font-size: 14px; color: var(--tg-muted); }
.tgmpe-card-main { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 18px; background: linear-gradient(135deg, #4f55d0, #363ba6); border: 0; color: #fff; padding: 26px; }
.tgmpe-card-main .tgmpe-card-ic { background: rgba(255, 255, 255, .16); color: #fff; width: 56px; height: 56px; margin: 0; }
.tgmpe-card-main strong { color: #fff; font-size: 22px; }
.tgmpe-card-main span { color: rgba(255, 255, 255, .85); font-size: 15px; }
.tgmpe-card-main .tgmpe-card-go { margin-left: auto; background: #fff; color: var(--tg-indigo); border-radius: 8px; padding: 10px 16px; font-weight: 700; white-space: nowrap; }
@media (max-width: 640px) { .tgmpe-card-main { flex-direction: column; align-items: flex-start; } .tgmpe-card-main .tgmpe-card-go { margin-left: 0; } }

/* ---------- editor ---------- */
.tgmpe-app { position: relative; background: #eef0f6; border-radius: 12px; min-height: 70vh; }
.tgmpe-head { position: sticky; top: var(--tgmpe-sticky-top, 0px); z-index: 40; }
.admin-bar .tgmpe-head { top: calc(var(--tgmpe-sticky-top, 0px) + 32px); }
@media (max-width: 782px) { .admin-bar .tgmpe-head { top: calc(var(--tgmpe-sticky-top, 0px) + 46px); } }
.tgmpe-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #fff;
  border-bottom: 1px solid var(--tg-line); border-radius: 12px 12px 0 0; box-shadow: 0 2px 8px rgba(20, 24, 50, .05);
}
.tgmpe-tools { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: thin; flex: 1; min-width: 0; padding-bottom: 1px; }
.tgmpe-tool {
  flex: none; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 62px; padding: 7px 8px 6px;
  border: 0; border-radius: 8px; background: transparent; color: var(--tg-ink); cursor: pointer; font-weight: 500; font-size: 12.5px; line-height: 1.1; font-family: inherit;
}
.tgmpe-tool span { display: inline-flex; align-items: center; gap: 2px; }
.tgmpe-tool:hover { background: var(--tg-slate); }
.tgmpe-tool.is-active { background: var(--tg-indigo-l); color: var(--tg-indigo); font-weight: 650; }
.tgmpe-tool:disabled { opacity: .35; cursor: not-allowed; background: none; }
.tgmpe-sep { width: 1px; height: 34px; background: var(--tg-line); margin: 0 6px; flex: none; }
.tgmpe-zoom { display: flex; align-items: center; gap: 2px; flex: none; border-left: 1px solid var(--tg-line); padding-left: 8px; }
.tgmpe-zval { border: 0; background: none; font-weight: 600; font-size: 13px; font-family: inherit; min-width: 50px; cursor: pointer; color: var(--tg-ink); border-radius: 6px; padding: 6px 4px; }
.tgmpe-zval:hover { background: var(--tg-slate); }
.tgmpe-propbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 12px; background: #fbfbfe; border-bottom: 1px solid var(--tg-line);
}
.tgmpe-plabel { font-weight: 700; font-size: 13px; color: var(--tg-navy); padding-right: 4px; }
.tgmpe-pgroup { display: inline-flex; align-items: center; gap: 6px; }
.tgmpe-psub { font-size: 12px; color: var(--tg-muted); }
.tgmpe-propbar .tgmpe-btn-danger { margin-left: auto; }
.tgmpe-select, .tgmpe-input, .tgmpe-stepper input {
  height: 32px; border: 1px solid var(--tg-line); border-radius: 7px; background: #fff; padding: 0 8px; font-size: 14px; font-family: inherit; color: var(--tg-ink);
}
.tgmpe-select:focus, .tgmpe-input:focus, .tgmpe-stepper input:focus { outline: 2px solid rgba(79, 85, 208, .4); border-color: var(--tg-indigo); }
.tgmpe-url { width: min(420px, 60vw); }
.tgmpe-fname-in { width: 150px; }
.tgmpe-stepper { display: inline-flex; align-items: center; gap: 2px; }
.tgmpe-stepper input { width: 58px; text-align: center; padding: 0 4px; }
.tgmpe-tbtn { min-width: 32px; height: 32px; border: 1px solid var(--tg-line); border-radius: 7px; background: #fff; cursor: pointer; font-size: 15px; font-family: inherit; color: var(--tg-ink); padding: 0 8px; }
.tgmpe-tbtn.is-active { background: var(--tg-indigo-l); border-color: var(--tg-indigo); color: var(--tg-indigo); }
.tgmpe-swatches { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tgmpe-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #c9cdd9; cursor: pointer; padding: 0; position: relative; flex: none; }
.tgmpe-swatch.is-active { box-shadow: 0 0 0 2px var(--tg-indigo); }
.tgmpe-swatch-custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.tgmpe-swatch-custom input { position: absolute; inset: -6px; opacity: 0; cursor: pointer; width: 40px; height: 40px; }
.tgmpe-hint { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 7px 12px; font-size: 13.5px; color: var(--tg-muted); background: rgba(238, 240, 246, .96); text-align: center; }
.tgmpe-pages { padding: 10px 12px 24px; overflow-x: auto; }
.tgmpe-pagewrap { width: max-content; min-width: 100%; display: flex; flex-direction: column; align-items: center; }
.tgmpe-pagebar { width: var(--tgmpe-pw); min-width: 240px; display: flex; align-items: center; justify-content: space-between; padding: 2px 0 4px; }
.tgmpe-pnum { font-size: 12.5px; font-weight: 600; color: var(--tg-muted); }
.tgmpe-pbtns { display: flex; gap: 1px; background: #fff; border-radius: 9px; box-shadow: 0 1px 3px rgba(20, 24, 50, .1); padding: 2px; }
.tgmpe-pagebox { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(20, 24, 50, .12), 0 8px 24px rgba(20, 24, 50, .08); touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; }
.tgmpe-sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.tgmpe-canvas { position: absolute; left: 0; top: 0; display: block; }
.tgmpe-layer { position: absolute; inset: 0; }
.tgmpe-l-covers { pointer-events: none; }
.tgmpe-cover { position: absolute; }
.tgmpe-l-text, .tgmpe-l-objs { pointer-events: none; }
.tgmpe-app[data-tool="text"] .tgmpe-pagebox { cursor: text; }
.tgmpe-app[data-tool="draw"] .tgmpe-pagebox, .tgmpe-app[data-tool="rect"] .tgmpe-pagebox, .tgmpe-app[data-tool="ellipse"] .tgmpe-pagebox,
.tgmpe-app[data-tool="line"] .tgmpe-pagebox, .tgmpe-app[data-tool="arrow"] .tgmpe-pagebox, .tgmpe-app[data-tool="whiteout"] .tgmpe-pagebox,
.tgmpe-app[data-tool="links"] .tgmpe-pagebox, .tgmpe-app[data-tool="field-text"] .tgmpe-pagebox, .tgmpe-app[data-tool="field-check"] .tgmpe-pagebox,
.tgmpe-app[data-tool="place"] .tgmpe-pagebox { cursor: crosshair; }
.tgmpe-app[data-tool="highlight"] .tgmpe-pagebox, .tgmpe-app[data-tool="underline"] .tgmpe-pagebox, .tgmpe-app[data-tool="strike"] .tgmpe-pagebox { cursor: text; }
.tgmpe-app[data-tool="draw"] .tgmpe-pagebox, .tgmpe-app[data-tool="rect"] .tgmpe-pagebox, .tgmpe-app[data-tool="ellipse"] .tgmpe-pagebox,
.tgmpe-app[data-tool="line"] .tgmpe-pagebox, .tgmpe-app[data-tool="arrow"] .tgmpe-pagebox, .tgmpe-app[data-tool="whiteout"] .tgmpe-pagebox,
.tgmpe-app[data-tool="highlight"] .tgmpe-pagebox, .tgmpe-app[data-tool="underline"] .tgmpe-pagebox, .tgmpe-app[data-tool="strike"] .tgmpe-pagebox,
.tgmpe-app[data-tool="links"] .tgmpe-pagebox, .tgmpe-app[data-tool="field-text"] .tgmpe-pagebox { touch-action: none; }
.tgmpe-ti { position: absolute; pointer-events: auto; cursor: text; border-radius: 2px; outline: 1px dashed rgba(79, 85, 208, .35); }
.tgmpe-ti:hover { background: rgba(79, 85, 208, .12); outline: 1.5px solid var(--tg-indigo); }

/* existing form fields */
.tgmpe-widget { position: absolute; margin: 0; border: 1px solid rgba(79, 85, 208, .35); background: rgba(225, 230, 255, .55); color: #000; padding: 0 3px; font-family: Helvetica, Arial, sans-serif; border-radius: 2px; }
.tgmpe-widget:hover { border-color: var(--tg-indigo); }
.tgmpe-widget:focus { outline: 2px solid var(--tg-indigo); background: rgba(255, 255, 255, .92); }
textarea.tgmpe-widget { resize: none; padding: 2px 3px; line-height: 1.2; }
.tgmpe-w-check, .tgmpe-w-radio { accent-color: var(--tg-indigo); padding: 0; cursor: pointer; }
select.tgmpe-widget { padding: 0 2px; }

/* objects */
.tgmpe-obj { position: absolute; pointer-events: auto; cursor: move; }
.tgmpe-obj.is-selected { outline: 1.5px solid var(--tg-indigo); outline-offset: 1px; z-index: 5; }
.tgmpe-obj.is-drawing { outline: 1px dashed var(--tg-indigo); }
.tgmpe-o-highlight, .tgmpe-o-line, .tgmpe-o-arrow, .tgmpe-o-draw, .tgmpe-o-underline, .tgmpe-o-strike { pointer-events: none; }
.tgmpe-o-highlight { mix-blend-mode: multiply; }
.tgmpe-o-highlight .tgmpe-svg rect, .tgmpe-o-underline .tgmpe-svg rect, .tgmpe-o-strike .tgmpe-svg rect, .tgmpe-hit { pointer-events: all; cursor: move; }
.tgmpe-o-line.is-selected, .tgmpe-o-arrow.is-selected, .tgmpe-o-draw.is-selected { outline: 1px dashed var(--tg-indigo); }
.tgmpe-o-rect .tgmpe-svg, .tgmpe-o-ellipse .tgmpe-svg { pointer-events: none; }
.tgmpe-svgwrap, .tgmpe-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; }
.tgmpe-o-image img { width: 100%; height: 100%; display: block; pointer-events: none; }
.tgmpe-o-whiteout { background: #fff; }
.tgmpe-o-whiteout:not(.is-selected) { box-shadow: inset 0 0 0 1px rgba(79, 85, 208, .15); }
.tgmpe-app:not([data-tool="select"]):not([data-tool="whiteout"]) .tgmpe-o-whiteout:not(.is-selected) { box-shadow: none; }
.tgmpe-o-link { background: rgba(37, 99, 235, .1); border: 1.5px dashed #2563eb; border-radius: 2px; }
.tgmpe-linktag { position: absolute; top: -9px; left: -9px; width: 18px; height: 18px; border-radius: 50%; background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center; }
.tgmpe-o-field { background: rgba(225, 230, 255, .7); border: 1px solid #8f95e0; border-radius: 2px; }
.tgmpe-o-field input[type=text] { width: 100%; height: 100%; border: 0; background: transparent; padding: 0 3px; font-family: Helvetica, Arial, sans-serif; color: #000; pointer-events: none; }
.tgmpe-o-field.is-selected input { pointer-events: auto; }
.tgmpe-o-field input[type=checkbox] { width: 100%; height: 100%; margin: 0; pointer-events: none; accent-color: var(--tg-indigo); }
.tgmpe-o-field.is-selected input[type=checkbox] { pointer-events: auto; }
.tgmpe-o-text, .tgmpe-o-edittext { cursor: text; }
.tgmpe-tx { white-space: pre; line-height: 1.2; min-width: 4px; min-height: 1.2em; outline: none; cursor: text; padding: 0; margin: 0; user-select: text; -webkit-user-select: text; caret-color: var(--tg-indigo); }
.tgmpe-o-text:not(.is-selected):hover, .tgmpe-o-edittext:not(.is-selected):hover { outline: 1px dashed rgba(79, 85, 208, .6); }
.tgmpe-o-text.is-editing, .tgmpe-o-edittext.is-editing { outline: 1.5px solid var(--tg-indigo); background: rgba(255, 255, 255, .4); }
.tgmpe-grip { position: absolute; left: -20px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 4px; background: var(--tg-indigo); color: #fff; display: none; align-items: center; justify-content: center; cursor: move; }
.tgmpe-obj.is-selected .tgmpe-grip { display: flex; }
.tgmpe-h { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: #fff; border: 2px solid var(--tg-indigo); border-radius: 50%; display: none; pointer-events: auto; z-index: 2; touch-action: none; }
.tgmpe-obj.is-selected .tgmpe-h { display: block; }
.tgmpe-h[data-h=nw] { left: 0; top: 0; cursor: nwse-resize; }
.tgmpe-h[data-h=ne] { left: 100%; top: 0; cursor: nesw-resize; }
.tgmpe-h[data-h=sw] { left: 0; top: 100%; cursor: nesw-resize; }
.tgmpe-h[data-h=se] { left: 100%; top: 100%; cursor: nwse-resize; }
.tgmpe-h[data-h=p1], .tgmpe-h[data-h=p2] { cursor: crosshair; }
.tgmpe-odel { position: absolute; right: -11px; top: -26px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--tg-danger); color: #fff; display: none; align-items: center; justify-content: center; cursor: pointer; padding: 0; pointer-events: auto; z-index: 3; }
.tgmpe-obj.is-selected .tgmpe-odel { display: flex; }
.tgmpe-obj.is-editing .tgmpe-odel { display: none; }
@media (pointer: coarse) { .tgmpe-h { width: 20px; height: 20px; margin: -10px 0 0 -10px; } }

.tgmpe-insert { display: flex; justify-content: center; padding: 8px 0; width: 100%; }
.tgmpe-insert button { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed #b9bedb; background: rgba(255, 255, 255, .6); color: var(--tg-muted); border-radius: 999px; padding: 5px 14px; font-weight: 600; font-size: 12.5px; font-family: inherit; cursor: pointer; opacity: .75; transition: opacity .15s, color .15s, border-color .15s; }
.tgmpe-insert button:hover, .tgmpe-insert button:focus-visible { opacity: 1; color: var(--tg-indigo); border-color: var(--tg-indigo); background: #fff; }
.tgmpe-applybar {
  position: sticky; bottom: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: #fff; border-top: 1px solid var(--tg-line); border-radius: 0 0 12px 12px; box-shadow: 0 -2px 10px rgba(20, 24, 50, .06);
}
.tgmpe-docinfo { display: flex; flex-direction: column; min-width: 0; }
.tgmpe-fname { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tg-navy); font-size: 14px; }
.tgmpe-pcount { font-size: 12.5px; color: var(--tg-muted); }
.tgmpe-applyact { display: flex; gap: 8px; }
.tgmpe-applyact .tgmpe-btn-primary { padding: 11px 26px; font-size: 16px; }
.tgmpe-spin { display: inline-block; width: 16px; height: 16px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: tgmpe-spin .7s linear infinite; }
@keyframes tgmpe-spin { to { transform: rotate(360deg); } }

/* menu */
.tgmpe-menu { position: fixed; z-index: 100000; min-width: 210px; background: #fff; border: 1px solid var(--tg-line); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 24, 50, .18); padding: 6px; display: flex; flex-direction: column; }
.tgmpe-menuitem { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 7px; font-size: 14px; font-family: inherit; color: var(--tg-ink); cursor: pointer; text-align: left; }
.tgmpe-menuitem:hover, .tgmpe-menuitem:focus-visible { background: var(--tg-slate); outline: none; }
.tgmpe-menuitem.is-active { color: var(--tg-indigo); font-weight: 650; background: var(--tg-indigo-l); }
.tgmpe-sigthumb { max-height: 40px; max-width: 180px; display: block; }

/* modal */
.tgmpe-modal { position: fixed; inset: 0; z-index: 100001; background: rgba(15, 18, 40, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.tgmpe-dialog { position: relative; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); padding: 24px; }
.tgmpe-mclose { position: absolute; right: 12px; top: 12px; border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--tg-muted); display: flex; align-items: center; justify-content: center; }
.tgmpe-mclose:hover { background: var(--tg-slate); }
.tgmpe-mtitle { margin: 0 0 14px; font-size: 21px; color: var(--tg-navy); }
.tgmpe-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--tg-line); margin-bottom: 14px; }
.tgmpe-tabs button { border: 0; background: none; padding: 9px 14px; font-weight: 600; font-size: 14px; font-family: inherit; color: var(--tg-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tgmpe-tabs button.is-active { color: var(--tg-indigo); border-bottom-color: var(--tg-indigo); }
.tgmpe-sigpad { width: 100%; height: auto; aspect-ratio: 1000 / 320; border: 1px solid var(--tg-line); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.tgmpe-sigrow { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.tgmpe-sigcolors { display: flex; gap: 6px; }
.tgmpe-signame { width: 100%; height: 44px; font-size: 17px; }
.tgmpe-sigfonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tgmpe-sigfont { border: 1px solid var(--tg-line); border-radius: 10px; background: #fff; padding: 12px; font-size: 28px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tgmpe-sigfont.is-active { border-color: var(--tg-indigo); box-shadow: 0 0 0 2px rgba(79, 85, 208, .25); }
.tgmpe-uploadsig { display: flex; align-items: center; justify-content: center; min-height: 120px; border: 2px dashed #c9cdf3; border-radius: 10px; cursor: pointer; color: var(--tg-indigo); font-weight: 600; gap: 8px; }
.tgmpe-uploadsig span { display: inline-flex; gap: 8px; align-items: center; }
.tgmpe-sigprev { max-width: 100%; max-height: 140px; display: block; margin: 10px auto 0; }
.tgmpe-muted { color: var(--tg-muted); font-size: 14px; margin: 8px 0 0; }
.tgmpe-mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.tgmpe-modal-done .tgmpe-dialog { text-align: center; width: min(460px, 100%); padding: 32px 24px 24px; }
.tgmpe-modal-done .tgmpe-btn-xl { margin-top: 18px; }
.tgmpe-done-ic { width: 60px; height: 60px; border-radius: 50%; background: #dcfce7; color: #16a34a; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.tgmpe-done-row { display: flex; justify-content: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.tgmpe-warn { background: #fff7ed; color: #9a3412; border-radius: 8px; padding: 10px 12px; font-size: 14px; text-align: left; }

/* toast */
.tgmpe-toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); z-index: 100002; background: var(--tg-navy); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
.tgmpe-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* small screens */
@media (max-width: 720px) {
  .tgmpe-tool { min-width: 46px; padding: 6px 3px; font-size: 11px; }
  .tgmpe-zoom { display: none; } /* every page has its own zoom buttons; frees room for Undo/Redo */
  .tgmpe-tools { flex-wrap: wrap; overflow: visible; justify-content: center; row-gap: 2px; } /* two rows: every tool incl. Undo/Redo visible, no hidden scrolling */
  .tgmpe-sep { display: none; }
  .tgmpe-zoom .tgmpe-zval { min-width: 42px; }
  .tgmpe-hint { font-size: 12.5px; }
  .tgmpe-pages { padding: 8px 4px 20px; }
  .tgmpe-applyact .tgmpe-btn-ghost { display: none; }
  .tgmpe-app { border-radius: 0; }
  .tgmpe-toolbar { border-radius: 0; }
  .tgmpe-applybar { border-radius: 0; }
  .tgmpe-sigfonts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .tgmpe-root *, .tgmpe-hub * { transition: none !important; animation: none !important; } }
