/* PDF 서명·도장 넣기 */

.ps-status {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.9rem;
  margin: 1rem 0;
}
.ps-status[hidden] { display: none; }

.ps-editor[hidden] { display: none; }

/* ── 도구줄 ── */
.ps-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.ps-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.ps-nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.ps-nav-btn:disabled { opacity: 0.35; cursor: default; }
/* 보이는 크기는 그대로, 히트 영역만 44px (T20 방식) */
.ps-nav-btn::after { content: ''; position: absolute; inset: -4px; }

.ps-page-label {
  font-family: var(--font-mono, monospace);
  font-size: 0.85rem;
  color: var(--text-sub);
  min-width: 56px;
  text-align: center;
}

/* ── 서명 보관함 ── */
.ps-tray {
  margin-bottom: 0.8rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
}
.ps-tray[hidden] { display: none; }

.ps-tray-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-bottom: 0.45rem;
}

.ps-tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ps-sig {
  position: relative;
  height: 52px;
  min-width: 64px;
  max-width: 160px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.ps-sig:hover { border-color: var(--primary); }
.ps-sig img {
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.ps-sig-x {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
}
.ps-sig-x::after { content: ''; position: absolute; inset: -10px; }

/* ── 페이지 무대 ── */
.ps-stagewrap {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
}

/* 오버레이는 stage 기준 %로 놓으므로, stage가 캔버스 박스와 정확히 겹쳐야 한다 */
.ps-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.ps-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #e0e0e0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ps-obj {
  position: absolute;
  cursor: move;
  touch-action: none;
}
.ps-obj img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.ps-obj.selected {
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}
.ps-obj:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.ps-obj-h {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  cursor: nwse-resize;
  touch-action: none;
}
.ps-obj-h::after { content: ''; position: absolute; inset: -15px; }

.ps-obj-x {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.ps-obj-x::after { content: ''; position: absolute; inset: -10px; }

/* 선택 전에는 손잡이를 감춰 문서를 가리지 않는다 */
.ps-obj:not(.selected):not(:focus-visible) .ps-obj-h,
.ps-obj:not(.selected):not(:focus-visible) .ps-obj-x { display: none; }

.ps-hint {
  margin: 0.6rem 0 1rem;
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* ── 서명 패드 ── */
.ps-pad {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 15, 20, 0.45);
}
.ps-pad[hidden] { display: none; }

.ps-pad-box {
  width: min(560px, 100%);
  background: var(--surface);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow-lg, 0 18px 50px rgba(0, 0, 0, 0.25));
}

.ps-pad-hint {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: var(--text-sub);
}

#ps-pad-canvas {
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
}

.ps-pad-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
}
.ps-pad-row .btn-primary { margin-left: auto; }

.ps-colors { display: flex; gap: 6px; }
.ps-color {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: #111827;
  cursor: pointer;
  position: relative;
}
.ps-color-blue { background: #1d4ed8; }
.ps-color.active { border-color: var(--primary); box-shadow: 0 0 0 2px #fff inset; }
.ps-color::after { content: ''; position: absolute; inset: -9px; }

@media (max-width: 480px) {
  .ps-toolbar { gap: 0.45rem; }
  .ps-nav { margin-left: 0; width: 100%; justify-content: center; }
  .ps-stagewrap { padding: 0.5rem; }
  .ps-pad-row { flex-wrap: wrap; }
}
