*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #6366f1;
  --success: #22c55e;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f1419 100%);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1.5rem;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo svg {
  color: var(--primary);
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.hidden {
  display: none !important;
}

/* Upload */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 4rem 2rem;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--surface-hover);
}

.drop-icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.drop-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.drop-hint {
  color: var(--text-muted);
  margin: 1rem 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
}

/* Work section */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.file-name {
  font-weight: 600;
  word-break: break-all;
}

.page-count {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.options-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  align-items: end;
}

.option-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.option-group select,
.option-group input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
}

.option-group select:focus,
.option-group input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

.quality-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.quality-row input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}

#qualityValue {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 2.5rem;
}

.option-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Progress */
.progress-bar {
  position: relative;
  height: 28px;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  transition: width 0.2s;
}

.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.preview-card:hover {
  border-color: var(--primary);
}

.preview-card img {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
}

.preview-card-footer {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.preview-card-footer span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.preview-card.loading .preview-placeholder {
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.preview-placeholder.error {
  color: #ef4444;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
  .options-panel {
    grid-template-columns: 1fr;
  }

  .option-actions {
    flex-direction: column;
  }

  .option-actions .btn {
    width: 100%;
  }
}
