/* Sign PDF. Site tokens from app.css, so light/dark mode just works. */
#ps { --k-sig: #3b82f6; --k-date: #f59e0b; --k-text: #a855f7; --k-check: #22c55e; }
.ps-narrow { max-width: 860px; margin-left: auto; margin-right: auto; }

/* sub navigation: single / auto / templates */
.ps-subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px auto 18px; }
.ps-subnav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; font-size: .9rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); text-decoration: none; }
.ps-subnav a .icon { width: 16px; height: 16px; }
.ps-subnav a:hover { color: var(--text); border-color: var(--muted); }
.ps-subnav a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.ps-drop { padding: 44px 20px; }
.ps-note { margin-top: 14px; }
.ps-gate { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.ps-gate p { margin: 0; }
.ps-gate .btn + .btn { margin-left: 0; }

/* editor top bar */
.ps-bar { position: sticky; top: 64px; z-index: 6; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); }
.ps-file { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.ps-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-pdf { flex: none; padding: 3px 7px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 700; }
.ps-bar-r { display: flex; gap: 8px; flex-wrap: wrap; }
.ps-bar .icon { width: 16px; height: 16px; }

.ps-work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.ps-side { position: sticky; top: 134px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 150px); overflow: auto;
  scrollbar-width: thin; }
@media (max-width: 960px) {
  .ps-work { grid-template-columns: 1fr; }
  .ps-side { position: static; max-height: none; order: -1; }
  .ps-bar { top: 58px; }
}

/* pages + placed items */
.ps-pages { display: flex; flex-direction: column; gap: 18px; padding: 18px; border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--line); }
.ps-page { position: relative; width: 100%; background: #fff; box-shadow: 0 2px 14px rgb(0 0 0 / .25); border-radius: 4px; touch-action: pan-y; }
.ps-page > img { display: block; width: 100%; height: 100%; border-radius: 4px; user-select: none; -webkit-user-drag: none; }
.ps-page-no { position: absolute; right: 8px; bottom: -22px; font-size: .75rem; color: var(--muted); }

.ps-item { --k: var(--k-sig); position: absolute; container-type: size; border: 1.5px dashed var(--k); border-radius: 4px;
  background: color-mix(in srgb, var(--k) 10%, transparent); cursor: move; touch-action: none; outline: none; }
.ps-item.k-date { --k: var(--k-date); } .ps-item.k-text { --k: var(--k-text); } .ps-item.k-check { --k: var(--k-check); }
.ps-item.sel { border-style: solid; box-shadow: 0 0 0 3px color-mix(in srgb, var(--k) 30%, transparent); }
.ps-item-in { position: absolute; inset: 0; display: flex; align-items: center; overflow: hidden; pointer-events: none;
  color: var(--ink, #1d4ed8); font-size: 76cqh; line-height: 1; white-space: nowrap; }
.ps-item-in img { width: 100%; height: 100%; object-fit: contain; }
.k-sig .ps-item-in, .k-check .ps-item-in { justify-content: center; }
.k-sig .ps-item-in span { font-size: min(40cqh, 18cqw); color: var(--k); font-family: var(--font); }
.k-text .ps-item-in span, .k-date .ps-item-in span { padding-left: 1px; }
.ps-x { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; display: none; place-items: center; padding: 0;
  border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
.ps-h { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 4px; background: var(--k);
  border: 2px solid #fff; cursor: nwse-resize; display: none; }
.ps-item.sel .ps-x, .ps-item:hover .ps-x { display: grid; }
.ps-item.sel .ps-h, .ps-item:hover .ps-h { display: block; }
@media (pointer: coarse) { .ps-x { display: grid; } .ps-h { display: block; width: 20px; height: 20px; right: -10px; bottom: -10px; } }

/* side panels */
.ps-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; margin: 0; transition: box-shadow .2s; }
.ps-panel.flash { box-shadow: 0 0 0 3px var(--accent); }
.ps-panel > b .icon { width: 16px; height: 16px; vertical-align: -3px; }
.ps-panel .field { margin-bottom: 0; }
.ps-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ps-sig-preview { display: grid; place-items: center; height: 34px; padding: 2px 8px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.ps-sig-preview img { max-height: 30px; max-width: 120px; }
.ps-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.ps-tabs button { padding: 7px 4px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; }
.ps-tabs button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.ps-pad { position: relative; border-radius: 12px; background: #fff; border: 1px dashed #c9c4bd; }
.ps-pad canvas { display: block; width: 100%; aspect-ratio: 3 / 1; touch-action: none; cursor: crosshair; }
.ps-pad span { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: .8rem; color: #9a948c; pointer-events: none; }
.ps-pad span::before { content: ""; display: block; margin: 0 14% 6px; border-top: 1px solid #e4e0da; }
.ps-pad.has-ink span { opacity: 0; }
.ps-upload { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 12px; border-radius: 12px; cursor: pointer;
  border: 1.5px dashed var(--line); text-align: center; }
.ps-upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.ps-upload .icon { width: 26px; height: 26px; color: var(--accent); }
.ps-tab input[type="text"] { width: 100%; }
.ps-fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.ps-fonts button { padding: 10px 4px; border-radius: 10px; background: #fff; color: #1d4ed8; border: 1.5px solid var(--line); font-size: 1.15rem; cursor: pointer; }
.ps-fonts button.on { border-color: var(--accent); }
.ps-inks { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ps-inks [data-ink] { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); background: var(--c);
  box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.ps-inks [data-ink].on { box-shadow: 0 0 0 2px var(--accent); }
.ps-inks.no-ink [data-ink], .ps-inks.no-ink > span { opacity: .35; pointer-events: none; }

.ps-adds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ps-add { --k: var(--k-sig); padding: 10px 8px; border-radius: 10px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  color: var(--text); background: color-mix(in srgb, var(--k) 12%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--k) 55%, transparent); }
.ps-add:hover { background: color-mix(in srgb, var(--k) 22%, var(--surface)); }
.a-date { --k: var(--k-date); } .a-text { --k: var(--k-text); } .a-check { --k: var(--k-check); }
.ps-selected { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.ps-chip { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .82rem; cursor: pointer; }
.ps-chip.on { border-color: var(--k-date); background: color-mix(in srgb, var(--k-date) 18%, var(--surface)); }
.ps-tpl { border-color: color-mix(in srgb, var(--yellow) 45%, var(--line)); }
.ps-tpl > b { color: var(--text); }

/* done */
.ps-done { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ps-done > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; min-width: 200px; }
.ps-tick { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.ps-tick .icon { width: 26px; height: 26px; }

/* auto */
.ps-auto { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 960px) { .ps-auto { grid-template-columns: 1fr; } .ps-auto > aside { order: -1; } }
.ps-list { padding: 0; margin: 0; overflow: hidden; }
.ps-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ps-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ps-row-wrap { border-bottom: 1px solid var(--line); }
.ps-row-wrap:last-child { border-bottom: 0; }
.ps-row-wrap .ps-row { border-bottom: 0; }
.ps-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.ps-row .btn { flex: none; }
.ps-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; padding: 4px 16px 16px; }
.ps-preview > p { grid-column: 1 / -1; margin: 0; }
.ps-mini { box-shadow: 0 1px 8px rgb(0 0 0 / .25); }
.ps-mini .ps-item { cursor: default; }
.ps-mini { align-self: start; }
.ps-mini .ps-page-no { display: none; }
.ps-row:last-child { border-bottom: 0; }
.ps-row b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ps-tag { flex: none; max-width: 40%; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-tag.ok { background: var(--ok-soft); color: var(--ok); }
.ps-tag.warn { background: var(--gold-soft); color: var(--gold); }
.ps-tag.bad { background: var(--bad-soft); color: var(--bad); }

/* templates list */
.ps-tcard { display: flex; gap: 18px; margin: 0; align-items: flex-start; }
.ps-tbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ps-thumb { flex: none; width: 120px; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: 0 1px 8px rgb(0 0 0 / .25); }
.ps-thumb img { display: block; width: 100%; }
.ps-thumb:hover { outline: 2px solid var(--accent); }
@media (max-width: 560px) { .ps-thumb { width: 80px; } }
/* editing a template from its saved pictures: nothing to sign or search */
.ps-tplmode #ps-download, .ps-tplmode #ps-suggest { display: none; }
.ps-tcard .field { margin: 0; gap: 3px; }
.ps-del { color: var(--bad); margin-left: auto; }
