.rgt-pdf-tool{max-width:1200px;margin:0 auto;
  /* Theme-aware colors (Astra / block themes / fallback) */
  --rgt-accent: var(--ast-global-color-0, var(--wp--preset--color--primary, #2563eb));
  --rgt-accent-contrast: var(--ast-global-color-5, var(--wp--preset--color--base, #ffffff));
  --rgt-surface: var(--ast-global-color-4, var(--wp--preset--color--base, #ffffff));
  --rgt-text: var(--ast-global-color-3, var(--wp--preset--color--contrast, #111827));
  --rgt-muted: var(--ast-global-color-2, #6b7280);
  --rgt-border: rgba(0,0,0,.12);

  /* If admin "Filter Button Styles" are set, use them for PDF UI buttons too.
     Use the NORMAL state as the base so text doesn't disappear on hover. */
  --rgt-ui-bg: var(--rgt-pill-bg, var(--rgt-accent));
  --rgt-ui-color: var(--rgt-pill-color, var(--rgt-accent-contrast));
  --rgt-ui-border: var(--rgt-pill-border, var(--rgt-accent));
  --rgt-ui-hover-bg: var(--rgt-pill-hover-bg, var(--rgt-ui-bg));
  --rgt-ui-hover-color: var(--rgt-pill-hover-color, var(--rgt-ui-color));
  --rgt-ui-hover-border: var(--rgt-pill-hover-border, var(--rgt-ui-border));
}
.rgt-pdf-tool .rgt-drop{border:2px dashed #d7dbe3;border-radius:16px;padding:18px;text-align:center;background:#fff}
.rgt-pdf-tool .rgt-drop.is-drag{background:#f3f4f6}
.rgt-pdf-tool .rgt-select-btn{padding:12px 18px;border-radius:999px;border:1px solid var(--rgt-accent);background:var(--rgt-accent);color:var(--rgt-accent-contrast);font-weight:700;cursor:pointer}
.rgt-pdf-tool .rgt-drop-sub{margin-top:8px;color:var(--rgt-muted)}
.rgt-pdf-tool .rgt-privacy-note{margin-top:10px;color:var(--rgt-muted);font-size:13px}
.rgt-pdf-actions{display:flex;gap:10px;justify-content:flex-end;align-items:center;margin:14px 0}
.rgt-btn{
  border:1px solid var(--rgt-pill-border, var(--rgt-border)) !important;
  background:var(--rgt-pill-bg, var(--rgt-surface)) !important;
  color:var(--rgt-pill-color, var(--rgt-text)) !important;
  padding:10px 14px;border-radius:10px;font-weight:700;cursor:pointer
}
.rgt-btn:hover{
  border-color:var(--rgt-pill-hover-border, var(--rgt-pill-border, var(--rgt-border))) !important;
  background:var(--rgt-pill-hover-bg, #f3f4f6) !important;
  color:var(--rgt-pill-hover-color, var(--rgt-pill-color, var(--rgt-text))) !important;
}
.rgt-btn.rgt-finish{
  background:var(--rgt-pill-active-bg, var(--rgt-accent)) !important;
  border-color:var(--rgt-pill-active-border, var(--rgt-accent)) !important;
  color:var(--rgt-pill-active-color, var(--rgt-accent-contrast)) !important;
}
.rgt-btn.rgt-finish:hover{
  background:var(--rgt-pill-active-bg, var(--rgt-accent)) !important;
  border-color:var(--rgt-pill-active-border, var(--rgt-accent)) !important;
  color:var(--rgt-pill-active-color, var(--rgt-accent-contrast)) !important;
  filter:brightness(0.95)
}
.rgt-pdf-files{display:flex;flex-direction:column;gap:16px}
.rgt-pdf-file{border:1px solid #e5e7eb;border-radius:16px;background:#fff;padding:14px}
.rgt-pdf-head{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap}
.rgt-pdf-name span{display:inline-block;margin-left:10px;color:var(--rgt-muted);font-size:13px}
.rgt-pdf-toolbar{display:flex;gap:8px;flex-wrap:wrap}
.rgt-mini{
  border:1px solid var(--rgt-pill-border, var(--rgt-border)) !important;
  background:var(--rgt-pill-bg, var(--rgt-surface)) !important;
  color:var(--rgt-pill-color, var(--rgt-text)) !important;
  padding:8px 10px;border-radius:10px;font-weight:700;cursor:pointer
}
.rgt-mini:hover{
  border-color:var(--rgt-pill-hover-border, var(--rgt-pill-border, var(--rgt-border))) !important;
  background:var(--rgt-pill-hover-bg, #f3f4f6) !important;
  color:var(--rgt-pill-hover-color, var(--rgt-pill-color, var(--rgt-text))) !important;
}
.rgt-pdf-grid{margin-top:12px;display:grid;gap:12px;grid-template-columns:repeat(5,minmax(0,1fr))}
@media (max-width:1100px){.rgt-pdf-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media (max-width:820px){.rgt-pdf-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:520px){.rgt-pdf-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
.rgt-pdf-page{position:relative;border:1px solid #e5e7eb;border-radius:14px;overflow:visible;background:#f9fafb;cursor:pointer;padding:10px;display:flex;align-items:center;justify-content:center;min-height:140px}
.rgt-pdf-page canvas{max-width:100%;max-height:160px;transform-origin:center center;transition:transform .12s ease}
.rgt-pdf-page.is-selected{outline:3px solid var(--rgt-accent)}
.rgt-pdf-page-label{position:absolute;bottom:8px;left:8px;background:rgba(17,24,39,.88);color:#fff;font-size:12px;padding:4px 8px;border-radius:999px}
.rgt-busy{position:fixed;inset:0;background:rgba(17,24,39,.55);display:flex;align-items:center;justify-content:center;flex-direction:column;gap:10px;color:#fff;z-index:99999}
.rgt-spinner{width:44px;height:44px;border-radius:999px;border:4px solid rgba(255,255,255,.25);border-top-color:#fff;animation:rgtspin 1s linear infinite}
@keyframes rgtspin{to{transform:rotate(360deg)}}

/* Per-page controls */
.rgt-pdf-page-actions{
  position:absolute;top:8px;right:8px;
  display:flex;gap:6px;
  opacity:0;transform:translateY(-4px);
  pointer-events:none;
  transition:opacity .12s ease, transform .12s ease;
  z-index:5
}
.rgt-pdf-page:hover .rgt-pdf-page-actions,
.rgt-pdf-page:focus-within .rgt-pdf-page-actions,
.rgt-pdf-page.is-active .rgt-pdf-page-actions{
  opacity:1;transform:none;
  pointer-events:auto;
}

/* Page action buttons */
.rgt-pdf-act{
  width:32px;height:32px;
  border-radius:10px;
  border:1px solid var(--rgt-ui-border) !important;
  background:var(--rgt-ui-bg) !important;
  /* Popup action buttons: force readable icon/text (theme CSS often makes currentColor invisible) */
  color:#111827 !important;
  cursor:pointer;
  font-weight:900;
  display:flex;align-items:center;justify-content:center;
  line-height:1;
  box-shadow:0 6px 18px rgba(0,0,0,.14)
}
.rgt-pdf-act:hover{
  background:var(--rgt-ui-hover-bg) !important;
  border-color:var(--rgt-ui-hover-border) !important;
  color:#111827 !important;
}
.rgt-pdf-act svg{
  width:18px !important;
  height:18px !important;
  min-width:18px !important;
  min-height:18px !important;
  flex:0 0 18px !important;
  max-width:none !important;
  max-height:none !important;
  display:block !important;
  opacity:1 !important;
  visibility:visible !important;
  stroke:#000 !important;
  fill:none !important;
  filter:none !important;
  stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round
}
.rgt-pdf-act svg *,
.rgt-pdf-rot svg *{
  /* Some themes force stroke/fill on path/polyline/etc. Override those too. */
  stroke:#000 !important;
  fill:none !important;
  filter:none !important;
  opacity:1 !important;
  visibility:visible !important;
}
.rgt-pdf-act .rgt-rot-ico{width:18px;height:18px}

/* Tooltip (theme-proof; avoids title-based tooltips that some themes restyle badly) */
.rgt-pdf-act[data-tip]{position:relative}
.rgt-pdf-act[data-tip]::after{
  content:attr(data-tip);
  position:absolute;
  left:50%;
  bottom:calc(100% + 8px);
  transform:translateX(-50%) translateY(4px);
  background:rgba(17,24,39,.95);
  color:#fff;
  font-size:12px;
  font-weight:700;
  padding:6px 10px;
  border-radius:10px;
  white-space:nowrap;
  opacity:0;
  pointer-events:none;
  transition:opacity .12s ease, transform .12s ease;
  z-index:9999;
  box-shadow:0 10px 26px rgba(0,0,0,.25)
}
.rgt-pdf-act[data-tip]::before{
  content:"";
  position:absolute;
  left:50%;
  bottom:calc(100% + 2px);
  transform:translateX(-50%);
  border:6px solid transparent;
  border-top-color:rgba(17,24,39,.95);
  opacity:0;
  pointer-events:none;
  transition:opacity .12s ease;
  z-index:9999
}
.rgt-pdf-act[data-tip]:hover::after,
.rgt-pdf-act[data-tip]:hover::before{
  opacity:1
}
.rgt-pdf-act[data-tip]:hover::after{
  transform:translateX(-50%) translateY(0)
}

/* Center rotate button (always visible) */
.rgt-pdf-rot{
  position:absolute;top:50%;left:50%;
  transform:translate(-50%,-50%);
  width:56px;height:56px;border-radius:999px;
  border:2px solid var(--rgt-ui-border) !important;
  background:var(--rgt-ui-bg) !important;
  /* Main rotate icon should always be visible */
  color:#111827 !important;
  cursor:pointer;
  opacity:1;
  z-index:4;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 10px 28px rgba(0,0,0,.14)
}
.rgt-pdf-rot:hover{
  background:var(--rgt-ui-hover-bg) !important;
  border-color:var(--rgt-ui-hover-border) !important;
  color:#111827 !important;
}

/* Theme-proof SVG rendering for the main rotate button */
.rgt-pdf-rot svg{
  width:22px !important;
  height:22px !important;
  min-width:22px !important;
  min-height:22px !important;
  flex:0 0 22px !important;
  max-width:none !important;
  max-height:none !important;
  display:block !important;
  opacity:1 !important;
  visibility:visible !important;
  stroke:#000 !important;
  fill:none !important;
  filter:none !important;
}

/* Static rotate icon (matches theme via currentColor) */
.rgt-rot-ico{width:26px;height:26px;display:block}
.rgt-rot-tail{stroke:currentColor;stroke-dasharray:1 5;opacity:.55}
.rgt-rot-ring{stroke:currentColor}
.rgt-rot-arrow{stroke:currentColor}

@media (hover: none){
  .rgt-pdf-page-actions{opacity:1;transform:none;pointer-events:auto}
  .rgt-pdf-rot{opacity:1}
}

/* Preview modal */
.rgt-pdf-modal{position:fixed;inset:0;display:none;align-items:center;justify-content:center;padding:18px;z-index:99999}
.rgt-pdf-modal.is-open{display:flex}
.rgt-pdf-modal-back{position:absolute;inset:0;background:rgba(17,24,39,.65)}
.rgt-pdf-modal-box{position:relative;background:#fff;border-radius:16px;max-width:920px;width:100%;max-height:90vh;overflow:auto;padding:16px 16px 18px;box-shadow:0 20px 60px rgba(0,0,0,.35)}
.rgt-pdf-modal-close{position:absolute;top:10px;right:10px;border:1px solid #e5e7eb;background:#fff;border-radius:10px;width:36px;height:36px;cursor:pointer;font-weight:900}
.rgt-pdf-modal-title{padding-right:48px;font-weight:800;margin-bottom:12px}
.rgt-pdf-preview{display:flex;align-items:center;justify-content:center}
.rgt-pdf-preview canvas{max-width:100%;height:auto}
