:root {
  --primary: #07c160;
  --bg: #ededed;
  --bubble-visitor: #95ec69;
  --bubble-agent: #ffffff;
  --text: #1a1a1a;
  --text-sub: #999;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
}

/* 顶部 */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f7f7f7;
  border-bottom: 1px solid #e0e0e0;
}

.agent-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.agent-name { font-size: 16px; font-weight: 600; }
.agent-status { font-size: 12px; color: var(--text-sub); }
.agent-status.online { color: var(--primary); }

/* 消息区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.loading-more { text-align: center; color: var(--text-sub); font-size: 12px; padding: 6px; }

.msg { display: flex; margin-bottom: 14px; align-items: flex-start; }
.msg.visitor { flex-direction: row-reverse; }
.msg.agent { flex-direction: row; }

.msg .avatar {
  width: 34px; height: 34px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
}
.msg.visitor .avatar { background: #3aa0ff; margin-left: 8px; }
.msg.agent .avatar { background: var(--primary); margin-right: 8px; }

.bubble {
  max-width: 76%;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  background: var(--bubble-agent);
  position: relative;
}
.msg.visitor .bubble { background: var(--bubble-visitor); }

.bubble .quote {
  font-size: 13px;
  color: #666;
  background: rgba(0,0,0,.06);
  padding: 4px 8px;
  border-left: 3px solid #ccc;
  border-radius: 3px;
  margin-bottom: 6px;
}

.bubble img { max-width: 200px; border-radius: 4px; display: block; cursor: zoom-in; }

.bubble .time { font-size: 11px; color: #b3b3b3; margin-top: 4px; text-align: right; }

.typing-hint { text-align: center; color: var(--text-sub); font-size: 12px; padding: 4px; }

/* 引用条 */
.quote-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
  font-size: 13px;
  color: #666;
}
.quote-bar button { border: none; background: none; font-size: 20px; color: #999; cursor: pointer; }

/* 表情面板 */
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
  max-height: 180px;
  overflow-y: auto;
}
.emoji-panel span { font-size: 24px; text-align: center; cursor: pointer; padding: 4px; border-radius: 6px; }
.emoji-panel span:active { background: #e0e0e0; }

/* 输入区 */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px;
  background: #f7f7f7;
  border-top: 1px solid #e0e0e0;
}
.tool-btn { border: none; background: none; font-size: 22px; cursor: pointer; padding: 4px; }
#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  line-height: 1.4;
  padding: 8px;
  border-radius: 6px;
  background: #fff;
  max-height: 96px;
}
.send-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.send-btn:active { opacity: .8; }

/* 图片预览 */
.preview-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 99;
}
.preview-mask img { max-width: 92%; max-height: 92%; border-radius: 6px; }
