/* Sign PDF (namespaced .sp-) */
.sp-work { display: flex; flex-direction: column; gap: 14px; }
.sp-file { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.sp-badge, .sp-res-badge { flex: 0 0 44px; height: 44px; border-radius: 10px; background: var(--cat-tint) !important; color: var(--cat-ink); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 14px; }
.sp-res-badge { flex-basis: 52px; height: 52px; }
.sp-file-meta { flex: 1 1 180px; min-width: 0; }
.sp-file-meta strong { display: block; overflow-wrap: anywhere; }
.sp-file-meta span { color: var(--muted); font-size: 14px; }
.sp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-radius: 14px; background: #F6F5F1; }
.sp-tool { min-height: 44px; padding: 0 14px; border: 1px solid var(--field); border-radius: 10px; background: #FFF; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.sp-tool[aria-pressed="true"] { border: 1.5px solid var(--cat); background: var(--cat-tint); color: var(--cat-ink); font-weight: 700; }
.sp-tool:disabled { opacity: .5; cursor: default; }
.sp-sep { width: 1px; height: 28px; background: var(--field); margin: 0 4px; }
.sp-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.sp-nav span { min-width: 56px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-icon { width: 44px; height: 44px; padding: 0; border: 1px solid var(--field); border-radius: 10px; background: #FFF; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.sp-icon:disabled { opacity: .4; cursor: default; }
.sp-plain { border: 0; background: transparent; color: var(--muted); }
.sp-layout { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.sp-thumbs { flex: 0 0 104px; max-width: 100%; max-height: 80vh; overflow: auto; }
.sp-thumbs ol { list-style: none; margin: 0; padding: 2px; display: flex; flex-direction: column; gap: 10px; }
.sp-thumbs button { position: relative; width: 100%; padding: 6px 6px 4px; border: 2px solid var(--border); border-radius: 10px; background: #FFF; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: #3A3A42; cursor: pointer; }
.sp-thumbs button[aria-current="page"] { border-color: var(--cat); background: var(--cat-tint); color: var(--cat-ink); }
.sp-thumbs button.has::after { content: ''; position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #FFF; }
.sp-thumbs canvas { display: block; width: 100%; height: auto; background: #FFF; border: 1px solid #EEE; }
.sp-stage { flex: 999 1 380px; min-width: 0; background: #E9E6DF; border-radius: 14px; padding: clamp(10px, 2.5vw, 24px); display: flex; justify-content: center; overflow: hidden; }
.sp-page { position: relative; background: #FFF; line-height: 0; box-shadow: 0 2px 4px rgba(26,26,31,.08), 0 18px 40px rgba(26,26,31,.12); }
.sp-page canvas { display: block; max-width: none; }
.sp-layer { position: absolute; left: 0; top: 0; }
.sp-item { position: absolute; cursor: move; touch-action: none; -webkit-user-select: none; user-select: none; outline: none; }
.sp-item::before { content: ''; position: absolute; inset: -3px; border: 1.5px dashed transparent; pointer-events: none; }
.sp-item:hover::before { border-color: rgba(36,83,255,.45); }
.sp-item.sel::before, .sp-item:focus-visible::before { border-color: var(--primary); background: rgba(36,83,255,.05); }
.sp-item img { display: block; width: 100%; height: 100%; pointer-events: none; max-width: none; }
.sp-txt { display: block; white-space: pre; font-family: Arial, Helvetica, sans-serif; line-height: 1; min-width: 4px; outline: none; cursor: move; -webkit-user-select: text; user-select: text; }
.sp-txt:focus { cursor: text; }
.sp-h { position: absolute; display: none; width: 12px; height: 12px; background: #FFF; border: 2px solid var(--primary); border-radius: 2px; }
.sp-h::after { content: ''; position: absolute; inset: -12px; }
.sp-item.sel .sp-h { display: block; }
.sp-nw { top: -9px; left: -9px; cursor: nwse-resize; }
.sp-ne { top: -9px; right: -9px; cursor: nesw-resize; }
.sp-sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.sp-se { bottom: -9px; right: -9px; cursor: nwse-resize; }
.sp-del { position: absolute; top: -42px; right: -8px; width: 32px; height: 32px; padding: 0; border: 1.5px solid var(--cat); border-radius: 999px; background: #FFF; color: var(--cat-ink); display: none; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(26,26,31,.15); cursor: pointer; line-height: 1; }
.sp-item.sel .sp-del { display: flex; }
.sp-pad { flex: 1 1 300px; min-width: 0; background: #FFF; border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: 0 14px 34px rgba(26,26,31,.10); display: flex; flex-direction: column; gap: 14px; }
.sp-pad-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sp-pad h2 { margin: 0; font-family: var(--display); font-size: 20px; letter-spacing: -.01em; }
.sp-saved { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; background: var(--soft); }
.sp-saved-label { font-weight: 700; font-size: 14px; }
.sp-saved-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sp-saved img { height: 48px; max-width: 150px; object-fit: contain; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: #FFF; }
.sp-tabs { display: flex; padding: 4px; border-radius: 12px; background: var(--soft); }
.sp-tabs button { flex: 1 1 0; min-height: 40px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; cursor: pointer; }
.sp-tabs button[aria-selected="true"] { background: var(--ink); color: #FFF; font-weight: 700; }
.sp-panel { display: flex; flex-direction: column; gap: 8px; }
.sp-drawbox { position: relative; height: 170px; border: 1px solid var(--field); border-radius: 12px; background: #FFF; overflow: hidden; }
#sp-draw { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 1; }
#sp-draw:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sp-line { position: absolute; left: 16px; right: 16px; bottom: 40px; border-top: 1.5px dashed #9A968C; pointer-events: none; }
.sp-x { position: absolute; left: 16px; bottom: 44px; color: var(--faint); font-size: 16px; font-weight: 700; pointer-events: none; }
.sp-clear { position: absolute; top: 8px; right: 8px; z-index: 2; min-height: 36px; padding: 0 12px; font-size: 14px; }
.sp-above { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.sp-help { margin: 0; color: var(--muted); font-size: 13px; }
.sp-fonts { margin: 0; padding: 0; border: 0; min-width: 0; }
.sp-fonts legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
#sp-fontlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.sp-font { position: relative; display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 6px 10px; border: 2px solid var(--border); border-radius: 12px; background: #FFF; font-size: 28px; line-height: 1.2; white-space: nowrap; overflow: hidden; cursor: pointer; }
.sp-font input { position: absolute; opacity: 0; pointer-events: none; }
.sp-font.on { border-color: var(--cat); background: var(--cat-tint); }
.sp-font:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.sp-check { font-size: 15px; }
.sp-check input { width: 20px; height: 20px; }
.sp-uppreview img { max-height: 90px; max-width: 100%; border-radius: 8px; background: repeating-conic-gradient(#EEE 0 25%, #FFF 0 50%) 0 0 / 16px 16px; }
.sp-ink { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-weight: 700; font-size: 15px; }
.sp-inks { display: flex; gap: 10px; }
.sp-inks button { min-height: 40px; padding: 0 12px 0 6px; border: 1px solid var(--field); border-radius: 999px; background: #FFF; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.sp-inks button span { width: 26px; height: 26px; border-radius: 50%; }
.sp-inks button[aria-checked="true"] { border: 2px solid var(--ink); font-weight: 700; }
.sp-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid #F0EDE6; }
.sp-foot .actions { margin-top: 0; }
#sp-hint { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .sp-thumbs { flex: 1 1 100%; max-height: none; overflow-x: auto; }
  .sp-thumbs ol { flex-direction: row; }
  .sp-thumbs li { flex: 0 0 72px; }
  .sp-nav { margin-left: 0; }
  .sp-pad { order: -1; }
  .sp-foot .actions, .sp-foot .btn { width: 100%; }
}
