*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
}

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

header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.01);
}

.upload-icon {
  color: var(--primary);
  margin-bottom: 16px;
}

.upload-text {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-hint {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.upload-limit {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-text {
  background: transparent;
  color: var(--danger);
  padding: 4px 8px;
}

.btn-text:hover {
  background: #fef2f2;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

/* Messages */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-top: 16px;
}

.message-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* File Section */
.file-section {
  margin-top: 32px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.section-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.file-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all 0.15s;
  background: var(--bg);
}

.file-item-icon {
  flex-shrink: 0;
  color: var(--danger);
}

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

.file-item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Page count badge */
.page-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: #e0e7ff;
  color: #4338ca;
  white-space: nowrap;
  line-height: 1.6;
}

.page-badge.loading {
  background: #fef3c7;
  color: #b45309;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Page range row */
.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.range-toggle {
  font-size: 12px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.range-toggle:hover,
.range-toggle.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.range-input {
  flex: 1;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
  min-width: 0;
}

.range-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.file-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.file-item-actions button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.file-item-actions button:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.file-item-actions button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.file-item-actions .remove-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}


.actions {
  text-align: center;
  margin-top: 24px;
}

/* Progress */
.progress-area {
  margin-top: 24px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s;
}

.progress-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Result */
.result-area {
  margin-top: 24px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.result-icon {
  margin-bottom: 16px;
}

.result-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.result-area .btn-secondary {
  margin-top: 12px;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}

.credit {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.5;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.25s ease-out;
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 20px 16px;
  }

  header h1 {
    font-size: 22px;
  }

  .upload-area {
    padding: 32px 16px;
  }

  .file-item {
    flex-wrap: wrap;
  }

  .file-item-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 4px;
  }

  .range-row {
    flex-wrap: wrap;
  }

  .btn-lg {
    width: 100%;
    justify-content: center;
  }
}
