/* ============================================
   Pixia - Split PDF studio (split.html)
   Complements css/ai-tool.css (.at-* primitives)
   Scope: body.at-split
   ============================================ */

body.at-split {
  --sp-accent: #06b6d4;
  --sp-accent-2: #22d3ee;
  --sp-accent-ink: #04222a;
  --sp-line: var(--glass-border);
  --sp-soft: var(--bg-secondary);
}

/* ---------- Layout ---------- */
.sp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 356px;
  gap: 22px;
  align-items: start;
}

.sp-col {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.sp-side {
  min-width: 0;
  display: grid;
  gap: 16px;
  /* Settings column follows the page scroll (sticky) while the main column scrolls. */
  position: sticky;
  inset-block-start: 84px;
  align-self: start;
}

@media (max-width: 1020px) {
  .sp-layout { grid-template-columns: 1fr; }
  .sp-col,
  .sp-side { position: static; }
}

.sp-panel { min-height: 0; }

body.at-split .sp-side .at-panel + .at-panel { margin-block-start: 0; }

.sp-panel h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sp-panel h2 .sp-count {
  margin-inline-start: auto;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px 10px;
}

.sp-hint {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-tertiary);
  min-height: 40px;
}

/* ---------- Drop zone ---------- */
.sp-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 42px 22px;
  border: 1.6px dashed var(--glass-border-hover);
  border-radius: var(--at-radius-lg);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color .2s var(--at-ease), background .2s var(--at-ease), transform .2s var(--at-ease);
}

.sp-drop:hover { border-color: var(--sp-accent); }

.sp-drop.drag {
  border-color: var(--sp-accent);
  background: color-mix(in srgb, var(--sp-accent) 10%, var(--glass-bg));
  transform: scale(1.006);
}

.sp-drop input { display: none; }

.sp-drop-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: color-mix(in srgb, var(--sp-accent) 16%, transparent);
  color: var(--sp-accent);
  margin-block-end: 4px;
}

.sp-drop-icon svg { width: 28px; height: 28px; }

.sp-drop-title {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sp-drop-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 46ch;
  line-height: 1.6;
}

.sp-drop-cta {
  margin-block-start: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
  color: var(--sp-accent-ink);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 14px 30px -18px rgba(6, 182, 212, .95);
}

.sp-drop-cta svg { width: 17px; height: 17px; }

.sp-drop.is-compact {
  flex-direction: row;
  justify-content: center;
  padding: 16px 20px;
  gap: 12px;
}

.sp-drop.is-compact .sp-drop-icon { width: 38px; height: 38px; border-radius: 11px; margin: 0; }
.sp-drop.is-compact .sp-drop-icon svg { width: 20px; height: 20px; }
.sp-drop.is-compact .sp-drop-sub,
.sp-drop.is-compact .sp-drop-cta { display: none; }
.sp-drop.is-compact .sp-drop-title { font-size: .96rem; }

/* ---------- Queue toolbar ---------- */
.sp-queue-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0 14px;
}

.sp-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .18s var(--at-ease), border-color .18s var(--at-ease), background .18s var(--at-ease);
}

.sp-tool-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
}

.sp-tool-btn svg { width: 15px; height: 15px; }

.sp-tool-btn[disabled] { opacity: .5; cursor: not-allowed; }

.sp-tool-btn.sp-danger:hover:not(:disabled) {
  color: #ef4444;
  border-color: color-mix(in srgb, #ef4444 45%, transparent);
}

/* ---------- Empty state ---------- */
.sp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--glass-border);
  border-radius: var(--at-radius-lg);
  color: var(--text-tertiary);
  font-size: 13.5px;
}

.sp-empty svg { width: 34px; height: 34px; color: var(--text-muted); }

/* ---------- File list ---------- */
.sp-files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.sp-file {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--at-radius-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color .18s var(--at-ease), box-shadow .18s var(--at-ease);
}

.sp-file:hover {
  border-color: var(--glass-border-hover);
  box-shadow: 0 14px 30px -24px rgba(0, 0, 0, .6);
}

.sp-file.is-active {
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 1px var(--sp-accent);
}

.sp-file.is-error { border-color: color-mix(in srgb, #ef4444 50%, transparent); }

.sp-thumb {
  position: relative;
  width: 52px;
  height: 66px;
  border-radius: 8px;
  overflow: hidden;
  background:
    repeating-conic-gradient(rgba(128, 128, 128, .18) 0% 25%, transparent 0% 50%) 50% / 14px 14px,
    var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  display: grid;
  place-items: center;
}

.sp-thumb img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }

.sp-thumb-spin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--glass-border-hover);
  border-top-color: var(--sp-accent);
  animation: at-spin .7s linear infinite;
}

.sp-thumb-icon { width: 22px; height: 22px; color: var(--text-muted); }

.sp-info { min-width: 0; display: grid; gap: 4px; }

.sp-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sp-sub .sp-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text-muted); }

.sp-status { font-size: 12px; font-weight: 600; }
.sp-status.is-reading { color: var(--text-tertiary); }
.sp-status.is-ready { color: var(--accent-emerald, #10b981); }
.sp-status.is-error { color: #ef4444; }

.sp-active-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--sp-accent);
  background: color-mix(in srgb, var(--sp-accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--sp-accent) 35%, transparent);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.sp-icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color .16s var(--at-ease), background .16s var(--at-ease);
}

.sp-icon-btn:hover:not(:disabled) { color: var(--text-primary); background: var(--glass-bg); }
.sp-icon-btn.sp-danger:hover:not(:disabled) {
  color: #ef4444;
  background: color-mix(in srgb, #ef4444 12%, transparent);
}
.sp-icon-btn svg { width: 16px; height: 16px; }

@media (max-width: 560px) {
  .sp-file { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .sp-active-badge { display: none; }
  .sp-thumb { width: 44px; height: 56px; }
}

/* ---------- Pages ---------- */
.sp-pages-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-block-end: 12px;
}

.sp-pages-head h2 { margin: 0; }

.sp-pages-stats {
  margin-inline-start: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sp-stat {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px 11px;
}

.sp-pages-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-block-end: 14px;
}

.sp-pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.sp-page {
  position: relative;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  background: var(--bg-card);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .16s var(--at-ease), transform .16s var(--at-ease), box-shadow .16s var(--at-ease);
}

.sp-page:hover { border-color: var(--glass-border-hover); transform: translateY(-2px); }

.sp-page.is-sel {
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sp-accent) 45%, transparent);
}

.sp-page-img {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  background:
    repeating-conic-gradient(rgba(128, 128, 128, .18) 0% 25%, transparent 0% 50%) 50% / 14px 14px,
    var(--bg-tertiary);
  overflow: hidden;
}

.sp-page-img img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }

.sp-page-img:not(.has-img)::after {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--glass-border-hover);
  border-top-color: var(--sp-accent);
  animation: at-spin .7s linear infinite;
}

.sp-page-num {
  position: absolute;
  inset-block-start: 5px;
  inset-inline-start: 5px;
  min-width: 19px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, #000 62%, transparent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.sp-page-check {
  position: absolute;
  inset-block-start: 5px;
  inset-inline-end: 5px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sp-accent);
  color: var(--sp-accent-ink);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .16s var(--at-ease), transform .16s var(--at-ease);
}

.sp-page-check svg { width: 12px; height: 12px; }

.sp-page.is-sel .sp-page-check { opacity: 1; transform: scale(1); }

/* ---------- Mode selector ---------- */
.sp-modes {
  display: grid;
  gap: 8px;
  margin-block-end: 16px;
}

.sp-mode {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--at-radius-md);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color .16s var(--at-ease), background .16s var(--at-ease);
}

.sp-mode:hover { border-color: var(--glass-border-hover); }

.sp-mode input { position: absolute; opacity: 0; width: 0; height: 0; }

.sp-mode-radio {
  position: relative;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-block-start: 1px;
  border-radius: 50%;
  border: 2px solid var(--glass-border-hover);
  transition: border-color .16s var(--at-ease);
}

.sp-mode-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--sp-accent);
  transform: scale(0);
  transition: transform .16s var(--at-ease);
}

.sp-mode input:checked ~ .sp-mode-radio { border-color: var(--sp-accent); }
.sp-mode input:checked ~ .sp-mode-radio::after { transform: scale(1); }
.sp-mode input:focus-visible ~ .sp-mode-radio { box-shadow: 0 0 0 3px color-mix(in srgb, var(--sp-accent) 30%, transparent); }

.sp-mode:has(input:checked) {
  border-color: var(--sp-accent);
  background: color-mix(in srgb, var(--sp-accent) 8%, var(--bg-secondary));
}

.sp-mode-body { display: grid; gap: 2px; min-width: 0; }

.sp-mode-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }

.sp-mode-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Fields ---------- */
.sp-field { display: grid; gap: 7px; margin-block-end: 16px; }
.sp-field:last-child { margin-block-end: 0; }

.sp-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }

.sp-subhint {font-size: 11.5px;color: var(--text-muted);line-height: 1.5;min-height: 18px;}

.sp-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .16s var(--at-ease), box-shadow .16s var(--at-ease);
}

.sp-input:focus {
  outline: none;
  border-color: var(--sp-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sp-accent) 22%, transparent);
}

.sp-inline { display: flex; gap: 8px; align-items: center; }
.sp-inline .sp-input { flex: 1 1 auto; min-width: 0; }

.sp-feedback { font-size: 11.5px; line-height: 1.5; min-height: 1em; }
.sp-feedback.is-ok { color: var(--accent-emerald, #10b981); }
.sp-feedback.is-warn { color: #f59e0b; }
.sp-feedback.is-error { color: #ef4444; }

.sp-num { max-width: 130px; }

/* switch rows */
.sp-switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
  cursor: pointer;
}

.sp-switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.sp-switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  transition: background .2s var(--at-ease), border-color .2s var(--at-ease);
  margin-block-start: 1px;
}

.sp-switch-track::after {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s var(--at-ease);
}

.sp-switch input:checked + .sp-switch-track { background: var(--sp-accent); border-color: var(--sp-accent); }
.sp-switch input:checked + .sp-switch-track::after { transform: translateX(17px); }
[dir="rtl"] .sp-switch input:checked + .sp-switch-track::after { transform: translateX(-17px); }
.sp-switch input:focus-visible + .sp-switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--sp-accent) 30%, transparent); }

.sp-switch-text { display: grid; gap: 2px; min-width: 0; }
.sp-switch-title { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.35; }
.sp-switch-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Summary ---------- */
.sp-summary-rows {display: grid;gap: 2px;min-hr: 210px;}

.sp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-block-end: 1px solid var(--glass-border);
  font-size: 13.5px;
}

.sp-row:last-child { border-block-end: 0; }

.sp-row-key {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sp-row-key svg { width: 15px; height: 15px; color: var(--text-muted); }

.sp-row-val { font-weight: 700; color: var(--text-primary); }

.sp-empty-note {
  padding: 16px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---------- Run area ---------- */
.sp-run-btn {
  width: 100%;
  padding: 15px 22px;
  font-size: 15.5px;
}

.sp-run-panel {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--sp-accent) 7%, transparent), transparent 60%),
    var(--bg-card);
}

body.at-split .at-progress-fill {
  background: linear-gradient(90deg, var(--sp-accent), var(--sp-accent-2));
}

.sp-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-block-start: 9px;
}

.sp-progress-row .at-progress-msg { margin: 0; }

/* ---------- Result ---------- */
.sp-result { display: grid; gap: 14px; }

.sp-success {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px;
  border-radius: var(--at-radius-md);
  border: 1px solid color-mix(in srgb, var(--accent-emerald, #10b981) 45%, transparent);
  background: color-mix(in srgb, var(--accent-emerald, #10b981) 10%, transparent);
  margin-top: 15px;
}

.sp-success-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-emerald, #10b981);
  color: #fff;
}

.sp-success-icon svg { width: 17px; height: 17px; }

.sp-success-body { display: grid; gap: 3px; }
.sp-success-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.sp-success-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

.sp-results-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.sp-result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
  scrollbar-width: thin;
}

.sp-result-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--at-radius-md);
  background: var(--bg-secondary);
}

.sp-result-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--sp-accent) 14%, transparent);
  color: var(--sp-accent);
}

.sp-result-icon svg { width: 18px; height: 18px; }

.sp-result-info { min-width: 0; display: grid; gap: 2px; }

.sp-result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-result-meta { font-size: 11.5px; color: var(--text-muted); }

.sp-result-dl {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--sp-accent);
  background: color-mix(in srgb, var(--sp-accent) 12%, transparent);
  transition: background .16s var(--at-ease), transform .16s var(--at-ease);
}

.sp-result-dl:hover { background: color-mix(in srgb, var(--sp-accent) 22%, transparent); transform: translateY(-1px); }
.sp-result-dl svg { width: 17px; height: 17px; }

.sp-more-note {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

.sp-result-actions { display: grid; gap: 9px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .sp-drop,
  .sp-file,
  .sp-page,
  .sp-mode,
  .sp-switch-track,
  .sp-switch-track::after { transition: none !important; }
}
