/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6c63ff;
  --primary-dark: #5a52d5;
  --primary-light: #ede9ff;
  --accent: #ff6584;
  --bg: #f4f3ff;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #7b7b9d;
  --border: #e2e0f5;
  --shadow-sm: 0 2px 8px rgba(108, 99, 255, 0.08);
  --shadow-md: 0 8px 32px rgba(108, 99, 255, 0.15);
  --shadow-lg: 0 16px 48px rgba(108, 99, 255, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
}

html {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 20%, #e0dcff 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, #ffd6e0 0%, transparent 50%),
    var(--bg);
}

/* ===== LAYOUT ===== */
.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  padding: 16px 0 8px;
}

.header__title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.header__subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  animation: fadeSlideIn 0.35s ease;
}

.card.hidden {
  display: none;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-label {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.card__title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}

/* ===== UPLOAD AREA ===== */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 48px 24px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.upload-area__icon {
  font-size: 3rem;
  line-height: 1;
}

.upload-area__text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.upload-area__hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== CANVAS ===== */
.canvas-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

#preview-canvas {
  max-width: 100%;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  cursor: grab;
  touch-action: none;
  display: block;
}

#preview-canvas:active {
  cursor: grabbing;
}

.canvas-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(108, 99, 255, 0.4);
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(108, 99, 255, 0.4);
}

/* ===== BUTTONS ===== */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  line-height: 1;
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.action-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-ghost {
  flex: 0 0 auto;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-primary {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.35);
  letter-spacing: 0.3px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(108, 99, 255, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding-top: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .app {
    padding: 16px 12px 32px;
  }

  .header__title {
    font-size: 1.6rem;
  }

  .upload-area {
    padding: 36px 16px;
  }

  .card {
    padding: 18px;
  }
}
