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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f5f5f5;
  overflow: hidden;
}

/* ========== 整体布局 ========== */
.chat-app {
  max-width: 768px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
}

/* ========== 顶部标题栏 ========== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.back-btn {
  color: #576b95;
  text-decoration: none;
  font-size: 20px;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}

.back-btn:hover {
  background: #f0f0f0;
}

.header-title {
  text-align: center;
  flex: 1;
}

.header-name {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

.header-status {
  font-size: 11px;
  color: #07c160;
  margin-top: 2px;
}

.header-extra {
  width: 40px;
}

/* ========== 聊天内容区 ========== */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  -webkit-overflow-scrolling: touch;
}

/* 滚动条美化 */
.chat-body::-webkit-scrollbar {
  width: 4px;
}
.chat-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

/* ========== 消息行 ========== */
.msg-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
}

.msg-row.user {
  justify-content: flex-end;
}

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

/* ========== 头像 ========== */
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  user-select: none;
}

.user-avatar {
  background: #95ec69;
  margin-left: 8px;
}

/* ========== 气泡 ========== */
.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  position: relative;
}

.system-bubble {
  background: #fff;
  margin-left: 8px;
  color: #1a1a1a;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.user-bubble {
  background: #95ec69;
  margin-right: 8px;
  color: #1a1a1a;
}

/* ========== 问题列表 ========== */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.q-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: #f7f7f7;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  color: #576b95;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.5;
}

.q-btn:hover {
  background: #e8f0fe;
  border-color: #c2d8fc;
}

/* ========== 附件下载框 ========== */
.attachment-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  background: #f7f7f7;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
}

.attachment-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-size: 14px;
  color: #1a1a1a;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-type {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

.attachment-download {
  padding: 6px 14px;
  background: #07c160;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.2s;
}

.attachment-download:hover {
  background: #06ad56;
}

/* ========== 底部关键词栏 ========== */
.chat-footer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e5e5e5;
  padding: 10px 15px 15px;
}

.footer-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 8px;
}

.keyword-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.keyword-bar::-webkit-scrollbar {
  height: 3px;
}
.keyword-bar::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

.kw-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.kw-btn:hover {
  background: #07c160;
  color: #fff;
  border-color: #07c160;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .chat-app {
    max-width: 100%;
  }
  .msg-bubble {
    max-width: 82%;
  }
  /* 关键词按钮换行 */
  .keyword-bar {
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .kw-btn {
    white-space: normal;
    text-align: center;
    line-height: 1.4;
  }
}
