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

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --danger: #e74c3c;
  --radius: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

/* ---------- 头部 ---------- */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 28px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  margin-top: 8px;
  color: var(--text-light);
  font-size: 14px;
}

/* ---------- 上传卡片 ---------- */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.upload-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-box {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--card);
  border: 2px dashed #dcdde1;
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-box:hover,
.upload-box.dragover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.15);
}

.upload-placeholder {
  text-align: center;
  color: var(--text-light);
  pointer-events: none;
}

.upload-icon {
  font-size: 44px;
  display: block;
  margin-bottom: 10px;
}

.upload-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 12px;
  line-height: 1.7;
}

.preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #a29bfe);
  color: #fff;
  padding: 14px 40px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.35);
}

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

.btn-secondary {
  background: #dfe6e9;
  color: var(--text);
  padding: 14px 32px;
}

.btn-secondary:hover {
  background: #cdd5d8;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 0;
  font-size: 13px;
}

.btn-ghost:hover {
  text-decoration: underline;
}

.btn-small {
  align-self: center;
}

.actions {
  text-align: center;
  margin: 32px 0 8px;
}

/* ---------- 提示 ---------- */
.alert {
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.alert-error {
  background: #ffeaea;
  color: var(--danger);
  border: 1px solid #fab1b1;
}

/* ---------- 加载动画 ---------- */
.loading {
  text-align: center;
  margin-top: 40px;
}

.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  border: 4px solid #e6e2ff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.loading-text {
  color: var(--text-light);
  font-size: 14px;
}

/* ---------- 结果 ---------- */
.result-section {
  margin-top: 40px;
}

.result-title {
  font-size: 18px;
  margin-bottom: 16px;
  text-align: center;
}

.result-image-wrap {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.result-image-wrap img {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.result-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .upload-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .upload-box {
    aspect-ratio: 4 / 5;
  }

  .header h1 {
    font-size: 24px;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .result-actions {
    flex-direction: column;
  }
}
