/**
 * split.css — Split PDF Tool  (v2 — full mobile overhaul)
 * Prefix: spt-
 * Accent: #FF7043
 *
 * MOBILE FIXES:
 *  - Single-column layout on mobile (controls → grid → output → button)
 *  - Sticky bottom action bar on mobile
 *  - Touch-friendly buttons (min 44px)
 *  - No horizontal scroll
 *  - Grid: desktop auto-fill, tablet 4 cols, mobile 3 cols
 *  - Mode buttons: card-style on all breakpoints
 */

/* ════ RESET ════════════════════════════════════════════════════════════════ */
.spt-shell *, .spt-shell *::before, .spt-shell *::after,
.spt-overlay *, .spt-overlay *::before, .spt-overlay *::after { box-sizing: border-box; }
.spt-shell button { font-family: inherit; cursor: pointer; }

/* ════ SHELL ════════════════════════════════════════════════════════════════ */
.spt-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-h, 68px));
  background: #f0f2f7;
  font-family: inherit;
  /* Reserve space for mobile sticky bar */
  padding-bottom: 0;
}

/* ════ STEP BAR ═════════════════════════════════════════════════════════════ */
.spt-stepbar { background: #fff; border-bottom: 1px solid #e4e9f2; flex-shrink: 0; z-index: 10; }
.spt-stepbar-inner {
  display: flex; align-items: center; justify-content: center;
  height: 44px; gap: 0; padding: 0 20px;
  max-width: 1500px; margin: 0 auto;
}
.spt-step {
  display: flex; align-items: center; gap: 8px;
  font-size: .76rem; font-weight: 700; letter-spacing: .02em; padding: 0 4px;
}
.spt-step-line { width: 36px; height: 2px; background: #e4e9f2; flex-shrink: 0; margin: 0 2px; }
.spt-step-line--done { background: #FF7043; }
.spt-step-dot {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .7rem; transition: all .2s;
}
.spt-step--done   .spt-step-dot { background: #FF7043; color: #fff; }
.spt-step--active .spt-step-dot { background: #FF7043; color: #fff; box-shadow: 0 0 0 4px rgba(255,112,67,.18); }
.spt-step--off    .spt-step-dot { background: #f0f2f7; color: #b0bac8; border: 1.5px solid #e4e9f2; }
.spt-step--done span, .spt-step--active span { color: #FF7043; }
.spt-step--off span { color: #b0bac8; }

/* ════ TOOLBAR ══════════════════════════════════════════════════════════════ */
.spt-toolbar {
  background: #fff; border-bottom: 1px solid #e4e9f2;
  box-shadow: 0 2px 10px rgba(30,50,100,.05);
  flex-shrink: 0; position: sticky; top: 0; z-index: 200; transition: box-shadow .2s;
}
.spt-toolbar.is-scrolled { box-shadow: 0 4px 20px rgba(30,50,100,.1); }
.spt-toolbar-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; height: 54px; max-width: 1500px; margin: 0 auto;
}
.spt-file-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: #FFF3EE; color: #BF360C; border-radius: 20px;
  padding: 5px 12px; font-size: .75rem; font-weight: 700; flex-shrink: 0; max-width: 280px;
}
.spt-file-pill svg { flex-shrink: 0; color: #FF7043; }
.spt-file-pill-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.spt-file-pill-sep { color: #FFAB91; }
.spt-tb-gap    { width: 1px; height: 22px; background: #e4e9f2; flex-shrink: 0; }
.spt-tb-spacer { flex: 1; min-width: 4px; }

.spt-startover-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1.5px solid #e4e9f2; border-radius: 8px;
  background: #fff; color: #8492a6; font-size: .78rem; font-weight: 600;
  text-decoration: none; transition: all .15s; flex-shrink: 0; white-space: nowrap;
}
.spt-startover-btn:hover { border-color: #c8d0dc; color: #4a5568; }

.spt-output-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0;
  border-radius: 20px; padding: 5px 12px; font-size: .73rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0; transition: all .2s;
}
.spt-output-pill.is-warn { background: #fff8e1; color: #92400e; border-color: #fde68a; }
.spt-output-pill svg { flex-shrink: 0; }

.spt-finish-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 20px; height: 38px;
  background: linear-gradient(135deg, #FF7043 0%, #E64A19 100%);
  color: #fff; border: none; border-radius: 10px;
  font-size: .85rem; font-weight: 800; transition: all .2s;
  box-shadow: 0 4px 14px rgba(255,112,67,.4); flex-shrink: 0; white-space: nowrap;
  letter-spacing: .01em; min-height: 38px;
}
.spt-finish-btn:hover   { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(255,112,67,.5); }
.spt-finish-btn:active  { transform: translateY(0);    box-shadow: 0 2px 8px  rgba(255,112,67,.3); }
.spt-finish-btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ════ 3-COLUMN WORKSPACE ═══════════════════════════════════════════════════ */
.spt-workspace {
  flex: 1; display: grid;
  grid-template-columns: 272px 1fr 260px;
  grid-template-rows: 1fr;
  min-height: 0; overflow: hidden;
}

/* ════ LEFT PANEL — controls ════════════════════════════════════════════════ */
.spt-panel-left {
  background: #fff; border-right: 1px solid #e4e9f2;
  overflow: hidden; display: flex; flex-direction: column;
}
.spt-panel-scroll {
  overflow-y: auto; overflow-x: hidden; flex: 1; padding: 16px 0 32px;
}
.spt-panel-scroll::-webkit-scrollbar { width: 4px; }
.spt-panel-scroll::-webkit-scrollbar-thumb { background: #dde3ee; border-radius: 4px; }

.spt-section-label {
  font-size: .67rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: #b0bac8; padding: 0 16px 8px;
}

/* Mode nav — card-style buttons */
.spt-mode-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; margin-bottom: 4px; }
.spt-mode-btn {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 10px 10px; border: none; border-radius: 10px;
  background: transparent; text-align: left; transition: background .15s, color .15s;
  color: #5a6778; min-height: 44px;
}
.spt-mode-btn:hover:not(.spt-mode-btn--active) { background: #f5f7fb; }
.spt-mode-btn--active { background: #FFF3EE; color: #BF360C; }
.spt-mode-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #f5f7fb; flex-shrink: 0; transition: background .15s;
}
.spt-mode-btn--active .spt-mode-icon { background: rgba(255,112,67,.15); color: #FF7043; }
.spt-mode-text { display: flex; flex-direction: column; gap: 1px; }
.spt-mode-name { font-size: .82rem; font-weight: 700; line-height: 1.2; }
.spt-mode-sub  { font-size: .7rem; color: #9aa3b2; line-height: 1.2; font-weight: 500; }
.spt-mode-btn--active .spt-mode-sub { color: #E64A19; opacity: .7; }

/* Controls wrap */
.spt-ctrl-wrap { margin-top: 8px; }
.spt-ctrl { display: none; padding: 0 12px; }
.spt-ctrl--active { display: block; }

/* Info cards */
.spt-info-card {
  display: flex; align-items: flex-start; gap: 9px; border-radius: 10px;
  padding: 11px 12px; font-size: .78rem; line-height: 1.55; margin-bottom: 12px;
}
.spt-info-card svg { flex-shrink: 0; margin-top: 1px; }
.spt-info-card--orange { background: #FFF3EE; color: #BF360C; border: 1px solid #FFCCBC; }
.spt-info-card--orange svg { color: #FF7043; }
.spt-info-card--blue   { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.spt-info-card--blue   svg { color: #3b82f6; }

/* Stat row */
.spt-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: #f5f7fb; border-radius: 8px; padding: 8px 12px;
  font-size: .78rem; color: #5a6778;
}
.spt-stat-row strong { color: #FF7043; font-size: .9rem; font-weight: 800; }

/* Field */
.spt-field { margin-bottom: 12px; }
.spt-field-label { display: block; font-size: .73rem; font-weight: 700; color: #4a5568; margin-bottom: 6px; }
.spt-field-hint  { font-weight: 400; color: #9aa3b2; margin-left: 6px; }

.spt-input-row { position: relative; display: flex; align-items: center; }
.spt-input {
  width: 100%; padding: 9px 32px 9px 10px;
  border: 1.5px solid #e4e9f2; border-radius: 8px;
  font-size: .82rem; color: #2d3748; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: 'Courier New', monospace; min-height: 42px;
}
.spt-input:focus     { border-color: #FF7043; box-shadow: 0 0 0 3px rgba(255,112,67,.12); }
.spt-input.is-valid  { border-color: #22c55e; }
.spt-input.is-invalid{ border-color: #ef4444; }

.spt-clear-btn {
  position: absolute; right: 7px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: #b0bac8; border-radius: 4px; transition: all .15s;
}
.spt-clear-btn:hover { color: #4a5568; background: #f0f2f7; }

.spt-feedback { margin-top: 5px; font-size: .71rem; font-weight: 600; min-height: 16px; }
.spt-feedback.is-ok  { color: #16a34a; }
.spt-feedback.is-err { color: #ef4444; }

.spt-hint-text { margin: 6px 0 0; font-size: .71rem; color: #9aa3b2; line-height: 1.5; }
.spt-hint-text code { font-family: 'Courier New', monospace; background: #f0f2f7; padding: 1px 4px; border-radius: 3px; color: #4a5568; }

/* Selection row */
.spt-sel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.spt-sel-count { font-size: .75rem; font-weight: 700; color: #5a6778; }
.spt-sel-count.has-sel { color: #FF7043; }
.spt-text-btn { font-size: .72rem; font-weight: 600; color: #9aa3b2; border: none; background: none; padding: 3px 7px; border-radius: 5px; transition: all .15s; }
.spt-text-btn:hover { color: #ef4444; background: #fef2f2; }

/* Range chips */
.spt-range-chips { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.spt-range-chip-item { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: #4a5568; padding: 5px 8px; background: #f5f7fb; border-radius: 7px; }
.spt-range-chip-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.spt-range-chip-label { flex: 1; font-weight: 600; }
.spt-range-chip-count { color: #9aa3b2; font-size: .68rem; }

/* Every-N stepper */
.spt-stepper { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.spt-stepper-btn {
  width: 36px; height: 36px; border: 1.5px solid #e4e9f2; border-radius: 7px;
  background: #fff; color: #5a6778; display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0; min-height: 36px;
}
.spt-stepper-btn:hover { border-color: #FF7043; color: #FF7043; background: #FFF3EE; }
.spt-n-input {
  width: 58px; text-align: center; padding: 7px; border: 1.5px solid #e4e9f2;
  border-radius: 7px; font-size: .88rem; font-weight: 800; color: #2d3748;
  outline: none; transition: border-color .15s;
}
.spt-n-input:focus { border-color: #FF7043; box-shadow: 0 0 0 3px rgba(255,112,67,.1); }
.spt-stepper-label { font-size: .76rem; font-weight: 600; color: #5a6778; }

/* Every-N chips */
.spt-everyn-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.spt-en-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: .68rem; font-weight: 700; border: 1.5px solid; }

/* Custom groups */
.spt-groups-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; max-height: 260px; overflow-y: auto; }
.spt-groups-list::-webkit-scrollbar { width: 3px; }
.spt-groups-list::-webkit-scrollbar-thumb { background: #e4e9f2; border-radius: 3px; }

.spt-group-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px;
  border-radius: 9px; border: 1.5px solid #e4e9f2;
  background: #f5f7fb; transition: all .15s; font-size: .75rem; color: #4a5568;
  min-height: 44px;
}
.spt-group-item:hover { border-color: var(--gc, #e4e9f2); }
.spt-group-item.is-active {
  border-color: var(--gc, #FF7043);
  background: color-mix(in srgb, var(--gc, #FF7043) 8%, white);
  color: color-mix(in srgb, var(--gc, #FF7043) 80%, #1a202c);
}
.spt-group-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.spt-group-name  { flex: 1; font-weight: 700; }
.spt-group-count { color: #9aa3b2; font-size: .68rem; }
.spt-group-delete {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: #b0bac8; border-radius: 3px;
  opacity: 0; transition: all .15s;
}
.spt-group-item:hover .spt-group-delete { opacity: 1; }
.spt-group-delete:hover { color: #ef4444; background: #fef2f2; }

.spt-add-group-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  padding: 10px; border: 1.5px dashed #d1d9e6; border-radius: 9px;
  background: transparent; color: #8492a6; font-size: .76rem; font-weight: 600;
  transition: all .15s; min-height: 44px;
}
.spt-add-group-btn:hover { border-color: #FF7043; color: #FF7043; background: #FFF3EE; }

/* ════ CENTER PANEL — thumbnails ════════════════════════════════════════════ */
.spt-panel-center {
  overflow-y: auto; overflow-x: hidden; padding: 20px 20px 60px;
  background: #f0f2f7; display: flex; flex-direction: column;
}
.spt-panel-center::-webkit-scrollbar { width: 5px; }
.spt-panel-center::-webkit-scrollbar-thumb { background: #ccd4e0; border-radius: 4px; }

.spt-center-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.spt-center-title { font-size: .95rem; font-weight: 800; color: #1a202c; margin: 0 0 2px; }
.spt-center-sub   { font-size: .74rem; color: #8492a6; font-weight: 500; display: block; }
.spt-center-header-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.spt-pages-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #e8edf7; color: #4a5568; border-radius: 20px;
  padding: 4px 10px; font-size: .7rem; font-weight: 700;
}
.spt-deselect-all {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1.5px solid #e4e9f2; border-radius: 20px;
  background: #fff; color: #8492a6; font-size: .7rem; font-weight: 600; transition: all .15s;
}
.spt-deselect-all:hover { border-color: #ef4444; color: #ef4444; }

/* Loading */
.spt-grid-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 80px 20px; color: #8492a6; font-size: .84rem; font-weight: 500;
}
.spt-spinner {
  width: 36px; height: 36px; border: 3px solid #e4e9f2;
  border-top-color: #FF7043; border-radius: 50%; animation: sptSpin .75s linear infinite;
}
@keyframes sptSpin { to { transform: rotate(360deg); } }

/* ── Page grid: desktop default (auto-fill ~140px) ── */
.spt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  align-items: start;
}

/* ── Page card ── */
.spt-card {
  background: #fff; border-radius: 10px; overflow: visible; user-select: none;
  position: relative; display: flex; flex-direction: column;
  box-shadow: 0 2px 8px rgba(30,50,100,.08), 0 0 0 0 transparent;
  border: 2px solid transparent; transition: box-shadow .2s, transform .2s, border-color .15s;
}
.spt-card:hover { box-shadow: 0 8px 24px rgba(30,50,100,.14); transform: translateY(-2px); }
.spt-card.is-selected { border-color: #FF7043; box-shadow: 0 0 0 3px rgba(255,112,67,.2), 0 6px 20px rgba(255,112,67,.15); }

/* Group color classes */
.spt-card.gc-0 { --gclr: #3b82f6; } .spt-card.gc-1 { --gclr: #22c55e; }
.spt-card.gc-2 { --gclr: #f59e0b; } .spt-card.gc-3 { --gclr: #8b5cf6; }
.spt-card.gc-4 { --gclr: #ec4899; } .spt-card.gc-5 { --gclr: #14b8a6; }
.spt-card.gc-6 { --gclr: #f97316; } .spt-card.gc-7 { --gclr: #6366f1; }

.spt-card.is-grouped { border-color: var(--gclr); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gclr) 25%, transparent); }
.spt-card.is-dragging { opacity: .45; transform: scale(.95); border-style: dashed; }
.spt-card.drag-over   { outline: 2.5px dashed #FF7043; outline-offset: 2px; }

.spt-card-bar { height: 4px; border-radius: 8px 8px 0 0; background: transparent; flex-shrink: 0; transition: background .15s; }
.spt-card.is-grouped .spt-card-bar { background: var(--gclr); }

.spt-card-thumb {
  position: relative; height: 170px; background: #f5f5f5; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
canvas.spt-thumb-canvas {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: contain;
}

.spt-card-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #f5f5f5 25%, #eee 50%, #f5f5f5 75%);
  background-size: 200% 100%; animation: sptShimmer 1.4s infinite;
}
@keyframes sptShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.spt-card-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; padding: 12px;
}
.spt-card-fallback-doc {
  width: 48px; height: 60px; background: #fff; border: 1px solid #e4e9f2; border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.07); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; padding: 8px; position: relative;
}
.spt-card-fallback-doc::after {
  content: ''; position: absolute; top: 0; right: 0; width: 10px; height: 10px;
  background: #e4e9f2; clip-path: polygon(100% 0, 0 0, 100% 100%); border-radius: 0 5px 0 0;
}
.spt-card-fallback-line { height: 2px; width: 80%; background: #e4e9f2; border-radius: 2px; }

.spt-card-check {
  position: absolute; top: 7px; right: 7px; width: 22px; height: 22px;
  background: #FF7043; border-radius: 50%; display: none; align-items: center; justify-content: center;
  z-index: 6; box-shadow: 0 2px 6px rgba(255,112,67,.4);
}
.spt-card.is-selected .spt-card-check { display: flex; }

.spt-card-num {
  position: absolute; bottom: 7px; left: 7px;
  background: rgba(255,112,67,.92); color: #fff; border-radius: 12px;
  font-size: .58rem; font-weight: 800; padding: 2px 6px; z-index: 4; min-width: 20px; text-align: center;
}
.spt-card-group-tag {
  position: absolute; bottom: 7px; right: 7px; background: var(--gclr, #e4e9f2);
  color: #fff; border-radius: 4px; font-size: .54rem; font-weight: 800; padding: 2px 5px; z-index: 4; display: none;
}
.spt-card.is-grouped .spt-card-group-tag { display: block; }
.spt-card-foot { padding: 6px 8px 7px; border-top: 1px solid #f0f2f7; }
.spt-card-foot-label { font-size: .68rem; font-weight: 600; color: #2d3748; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ════ RIGHT PANEL — output preview ═════════════════════════════════════════ */
.spt-panel-right { background: #fff; border-left: 1px solid #e4e9f2; display: flex; flex-direction: column; overflow: hidden; }
.spt-out-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid #f0f2f7; flex-shrink: 0;
}
.spt-out-title { font-size: .82rem; font-weight: 800; color: #1a202c; margin: 0; }
.spt-out-badge { background: #FF7043; color: #fff; border-radius: 20px; font-size: .67rem; font-weight: 800; padding: 2px 9px; white-space: nowrap; }
.spt-out-badge.is-zero { background: #e4e9f2; color: #8492a6; }
.spt-out-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0; }
.spt-out-list::-webkit-scrollbar { width: 3px; }
.spt-out-list::-webkit-scrollbar-thumb { background: #e4e9f2; border-radius: 3px; }
.spt-out-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 40px 20px; color: #b0bac8; text-align: center; font-size: .77rem; line-height: 1.55;
}
.spt-out-empty-icon { color: #d1d9e6; }

.spt-out-file { display: flex; align-items: flex-start; gap: 10px; padding: 9px 14px; border-bottom: 1px solid #f0f4f8; transition: background .12s; }
.spt-out-file:last-child { border-bottom: none; }
.spt-out-file:hover { background: #fafbfd; }
.spt-out-file-icon {
  width: 28px; height: 34px; background: #FFF3EE; border: 1px solid #FFCCBC;
  border-radius: 5px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; position: relative; margin-top: 1px;
}
.spt-out-file-icon::after {
  content: ''; position: absolute; top: 0; right: 0; width: 7px; height: 7px;
  background: #FFCCBC; clip-path: polygon(100% 0, 0 0, 100% 100%); border-radius: 0 4px 0 0;
}
.spt-out-file-icon svg { color: #FF7043; }
.spt-out-file-info  { flex: 1; min-width: 0; }
.spt-out-file-name  { font-size: .74rem; font-weight: 700; color: #2d3748; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.spt-out-file-pages { font-size: .67rem; color: #9aa3b2; display: block; margin-top: 1px; }
.spt-out-file-size  { font-size: .68rem; font-weight: 700; color: #4a5568; flex-shrink: 0; align-self: center; white-space: nowrap; }
.spt-out-file-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; align-self: center; margin-right: -2px; }

.spt-out-footer { border-top: 1px solid #f0f2f7; padding: 10px 14px; flex-shrink: 0; display: flex; flex-direction: column; gap: 5px; }
.spt-out-stat { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; color: #5a6778; }
.spt-out-stat strong { color: #2d3748; font-weight: 700; }
.spt-out-warn { display: flex; align-items: center; gap: 6px; font-size: .72rem; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 7px; padding: 5px 9px; margin-top: 2px; }

.spt-out-action { padding: 12px; flex-shrink: 0; border-top: 1px solid #f0f2f7; }
.spt-right-split-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%;
  padding: 11px; background: linear-gradient(135deg, #FF7043 0%, #E64A19 100%);
  color: #fff; border: none; border-radius: 10px; font-size: .84rem; font-weight: 800;
  transition: all .2s; box-shadow: 0 4px 14px rgba(255,112,67,.35); min-height: 44px;
}
.spt-right-split-btn:hover  { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(255,112,67,.5); }
.spt-right-split-btn:active { transform: translateY(0);    box-shadow: 0 2px 8px  rgba(255,112,67,.2); }
.spt-right-split-btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ════ MOBILE STICKY ACTION BAR ═════════════════════════════════════════════
   Shown only on mobile (≤699px). Fixed at bottom of screen.
   Triggers same submitFinish() as all other Split PDF buttons.
══════════════════════════════════════════════════════════════════════════════ */
.spt-mobile-bar {
  display: none; /* hidden by default — shown via @media below */
}

/* ════ PROCESSING OVERLAY ═══════════════════════════════════════════════════ */
.spt-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,20,40,.75); backdrop-filter: blur(14px);
  z-index: 9999; align-items: center; justify-content: center;
}
.spt-overlay.visible { display: flex; }
.spt-overlay-card {
  background: #fff; border-radius: 20px; padding: 40px 36px 34px;
  max-width: 360px; width: 92%; display: flex; flex-direction: column;
  align-items: center; gap: 10px; text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,.25);
  animation: sptCardPop .35s cubic-bezier(.34,1.4,.64,1);
}
@keyframes sptCardPop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.spt-overlay-ring {
  width: 54px; height: 54px; border: 4px solid #FFE0D4; border-top-color: #FF7043;
  border-radius: 50%; animation: sptSpin .85s linear infinite; margin-bottom: 4px;
}
.spt-overlay-title { font-size: 1.05rem; font-weight: 800; color: #1a202c; margin: 0; }
.spt-overlay-sub   { font-size: .82rem; color: #8492a6; margin: 0; }
.spt-overlay-stages { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 4px; }
.spt-ov-stage {
  display: flex; align-items: center; gap: 9px; padding: 7px 12px; border-radius: 9px;
  background: #f5f7fb; font-size: .8rem; color: #9aa3b2; font-weight: 500; transition: all .3s;
}
.spt-ov-stage--active { background: #FFF3EE; color: #E64A19; font-weight: 700; }
.spt-ov-stage--done   { background: #f0fdf4; color: #16a34a; font-weight: 700; }
.spt-ov-dot { width: 8px; height: 8px; border-radius: 50%; background: #d1d9e6; flex-shrink: 0; transition: background .3s; }
.spt-ov-stage--active .spt-ov-dot { background: #FF7043; animation: sptPulse 1.1s ease-in-out infinite; }
.spt-ov-stage--done   .spt-ov-dot { background: #22c55e; }
@keyframes sptPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,112,67,.55); } 50% { box-shadow: 0 0 0 5px rgba(255,112,67,0); } }

/* ════ TOAST ════════════════════════════════════════════════════════════════ */
#sptToastTray {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 10000; pointer-events: none;
}
.spt-toast {
  background: #1a202c; color: #fff; padding: 8px 16px; border-radius: 9px;
  font-size: .8rem; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  display: flex; align-items: center; gap: 8px; white-space: nowrap; pointer-events: none;
}
.spt-toast.info    { border-left: 3px solid #FF7043; }
.spt-toast.success { border-left: 3px solid #22c55e; }
.spt-toast.warn    { border-left: 3px solid #f59e0b; }
.spt-toast.error   { border-left: 3px solid #ef4444; }

/* ════ COLOR TOKENS ══════════════════════════════════════════════════════════ */
:root {
  --spt-gc0: #3b82f6; --spt-gc1: #22c55e; --spt-gc2: #f59e0b; --spt-gc3: #8b5cf6;
  --spt-gc4: #ec4899; --spt-gc5: #14b8a6; --spt-gc6: #f97316; --spt-gc7: #6366f1;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
════════════════════════════════════════════════════════════════════════════ */

/* ── Large desktop (> 1400px) ── */
@media (min-width: 1400px) {
  .spt-workspace { grid-template-columns: 290px 1fr 280px; }
  .spt-panel-center { padding: 24px 28px 60px; }
  .spt-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .spt-card-thumb { height: 195px; }
}

/* ── Tablet (768px – 1099px) ──
   2-column: left panel + center
   Right panel spans full width below as a compact strip
 */
@media (max-width: 1099px) {
  .spt-workspace {
    grid-template-columns: 240px 1fr;
    grid-template-rows: 1fr auto;
  }
  .spt-panel-right {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid #e4e9f2;
    max-height: 280px;
    flex-direction: row;
    overflow: hidden;
  }
  .spt-out-list  { flex: 1; }
  .spt-out-action { display: none; }
  .spt-out-footer {
    flex-direction: column; justify-content: center;
    width: 160px; flex-shrink: 0; border-top: none;
    border-left: 1px solid #f0f2f7;
  }
  /* Tablet grid: 4 columns */
  .spt-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .spt-card-thumb { height: 150px; }
}

/* ── Small tablet (600px – 767px) ── */
@media (max-width: 767px) {
  .spt-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }

  /* Controls panel: compact horizontal scroll on small tablet */
  .spt-panel-left {
    border-right: none;
    border-bottom: 1px solid #e4e9f2;
    max-height: none;
  }

  /* Mode buttons: horizontal scroll row on small screens */
  .spt-mode-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 12px 8px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .spt-mode-nav::-webkit-scrollbar { display: none; }
  .spt-mode-btn {
    flex-direction: column; align-items: center; text-align: center;
    min-width: 76px; flex-shrink: 0; padding: 10px 8px; border-radius: 10px;
    border: 1.5px solid #e4e9f2; gap: 6px;
  }
  .spt-mode-btn--active { border-color: #FF7043; }
  .spt-mode-sub { display: none; } /* hide subtitle on small screens */
  .spt-mode-icon { width: 28px; height: 28px; }

  .spt-panel-right {
    grid-column: 1;
    flex-direction: column;
    max-height: none;
    border-top: 1px solid #e4e9f2;
    border-left: none;
  }
  .spt-out-footer { flex-direction: row; border-top: 1px solid #f0f2f7; border-left: none; width: auto; }
  .spt-out-action { display: none; }

  /* Grid: 3 columns on small tablet */
  .spt-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .spt-card-thumb { height: 120px; }
  .spt-panel-center { padding: 14px 12px 80px; }

  .spt-step-line { width: 20px; }
  .spt-stepbar-inner { gap: 0; }
  .spt-file-pill-name { max-width: 100px; }
  .spt-startover-btn  { display: none; }
  .spt-output-pill    { display: none; }
  .spt-finish-btn     { display: none; }
}

/* ── Mobile (< 600px) ── */
@media (max-width: 599px) {
  /* Shell needs bottom padding to clear sticky bar */
  .spt-shell { padding-bottom: 72px; }

  .spt-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
    /* On mobile: scroll the whole page, not individual panels */
    overflow: visible;
    height: auto;
  }

  /* All panels: no fixed heights, natural flow */
  .spt-panel-left { max-height: none; border-right: none; border-bottom: 1px solid #e4e9f2; }
  .spt-panel-center {
    overflow: visible; padding: 14px 12px 20px;
    /* Let center panel scroll with page */
    height: auto; min-height: 200px;
  }
  .spt-panel-right {
    grid-column: 1; flex-direction: column;
    max-height: none; border-top: 1px solid #e4e9f2;
    border-left: none; overflow: visible; height: auto;
  }

  /* Output panel: show list + footer, hide right-side button (use sticky bar) */
  .spt-out-list   { max-height: 300px; overflow-y: auto; }
  .spt-out-action { display: none; }
  .spt-out-footer { flex-direction: row; border-left: none; width: auto; border-top: 1px solid #f0f2f7; }

  /* Toolbar: compact */
  .spt-toolbar-inner { padding: 0 12px; gap: 6px; height: 48px; }
  .spt-file-pill     { max-width: 160px; }
  .spt-file-pill-name { max-width: 90px; }
  .spt-startover-btn { display: none; }
  .spt-output-pill   { display: none; }
  .spt-finish-btn    { display: none; } /* replaced by sticky bar */
  .spt-tb-gap        { display: none; }
  .spt-stepbar-inner { gap: 0; padding: 0 12px; }
  .spt-step-line     { width: 16px; }
  .spt-step span     { display: none; } /* hide step labels on mobile */

  /* Mode nav: horizontal card row */
  .spt-mode-nav {
    flex-direction: row; overflow-x: auto; padding: 0 12px 10px;
    gap: 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .spt-mode-nav::-webkit-scrollbar { display: none; }
  .spt-mode-btn {
    flex-direction: column; align-items: center; text-align: center;
    min-width: 70px; flex-shrink: 0; padding: 10px 8px; border-radius: 10px;
    border: 1.5px solid #e4e9f2; gap: 5px; min-height: 64px;
  }
  .spt-mode-btn--active { border-color: #FF7043; background: #FFF3EE; }
  .spt-mode-sub  { display: none; }
  .spt-mode-name { font-size: .72rem; }
  .spt-mode-icon { width: 28px; height: 28px; border-radius: 7px; }

  /* Grid: 3 columns on mobile */
  .spt-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .spt-card-thumb { height: 110px; }
  .spt-card-num   { font-size: .52rem; padding: 1px 5px; }
  .spt-card-group-tag { font-size: .48rem; padding: 1px 4px; }
  .spt-card-foot-label { font-size: .62rem; }

  /* Right panel becomes single column, natural height */
  .spt-out-title { font-size: .8rem; }
  .spt-center-title { font-size: .88rem; }
  .spt-center-sub   { font-size: .7rem; }
  .spt-section-label { padding-left: 12px; }
  .spt-ctrl { padding: 0 10px; }

  /* ── MOBILE STICKY BAR — visible ── */
  .spt-mobile-bar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 500;
    background: #fff;
    border-top: 1px solid #e4e9f2;
    box-shadow: 0 -4px 20px rgba(30,50,100,.1);
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    align-items: center;
    gap: 12px;
  }
  .spt-mobile-bar-info {
    display: flex; flex-direction: column; gap: 1px;
    font-size: .72rem; color: #8492a6; font-weight: 500; flex: 1; min-width: 0;
  }
  .spt-mobile-bar-info strong { color: #2d3748; font-weight: 800; font-size: .82rem; }
  .spt-mobile-bar-row { display: flex; gap: 12px; }
  .spt-mobile-bar-stat { display: flex; flex-direction: column; align-items: center; }
  .spt-mobile-bar-stat-val { font-size: .95rem; font-weight: 800; color: #FF7043; line-height: 1; }
  .spt-mobile-bar-stat-lbl { font-size: .6rem; color: #9aa3b2; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
  .spt-mobile-split-btn {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 0 22px; height: 48px;
    background: linear-gradient(135deg, #FF7043 0%, #E64A19 100%);
    color: #fff; border: none; border-radius: 12px;
    font-size: .9rem; font-weight: 800; letter-spacing: .01em;
    box-shadow: 0 4px 16px rgba(255,112,67,.45);
    white-space: nowrap; flex-shrink: 0; transition: all .2s;
    min-width: 130px;
  }
  .spt-mobile-split-btn:hover  { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255,112,67,.55); }
  .spt-mobile-split-btn:active { transform: translateY(0);    box-shadow: 0 2px 8px  rgba(255,112,67,.3); }
  .spt-mobile-split-btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

  /* Toast above mobile bar */
  #sptToastTray { bottom: 84px; }

  /* Custom groups: make delete always visible (no hover on mobile) */
  .spt-group-delete { opacity: 1; }
}

/* ── Very small screens (< 380px) ── */
@media (max-width: 379px) {
  .spt-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .spt-card-thumb { height: 120px; }
  .spt-mobile-split-btn { min-width: 110px; padding: 0 14px; font-size: .82rem; }
}
