* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

/* 手机App容器 */
.app-container {
  width: 380px;
  height: 700px;
  background: linear-gradient(180deg, #1e1e2e 0%, #2d2d44 100%);
  border-radius: 40px;
  box-shadow: 
    0 25px 50px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.1),
    inset 0 1px 0 rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 顶部状态栏模拟 */
.app-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 28px;
  background: #000;
  border-radius: 0 0 20px 20px;
  z-index: 10;
}

header {
  background: transparent;
  color: white;
  padding: 45px 20px 15px;
  text-align: center;
  position: relative;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  background: linear-gradient(90deg, #00d4ff, #7b2cbf, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.theme-btn {
  position: absolute;
  right: 15px;
  top: 45px;
  background: rgba(255,255,255,0.1);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.theme-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: rotate(30deg);
}

/* ===== 主题变量 ===== */
:root {
  --bg-primary: linear-gradient(180deg, #1e1e2e 0%, #2d2d44 100%);
  --bg-body: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --text-primary: #e0e0e0;
  --text-secondary: rgba(255,255,255,0.4);
  --bubble-bg: rgba(255,255,255,0.08);
  --bubble-border: rgba(255,255,255,0.1);
  --input-bg: rgba(255,255,255,0.08);
  --input-border: rgba(255,255,255,0.1);
}

/* 浅色主题 */
[data-theme="light"] {
  --bg-primary: linear-gradient(180deg, #ffffff 0%, #f5f7fa 100%);
  --bg-body: linear-gradient(135deg, #e0e5ec 0%, #f5f7fa 100%);
  --text-primary: #333;
  --text-secondary: rgba(0,0,0,0.4);
  --bubble-bg: rgba(0,0,0,0.05);
  --bubble-border: rgba(0,0,0,0.1);
  --input-bg: rgba(0,0,0,0.05);
  --input-border: rgba(0,0,0,0.1);
}

[data-theme="light"] .app-container {
  background: var(--bg-primary);
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
}

[data-theme="light"] body {
  background: var(--bg-body);
}

[data-theme="light"] .content {
  background: var(--bubble-bg);
  color: var(--text-primary);
  border-color: var(--bubble-border);
}

[data-theme="light"] #userInput {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}

[data-theme="light"] #userInput::placeholder {
  color: var(--text-secondary);
}

[data-theme="light"] .theme-btn {
  background: rgba(0,0,0,0.05);
  color: #333;
}

[data-theme="light"] .input-area {
  background: rgba(255,255,255,0.8);
  border-top-color: rgba(0,0,0,0.05);
}

/* 粉色主题 */
[data-theme="pink"] {
  --bg-primary: linear-gradient(180deg, #ffe4ec 0%, #ffb6c1 100%);
  --bg-body: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fdfbfb 100%);
}

[data-theme="pink"] .app-container {
  background: var(--bg-primary);
}

[data-theme="pink"] body {
  background: var(--bg-body);
}

[data-theme="pink"] header h1 {
  background: linear-gradient(90deg, #ff6b95, #c44569, #ff6b6b);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="pink"] .content {
  background: rgba(255,255,255,0.6);
  color: #333;
  border-color: rgba(255,107,149,0.2);
}

[data-theme="pink"] .message.user .content {
  background: linear-gradient(135deg, #ff6b95 0%, #c44569 100%);
}

[data-theme="pink"] .avatar {
  background: linear-gradient(135deg, #ff6b95 0%, #c44569 100%);
}

[data-theme="pink"] #sendBtn {
  background: linear-gradient(135deg, #ff6b95 0%, #c44569 100%);
}

[data-theme="pink"] #userInput {
  background: rgba(255,255,255,0.6);
  color: #333;
  border-color: rgba(255,107,149,0.3);
}

[data-theme="pink"] .input-area {
  background: rgba(255,255,255,0.5);
}

[data-theme="pink"] .theme-btn {
  background: rgba(255,255,255,0.5);
  color: #c44569;
}

/* 绿色主题 */
[data-theme="green"] {
  --bg-primary: linear-gradient(180deg, #1a3a2a 0%, #2d5a3d 100%);
  --bg-body: linear-gradient(135deg, #134e5e 0%, #71b280 100%);
}

[data-theme="green"] .app-container {
  background: var(--bg-primary);
}

[data-theme="green"] body {
  background: var(--bg-body);
}

[data-theme="green"] header h1 {
  background: linear-gradient(90deg, #71b280, #00d4aa, #71b280);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="green"] .avatar {
  background: linear-gradient(135deg, #00d4aa 0%, #71b280 100%);
  box-shadow: 0 4px 15px rgba(0, 212, 170, 0.4);
}

[data-theme="green"] .message.user .content {
  background: linear-gradient(135deg, #00d4aa 0%, #71b280 100%);
}

[data-theme="green"] #sendBtn {
  background: linear-gradient(135deg, #00d4aa 0%, #71b280 100%);
  box-shadow: 0 4px 15px rgba(0, 212, 170, 0.4);
}

/* 聊天区域 */
.chat-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: transparent;
}

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  animation: messageIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes messageIn {
  from { 
    opacity: 0; 
    transform: translateY(20px) scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.message.user .avatar {
  background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
}

.content {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  padding: 12px 16px;
  border-radius: 20px;
  border-top-left-radius: 6px;
  max-width: 78%;
  color: #e0e0e0;
  line-height: 1.6;
  font-size: 0.92rem;
  word-break: break-word;
  border: 1px solid rgba(255,255,255,0.1);
}

.message.user .content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-top-left-radius: 20px;
  border-top-right-radius: 6px;
  border: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 输入区域 */
.input-area {
  display: flex;
  gap: 10px;
  padding: 15px 20px 30px;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,0.05);
}

#userInput {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 25px;
  font-size: 0.95rem;
  outline: none;
  background: rgba(255,255,255,0.08);
  color: white;
  transition: all 0.3s;
}

#userInput::placeholder {
  color: rgba(255,255,255,0.4);
}

#userInput:focus {
  border-color: #667eea;
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

#sendBtn {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#sendBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#sendBtn:active {
  transform: scale(0.95);
}

/* 弹窗 */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

.modal-content {
  background: linear-gradient(180deg, #2d2d44 0%, #1e1e2e 100%);
  width: 100%;
  max-height: 85%;
  border-radius: 25px 25px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  border-top: 1px solid rgba(255,255,255,0.1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h3 {
  font-size: 1.1rem;
  color: white;
  font-weight: 600;
}

.modal-header button {
  background: rgba(255,255,255,0.1);
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #aaa;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-header button:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.9rem;
  color: #e0e0e0;
}

/* 加载动画 */
.loading {
  display: flex;
  gap: 6px;
  padding: 15px;
  align-items: center;
}

.loading span {
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  animation: pulse 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 pulse {
  0%, 80%, 100% { 
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% { 
    transform: scale(1);
    opacity: 1;
  }
}

/* 滚动条美化 */
.chat-container::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 4px;
}

.chat-container::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

/* 响应式 */
@media (max-width: 420px) {
  body {
    padding: 0;
  }
  .app-container {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }
  .app-container::before {
    display: none;
  }
  header {
    padding-top: 20px;
  }
}
