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

:root {
  --green: #07C160;
  --green-dark: #06AD56;
  --green-light: #E8F8EE;
  --bg: #EDEDED;
  --white: #FFFFFF;
  --text: #333333;
  --text-secondary: #888888;
  --text-light: #BBBBBB;
  --border: #E0E0E0;
  --bubble-user: #95EC69;
  --bubble-ai: #FFFFFF;
}

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

.page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ===== 搜索首页 ===== */
.search-page {
  background: var(--white);
}

.search-home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.logo-text {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 2px;
}

/* 搜索栏 */
.search-bar {
  width: 100%;
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

#searchInput {
  flex: 1;
  height: 48px;
  padding: 0 20px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 16px;
  outline: none;
  background: var(--white);
  transition: border-color 0.2s;
}

#searchInput:focus {
  border-color: var(--green);
}

.search-submit {
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 24px;
  background: var(--green);
  color: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}

.search-submit:active {
  background: var(--green-dark);
}

/* 懂你模式标记 */
.mode-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--green-dark);
  margin-bottom: 16px;
}

/* 首页人格画像按钮 */
.profile-btn {
  display: inline-block;
  padding: 8px 20px;
  border: 1.5px solid var(--green);
  border-radius: 20px;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 32px;
  transition: all 0.15s;
}

.profile-btn:active {
  background: var(--green);
  color: white;
}

/* 对话页画像按钮 */
.context-link-btn {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: white;
  color: var(--green-dark);
  font-size: 11px;
  text-decoration: none;
  margin-left: 4px;
  vertical-align: middle;
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(7, 193, 96, 0); }
}

/* 推荐搜索 */
.suggestions {
  width: 100%;
}

.suggestions-label {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 12px;
}

.suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion:active {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
}

/* 首页底部 */
.home-footer {
  position: absolute;
  bottom: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
}

.home-footer a {
  color: var(--green);
  text-decoration: none;
}

.footer-note {
  margin-top: 4px;
}

/* ===== 对话页面 ===== */
.chat-page {
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--green);
  color: white;
  flex-shrink: 0;
}

.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  margin-right: 8px;
}

.chat-title {
  flex: 1;
  font-size: 17px;
  font-weight: 500;
}

.chat-mode {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.9;
}

.chat-mode .mode-dot {
  width: 6px;
  height: 6px;
  background: white;
}

/* 上下文提示条 */
.context-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--green-light);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.context-avatar {
  font-size: 28px;
}

.context-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--green-dark);
}

.context-detail {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* 消息区域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* 消息气泡 */
.message {
  display: flex;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease;
}

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

.message-user {
  justify-content: flex-end;
}

.message-ai {
  justify-content: flex-start;
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-line;
}

.bubble-user {
  background: var(--bubble-user);
  color: var(--text);
  border-top-right-radius: 4px;
}

.bubble-ai {
  background: var(--bubble-ai);
  color: var(--text);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* 打字光标 */
.typing::after {
  content: '▌';
  animation: blink 0.7s infinite;
  color: var(--green);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 数据来源（消息内嵌） */
.sources-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.source-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--green-light);
  color: var(--green-dark);
}

/* 操作按钮（消息下方） */
.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 16px;
  padding-left: 4px;
}

.msg-action-btn {
  padding: 6px 14px;
  border: 1px solid var(--green);
  border-radius: 16px;
  background: var(--white);
  color: var(--green-dark);
  font-size: 13px;
  cursor: pointer;
}

.msg-action-btn:active {
  background: var(--green-light);
}

/* Loading */
.loading-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.loading-bubble span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: bounce 1.2s ease-in-out infinite;
}

.loading-bubble span:nth-child(2) { animation-delay: 0.15s; }
.loading-bubble span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* 底部输入栏 */
.chat-input-bar {
  padding: 10px 16px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-bar form {
  display: flex;
  gap: 10px;
}

#chatInput {
  flex: 1;
  height: 40px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  outline: none;
  background: var(--bg);
}

#chatInput:focus {
  border-color: var(--green);
  background: var(--white);
}

.chat-submit {
  height: 40px;
  padding: 0 20px;
  border: none;
  border-radius: 20px;
  background: var(--green);
  color: white;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-submit:active {
  background: var(--green-dark);
}

/* ===== 响应式 ===== */
@media (min-width: 640px) {
  .chat-page {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .search-home {
    padding-top: 80px;
    justify-content: flex-start;
  }
}
