* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif; background: #e8e8e8; color: #000; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
textarea, input { font-family: inherit; outline: none; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  background: #ededed;
  position: relative;
}

/* 电脑端美化 */
@media (min-width: 601px) {
  body { background: #d8d8d8; padding: 20px 0; }
  .chat-panel {
    height: calc(100vh - 40px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    overflow: hidden;
  }
}

/* 顶部栏 */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7f7f7;
  border-bottom: 1px solid #d6d6d6;
  padding: 0 12px;
  height: 50px;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; flex: 1; gap: 8px; }
.btn-clear {
  background: #fa5151; color: #fff; border: none; border-radius: 4px;
  padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.header-center { display: flex; align-items: center; gap: 6px; position: relative; }
.header-right { display: flex; align-items: center; flex: 1; justify-content: flex-end; }
.chat-name { font-size: 16px; font-weight: 600; color: #1a1a1a; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ccc; flex-shrink: 0;
}
.conn-dot.online { background: #07C160; }
.conn-text { font-size: 12px; color: #999; white-space: nowrap; }

.btn-admin {
  padding: 5px 20px;
  background: transparent;
  color: #576b95;
  font-size: 14px;
}
.btn-admin.admin-mode { color: #1989fa; font-weight: 600; }

/* 功能下拉面板 */
.func-wrap { position: relative; }
.func-panel {
  position: absolute;
  top: 100%;
  right: -24px;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 3px;
  min-width: 100px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.func-panel-title {
  font-size: 11px;
  color: #999;
  padding: 2px 6px;
  text-align: center;
}
.func-item {
  display: block;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  text-align: center;
  background: transparent;
  width: 100%;
  border: none;
  white-space: nowrap;
}
.func-item:hover { background: rgba(7, 193, 96, 0.1); }

/* 聊天消息中的链接 */
.chat-link {
  color: #576b95;
  text-decoration: underline;
  cursor: pointer;
}

/* 昵称输入框（半宽，放在工具栏） */
.nickname-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
}
.nickname-input-half {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  background: #fff;
  width: 120px;
}
.nickname-input-half:focus { border-color: #07C160; }
.nickname-input-half::placeholder { color: #bbb; }
.nick-edit-btn {
  font-size: 11px;
  font-weight: 600;
  color: #576b95;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  white-space: nowrap;
}

/* 表情面板 */
.emoji-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-panel span {
  font-size: 22px;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.emoji-panel span:hover { background: #f0f0f0; }

/* 拖拽遮罩 */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 193, 96, 0.1);
  border: 2px dashed #07C160;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-overlay-inner {
  text-align: center;
  color: #07C160;
  font-size: 18px;
  font-weight: 600;
}
.drop-overlay-inner p { margin-top: 10px; }

/* 消息列表 */
.msg-list {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg-row { display: flex; gap: 8px; align-items: flex-start; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-avatar {
  width: 38px; height: 38px; border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 600; background: #999;
}
.msg-row.mine .msg-avatar { background: #07C160; }
.msg-body { max-width: 70%; display: flex; flex-direction: column; }
.msg-row.mine .msg-body { align-items: flex-end; }
.msg-meta { font-size: 11px; color: #999; margin-bottom: 3px; padding: 0 4px; }
.msg-meta.admin-name { color: #fa5151; }

/* 管理员昵称七彩变色左往右 */
.admin-nickname {
  background: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #00bfff, #4b0082, #8b00ff, #ff0000, #ff7f00, #ffff00, #00ff00, #00bfff, #4b0082, #8b00ff, #ff0000);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbow-right 8s linear infinite;
  font-weight: 600;
  display: inline-block;
}
@keyframes rainbow-right {
  0% { background-position: 200% 50%; }
  100% { background-position: 0% 50%; }
}
.msg-bubble {
  position: relative;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 15px; line-height: 1.45; word-break: break-word;
  background: #fff; color: #000;
}
.msg-row.mine .msg-bubble { background: #fff; }
.msg-bubble.admin-msg { color: #1989fa; }
.msg-row.mine .msg-bubble.admin-msg { color: #1989fa; }
.msg-bubble::before {
  content: ''; position: absolute; top: 12px; left: -6px;
  border: 6px solid transparent; border-right-color: #fff; border-left: none;
}
.msg-row.mine .msg-bubble::before {
  left: auto; right: -6px;
  border: 6px solid transparent; border-left-color: #fff; border-right: none;
}

/* 图片/视频消息 */
.msg-bubble.media-bubble { padding: 4px; background: transparent; }
.msg-bubble.media-bubble img,
.msg-bubble.media-bubble video {
  max-width: 240px; max-height: 240px; border-radius: 4px; display: block;
}
.msg-bubble.media-bubble::before { display: none; }

.msg-time { text-align: center; font-size: 11px; color: #b2b2b2; margin: 4px 0; }

/* 输入区 */
.chat-input-bar {
  background: #f7f7f7;
  border-top: 1px solid #d6d6d6;
  padding: 8px 12px;
  flex-shrink: 0;
}
.tool-row { display: flex; gap: 2px; margin-bottom: 6px; align-items: center; flex-wrap: wrap; }
.tool-btn {
  padding: 4px 8px;
  color: #576b95;
  display: flex; align-items: center; border-radius: 6px;
}
.tool-btn:hover { background: #e8e8e8; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-input {
  flex: 1;
  border: 1px solid #ddd; border-radius: 6px;
  padding: 8px 10px; font-size: 15px;
  resize: none; max-height: 100px; line-height: 1.4; background: #fff;
}
.btn-send {
  padding: 8px 20px;
  background: #07C160; color: #fff;
  border-radius: 6px; font-size: 14px; white-space: nowrap;
}
.btn-send:active { opacity: 0.8; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-card {
  background: #fff; border-radius: 12px;
  padding: 24px; width: 90%; max-width: 320px;
}
.modal-card h3 { font-size: 17px; text-align: center; margin-bottom: 16px; }
.modal-card input {
  width: 100%;
  border: 1px solid #ddd; border-radius: 8px;
  padding: 10px 12px; font-size: 14px; margin-bottom: 12px;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.btn-primary { background: #07C160; color: #fff; }
.btn-secondary { background: #e8e8e8; color: #333; }
.admin-err { color: #fa5151; font-size: 12px; text-align: center; margin-top: 8px; min-height: 16px; }

.msg-list::-webkit-scrollbar { width: 4px; }
.msg-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* 毛玻璃提示弹窗 */
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 150;
  text-align: center;
  max-width: 260px;
}
.toast p {
  font-size: 14px;
  color: #333;
  margin-bottom: 12px;
  line-height: 1.5;
}
.toast-btn {
  background: rgba(7, 193, 96, 0.85);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 24px;
  font-size: 13px;
  cursor: pointer;
}
.toast-btn:active { opacity: 0.8; }

/* 手机端自适应 */
@media (max-width: 600px) {
  body { background: #ededed; padding: 0; }
  .chat-panel { max-width: 100%; border-radius: 0; box-shadow: none; }
  .chat-header { padding: 0 8px; height: 44px; }
  .chat-name { font-size: 15px; }
  .msg-list { padding: 8px; gap: 10px; }
  .msg-avatar { width: 32px; height: 32px; font-size: 12px; }
  .msg-bubble { padding: 7px 10px; font-size: 14px; }
  .msg-body { max-width: 75%; }
  .chat-input-bar { padding: 6px 8px; }
  .tool-row { gap: 2px; flex-wrap: wrap; }
  .tool-btn { padding: 4px 6px; }
  .tool-btn svg { width: 20px; height: 20px; }
  .nickname-wrap { gap: 3px; }
  .nickname-input-half { font-size: 12px; width: 100px; padding: 4px 8px; }
  .nick-edit-btn { font-size: 10px; padding: 2px 4px; }
  .input-row { gap: 6px; }
  .msg-input { font-size: 14px; padding: 6px 8px; }
  .btn-send { padding: 6px 14px; font-size: 13px; }
  .func-panel { min-width: 90px; }
  .func-item { font-size: 12px; padding: 5px 8px; }
  .btn-admin { padding: 4px 12px; font-size: 13px; }
}

/* 左下角 @提示列表 */
.at-alerts {
  position: fixed;
  left: 10px;
  bottom: 120px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 220px;
}
.at-alert-item {
  background: rgba(255, 81, 81, 0.95);
  color: #fff;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  line-height: 1.4;
}
.at-alert-item:hover { background: rgba(255, 60, 60, 1); }

/* 顶部未读@横幅 */
.at-banner {
  position: absolute;
  top: 56px;
  right: 12px;
  background: rgba(255, 81, 81, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  z-index: 150;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.at-banner-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.at-banner-item {
  background: rgba(255,255,255,0.25);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.at-banner-item:hover { background: rgba(255,255,255,0.4); }
.at-banner-close {
  color: #fff;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}

/* 返回最新消息按钮 */
.btn-back-bottom {
  position: absolute;
  right: 12px;
  bottom: 130px;
  background: rgba(255,255,255,0.95);
  color: #07C160;
  border: 1px solid #07C160;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 90;
}

/* 在线成员下拉列表 */
.members-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 8px;
  min-width: 140px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.members-dropdown::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(255,255,255,0.95);
}
.member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
}
.member-item:hover { background: rgba(7,193,96,0.08); }
.member-avatar {
  width: 28px; height: 28px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600;
  background: #07C160;
  flex-shrink: 0;
}
.member-avatar.admin { background: #fa5151; }
.member-name { font-size: 13px; color: #333; }
