/**
 * 童画心声 - 主样式表
 * 
 * 设计理念：
 * - 儿童友好的暖色调配色（橙色、绿色、黄色为主）
 * - 圆润的边角和柔和的阴影
 * - 大字号、高对比度，适合各年龄段
 * - 活泼但不杂乱的布局
 * - 响应式设计，适配手机和电脑
 */

/* ========== CSS 变量 ========== */
:root {
  /* 主色调 - 温暖橙色系 */
  --primary: #FF8C42;
  --primary-light: #FFB07A;
  --primary-dark: #E67332;
  
  /* 辅助色 - 自然绿色 */
  --secondary: #4CAF50;
  --secondary-light: #81C784;
  --secondary-dark: #388E3C;
  
  /* 强调色 - 阳光黄色 */
  --accent: #FFD54F;
  --accent-light: #FFF176;
  --accent-dark: #FFC107;
  
  /* 背景色 - 温暖米白 */
  --bg-main: #FFF8F0;
  --bg-card: #FFFFFF;
  --bg-section: #FFF3E6;
  
  /* 文字色 */
  --text-primary: #3D2C1E;
  --text-secondary: #7A6555;
  --text-light: #A89585;
  
  /* 功能色 */
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #EF5350;
  --info: #29B6F6;
  
  /* 边框与阴影 */
  --border: #F0E0D0;
  --shadow-sm: 0 2px 8px rgba(61, 44, 30, 0.08);
  --shadow-md: 0 4px 16px rgba(61, 44, 30, 0.12);
  --shadow-lg: 0 8px 32px rgba(61, 44, 30, 0.16);
  
  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  
  /* 字体 */
  --font-display: 'ZCOOL KuaiLe', cursive;
  --font-body: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* 导航栏高度 */
  --navbar-height: 64px;
}

/* ========== 全局重置 ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== 导航栏 ========== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 1000;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
}

.nav-logo {
  font-size: 1.8rem;
}

.nav-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: var(--space-xs);
}

.nav-link {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-section);
  color: var(--primary);
}

.nav-link.active {
  background: var(--primary);
  color: white;
}

.nav-settings-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-full);
  transition: background 0.2s;
}

.nav-settings-btn:hover {
  background: var(--bg-section);
}

/* ========== 主内容区 ========== */
.main-content {
  margin-top: var(--navbar-height);
  min-height: calc(100vh - var(--navbar-height));
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

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

/* ========== 按钮系统 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.btn-secondary:hover {
  background: var(--secondary-dark);
  border-color: var(--secondary-dark);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(255, 140, 66, 0.05);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #D32F2F;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
}

/* ========== 首页 ========== */
.home-hero {
  position: relative;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  background: linear-gradient(180deg, var(--bg-section) 0%, var(--bg-main) 100%);
  overflow: hidden;
}

.hero-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.float-icon {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: 2rem;
  animation: floatUp 4s ease-in-out infinite;
  animation-delay: var(--delay);
  opacity: 0.6;
}

@keyframes floatUp {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(10deg); }
}

.hero-title {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: var(--space-md);
}

.hero-title .highlight {
  color: var(--primary);
  position: relative;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.hero-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* 功能卡片 */
.home-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-xl) var(--space-lg);
  max-width: 1000px;
  margin: 0 auto;
}

.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.feature-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 使用步骤 */
.home-how {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  background: var(--bg-section);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.section-desc {
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: nowrap;
  margin-top: var(--space-lg);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.step-icon {
  font-size: 2.5rem;
}

.step p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.step-arrow {
  font-size: 1.5rem;
  color: var(--text-light);
  margin-top: -20px;
}

/* ========== 画画页 ========== */
.draw-container {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.draw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.draw-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.draw-actions {
  display: flex;
  gap: var(--space-sm);
}

/* 模式切换 */
.draw-mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-md);
  background: var(--bg-section);
  border-radius: var(--radius-full);
  padding: 3px;
}

.mode-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.mode-tab:hover:not(.active) {
  color: var(--text-primary);
}

/* 上传区域 */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-2xl);
  border: 3px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: var(--space-md);
}

.upload-area:hover {
  border-color: var(--primary-light);
  background: rgba(255, 140, 66, 0.03);
}

.upload-icon {
  font-size: 3.5rem;
  opacity: 0.6;
}

.upload-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* 上传预览 */
.upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.upload-preview img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-md);
  border: 3px solid var(--border);
  object-fit: contain;
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.tool-label {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
}

.color-palette {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.15s ease;
}

.color-btn:hover {
  transform: scale(1.15);
}

.color-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.brush-slider {
  width: 100px;
  accent-color: var(--primary);
}

.brush-size-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 24px;
  text-align: center;
}

.tool-buttons {
  display: flex;
  gap: 4px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  position: relative;
}

.tool-btn:hover {
  border-color: var(--primary-light);
}

.tool-btn.active {
  border-color: var(--primary);
  background: rgba(255, 140, 66, 0.1);
}

/* 工具按钮悬浮提示 */
.tool-tip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--text-primary);
  color: white;
  font-family: var(--font-display);
  font-size: 0.8rem;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.tool-tip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--text-primary);
}

.tool-btn:hover .tool-tip {
  opacity: 1;
}

/* 画布 */
.canvas-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

#drawCanvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  background: white;
}

/* 画作信息 */
.draw-info {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.info-field {
  flex: 1;
  min-width: 200px;
}

.info-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.info-field input {
  width: 100%;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color 0.2s;
}

.info-field input:focus {
  outline: none;
  border-color: var(--primary);
}

.info-field input::placeholder {
  color: var(--text-light);
}

.draw-bottom-actions {
  text-align: center;
  padding: var(--space-md) 0;
}

/* ========== 故事结果页 ========== */
.story-result {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.story-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.story-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.story-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.story-artwork {
  display: flex;
  gap: var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.story-artwork img {
  width: 200px;
  height: auto;
  border-radius: var(--radius-md);
  border: 3px solid var(--border);
  object-fit: contain;
}

.story-artwork-info h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: var(--space-xs);
}

.story-artwork-info p {
  color: var(--text-secondary);
}

/* 故事文本 */
.story-text-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}

.story-text-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.story-text-header h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  flex: 1;
}

.story-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* AI 对话 */
.story-chat {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.story-chat h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: var(--space-xs);
}

.chat-hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: var(--space-md);
}

.chat-messages {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chat-msg {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}

.chat-msg.ai {
  align-self: flex-start;
  background: var(--bg-section);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-input-area {
  display: flex;
  gap: var(--space-sm);
}

.chat-input-area input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.chat-input-area input:focus {
  outline: none;
  border-color: var(--primary);
}

/* 心理分析预览 */
.story-analysis-preview {
  background: linear-gradient(135deg, #FFF3E6, #E8F5E9);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.story-analysis-preview h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
}

#analysisPreviewContent {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.story-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ========== 故事集页 ========== */
.stories-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
  text-align: left;
}

.story-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.story-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.story-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--bg-section);
}

.story-card-body {
  padding: var(--space-md);
}

.story-card-body h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.story-card-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-light);
}

/* 待分析画作卡片 */
.story-card-pending {
  opacity: 0.85;
  border-style: dashed;
  border-color: var(--text-light);
}

.story-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  background: var(--warning);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
}

.story-card {
  position: relative;
}

/* 空状态 */
.stories-empty,
.analysis-empty,
.share-empty,
.message-empty {
  text-align: center;
  padding: var(--space-2xl);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-hint {
  color: var(--text-light);
  margin-bottom: var(--space-lg);
}

/* ========== 心理分析页 ========== */
.analysis-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}

.analysis-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.overview-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.overview-number {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--primary);
}

.overview-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.student-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
  text-align: left;
}

.student-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.student-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.student-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.student-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--bg-section);
}

.student-card-header h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.student-card-header .artwork-count {
  font-size: 0.8rem;
  color: var(--text-light);
}

.student-tags {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.tag {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.tag-positive {
  background: #E8F5E9;
  color: #2E7D32;
}

.tag-neutral {
  background: #FFF3E6;
  color: #E67E22;
}

.tag-attention {
  background: #FFEBEE;
  color: #C62828;
}

/* 学生详情 */
.student-detail {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.detail-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  flex: 1;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.detail-artworks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-md);
}

.detail-artwork-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.detail-artwork-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.detail-artwork-item p {
  padding: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

.detail-analysis-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.detail-analysis-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
  color: var(--primary);
}

.detail-analysis-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ========== 亲情连接页 ========== */
.share-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}

.share-create h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: var(--space-lg);
  text-align: left;
}

.share-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.share-artwork-item {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 3px solid transparent;
}

.share-artwork-item:hover {
  border-color: var(--primary);
}

.share-artwork-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.share-artwork-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.share-artwork-item .share-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.share-artwork-item.selected .share-check {
  display: flex;
}

/* ========== 分享预览 ========== */
.share-preview-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.preview-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.preview-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  flex: 1;
}

.share-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.share-card-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: var(--space-lg);
  text-align: center;
  color: white;
}

.share-card-header h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.share-card-header p {
  opacity: 0.9;
  font-size: 0.9rem;
}

.share-card-body {
  padding: var(--space-lg);
}

.share-card-artwork {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.share-card-story {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-bottom: var(--space-md);
}

.share-card-footer {
  text-align: center;
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-light);
}

/* 分享卡片图片占位（分享链接场景） */
.share-card-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  margin-bottom: var(--space-md);
  background: var(--bg-section);
  border-radius: var(--radius-md);
  border: 2px dashed var(--border);
}

.share-card-image-placeholder .placeholder-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.share-card-image-placeholder p {
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: center;
}

.preview-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin-top: var(--space-xl);
  flex-wrap: wrap;
}

/* ========== 设置页 ========== */
.settings-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

.settings-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}

.settings-section h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
}

.settings-hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: var(--space-md);
}

.settings-field {
  margin-bottom: var(--space-md);
}

.settings-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.settings-field input {
  width: 100%;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.settings-field input:focus {
  outline: none;
  border-color: var(--primary);
}

.settings-section .btn {
  margin-right: var(--space-sm);
  margin-top: var(--space-sm);
}

.settings-status {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: none;
}

.settings-status.success {
  display: block;
  background: #E8F5E9;
  color: #2E7D32;
}

.settings-status.error {
  display: block;
  background: #FFEBEE;
  color: #C62828;
}

.settings-version {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: var(--space-sm);
}

/* API 获取指南 */
.api-guide {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--bg-section);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary);
}

.api-guide h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.api-guide ol {
  padding-left: 20px;
  margin: 0;
}

.api-guide li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.api-guide a {
  color: var(--primary);
  text-decoration: underline;
}

/* ========== 加载遮罩 ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 248, 240, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-content {
  text-align: center;
}

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

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

.loading-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-secondary);
  transition: opacity 0.3s ease;
  min-height: 1.6em;
}

.loading-text.fade-out {
  opacity: 0;
}

/* ========== Toast 提示 ========== */
.toast-container {
  position: fixed;
  top: calc(var(--navbar-height) + var(--space-md));
  right: var(--space-md);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  max-width: 320px;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.info {
  border-left: 4px solid var(--info);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  
  .hero-title {
    font-size: 2.2rem;
  }
  
  .steps {
    gap: var(--space-xs);
  }

  .step-icon {
    font-size: 1.8rem;
  }

  .step p {
    font-size: 0.8rem;
  }

  .step-number {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .step-arrow {
    font-size: 1rem;
  }
  
  .story-artwork {
    flex-direction: column;
    text-align: center;
  }
  
  .analysis-overview {
    grid-template-columns: 1fr;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .draw-info {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  :root {
    --space-lg: 16px;
    --space-xl: 24px;
  }
  
  .navbar {
    padding: 0 var(--space-md);
  }
  
  .hero-title {
    font-size: 1.8rem;
  }
  
  .btn-lg {
    padding: 12px 20px;
    font-size: 1rem;
  }
}
