/* ==========================================================================
   Document viewer, thumbnail rail, signature capture
   ========================================================================== */

.dv { position: relative; display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; background: var(--bg-canvas); }
.dv__scroll {
  flex: 1 1 auto; min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.dv__stack { display: flex; flex-direction: column; align-items: center; min-width: min-content; }
.dv__page { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.dv__plabel {
  font-size: var(--fs-11); color: var(--tx-3);
  font-variant-numeric: tabular-nums; user-select: none;
  padding-bottom: 2px;
}
.dv__layer { position: absolute; top: 0; left: 0; z-index: 5; transform-origin: 0 0; }

.dv__preview { display: flex; gap: var(--s-6); overflow-x: auto; padding: var(--s-3) 0 var(--s-6); }
.dv__previewitem { flex: none; }

.dv__zoom {
  display: inline-flex; align-items: center; gap: 1px;
  background: var(--bg-surface); border: 1px solid var(--br-2);
  border-radius: var(--r-6); padding: 2px;
}
.dv__zoomval {
  min-width: 50px; height: 24px; padding: 0 var(--s-3);
  font-size: var(--fs-12); font-weight: 560; color: var(--tx-2);
  border-radius: var(--r-4);
}
.dv__zoomval:hover { background: var(--bg-hover); }

/* ------------------------------------------------------------- thumbnails */
.thumbs {
  overflow-y: auto; overflow-x: hidden;
  padding: var(--s-6) var(--s-5);
  background: var(--bg-sunken);
  border-right: 1px solid var(--br-1);
  scrollbar-width: thin;
}
.thumbs__inner { display: flex; flex-direction: column; gap: var(--s-6); align-items: center; }
.thumbs__item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 3px; border-radius: var(--r-6);
  transition: background var(--dur-2) var(--ease);
}
.thumbs__item:hover { background: var(--bg-hover); }
.thumbs__paper {
  display: block; border-radius: 2px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--br-2), 0 1px 2px rgba(16,24,40,.12);
  transition: box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.thumbs__item:hover .thumbs__paper { transform: translateY(-1px); }
.thumbs__item.is-active .thumbs__paper { box-shadow: 0 0 0 2px var(--a-500), 0 2px 6px rgba(16,24,40,.18); }
.thumbs__n { font-size: var(--fs-11); color: var(--tx-3); }
.thumbs__item.is-active .thumbs__n { color: var(--tx-accent); font-weight: 620; }
.thumbs__badge {
  position: absolute; top: 0; right: 0;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--a-500); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg-sunken);
}

/* ---------------------------------------------------- adopt signature -- */
.adopt { display: flex; flex-direction: column; gap: var(--s-7); }
.adopt__names { display: flex; gap: var(--s-7); align-items: flex-end; }
.adopt__names .field:first-child { flex: 1; }
.adopt__tabs { margin: 0 calc(var(--s-10) * -1); padding: 0 var(--s-10); }
.adopt__panel { min-height: 208px; }

.adopt__styles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: var(--s-5); max-height: 268px; overflow-y: auto; padding: 2px;
}
.adopt__style {
  position: relative; text-align: left;
  border: 1px solid var(--br-2); border-radius: var(--r-8);
  background: var(--bg-surface); padding: var(--s-5) var(--s-6);
  display: flex; flex-direction: column; gap: 2px; min-height: 84px;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.adopt__style:hover { border-color: var(--a-300); background: var(--a-25); }
.adopt__style.is-on { border-color: var(--a-500); box-shadow: 0 0 0 1px var(--a-500); background: var(--a-25); }
.adopt__stylename {
  font-size: var(--fs-11); color: var(--tx-4); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 620;
}
.adopt__styleink {
  color: var(--tx-1); line-height: 1.15; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.adopt__styleinit { font-size: 15px; color: var(--tx-3); }
.adopt__stylecheck {
  position: absolute; top: var(--s-4); right: var(--s-4);
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--a-500); color: #fff; display: grid; place-content: center;
}

.adopt__preview { display: flex; gap: var(--s-6); }
.adopt__prevbox {
  flex: 1; border: 1px solid var(--br-1); border-radius: var(--r-8);
  background: var(--bg-sunken); overflow: hidden;
}
.adopt__prevbox--sm { flex: 0 0 148px; }
.adopt__prevlabel {
  font-size: var(--fs-11); font-weight: 620; color: var(--tx-4);
  text-transform: uppercase; letter-spacing: .06em;
  padding: var(--s-3) var(--s-6); border-bottom: 1px solid var(--br-1);
  background: var(--bg-surface);
}
.adopt__prevink {
  min-height: 66px; display: grid; place-content: center;
  padding: var(--s-4) var(--s-6); color: var(--paper-ink);
  background: repeating-linear-gradient(45deg, transparent, transparent 9px, rgba(0,0,0,.014) 9px, rgba(0,0,0,.014) 18px);
}
:root[data-theme="dark"] .adopt__prevink { color: var(--tx-1); }
.adopt__legal { font-size: var(--fs-11); color: var(--tx-3); line-height: 1.55; }

.adopt__uploaded {
  display: flex; gap: var(--s-8); align-items: center;
  border: 1px solid var(--br-2); border-radius: var(--r-8); padding: var(--s-7);
  background: var(--bg-sunken);
}
.adopt__uploaded img { max-height: 76px; max-width: 46%; background: #fff; border-radius: var(--r-4); padding: 4px; }

/* ------------------------------------------------------- signature pad -- */
.sigpad__wrap { position: relative; }
.sigpad {
  position: relative;
  border: 1px solid var(--br-2); border-radius: var(--r-8);
  background: var(--bg-surface);
  height: 168px; overflow: hidden;
  background-image: linear-gradient(to bottom, transparent calc(72% - 1px), var(--br-2) 72%, transparent calc(72% + 1px));
  touch-action: none;
}
.sigpad__canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.sigpad__canvas:focus-visible { outline: 2px solid var(--a-500); outline-offset: -2px; }
.sigpad__hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: var(--fs-13); color: var(--tx-4); pointer-events: none; user-select: none;
}
.sigpad__canvas:not(:placeholder-shown) + .sigpad__hint { display: none; }

.sigvis__img { display: inline-block; }
.sigvis__type { display: inline-block; white-space: nowrap; }

@media (max-width: 700px) {
  .adopt__names { flex-direction: column; align-items: stretch; gap: var(--s-5); }
  .adopt__names .field { max-width: none !important; }
  .adopt__styles { grid-template-columns: 1fr 1fr; max-height: 220px; }
  .adopt__preview { flex-direction: column; }
  .adopt__prevbox--sm { flex: none; }
  .sigpad { height: 148px; }
}
