*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-dark: #0b1120;
  --bg-gradient-top: #111827;
  --card-bg: #1a2332;
  --card-border: rgba(148, 163, 184, 0.12);
  --card-border-active: #3b82f6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-orange: #f97316;
  --btn-disabled: #7c3a1e;
  --btn-disabled-text: #a8a29e;
  --btn-active: #ea580c;
  --btn-active-hover: #f97316;
  --icon-green-bg: rgba(16, 185, 129, 0.15);
  --icon-purple-bg: rgba(139, 92, 246, 0.15);
  --icon-pink-bg: rgba(236, 72, 153, 0.15);
  --icon-green: #34d399;
  --icon-purple: #a78bfa;
  --icon-pink: #f472b6;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-dark) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 20px 100px;
  min-height: 100vh;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.title {
  font-size: 1.625rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Section */
.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.section-icon--spark {
  color: var(--accent-blue);
}

.section-icon--upload {
  color: var(--accent-blue);
}

/* Service Cards */
.service-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-card {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.service-card:hover {
  border-color: rgba(59, 130, 246, 0.3);
}

.service-card.selected {
  border-color: var(--card-border-active);
  background: rgba(59, 130, 246, 0.06);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15);
}

.service-card__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.service-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.service-icon--green {
  background: var(--icon-green-bg);
  color: var(--icon-green);
}

.service-icon--purple {
  background: var(--icon-purple-bg);
  color: var(--icon-purple);
}

.service-icon--pink {
  background: var(--icon-pink-bg);
  color: var(--icon-pink);
}

.service-card__info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.service-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.service-price {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-orange);
  white-space: nowrap;
}

.badge-free {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-green);
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.radio {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

.service-card.selected .radio {
  border-color: var(--accent-blue);
}

.radio__inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s, transform 0.2s;
  transform: scale(0);
}

.service-card.selected .radio__inner {
  background: var(--accent-blue);
  transform: scale(1);
}

.service-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 52px;
}

/* Upload Box */
.upload-box {
  position: relative;
  border: 1.5px dashed rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.5);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}

.upload-box.dragover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.06);
}

.upload-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 160px;
}

.upload-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.upload-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.upload-btn:active {
  transform: scale(0.97);
}

.upload-preview {
  position: relative;
  width: 100%;
  height: 160px;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
}

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.remove-btn:hover {
  background: rgba(239, 68, 68, 0.8);
}

/* Action Bar */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  background: linear-gradient(180deg, transparent, var(--bg-dark) 30%);
  max-width: 480px;
  margin: 0 auto;
}

.action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  cursor: not-allowed;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  background: var(--btn-disabled);
  color: var(--btn-disabled-text);
}

.action-btn:not(:disabled) {
  background: linear-gradient(135deg, #c2410c, var(--btn-active));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.35);
}

.action-btn:not(:disabled):hover {
  background: linear-gradient(135deg, var(--btn-active), var(--btn-active-hover));
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.4);
}

.action-btn:not(:disabled):active {
  transform: translateY(0);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal__content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  border: 1px solid var(--card-border);
}

.modal__content--result {
  max-width: 420px;
  position: relative;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover {
  background: rgba(148, 163, 184, 0.2);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal__title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal__desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.result-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.result-item img,
.result-item canvas {
  width: 100%;
  height: 140px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.download-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.download-btn:hover {
  background: #2563eb;
}
