* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* 品牌主色调 - 基于 logo 的黄色 */
  --primary-color: #FFC300;
  --primary-light: #FFD54F;
  --primary-dark: #FFB300;
  --primary-darker: #FFA000;
  --primary-lightest: #FFF3CD;
  
  /* 中性色 */
  --bg-color: #F8F9FA;
  --chat-bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-variant: #F5F5F5;
  
  /* 文字颜色 */
  --text-primary: #191919;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-inverse: #FFFFFF;
  
  /* 功能色 */
  --user-bubble: #FFC300;
  --assistant-bubble: #F5F5F5;
  --success: #4CAF50;
  --error: #F44336;
  --warning: #FF9800;
  
  /* 边框和分割线 */
  --border-color: #E0E0E0;
  --divider: #EEEEEE;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* 头部配色 */
  --header-bg-start: #FFC300;
  --header-bg-end: #FFB300;
  --header-text: #FFFFFF;
  
  /* 间距系统 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  
  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: var(--chat-bg);
  box-shadow: var(--shadow-lg);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg) var(--spacing-xl);
  background: linear-gradient(135deg, var(--header-bg-start), var(--header-bg-end));
  color: var(--header-text);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

/* Logo 图片样式 */
.logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  background: var(--primary-color);
}

/* 备用文字 Logo */
.logo-circle {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #FFFFFF 0%, #FFF9E6 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  color: #FF8C00;
  box-shadow: var(--shadow), inset 0 -2px 4px rgba(0,0,0,0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  letter-spacing: 1px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  cursor: pointer;
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 40px;
  height: 40px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--success);
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
  transition: background 0.3s;
}

.status-indicator.offline {
  background: var(--error);
  box-shadow: 0 0 6px rgba(244, 67, 54, 0.6);
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-xl);
  scroll-behavior: smooth;
  background-color: var(--chat-bg);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

.message {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.message.user .avatar {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-darker));
}

.bubble {
  max-width: 75%;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  line-height: 1.6;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

.message.assistant .bubble {
  background: var(--assistant-bubble);
  border-top-left-radius: var(--radius-sm);
  color: var(--text-primary);
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--user-bubble), var(--primary-dark));
  color: white;
  border-top-right-radius: var(--radius-sm);
}

.loading {
  display: flex;
  justify-content: center;
  padding: var(--spacing-lg);
}

.loading.hidden {
  display: none;
}

.loading span {
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: var(--radius-full);
  margin: 0 3px;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.input-area {
  display: flex;
  padding: var(--spacing-lg) var(--spacing-xl);
  background: var(--surface);
  border-top: 1px solid var(--divider);
  gap: var(--spacing-md);
  align-items: center;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.input-area input {
  flex: 1;
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  outline: none;
  font-size: 14px;
  transition: all 0.2s ease;
  background: var(--surface);
  color: var(--text-primary);
}

.input-area input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 195, 0, 0.1);
}

.input-area input::placeholder {
  color: var(--text-tertiary);
}

.input-area button {
  padding: var(--spacing-md) var(--spacing-xl);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.input-area button:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.input-area button:active {
  transform: translateY(0);
}

.input-area button:disabled {
  background: var(--surface-variant);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  max-height: 80%;
  background: var(--surface);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg) var(--spacing-xl);
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: all 0.2s;
}

.close-btn:hover {
  background: var(--surface-variant);
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  padding: var(--spacing-xl);
  overflow-y: auto;
  background: var(--surface);
}

.btn-danger {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  background: linear-gradient(135deg, #ff4d4f, #ff3b30);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: var(--spacing-lg);
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #ff3b30, #ff2d22);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.history-time {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: var(--spacing-sm) 0 var(--spacing-xs);
  font-weight: 500;
}

.history-item {
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--surface-variant);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
}

.history-item:hover {
  background: var(--primary-lightest);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.history-item-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--text-primary);
}

.history-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--spacing-xs);
  font-size: 11px;
  color: var(--text-tertiary);
}

.session-item {
  padding: var(--spacing-lg);
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: var(--spacing-md);
}

.session-item:hover {
  background: #FFF8E1;
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(255, 195, 0, 0.15);
}

.session-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.session-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.session-item-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-color);
  padding: 4px 8px;
  border-radius: 4px;
}

.session-item-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-item .preview {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 768px) {
  #app {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
  }
}

@media (max-width: 480px) {
  .bubble {
    max-width: 85%;
    padding: 10px 14px;
  }
  
  .input-area {
    padding: 10px 12px;
  }
  
  .input-area input {
    padding: 10px 14px;
  }
  
  /* 移动端头部优化 */
  .header {
    padding: 10px 12px;
  }
  
  .header h1 {
    font-size: 16px;
  }
  
  .logo-circle {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  .header-logo {
    gap: 8px;
  }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .logo-circle {
    border: 1.5px solid rgba(255, 255, 255, 0.5);
  }
}

/* 深色模式支持（可选） */
@media (prefers-color-scheme: dark) {
  :root {
    --header-bg-start: #FFA000;
    --header-bg-end: #FF6F00;
    --header-logo-text: #FFCA28;
  }
}

/* 分享菜单样式 */
.share-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1001;
  animation: slideUp 0.3s ease;
}

.share-menu.hidden {
  display: none;
}

.share-menu-content {
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  animation: fadeIn 0.3s ease;
}

.share-menu-content h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.share-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  color: var(--text-primary);
}

.share-option:hover {
  background: #FFF8E1;
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.share-option svg {
  flex-shrink: 0;
}

/* 反馈模态框样式 */
.feedback-modal {
  max-width: 500px;
}

.feedback-hint {
  color: #666;
  font-size: 14px;
  margin-bottom: 16px;
}

.rating-section {
  margin-bottom: 16px;
}

.rating-section label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-weight: 500;
}

.stars {
  display: flex;
  gap: 8px;
  font-size: 28px;
  cursor: pointer;
}

.stars span {
  transition: opacity 0.2s;
  user-select: none;
}

.stars span:hover,
.stars span[style*="opacity: 1"] {
  opacity: 1;
}

.feedback-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.feedback-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary {
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #e5e5e5;
}

/* 动画 */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
