:root {
  --bg: #070b14;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf6;
  --muted: #9aa4bc;
  --accent1: #6366f1;
  --accent2: #8b5cf6;
  --accent3: #06b6d4;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --ok: #34d399;
  --err: #f87171;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --font: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(620px 420px at 12% 8%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(720px 520px at 88% 18%, rgba(6, 182, 212, 0.13), transparent 60%),
    radial-gradient(860px 620px at 50% 105%, rgba(139, 92, 246, 0.12), transparent 65%);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 44px 20px 60px;
}

/* ---------- header ---------- */
header { text-align: center; margin-bottom: 34px; }

.logo { display: inline-flex; align-items: center; gap: 14px; }

.logo-badge {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--grad);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.42);
  animation: float 5s ease-in-out infinite;
}

.logo-badge svg { width: 28px; height: 28px; }

h1 { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: -0.5px; }

.tagline {
  color: var(--muted);
  margin: 12px auto 0;
  max-width: 620px;
  font-size: 15px;
}

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed rgba(139, 92, 246, 0.4);
  border-radius: 24px;
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--card);
  backdrop-filter: blur(10px);
  transition: border-color 0.25s, background 0.25s, transform 0.25s, box-shadow 0.25s;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent2);
  background: rgba(139, 92, 246, 0.08);
  box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.12), var(--shadow);
  transform: translateY(-2px);
}

.dropzone.drag { transform: scale(1.015); }

.dropzone.uploading { pointer-events: none; opacity: 0.85; }

.dz-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.2));
  color: #a5b4fc;
  animation: float 4s ease-in-out infinite;
}

.dz-icon svg { width: 30px; height: 30px; }

.dz-main { font-size: 18px; font-weight: 700; margin: 0 0 6px; }

.dz-sub { color: var(--muted); font-size: 13.5px; margin: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 18px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}

.section-title { font-size: 17px; font-weight: 800; margin: 0 0 16px; }

.hidden { display: none !important; }

/* ---------- file card ---------- */
.file-info { display: flex; align-items: center; gap: 14px; }

.file-icon {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}

.file-icon svg { width: 24px; height: 24px; }

.file-meta { flex: 1; min-width: 0; }

.file-name {
  font-weight: 700;
  font-size: 15.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: right;
}

.file-tags { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.tag.pages { color: #67e8f9; }

.tag svg { width: 13px; height: 13px; }

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.icon-btn:hover { background: rgba(248, 113, 113, 0.12); color: var(--err); border-color: rgba(248, 113, 113, 0.3); }

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

/* ---------- mode cards ---------- */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mode-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
  padding: 16px;
  border-radius: 14px;
  border: 1.5px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.22s;
}

.mode-card:hover { border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.06); transform: translateY(-1px); }

.mode-card.active {
  border-color: var(--accent2);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(6, 182, 212, 0.12));
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.mode-icon {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: #a5b4fc;
}

.mode-icon svg { width: 22px; height: 22px; }

.mode-card.active .mode-icon { background: var(--grad); color: #fff; }

.mode-text { flex: 1; display: flex; flex-direction: column; }

.mode-text strong { font-size: 15px; }

.mode-text span { font-size: 12px; color: var(--muted); margin-top: 3px; }

.check {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.mode-card.active .check {
  border-color: var(--ok);
  background: var(--ok);
}

.mode-card.active .check::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid #052e2b;
  border-bottom: 2px solid #052e2b;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* ---------- controls ---------- */
.controls { margin-top: 18px; }

.stepper-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.stepper-row label { font-size: 14px; color: var(--muted); }

.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 4px;
}

.step-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.18s;
  display: grid;
  place-items: center;
}

.step-btn:hover:not(:disabled) { background: var(--grad); }

.step-btn:disabled { opacity: 0.35; cursor: default; }

.step-value {
  min-width: 34px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chips { display: flex; gap: 8px; }

.chips button {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s;
}

.chips button:hover { color: var(--text); border-color: rgba(139, 92, 246, 0.5); }

.chips button.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
}

.ranges-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 10px;
}

.ranges-toggle input { display: none; }

.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  position: relative;
  transition: background 0.25s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s;
}

.ranges-toggle input:checked + .toggle-track { background: var(--grad); }

.ranges-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(-18px); }

#rangesWrap, #customWrap { margin-bottom: 10px; animation: rise 0.3s ease both; }

.ranges-toggle + .ranges-toggle { margin-right: 22px; }

.text-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: rtl;
}

.text-input:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }

.hint, .mode-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 0;
}

.mode-hint {
  border-right: 3px solid var(--accent2);
  padding-right: 10px;
  background: rgba(99, 102, 241, 0.06);
  padding: 8px 12px;
  border-radius: 8px;
}

/* ---------- split button ---------- */
.split-btn {
  width: 100%;
  margin-top: 20px;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font-family: var(--font);
  font-size: 16.5px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 14px 34px rgba(99, 102, 241, 0.4);
  transition: all 0.22s;
}

.split-btn svg { width: 20px; height: 20px; transition: transform 0.22s; }

.split-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 20px 44px rgba(99, 102, 241, 0.5); }

.split-btn:hover:not(:disabled) svg { transform: translateX(-4px); }

.split-btn:active:not(:disabled) { transform: scale(0.98); }

.split-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- results ---------- */
.results-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.results-head .section-title { margin: 0; }

.results-stats { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.part-card {
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: rise 0.4s ease both;
  transition: all 0.2s;
}

.part-card:hover { border-color: rgba(6, 182, 212, 0.45); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); }

.part-head { display: flex; align-items: center; gap: 10px; }

.part-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(6, 182, 212, 0.12);
  color: #67e8f9;
}

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

.part-num { font-size: 13px; font-weight: 800; color: #67e8f9; }

.part-name {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: right;
}

.part-meta { display: flex; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

.download-btn {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.1);
  color: #67e8f9;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.download-btn:hover { background: var(--grad); color: #fff; border-color: transparent; }

.download-btn svg { width: 16px; height: 16px; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.ghost-btn:hover { border-color: rgba(139, 92, 246, 0.55); background: rgba(139, 92, 246, 0.1); }

.ghost-btn svg { width: 17px; height: 17px; }

.ghost-btn.busy { opacity: 0.6; pointer-events: none; }

.ghost-btn.full { width: 100%; margin-top: 16px; justify-content: center; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 7, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.25s ease both;
}

.modal-card {
  width: 100%;
  max-width: 430px;
  background: #0e1526;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 26px;
  box-shadow: var(--shadow);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.progress-row { display: flex; align-items: center; gap: 12px; }

.progress-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--grad);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  transition: width 0.5s ease;
}

.progress-pct {
  font-size: 13px;
  font-weight: 800;
  color: #a5b4fc;
  min-width: 42px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.stages { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.stage {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.3s;
}

.stage.active { color: var(--text); font-weight: 700; }

.dot {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
}

.stage.active .dot {
  border-color: transparent;
  border-top-color: var(--accent3);
  animation: spin 0.8s linear infinite;
}

.stage.done .dot { border-color: var(--ok); background: var(--ok); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  right: 50%;
  transform: translate(50%, 30px);
  z-index: 60;
  max-width: min(92vw, 480px);
  background: #0e1526;
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.show { opacity: 1; transform: translate(50%, 0); }

.toast.error { border-color: rgba(248, 113, 113, 0.55); }

/* ---------- footer ---------- */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 10px 20px 34px;
}

footer p { margin: 4px 0; }

/* ---------- animations ---------- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .container { padding-top: 28px; }
  h1 { font-size: 24px; }
  .mode-cards { grid-template-columns: 1fr; }
  .dropzone { padding: 36px 16px; }
  .results-grid { grid-template-columns: 1fr; }
}
