* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #e8eef3;
  height: 100vh;
  overflow: hidden;
}

.chat-app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  position: relative;
}

/* 顶部横幅 */
.chat-top-box {
  flex-shrink: 0;
  text-align: center;
  background: #f4f9ff;
}

.chat-top-img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.chat-top-hint1 {
  padding: 6px 12px 2px;
  font-size: 13px;
  line-height: 1.6;
}

.chat-top-hint2 {
  padding: 0 12px 10px;
  font-size: 13px;
  line-height: 1.6;
}

.chat-top-min-hint {
  color: #333;
}

.chat-top-max-hint {
  color: #3478f6;
  font-weight: 600;
}

/* 消息列表 */
.chat-context-list {
  flex: 1;
  overflow-y: auto;
  background-color: #fff;
  -webkit-overflow-scrolling: touch;
}

.chat-spacer-top {
  height: 10px;
  width: 100%;
}

.chat-spacer-bottom {
  height: 10px;
  width: 100%;
}

.conversation {
  list-style: none;
  padding: 0 12px;
}

/* 客服消息（左侧） */
.chat-left-item {
  margin-bottom: 18px;
}

.chat-left-head {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-time {
  margin-left: 10px;
  font-size: 12px;
  color: #999;
  line-height: 1.4;
}

.chat-time .chat-name {
  color: #000;
}

.chat-left-content {
  padding-left: 50px;
}

.chat-bubble-left {
  display: inline-block;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 0 12px 12px 12px;
  padding: 10px 14px;
  max-width: 100%;
}

.chat-bubble-left p {
  font-size: 15px;
  line-height: 1.7;
  color: #222;
  word-break: break-word;
}

.chat-bubble-left img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 4px;
  cursor: pointer;
  display: block;
}

/* 访客消息（右侧） */
.chat-right-item {
  margin-bottom: 18px;
}

.chat-right-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.chat-right-head .chat-time {
  margin-left: 0;
  margin-right: 10px;
  text-align: right;
}

.chat-avatar-user {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(180deg, #5eb0ea 0%, #3d96d9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-avatar-user svg {
  width: 24px;
  height: 24px;
}

.chat-right-content {
  padding-right: 50px;
  text-align: right;
}

.chat-bubble-right {
  display: inline-block;
  background: #f2f2f2;
  border: none;
  border-radius: 12px 0 12px 12px;
  padding: 10px 14px;
  max-width: 100%;
  text-align: left;
}

.chat-bubble-right p {
  font-size: 15px;
  line-height: 1.7;
  color: #222;
  word-break: break-word;
}

.chat-bubble-right img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 4px;
  cursor: pointer;
  display: block;
}

/* 输入栏 */
.chat-input-bar {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #eee;
  padding: 8px 12px 12px;
  position: relative;
  z-index: 20;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 100px;
  padding: 8px 4px;
  font-family: inherit;
  background: transparent;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #5a9fd4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.icon-btn:hover {
  background: #f0f7fc;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.send-btn {
  color: #3478f6;
}

.icon-btn-emoji {
  color: #6eb5e8;
}

.emoji-panel {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 4px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
  max-height: 220px;
  overflow-y: auto;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  z-index: 30;
}

.emoji-panel.show {
  display: grid;
}

.emoji-panel span {
  font-size: 22px;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  border-radius: 4px;
  user-select: none;
}

.emoji-panel span:hover {
  background: #f0f7fc;
}

.connection-status {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  padding: 4px;
  background: #fff3cd;
  color: #856404;
  transform: translateY(-100%);
  transition: transform 0.3s;
  z-index: 10;
}

.connection-status.show {
  transform: translateY(0);
}

.connection-status.connected {
  background: #d4edda;
  color: #155724;
}

@media (min-width: 481px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dde8f0;
  }
  .chat-app {
    height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  }
}
