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

:root {
  --color-primary: #e91e63;
  --color-primary-light: #f8bbd9;
  --color-primary-dark: #ad1457;
  --color-bg: #fff5f8;
  --color-surface: #ffffff;
  --color-text: #333;
  --color-text-secondary: #666;
  --color-border: #f0e0e8;
  --color-success: #4caf50;
  --color-error: #f44336;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(233, 30, 99, 0.08);
  --shadow-hover: 0 4px 20px rgba(233, 30, 99, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #fff5f8 0%, #ffe8f0 100%);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 头部 */
.header {
  text-align: center;
  padding: 24px 0;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-primary-dark);
  margin-bottom: 8px;
}

.subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* 上传区 */
.upload-section {
  margin-bottom: 20px;
}

.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 20px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--color-primary-light);
  background: #fffbfc;
}

.upload-placeholder {
  text-align: center;
  color: var(--color-text-secondary);
}

.upload-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.upload-placeholder p {
  font-size: 14px;
}

.upload-hint,
.upload-count {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

/* 图片管理区 */
.images-section {
  margin-bottom: 24px;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.image-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s;
}

.image-item .remove-btn:hover {
  background: var(--color-error);
}

/* 分析按钮 */
.action-section {
  margin-bottom: 24px;
}

.btn-analyze {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.btn-analyze:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-analyze:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-analyze:active:not(:disabled) {
  transform: translateY(0);
}

/* 加载态 */
.loading-section {
  text-align: center;
  padding: 40px 20px;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

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

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

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

.loading-hint {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

/* 分析结果 */
.result-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.result-section h2 {
  font-size: 18px;
  color: var(--color-primary-dark);
  margin-bottom: 8px;
}

.result-disclaimer {
  font-size: 12px;
  color: #999;
  margin-bottom: 16px;
}

.result-content {
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-content p {
  margin-bottom: 12px;
}

/* 错误提示 */
.error-section {
  margin-bottom: 24px;
}

.error-box {
  background: #ffebee;
  border: 1px solid #ffcdd2;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.error-icon {
  font-size: 20px;
}

.error-box p {
  color: var(--color-error);
  font-size: 14px;
}

/* 页脚 */
.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
}

.footer p {
  font-size: 12px;
  color: #999;
}

/* 图片预览弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* 关键：hidden 时强制隐藏，避免 display:flex 覆盖 */
.modal[hidden] {
  display: none !important;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.modal-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
}

.modal-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
