/* PDF Tools modal (opened by the "PDF Tools" pill in the maker toolbar; js/pdf-modal.js).
   Everything is prefixed .pm- so nothing leaks into the maker's own .btn / .grid / .tile rules.
   Colours come from the maker's tokens (--panel, --text, --brass ...) so dark and light themes follow automatically. */

.pm {
  --pm-ink: #1c1204;
  --pm-bubble: rgba(233, 160, 46, .16);
  --pm-grad: linear-gradient(115deg, #efa82f 0%, #de8622 100%);
  --pm-wave-c: #e9a02e;
  --pm-wave-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 12' preserveAspectRatio='none'%3E%3Cpath d='M0 6Q22.5 0 45 6T90 6V12H0Z' fill='%23e9a02e'/%3E%3C/svg%3E");
  --pm-wave-svg-2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7Q30 0 60 7T120 7V14H0Z' fill='%23e9a02e'/%3E%3C/svg%3E");
  --pm-spring: cubic-bezier(.34, 1.56, .64, 1);

  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  padding: 20px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .18s ease, visibility 0s linear .18s;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  touch-action: pan-y;
  overscroll-behavior: contain;
}

html[data-theme="light"] .pm {
  --pm-bubble: rgba(185, 127, 20, .14);
  --pm-grad: linear-gradient(115deg, #f0b23d 0%, #e08d27 100%);
}

.pm.show {
  visibility: visible;
  opacity: 1;
  transition: opacity .18s ease;
}

.pm [hidden] { display: none !important; }
.pm *, .pm *::before, .pm *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html.pm-lock, html.pm-lock body { overflow: hidden; }

.pm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 11, 16, .6);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.pm-card {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: 26px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  transform: translateY(10px) scale(.98);
  transition: transform .2s var(--ease);
}

.pm.show .pm-card { transform: none; }

/* close button: same behaviour as the Lookup modal's cross */
.pm-x {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
  outline: none;
  transition: background .3s var(--ease), color .3s var(--ease), box-shadow .3s var(--ease);
}
.pm-x i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  line-height: 1;
  transform-origin: 50% 50%;
  transition: transform .6s var(--ease);
}
.pm-x:hover{
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 10px -4px rgba(226, 104, 90, .6);
}
.pm-x:hover i{ transform: rotate(90deg); }
/* on click: spins once, turns deep red, then the modal closes (see closeWithSpin in pdf-modal.js) */
.pm-x.is-closing {
  pointer-events: none;
  background: #c4372a;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(226, 104, 90, .28), 0 6px 14px -4px rgba(196, 55, 42, .75);
}
.pm-x.is-closing i { transform: rotate(360deg); transition-duration: .7s; }

.pm-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 24px 26px;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* ---------- hub ---------- */
.pm-hub { text-align: center; }
.pm-hub h2 {
  margin: 0 0 8px;
  font: 700 clamp(30px, 6vw, 42px)/1.05 'Space Grotesk', sans-serif;
  letter-spacing: -.02em;
  color: var(--text);
}
.pm-sub { margin: 0 auto 26px; max-width: 420px; color: var(--text-dim); font-size: 16px; }
.pm-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-width: 540px; margin: 0 auto; text-align: left; }

.pm-tool {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 18px;
  border-radius: 22px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .2s, box-shadow .25s;
}
.pm-tool:active { transform: scale(.985); }
.pm-tool > *:not(.pm-wave) { position: relative; z-index: 1; }
.pm-tool b { display: block; font: 600 19px 'Space Grotesk', sans-serif; }
.pm-tool .pm-d { display: block; color: var(--text-dim); font-size: 15px; }
.pm-tool .pm-chev { margin-left: auto; color: var(--text-faint); font-size: 16px; transition: transform .25s var(--ease), color .2s; }

.pm-tool.pm-primary {
  padding: 22px 18px;
  background: var(--pm-grad);
  border-color: transparent;
  color: var(--pm-ink);
  --pm-wave-c: #fff;
  --pm-wave-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 12' preserveAspectRatio='none'%3E%3Cpath d='M0 6Q22.5 0 45 6T90 6V12H0Z' fill='%23ffffff'/%3E%3C/svg%3E");
  --pm-wave-svg-2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7Q30 0 60 7T120 7V14H0Z' fill='%23ffffff'/%3E%3C/svg%3E");
}
.pm-tool.pm-primary .pm-d, .pm-tool.pm-primary .pm-chev { color: rgba(28, 18, 4, .78); }

/* icon bubble */
.pm-bub {
  position: relative;
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 23px;
  background: var(--pm-bubble);
  color: var(--brass);
}
.pm-primary .pm-bub { background: rgba(255, 255, 255, .35); color: var(--pm-ink); }

/* ---- Scan: a thin scanner bar sweeping gently over the camera ---- */
.pm-scanbar {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent 0, var(--pm-ink) 22%, var(--pm-ink) 78%, transparent 100%);
  opacity: .8;
  pointer-events: none;
  will-change: transform;
  transform: translate3d(0, 17px, 0);
  animation: pmScan 1.9s cubic-bezier(.45, 0, .55, 1) infinite alternate;
}
@keyframes pmScan {
  from { transform: translate3d(0, 17px, 0); }
  to   { transform: translate3d(0, 39px, 0); }
}

/* ---- Wave fill that rises on hover (all three cards) ---- */
.pm-wave { position: absolute; inset: 0; z-index: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.pm-wave::before, .pm-wave::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateY(104%);
  transition: transform .8s var(--ease);
  animation: pmWaveX 3.2s linear infinite paused;
}
.pm-wave::before {
  opacity: .22;
  background:
    var(--pm-wave-svg) repeat-x 0 0 / 90px 12px,
    linear-gradient(var(--pm-wave-c), var(--pm-wave-c)) 0 11px / 100% 100% no-repeat;
}
.pm-wave::after {
  opacity: .16;
  transition-delay: .07s;
  animation-duration: 4.6s;
  animation-direction: reverse;
  background:
    var(--pm-wave-svg-2) repeat-x 0 0 / 120px 14px,
    linear-gradient(var(--pm-wave-c), var(--pm-wave-c)) 0 13px / 100% 100% no-repeat;
  top: 5px;
}
@keyframes pmWaveX {
  to { background-position-x: 90px, 0; }
}
.pm-wave::after { animation-name: pmWaveX2; }
@keyframes pmWaveX2 {
  to { background-position-x: 120px, 0; }
}

.pm-tool:is(:active, .is-go) .pm-wave::before,
.pm-tool:is(:active, .is-go) .pm-wave::after { transform: translateY(30%); animation-play-state: running; }
@media (hover: hover) {
  .pm-tool:hover { border-color: var(--brass); box-shadow: 0 14px 28px -18px rgba(214, 162, 74, .55); }
  .pm-tool.pm-primary:hover { border-color: transparent; }
  .pm-tool:hover .pm-chev { transform: translateX(3px); color: var(--brass); }
  .pm-tool.pm-primary:hover .pm-chev { color: var(--pm-ink); }
  .pm-tool:hover .pm-wave::before,
  .pm-tool:hover .pm-wave::after { transform: translateY(30%); animation-play-state: running; }
}

/* ---- Merge icon: layers sit slightly apart, compress and settle into place on hover ---- */
.pm-ic-merge { width: 28px; height: 28px; overflow: visible; }
.pm-ic-merge .pm-lay {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .55s var(--pm-spring);
}
.pm-ic-merge .pm-lay-top { fill: currentColor; fill-opacity: .22; transform: translateY(-3.4px); }
.pm-ic-merge .pm-lay-mid { transform: translateY(0); }
.pm-ic-merge .pm-lay-bot { transform: translateY(3.4px); }
.pm-tool:is(:active, .is-go) .pm-ic-merge .pm-lay { transform: none; }
@media (hover: hover) {
  .pm-tool:hover .pm-ic-merge .pm-lay { transform: none; }
}

/* ---- Organise icon: three outlined sheets swap their stacking order on hover ---- */
.pm-ic-org {
  --pm-sheet: #2b2a2a;
  --pm-sheet: color-mix(in srgb, var(--brass) 12%, var(--panel-2));
  position: relative;
  width: 28px;
  height: 28px;
}
.pm-ic-org b {
  position: absolute;
  left: 3px;
  top: 8px;
  width: 15px;
  height: 18px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 4px;
  background: var(--pm-sheet);
  transition: transform .6s var(--pm-spring), background-color .45s, z-index 0s .25s;
}
/* a short text line so each sheet reads as a page */
.pm-ic-org b::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 3px;
  width: 5px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: .8;
}
/* resting order: front, middle, back (the back sheets get a little more tint) */
.pm-ic-org .pm-sa { z-index: 3; transform: translate(0, 0); }
.pm-ic-org .pm-sb { z-index: 2; transform: translate(5px, -3px); background: #3a3328; background: color-mix(in srgb, var(--brass) 22%, var(--panel-2)); }
.pm-ic-org .pm-sc { z-index: 1; transform: translate(10px, -6px); background: #4a3d27; background: color-mix(in srgb, var(--brass) 34%, var(--panel-2)); }
/* hover: front sheet goes to the back, the middle one comes forward, the back one moves to the middle */
.pm-tool:is(:active, .is-go) .pm-ic-org .pm-sa { z-index: 1; transform: translate(10px, -6px); background: #4a3d27; background: color-mix(in srgb, var(--brass) 34%, var(--panel-2)); }
.pm-tool:is(:active, .is-go) .pm-ic-org .pm-sb { z-index: 3; transform: translate(0, 0); background: var(--pm-sheet); }
.pm-tool:is(:active, .is-go) .pm-ic-org .pm-sc { z-index: 2; transform: translate(5px, -3px); background: #3a3328; background: color-mix(in srgb, var(--brass) 22%, var(--panel-2)); }
@media (hover: hover) {
  .pm-tool:hover .pm-ic-org .pm-sa { z-index: 1; transform: translate(10px, -6px); background: #4a3d27; background: color-mix(in srgb, var(--brass) 34%, var(--panel-2)); }
  .pm-tool:hover .pm-ic-org .pm-sb { z-index: 3; transform: translate(0, 0); background: var(--pm-sheet); }
  .pm-tool:hover .pm-ic-org .pm-sc { z-index: 2; transform: translate(5px, -3px); background: #3a3328; background: color-mix(in srgb, var(--brass) 22%, var(--panel-2)); }
}

.pm-priv { margin: 26px auto 0; color: var(--text-dim); font-size: 14px; text-align: center; }
.pm-priv i { margin-right: 6px; }

/* ---------- tool views ---------- */
.pm-vhead { display: flex; align-items: center; gap: 12px; padding: 0 40px 6px 0; }
.pm-back {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .2s, transform .15s var(--ease);
}
.pm-back:hover { border-color: var(--brass); }
.pm-back:active { transform: scale(.94); }
.pm-vhead h3 { margin: 0; font: 700 23px 'Space Grotesk', sans-serif; color: var(--text); }
.pm-vdesc { margin: 4px 0 16px; color: var(--text-dim); font-size: 14.5px; }

.pm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: 600 15px 'Inter', sans-serif;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .2s, filter .2s;
}
/* ---- Same rising wave as the tool cards, on every button (Add PDFs, Choose PDF, Download PDF ...).
   Plays on mouse hover, on keyboard focus, while pressed, and for a moment after a tap (.is-go, set in pdf-modal.js) ---- */
.pm-btn { position: relative; overflow: hidden; isolation: isolate; --pm-bw: var(--pm-wave-c); --pm-bw1: .22; --pm-bw2: .16; }
.pm-btn.pm-pri {
  --pm-bw1: .42; --pm-bw2: .3;
  --pm-wave-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 12' preserveAspectRatio='none'%3E%3Cpath d='M0 6Q22.5 0 45 6T90 6V12H0Z' fill='%23ffffff'/%3E%3C/svg%3E");
  --pm-wave-svg-2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7Q30 0 60 7T120 7V14H0Z' fill='%23ffffff'/%3E%3C/svg%3E");
  --pm-bw: #fff;
}
.pm-btn::before, .pm-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transform: translateY(104%);
  transition: transform .8s var(--ease);
  animation: pmWaveX 3.2s linear infinite paused;
}
.pm-btn::before {
  opacity: var(--pm-bw1);
  background:
    var(--pm-wave-svg) repeat-x 0 0 / 90px 12px,
    linear-gradient(var(--pm-bw), var(--pm-bw)) 0 11px / 100% 100% no-repeat;
}
.pm-btn::after {
  opacity: var(--pm-bw2);
  top: 4px;
  transition-delay: .07s;
  animation-name: pmWaveX2;
  animation-duration: 4.6s;
  animation-direction: reverse;
  background:
    var(--pm-wave-svg-2) repeat-x 0 0 / 120px 14px,
    linear-gradient(var(--pm-bw), var(--pm-bw)) 0 13px / 100% 100% no-repeat;
}
.pm-btn:is(:active, .is-go)::before,
.pm-btn:is(:active, .is-go)::after { transform: translateY(12%); animation-play-state: running; }
@media (hover: hover) {
  .pm-btn:hover::before, .pm-btn:hover::after { transform: translateY(12%); animation-play-state: running; }
}
@media (prefers-reduced-motion: reduce) {
  .pm-btn::before, .pm-btn::after { animation: none; transition-duration: .01s; }
}
.pm-btn:active { transform: scale(.97); }
.pm-btn.pm-pri { background: var(--pm-grad); border-color: transparent; color: var(--pm-ink); }
.pm-btn.pm-sm { min-height: 36px; padding: 0 13px; border-radius: 11px; font-size: 13.5px; }
.pm-btn[disabled] { opacity: .45; pointer-events: none; }
@media (hover: hover) {
  .pm-btn:hover { border-color: var(--brass); }
  .pm-btn.pm-pri:hover { filter: brightness(1.06); }
}
.pm-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.pm-drop {
  border: 2px dashed var(--line-2);
  border-radius: 20px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-dim);
  background: var(--panel-2);
  transition: border-color .2s, background .2s;
}
.pm-drop.over { border-color: var(--brass); background: var(--panel-3); }
.pm-drop .pm-big { font-size: 32px; color: var(--brass); margin-bottom: 8px; }
.pm-drop .pm-btn { margin-top: 14px; }
.pm-chips { display: inline-flex; gap: 6px; padding: 4px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel-2); }
.pm-chips button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font: 600 13.5px 'Inter', sans-serif; color: var(--text-dim); cursor: pointer; }
.pm-chips button.on { background: var(--pm-grad); color: var(--pm-ink); }
.pm-lbl { font-size: 13.5px; color: var(--text-dim); font-weight: 600; }

.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 12px; margin-top: 6px; }
.pm-tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 15px; padding: 9px; display: flex; flex-direction: column; gap: 8px; touch-action: manipulation; }
.pm-tile.dragging { opacity: .4; }
.pm-tile.over { outline: 2px solid var(--brass); }
.pm-thumb { aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; background: var(--panel-3); border-radius: 10px; overflow: hidden; }
.pm-thumb canvas { max-width: 100%; max-height: 100%; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); background: #fff; }
.pm-tbar { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.pm-num { font-weight: 700; font-size: 13px; color: var(--text-dim); padding-left: 4px; }
.pm-tbtns { display: flex; gap: 2px; }
.pm-tbtns button { width: 32px; height: 32px; border-radius: 9px; border: 0; background: transparent; color: var(--text-dim); font-size: 13px; cursor: pointer; }
.pm-tbtns button:hover { background: var(--panel-3); color: var(--text); }
.pm-tbtns button.del:hover { color: var(--danger); }

.pm-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.pm-item { min-width: 0; max-width: 100%; display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 15px; padding: 11px 10px 11px 14px; }
.pm-item .pm-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--pm-bubble); color: var(--brass); display: grid; place-items: center; }
.pm-item .pm-nm { min-width: 0; flex: 1 1 0; }
.pm-item .pm-tbtns { flex: none; }
.pm-view { min-width: 0; }
.pm-item .pm-nm b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14.5px; }
.pm-item .pm-nm small { color: var(--text-dim); font-size: 12.5px; }
.pm-empty { color: var(--text-faint); text-align: center; padding: 22px 0; }

.pm-bar { flex: none; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--panel); display: flex; justify-content: flex-end; }
.pm-bar { justify-content: stretch; }
.pm-bar .pm-btn { min-height: 48px; padding: 0 26px; font-size: 16px; flex: 1 1 100%; width: 100%; max-width: none; }

.pm-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 5;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 11px 17px;
  border-radius: 13px;
  max-width: calc(100vw - 32px);
  font-size: 14px;
  box-shadow: var(--shadow-lift);
  transition: opacity .25s, transform .25s;
}
.pm-toast.show { opacity: 1; transform: translate(-50%, 0); }
.pm-toast.err { border-color: var(--danger); }
.pm-busy { position: fixed; inset: 0; z-index: 4; background: rgba(10, 8, 5, .55); display: grid; place-items: center; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.pm-busy > div { background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; padding: 20px 26px; text-align: center; min-width: 210px; }
/* Busy card: the same "Brass Orbit" loader as the page loader (halo, hairline ring, orbiting arcs, logo tile), scaled down. Self-contained so every page that loads this file gets it. */
.pm-busy { background: radial-gradient(60% 46% at 50% 46%, rgba(214, 162, 74, .14), transparent 72%), rgba(9, 11, 16, .80); -webkit-backdrop-filter: blur(10px) saturate(1.1); backdrop-filter: blur(10px) saturate(1.1); }
html[data-theme="light"] .pm-busy { background: radial-gradient(60% 46% at 50% 46%, rgba(185, 127, 20, .10), transparent 72%), rgba(238, 241, 246, .84); }
.pm-busy > div { min-width: 0; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
.pm-orbit { --o: 88px; --t: 2.4s; --g1: #F0C378; --g2: #D6A24A; --g3: #8A6A2C; --glow: rgba(214, 162, 74, .42); --hair: rgba(214, 162, 74, .28);
  position: relative; display: block; width: var(--o); height: var(--o); margin: 12px auto 22px; }
html[data-theme="light"] .pm-orbit { --g1: #E3B35A; --g2: #B97F14; --g3: #8A5E10; --glow: rgba(185, 127, 20, .30); --hair: rgba(185, 127, 20, .32); }
.pm-orbit > i { position: absolute; display: block; border-radius: 50%; pointer-events: none; }
.pm-o-halo { inset: -30px; background: radial-gradient(circle, var(--glow) 0%, rgba(214, 162, 74, .10) 42%, transparent 66%); animation: pmoBreathe var(--t) cubic-bezier(.45, .05, .55, .95) infinite; }
.pm-o-ring { inset: 0; box-shadow: inset 0 0 0 1px var(--hair); }
.pm-o-arc { inset: 0; animation: pmoOrbit var(--t) cubic-bezier(.42, .12, .58, .88) infinite; }
.pm-o-arc::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg 190deg, rgba(214, 162, 74, 0) 190deg, var(--g3) 262deg, var(--g2) 330deg, var(--g1) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.4px), #000 calc(100% - .6px), transparent 100%);
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.4px), #000 calc(100% - .6px), transparent 100%); }
.pm-o-arc::after { content: ""; position: absolute; top: -2.5px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff 0, var(--g1) 45%, var(--g2) 100%); box-shadow: 0 0 8px 1px var(--g1), 0 0 16px 3px var(--glow); }
.pm-o-arc2 { inset: -9px; animation: pmoOrbitBack calc(var(--t) * 2) linear infinite; }
.pm-o-arc2::before { opacity: .55; background: conic-gradient(from 0deg, transparent 0deg 250deg, var(--g3) 330deg, var(--g2) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px), #000 calc(100% - .5px), transparent 100%);
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px), #000 calc(100% - .5px), transparent 100%); }
.pm-o-arc2::after { width: 4px; height: 4px; margin-left: -2px; top: -1.5px; opacity: .8; box-shadow: 0 0 6px 1px var(--g1); }
.pm-o-tile { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 24%; overflow: hidden; background: #000;
  box-shadow: 0 0 0 1px rgba(214, 162, 74, .55), 0 12px 22px -12px rgba(0, 0, 0, .75), 0 0 22px -6px var(--glow); animation: pmoFloat var(--t) cubic-bezier(.45, .05, .55, .95) infinite; }
.pm-o-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pm-o-tile::after { content: ""; position: absolute; inset: -10%; background: linear-gradient(115deg, transparent 36%, rgba(255, 255, 255, .30) 50%, transparent 64%); transform: translateX(-130%); animation: pmoSheen var(--t) cubic-bezier(.45, .05, .55, .95) infinite; }
#pmBusyTxt { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-dim); }
.pm-bar-line { position: relative; display: block; width: 130px; height: 2px; margin: 14px auto 0; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, .10); }
html[data-theme="light"] .pm-bar-line { background: rgba(20, 28, 48, .12); }
.pm-bar-line > i { position: absolute; inset: 0 auto 0 0; width: 42%; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--brass) 35%, var(--brass-2) 60%, transparent); transform: translateX(-100%); animation: pmoSlide var(--t) cubic-bezier(.6, .02, .35, .98) infinite; }
@keyframes pmoBreathe { 0%, 100% { opacity: .55; transform: scale(.93); } 50% { opacity: 1; transform: scale(1.07); } }
@keyframes pmoOrbit { to { transform: rotate(360deg); } }
@keyframes pmoOrbitBack { to { transform: rotate(-360deg); } }
@keyframes pmoFloat { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3px) scale(1.035); } }
@keyframes pmoSheen { 0% { transform: translateX(-130%); } 52%, 100% { transform: translateX(130%); } }
@keyframes pmoSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(240%); } }
@media (prefers-reduced-motion: reduce) { .pm-o-arc, .pm-o-arc2, .pm-o-tile, .pm-o-tile::after, .pm-bar-line > i { animation: none; } .pm-o-arc { transform: rotate(-35deg); } .pm-bar-line > i { transform: none; width: 100%; opacity: .6; } }

@media (max-width: 560px) {
  .pm { padding: 10px; }
  .pm-card { border-radius: 22px; max-height: calc(100dvh - 20px); }
  .pm-scroll { padding: 26px 16px 20px; }
  .pm-tool { padding: 14px; gap: 13px; }
  .pm-tool.pm-primary { padding: 18px 14px; }
  .pm-bub { width: 52px; height: 52px; }
  /* merge list: give the file name more room on phones */
  .pm-item { gap: 9px; padding: 10px 6px 10px 10px; }
  .pm-item .pm-ic { width: 34px; height: 34px; border-radius: 10px; }
  .pm-item .pm-tbtns { gap: 0; }
  .pm-item .pm-tbtns button { width: 28px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .pm-scanbar { animation: none; transform: translate3d(0, 28px, 0); }
  .pm-wave::before, .pm-wave::after { animation: none; }
  .pm-ic-merge .pm-lay, .pm-ic-org b { transition-duration: .01s; }
  .pm-x i { transition: none; }
}

/* ---- Maker toolbar on phones: Say Thanks / PDF Tools / Contribute as three same-height pills ----
   (the old row was built for two pills, and the PDF Tools button rendered at a different height than the links) */
@media (max-width: 760px) {
  .stage-toolbar .dims-pills {
    width: 100%;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: stretch;
    gap: 6px;
  }
  .stage-toolbar .dims-pills .pill {
    flex: 1 1 auto;
    min-width: 0;
    height: 28px;
    padding: 0 8px;
    justify-content: center;
    gap: 5px;
    font-size: 9.5px;
    line-height: 1;
    white-space: nowrap;
  }
  .stage-toolbar .dims-pills .theme-toggle { flex: none; }
}
/* very narrow phones: drop the little icons so the three labels still fit in full */
@media (max-width: 360px) {
  .stage-toolbar .dims-pills .pill .plus,
  .stage-toolbar .dims-pills .pill .heart { display: none; }
  .stage-toolbar .dims-pills .pill { padding: 0 6px; font-size: 9px; }
}
/* ---- Page cropper (Scan to PDF) ---- */
.pm-card.is-cropping { height: min(calc(100vh - 40px), 820px); height: min(calc(100dvh - 40px), 820px); }
.pm-crop {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: inherit;
}
.pm-crop[hidden] { display: none; }
.pm-chead { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px 10px; }
.pm-chead b { font-size: 19px; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.pm-chead span { font-size: 13.5px; color: var(--text-dim); }
.pm-cstage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 12px;
  border-radius: 16px;
  background: #0a0c10;
  border: 1px solid var(--line-2);
  overflow: hidden;
}
.pm-cstage canvas#pmCCanvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.pm-loupe {
  position: absolute;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 3px solid #efa82f;
  overflow: hidden;
  pointer-events: none;
  background: #0a0c10;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .55);
}
.pm-loupe[hidden] { display: none; }
.pm-loupe canvas { display: block; width: 100%; height: 100%; }
.pm-cfoot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 12px 14px; }
.pm-cfoot .pm-pri { flex: 1 1 100%; min-height: 48px; font-size: 16px; order: -1; }
.pm-cfoot .pm-sm { flex: 1 1 0; }

/* crop button under each scanned page */
.pm-tcrop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text);
  font: 600 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.pm-tcrop i { color: var(--brass); }
@media (hover: hover) { .pm-tcrop:hover { border-color: var(--brass); background: var(--panel-3); } }
.pm-tcrop:active { background: var(--panel-3); }
/* =====================================================================
   Scan to PDF polish: toolbar, page tiles (no more overflow), crop screen
   ===================================================================== */

/* ---- toolbar: Take photo + Add from gallery share the row, Clear all is a quiet ghost ---- */
[data-view="scan"] .pm-vdesc { margin: 6px 0 18px; line-height: 1.5; }
[data-view="scan"] > .pm-row:first-of-type { gap: 10px; margin-bottom: 16px; }
[data-view="scan"] > .pm-row:first-of-type .pm-btn:not(.pm-sm) { flex: 1 1 170px; }
.pm-btn.pm-sm#pmScanClear { margin-left: auto; background: transparent; color: var(--text-dim); }
@media (hover: hover) {
  .pm-btn.pm-sm#pmScanClear:hover { color: var(--danger); border-color: var(--danger); }
}

/* ---- Look: a clean segmented control ---- */
#pmScanFilterRow { gap: 12px; margin-bottom: 16px; }
.pm-chips { gap: 2px; padding: 3px; background: var(--panel-2); }
.pm-chips button { min-width: 64px; padding: 8px 16px; transition: background .2s, color .2s; }
@media (hover: hover) { .pm-chips button:not(.on):hover { color: var(--text); background: var(--panel-3); } }

/* ---- empty state ---- */
#pmScanEmpty {
  padding: 34px 16px;
  border: 1.5px dashed var(--line-2);
  border-radius: 18px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 14.5px;
}

/* ---- page grid + tiles ---- */
.pm-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-top: 4px; }
.pm-tile {
  min-width: 0;
  padding: 10px;
  gap: 10px;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
}
.pm-thumb {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-3);
  padding: 6px;
}
.pm-thumb canvas { box-shadow: none; border-radius: 3px; }

/* page number: a small badge on the thumbnail instead of eating space in the button row */
.pm-thumb .pm-num {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--pm-grad);
  color: var(--pm-ink);
  font: 700 12px/1 'Inter', sans-serif;
}

/* Edit crop: full-width, flat, centred */
.pm-btn.pm-tcrop { width: 100%; min-height: 36px; padding: 0 10px; border-radius: 10px; background: var(--panel); font-size: 13px; gap: 7px; }
.pm-tcrop span { white-space: nowrap; }

/* the four actions share the card width evenly, so nothing can overflow */
.pm-tile .pm-tbar { display: block; padding-top: 8px; border-top: 1px solid var(--line); }
.pm-tile .pm-tbtns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; width: 100%; }
.pm-tile .pm-tbtns button { width: 100%; min-width: 0; height: 32px; padding: 0; border-radius: 9px; display: grid; place-items: center; }
.pm-tile.over { outline-offset: 1px; }

/* ---- crop screen ---- */
.pm-crop { border: 0; }
.pm-chead {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.pm-chead .pm-cico {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--pm-bubble);
  color: var(--brass);
  font-size: 16px;
}
.pm-chead .pm-ctxt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pm-chead .pm-ctxt b { font: 700 19px/1.2 'Space Grotesk', sans-serif; letter-spacing: -.01em; }
.pm-chead .pm-ctxt span { font-size: 13.5px; color: var(--text-dim); }

.pm-cstage {
  margin: 14px 16px;
  border-radius: 14px;
  background: #0a0c10;
  border: 1px solid var(--line-2);
}
.pm-loupe { width: 104px; height: 104px; border: 2px solid #efa82f; box-shadow: none; }

/* footer: Auto / Reset / Cancel in one even row, Apply crop as the main button underneath */
.pm-cfoot {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.pm-cfoot .pm-sm { min-height: 40px; padding: 0 10px; flex: none; }
.pm-cfoot .pm-pri { grid-column: 1 / -1; order: 1; min-height: 48px; font-size: 16px; }
#pmCCancel { background: transparent; color: var(--text-dim); }
@media (hover: hover) { #pmCCancel:hover { color: var(--text); } }

@media (max-width: 560px) {
  .pm-grid { gap: 10px; }
  .pm-tile { padding: 8px; }
  .pm-chead { padding: 14px 14px 12px; }
  .pm-cstage { margin: 12px; }
  .pm-cfoot { padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* keep a page card clear of the sticky Download bar when it is scrolled into view */
.pm-tile { scroll-margin-bottom: 18px; }
#pmScroll { scroll-padding-bottom: 18px; }

/* Clear all: same rising wave, tinted a soft red */
.pm-btn#pmScanClear {
  --pm-bw: #e2685a;
  --pm-bw1: .2;
  --pm-bw2: .14;
  --pm-wave-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 12' preserveAspectRatio='none'%3E%3Cpath d='M0 6Q22.5 0 45 6T90 6V12H0Z' fill='%23e2685a'/%3E%3C/svg%3E");
  --pm-wave-svg-2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7Q30 0 60 7T120 7V14H0Z' fill='%23e2685a'/%3E%3C/svg%3E");
}
/* ---- Scan: effect-strength slider ---- */
.pm-strength { flex-wrap: nowrap; gap: 12px; }
.pm-range {
  --pct: 50%;
  flex: 1 1 auto; min-width: 120px; height: 26px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none; touch-action: pan-y;
}
.pm-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--pm-wave-c) 0 var(--pct), var(--line-2) var(--pct) 100%);
}
.pm-range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line-2); }
.pm-range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--pm-wave-c); }
.pm-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: #fff; border: 2px solid var(--pm-wave-c); box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.pm-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--pm-wave-c); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pm-strval { min-width: 28px; text-align: right; font: 600 13.5px 'Inter', sans-serif; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pm-strength[hidden] { display: none; }

/* PDF to images + Compress PDF */
.pm-item .pm-th { flex: none; width: 40px; height: 52px; object-fit: cover; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); }
.pm-note { margin: 0 0 14px; color: var(--text-faint); font-size: 12.5px; line-height: 1.5; }
.pm-row.pm-stack { flex-direction: column; align-items: flex-start; gap: 8px; }

/* ---- Tidy pass (phones): compact buttons, clear spacing, one-line download label ---- */
.pm-bar { padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px)); }
.pm-bar .pm-btn { min-height: 42px; padding: 0 20px; font-size: 14.5px; border-radius: 12px; }
.pm-bar .pm-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#pmCmpGo, #pmImgGo { min-height: 42px; padding: 0 22px; font-size: 14.5px; border-radius: 12px; }
#pmCmpWork .pm-row:has(> #pmCmpGo), #pmImgWork .pm-row:has(> #pmImgGo) { margin: 6px 0 22px; }
.pm-row.pm-stack { flex-direction: column; align-items: stretch; gap: 10px; margin: 22px 0 16px; }
.pm-stack .pm-chips { display: flex; width: 100%; box-sizing: border-box; }
.pm-stack .pm-chips button { flex: 1 1 0; min-width: 0; padding: 9px 6px; text-align: center; }
#pmCmpChange { flex: none; }
#pmCmpWork .pm-note { margin: 0 0 20px; line-height: 1.6; }
.pm-list { gap: 12px; }
.pm-item .pm-nm b { overflow-wrap: anywhere; }

/* PDF icon beside the chosen file's name */
.pm-fico { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--pm-bubble, var(--panel-3)); color: var(--brass); font-size: 18px; }

/* ---- Polished tool screens: file card + settings card ---- */
.pm-view .pm-file { display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; margin: 18px 0 0; padding: 12px 12px 12px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; }
.pm-file .pm-fico { width: 42px; height: 42px; border-radius: 12px; font-size: 19px; }
.pm-fmeta { min-width: 0; flex: 1 1 0; display: flex; flex-direction: column; gap: 2px; }
.pm-fmeta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 14.5px 'Inter', sans-serif; color: var(--text); }
.pm-fmeta small { color: var(--text-dim); font-size: 12.5px; }
.pm-file .pm-btn.pm-sm { flex: none; min-height: 34px; padding: 0 12px; gap: 7px; font-size: 13px; background: transparent; color: var(--text-dim); }
.pm-set { margin: 14px 0 0; padding: 4px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; }
.pm-opt { display: flex; align-items: center; gap: 12px; margin: 0; padding: 11px 0; }
.pm-opt + .pm-opt { border-top: 1px solid var(--line); }
.pm-opt .pm-lbl { flex: none; width: 66px; }
.pm-opt .pm-chips { flex: 1 1 0; min-width: 0; display: flex; box-sizing: border-box; background: var(--panel); }
.pm-opt .pm-chips button { flex: 1 1 0; min-width: 0; padding: 8px 4px; text-align: center; }
.pm-set .pm-row.pm-stack { margin: 0; padding: 12px 0 14px; }
.pm-set .pm-stack .pm-chips { background: var(--panel); }
.pm-set + .pm-note { margin-top: 14px; }
#pmImgWork .pm-row:has(> #pmImgGo) { margin: 18px 0 20px; }
#pmCmpWork .pm-set + .pm-note { margin: 16px 2px 20px; }
.pm-opt .pm-chips button { white-space: nowrap; font-size: 13px; padding: 8px 2px; }
.pm-view .pm-grid { margin-top: 14px; }

/* ---- Compact hub: smaller title, slimmer tool rows, smaller icon tiles ---- */
.pm-hub h2 { margin: 0 0 6px; font-size: clamp(24px, 5vw, 30px); }
.pm-sub { margin: 0 auto 16px; max-width: 380px; font-size: 14px; line-height: 1.5; }
.pm-tools { gap: 8px; max-width: 500px; }
.pm .pm-tool, .pm .pm-tool.pm-primary { gap: 12px; padding: 10px 14px 10px 10px; border-radius: 16px; }
.pm .pm-tool.pm-primary { padding: 12px 14px 12px 10px; }
.pm .pm-bub { width: 42px; height: 42px; border-radius: 13px; font-size: 18px; }
.pm .pm-tool b { font-size: 15.5px; line-height: 1.25; }
.pm .pm-tool .pm-d { font-size: 12.5px; line-height: 1.35; }
.pm .pm-tool .pm-chev { font-size: 13px; }
.pm .pm-scroll { padding: 22px 16px 16px; }
.pm-priv { margin: 14px auto 0; font-size: 12.5px; line-height: 1.5; }
.pm-vhead h3 { font-size: 20px; }
.pm-back { width: 38px; height: 38px; }
