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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: #ededed;
  overscroll-behavior: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- 顶部栏 ---------- */
.chat-header {
  height: 48px;
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 16px;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}
.header-title { font-size: 17px; font-weight: 600; color: #000; }
.header-status {
  position: absolute;
  right: 12px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
}
.header-status.online { color: #07c160; background: rgba(7,193,96,.1); }
.header-status.offline { color: #fa5151; background: rgba(250,81,81,.1); }
.header-status.connecting { color: #fa9d3b; background: rgba(250,157,59,.1); }

/* ---------- 消息列表 ---------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 0;
  -webkit-overflow-scrolling: touch;
}

.empty-tip {
  text-align: center;
  color: #999;
  font-size: 14px;
  margin-top: 40%;
}

/* ---------- 消息行 ---------- */
.msg-row {
  display: flex;
  margin-bottom: 16px;
  animation: fadeIn .2s ease;
}
.msg-mine { flex-direction: row-reverse; }

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

.msg-avatar {
  width: 38px; height: 38px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: #ccc;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-body { max-width: 72%; margin: 0 10px; }
.msg-mine .msg-body { text-align: right; }

.msg-name {
  font-size: 11px;
  color: #999;
  margin-bottom: 3px;
  padding-left: 2px;
}

.msg-bubble {
  display: inline-block;
  padding: 9px 13px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  text-align: left;
  position: relative;
}
.msg-other .msg-bubble {
  background: #fff;
  color: #000;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.msg-mine .msg-bubble {
  background: #95ec69;
  color: #000;
}

.msg-meta {
  font-size: 10px;
  color: #b2b2b2;
  margin-top: 3px;
  padding: 0 2px;
}
.msg-mine .msg-meta { text-align: right; }

/* ---------- 输入区 ---------- */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  padding: 8px 10px;
  background: #f7f7f7;
  border-top: 1px solid #d6d6d6;
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
}

.msg-input {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 15px;
  background: #fff;
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  line-height: 1.4;
}

.send-btn {
  background: #07c160;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 500;
  flex-shrink: 0;
  height: 38px;
}
.send-btn:active { background: #06ad56; }

/* ---------- 新消息提示 ---------- */
.new-msg-tip {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #07c160;
  color: #fff;
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  z-index: 10;
  animation: fadeIn .2s ease;
}