:root {
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.4);
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
}

/* App Layout */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.icon-sparkles { font-size: 1.8rem; }
.subtitle { color: var(--text-sub); margin: 0; font-size: 1.1rem; }

/* Step Cards */
.step-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 32px;
  display: none;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.step-card.active { display: block; }

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

/* Step 1: Upload */
.main-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 60px 20px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  background: #fcfdfe;
}

.main-dropzone:hover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.02);
}

.upload-icon { color: var(--primary); margin-bottom: 24px; opacity: 0.8; }
.main-dropzone h3 { margin: 0 0 8px; font-size: 1.3rem; }
.main-dropzone p { color: var(--text-sub); margin: 0 0 24px; }

/* Buttons & Inputs */
.btn-primary-large {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: transform 0.2s;
}

.btn-primary-large:hover { transform: scale(1.02); }

.btn-primary-glow {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 40px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px var(--primary-glow);
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  font-size: 0.95rem;
}

.btn-secondary {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  height: 40px;
  font-size: 0.95rem;
}

.btn-text {
  background: rgba(79, 70, 229, 0.05);
  border: 1px solid rgba(79, 70, 229, 0.1);
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-text:hover {
  background: rgba(79, 70, 229, 0.1);
  border-color: rgba(79, 70, 229, 0.2);
}

/* Step 2: Settings */
.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.config-header h2 { font-size: 1.25rem; margin: 0; font-weight: 700; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.setting-item label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
}

.intensity-options {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 14px;
  gap: 4px;
}

.intensity-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s;
}

.intensity-btn strong { font-size: 0.95rem; color: #475569; }
.intensity-btn span { font-size: 0.8rem; color: #94a3b8; }

.intensity-btn.active {
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.intensity-btn.active strong { color: var(--primary); }

.counter-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  height: 52px;
  background: #fff;
}

.counter-input button {
  width: 52px;
  height: 52px;
  border: none;
  background: #f8fafc;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-sub);
  transition: background 0.2s;
}

.counter-input button:hover { background: #f1f5f9; color: var(--text-main); }

.counter-input input {
  flex: 1;
  border: none;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-main);
  outline: none;
  width: 100%;
}

/* Hide Number Input Spinners */
.counter-input input::-webkit-outer-spin-button,
.counter-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.counter-input input[type=number] {
  -moz-appearance: textfield;
}

.mini-file-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 16px;
  margin-bottom: 24px;
}

.mini-file-item {
  position: relative;
  flex-shrink: 0;
}

.mini-file-item img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.btn-remove-file {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 0;
  line-height: 1;
}

.action-bar {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
}

/* Step 3: Processing */
.processing-view {
  text-align: center;
  padding: 40px 0;
}

.spinner-container {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 32px;
}

.loading-spinner {
  width: 100%;
  height: 100%;
  border: 4px solid #f1f5f9;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.processing-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
}

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

.progress-bar-bg {
  height: 10px;
  background: #f1f5f9;
  border-radius: 5px;
  margin-bottom: 16px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #9333ea);
  width: 0%;
  transition: width 0.3s ease;
}

.processing-note { color: var(--text-sub); font-size: 0.95rem; }

/* Step 4: Results */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.results-header h2 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.results-actions { display: flex; gap: 12px; align-items: center; }

.modern-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.result-card {
  background: #f8fafc;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.result-card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

.result-card img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  cursor: zoom-in;
}

.result-card-info {
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-card-info span {
  font-size: 0.85rem;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.btn-download-icon {
  background: var(--primary);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 40px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

.stat-text { font-weight: 700; color: var(--primary); margin-bottom: 8px; font-size: 1.1rem; }
.footer-links { font-size: 0.9rem; color: var(--text-sub); margin-bottom: 12px; }
.footer-disclaimer { font-size: 0.7rem; color: #cbd5e1; max-width: 650px; margin: 0 auto; line-height: 1.5; font-weight: 400; }
.separator { margin: 0 10px; opacity: 0.3; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
}

.lightbox.active { display: grid; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(8px); }

.lightbox-content {
  position: relative;
  width: min(90vw, 1000px);
  max-height: 90vh;
}

.lightbox-content img {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
}

.lightbox-info {
  padding: 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lightbox-nav button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
}

.lightbox-close {
  position: absolute;
  top: -60px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
}

@media (max-width: 600px) {
  .settings-grid { grid-template-columns: 1fr; gap: 16px; }
  .action-bar { grid-template-columns: 1fr; }
  .results-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .results-actions { width: 100%; flex-wrap: wrap; }
  .btn-primary, .btn-secondary { flex: 1; justify-content: center; }
}
