/* ==========================================================================
   PDF Tools
   ========================================================================== */

.workspace.pdft { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
@media (max-width: 960px) { .workspace.pdft { grid-template-columns: 1fr; } }

.pdft-opts { display: flex; flex-direction: column; gap: 1rem; }
.pdft-opts[hidden], [data-show][hidden], [data-show-split][hidden] { display: none !important; }
.pdft-lead { margin: 0; }

.pdft-range { width: 100%; accent-color: var(--violet); }
.pdft-out {
  display: inline-block;
  min-width: 2.8em;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--lilac);
  font-size: 0.8rem;
  text-align: center;
}
.pdft-color { padding: 0.4rem; cursor: pointer; }
.pdft-color::-webkit-color-swatch-wrapper { padding: 0; }
.pdft-color::-webkit-color-swatch { border: 0; border-radius: 6px; }
.pdft-color::-moz-color-swatch { border: 0; border-radius: 6px; }

.pdft-files { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.pdft-files[hidden] { display: none; }
.pdft-file {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 0.86rem;
  animation: fade-up 0.35s var(--ease);
}
.pdft-file-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--hue) 80% 62%); }
.pdft-file-name { flex: 1; min-width: 0; overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.pdft-file-meta { flex: none; color: var(--muted); font-size: 0.78rem; }
.pdft-file-x {
  display: grid; place-items: center;
  flex: none;
  width: 28px; height: 28px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.pdft-file-x:hover { background: rgba(251, 113, 133, 0.12); color: var(--danger); }
.pdft-file-x .icon { width: 15px; height: 15px; }

.pdft-meta { margin-top: 0; }

.pdft-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pdft-page {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.pdft-page:hover { border-color: var(--border-2); }
.pdft-page:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
.pdft-page.is-dragging {
  z-index: 5;
  border-color: rgba(139, 92, 246, 0.7);
  background: var(--bg-soft);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.55);
  cursor: grabbing;
  pointer-events: none;
}
.pdft-grid.is-dragging .pdft-page:not(.is-dragging) { transition: border-color 0.2s; }
.pdft-grid.is-selecting .pdft-page { cursor: pointer; }
.pdft-page.is-selected { border-color: rgba(139, 92, 246, 0.75); background: var(--grad-soft); }

.pdft-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 9px;
  background: rgba(var(--ink), 0.04);
}
.pdft-sheet {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  transform: rotate(var(--r, 0deg));
  transition: transform 0.3s var(--ease);
}
.pdft-sheet img {
  max-width: 92%;
  max-height: 92%;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.pdft-sheet.is-loading::after {
  content: "";
  width: 58%;
  height: 78%;
  border-radius: 3px;
  background: linear-gradient(100deg, rgba(var(--ink), 0.06) 30%, rgba(var(--ink), 0.14) 50%, rgba(var(--ink), 0.06) 70%) 0 0 / 300% 100%;
  animation: pdft-shimmer 1.3s linear infinite;
}
.pdft-sheet.is-failed::after { animation: none; }
@keyframes pdft-shimmer { to { background-position: -150% 0; } }

.pdft-check {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}
.pdft-check .icon { width: 13px; height: 13px; stroke-width: 3; opacity: 0; }
.pdft-grid.is-selecting .pdft-check { display: grid; }
.pdft-page.is-selected .pdft-check { border-color: transparent; background: var(--violet); }
.pdft-page.is-selected .pdft-check .icon { opacity: 1; }

.pdft-foot { display: flex; align-items: center; gap: 0.4rem; min-width: 0; font-size: 0.74rem; }
.pdft-num { flex: none; color: var(--text); font-weight: 700; }
.pdft-src { min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.pdft-src::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.3rem;
  border-radius: 50%;
  background: hsl(var(--hue) 80% 62%);
  vertical-align: 1px;
}

.pdft-tools { display: flex; justify-content: center; gap: 0.2rem; }
.pdft-tool {
  display: grid; place-items: center;
  width: 30px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}
.pdft-tool:hover { color: var(--on-soft); border-color: rgba(139, 92, 246, 0.55); background: rgba(139, 92, 246, 0.15); }
.pdft-tool.is-danger:hover { color: var(--danger); border-color: rgba(251, 113, 133, 0.5); background: rgba(251, 113, 133, 0.12); }
.pdft-tool:focus-visible { outline: 2px solid var(--lilac); outline-offset: 1px; }
.pdft-tool .icon { width: 14px; height: 14px; }

.pdft-hint { margin: 0; }

.pdft-result {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius);
  background: var(--surface);
  animation: fade-up 0.4s var(--ease);
}
.pdft-result[hidden] { display: none; }
.pdft-result-note { margin: 0; color: var(--text-2); font-size: 0.86rem; line-height: 1.5; }
.pdft-result-note.is-warn { color: var(--warn-text); }
.pdft-result-note[hidden] { display: none; }

.is-busy .pdft-grid { opacity: 0.7; pointer-events: none; }
