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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== 登录页 ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-box h1 { font-size: 20px; margin-bottom: 6px; }
.login-sub { color: #6b7280; font-size: 13px; margin-bottom: 24px; }
.login-hint { color: #9ca3af; font-size: 12px; margin-top: 16px; text-align: center; }
.login-link-btn {
  width: 100%;
  margin-top: 10px;
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 13px;
  cursor: pointer;
}
.login-link-btn:hover { text-decoration: underline; }
.login-register-msg {
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}
.login-register-msg.ok { color: #16a34a; }
.login-register-msg.error { color: #dc2626; }

.login-box label { display: block; font-size: 13px; color: #374151; margin-bottom: 4px; margin-top: 12px; }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}
.login-box button[type="submit"] {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}
.login-box button[type="submit"]:hover { background: #1d4ed8; }

.error-msg { color: #dc2626; font-size: 13px; margin-top: 8px; }

/* ===== 顶部栏 ===== */
.top-bar {
  height: 48px;
  background: #1e3a5f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.logo { font-weight: 600; font-size: 15px; }
.user-info { margin-left: 16px; font-size: 13px; opacity: 0.85; }
.top-right { display: flex; gap: 8px; }

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
}
.btn-sm:hover { background: #1d4ed8; }
.btn-sm.has-pending {
  background: #dc2626;
}
.btn-sm.has-pending:hover {
  background: #b91c1c;
}
.btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }

/* ===== 三栏布局 ===== */
.main-layout {
  display: flex;
  height: calc(100vh - 48px);
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  min-height: 0;
}

.panel-bots { width: 240px; flex-shrink: 0; }
.panel-convs { width: 300px; flex-shrink: 0; }
.panel-chat { flex: 1; min-height: 0; }
.panel-quick { width: 280px; flex-shrink: 0; border-right: none; }
.mobile-back-btn,
.mobile-bottom-nav {
  display: none;
}

.panel-header {
  height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.panel-header > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scroll-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.empty-tip {
  padding: 24px 16px;
  color: #9ca3af;
  text-align: center;
  font-size: 13px;
}

/* ===== Bot 列表项 ===== */
.bot-item {
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.15s;
}
.bot-item:hover { background: #f9fafb; }
.bot-item.active { background: #eff6ff; border-left: 3px solid #2563eb; }
.bot-item.disabled { opacity: 0.55; }

.bot-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.bot-username { font-size: 12px; color: #6b7280; }
.bot-agent { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.bot-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.bot-status { font-size: 11px; }
.bot-status.on { color: #16a34a; }
.bot-status.off { color: #9ca3af; }

/* ===== 会话列表项 ===== */
.conv-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
  flex-shrink: 0;
}

.conv-filter {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.conv-filter:hover { background: #f3f4f6; }
.conv-filter.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.conv-item {
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.conv-item:hover { background: #f9fafb; }
.conv-item.active { background: #eff6ff; border-left: 3px solid #2563eb; }
.conv-item.pinned { background: #fffbeb; }
.conv-item.pinned.active { background: #eff6ff; }

.conv-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.conv-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-pin {
  color: #f59e0b;
  font-size: 12px;
  flex-shrink: 0;
}
.conv-username { font-size: 12px; color: #6b7280; }
.conv-preview {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: #9ca3af;
}
.conv-assignee {
  color: #6b7280;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-status {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  flex-shrink: 0;
}
.conv-status.open { background: #dcfce7; color: #166534; }
.conv-status.pending { background: #fef3c7; color: #92400e; }
.conv-status.closed { background: #e5e7eb; color: #4b5563; }

.conv-category-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  flex-shrink: 0;
}

.conv-mention-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
  flex-shrink: 0;
}

.conv-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.conv-action-btn,
.conv-status-select {
  font-size: 11px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  color: #374151;
  cursor: pointer;
}
.conv-action-btn:hover,
.conv-status-select:hover { background: #f3f4f6; }

.category-create-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.category-create-row input[type="text"] { flex: 1; }
.category-create-row input[type="color"] {
  width: 42px;
  height: 36px;
  padding: 2px;
}

.btn-full {
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: #2563eb;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-full:hover { background: #1d4ed8; }

.category-manage-list {
  margin-top: 14px;
  border-top: 1px solid #e5e7eb;
  max-height: 260px;
  overflow-y: auto;
}

.category-manage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}

.category-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-manage-name {
  flex: 1;
  font-size: 13px;
}

/* 未读红点 */
.unread-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* ===== 聊天区域 ===== */
.pinned-message-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #fde68a;
  background: #fffbeb;
  flex-shrink: 0;
}

.pinned-message-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pinned-message-label {
  color: #92400e;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.pinned-message-list {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pinned-message-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pinned-message-text {
  flex: 1;
  min-width: 0;
  color: #374151;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pinned-message-btn {
  border: 1px solid #fcd34d;
  background: #fff;
  color: #92400e;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}
.pinned-message-btn:hover { background: #fef3c7; }
.pinned-message-btn.danger {
  color: #dc2626;
  border-color: #fecaca;
}

.messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  background: #f9fafb;
}

.messages-inner {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  min-height: 100%;
}

.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  flex-shrink: 0;
}
.msg-bubble.in {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
}
.msg-bubble.out {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
}

.messages-anchor {
  height: 1px;
  flex-shrink: 0;
}
.msg-time {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 4px;
}

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-mention-alert {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.msg-bot-mention {
  color: #1d4ed8;
  font-weight: 700;
  background: #dbeafe;
  border-radius: 4px;
  padding: 0 3px;
}

.msg-sender-name {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  margin-bottom: 4px;
}

.msg-media-img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}
.msg-gif {
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.msg-video {
  display: block;
  width: min(320px, 70vw);
  aspect-ratio: 16 / 9;
  max-height: 320px;
  height: auto;
  border-radius: 8px;
  background: #000;
  margin-bottom: 4px;
  object-fit: contain;
}

.msg-video-note {
  display: block;
  width: min(240px, 60vw);
  height: min(240px, 60vw);
  border-radius: 50%;
  background: #000;
  margin-bottom: 4px;
  object-fit: cover;
}

.msg-video-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: min(320px, 70vw);
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #eff6ff;
  margin-bottom: 4px;
}

.msg-video-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: 0 0 auto;
}

.msg-video-info {
  min-width: 0;
}

.msg-video-title {
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 2px;
}

.msg-video-meta {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.msg-video-download {
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
}

.msg-video-download:hover {
  text-decoration: underline;
}

.msg-video-unavailable {
  font-size: 12px;
  line-height: 1.4;
  color: #b45309;
}

.msg-video-wrap {
  margin-top: 6px;
}

.msg-video-play-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  color: #1d4ed8;
  cursor: pointer;
  font-size: 13px;
}

.msg-video-play-btn:hover {
  background: #eff6ff;
}

.msg-video-play-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.msg-video-loading {
  padding: 8px 0;
  font-size: 12px;
  color: #64748b;
}

.msg-video-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-video-inline .msg-video-play-btn {
  background: transparent;
  border-color: #dbeafe;
}

.msg-sticker {
  width: 120px;
  height: 120px;
  object-fit: contain;
}
.msg-sticker-placeholder {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
}

.msg-audio {
  display: block;
  width: 260px;
  min-height: 40px;
  margin-bottom: 4px;
}

.voice-label {
  font-size: 12px;
  opacity: 0.75;
}

.load-more-tip {
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding: 8px 0 12px;
  flex-shrink: 0;
}

.load-more-tip.loading {
  color: #2563eb;
}

/* ===== 快捷回复面板 ===== */
.quick-tabs {
  display: flex;
  gap: 4px;
}

.quick-tab {
  padding: 4px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: #6b7280;
}
.quick-tab.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}
.quick-import-btn {
  display: inline-flex;
  align-items: center;
}

.quick-body {
  padding: 8px;
}

.quick-folder {
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.quick-folder-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #f9fafb;
  font-size: 13px;
  cursor: default;
}

.quick-folder-toggle {
  cursor: pointer;
  font-size: 10px;
  color: #6b7280;
  width: 14px;
}

.quick-folder-name {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-folder-count {
  font-size: 11px;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 999px;
}

.quick-folder-body {
  display: none;
  padding: 6px;
}
.quick-folder.open .quick-folder-body {
  display: block;
}

.quick-empty {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 10px;
}

.quick-item {
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
}
.quick-item:hover { background: #eff6ff; }

.quick-item-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.quick-item-badge,
.inline-quick-badge {
  display: inline-block;
  width: fit-content;
  margin-bottom: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
}

.quick-item-preview {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
  max-height: 40px;
  overflow: hidden;
  margin-bottom: 6px;
}

.quick-item-actions, .quick-img-actions {
  display: flex;
  gap: 4px;
}

.qi-btn {
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.qi-btn:hover { background: #f3f4f6; }
.qi-btn.qi-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.qi-btn.qi-primary:hover { background: #1d4ed8; }
.qi-btn.qi-danger { color: #dc2626; border-color: #fecaca; }
.qi-btn.qi-danger:hover { background: #fef2f2; }

.img-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.quick-img-item {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  background: #f9fafb;
}
.quick-img-item img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.quick-img-name {
  font-size: 11px;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-img-actions {
  padding: 4px 6px 6px;
}

.modal-small { width: 340px; }

.delete-bot-desc {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 12px;
}

.btn-danger {
  background: #dc2626 !important;
  color: #fff !important;
  border: none;
}
.btn-danger:hover { background: #b91c1c !important; }

/* ===== 手机端布局 ===== */
@media (max-width: 768px) {
  body {
    height: 100dvh;
    overflow: hidden;
  }

  .top-bar {
    height: 44px;
    padding: 0 10px;
  }

  .logo {
    font-size: 14px;
  }

  .user-info {
    display: none;
  }

  .top-right {
    gap: 6px;
  }

  .top-right .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
  }

  .main-layout {
    height: calc(100dvh - 44px - 58px);
    display: block;
    position: relative;
    overflow: hidden;
  }

  .panel {
    display: none;
    width: 100% !important;
    height: 100%;
    border-right: none;
    min-width: 0;
  }

  body[data-mobile-view="bots"] .panel-bots,
  body[data-mobile-view="conversations"] .panel-convs,
  body[data-mobile-view="chat"] .panel-chat,
  body[data-mobile-view="quick"] .panel-quick {
    display: flex;
  }

  .panel-header {
    height: 46px;
    padding: 0 10px;
    gap: 8px;
  }

  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  .panel-bots .mobile-back-btn {
    display: none;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid #e5e7eb;
    background: #fff;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-nav-item {
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
  }

  .mobile-nav-item.active {
    color: #2563eb;
    font-weight: 700;
    background: #eff6ff;
  }

  .scroll-list {
    -webkit-overflow-scrolling: touch;
  }

  .conv-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 10px;
  }

  .conv-filter {
    flex: 0 0 auto;
  }

  .bot-item,
  .conv-item {
    padding: 14px 12px;
  }

  .conv-actions {
    flex-wrap: wrap;
  }

  .conv-status-select {
    max-width: 132px;
  }

  .panel-chat {
    min-height: 0;
  }

  .pinned-message-bar {
    padding: 7px 10px;
  }

  .pinned-message-item {
    gap: 4px;
  }

  .pinned-message-btn {
    padding: 3px 6px;
    font-size: 11px;
  }

  .messages-area {
    padding: 12px 10px;
  }

  .messages-inner {
    gap: 8px;
  }

  .msg-bubble {
    max-width: 86%;
    padding: 9px 12px;
  }

  .msg-media-img,
  .msg-video,
  .msg-video-note {
    max-width: min(260px, 68vw);
    max-height: 220px;
  }

  .msg-video-note {
    width: min(220px, 58vw);
    height: min(220px, 58vw);
  }

  .msg-audio {
    width: min(260px, 70vw);
  }

  .msg-actions {
    opacity: 1;
    top: -10px;
    right: -4px;
  }

  .msg-bubble.out .msg-actions {
    left: -4px;
  }

  .msg-action-trigger {
    height: 28px;
    min-width: 46px;
  }

  .msg-action-menu {
    top: 30px;
    min-width: 112px;
  }

  .msg-action-item {
    padding: 9px 10px;
    font-size: 13px;
  }

  .reply-bar {
    flex-shrink: 0;
    padding: 8px 10px;
  }

  .reply-bar-row {
    align-items: flex-end;
    gap: 8px;
  }

  .reply-tools {
    flex-direction: row;
  }

  .inline-quick-panel {
    left: 10px;
    width: calc(100% - 20px);
    max-height: min(420px, 52dvh);
  }

  .inline-quick-item {
    align-items: flex-start;
  }

  .inline-quick-actions {
    flex-direction: column;
  }

  .inline-quick-actions button {
    padding: 7px 10px;
  }

  #reply-input {
    min-height: 40px;
    max-height: 96px;
  }

  .btn-send {
    height: 40px;
    padding: 0 12px;
  }

  .quick-body {
    padding-bottom: 8px;
  }

  .modal-content,
  .modal-content.modal-wide,
  .modal-content.modal-small {
    width: calc(100vw - 28px);
    max-width: none;
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
  }
}
.modal-small input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.msg-emoji {
  font-size: 48px;
  line-height: 1.2;
}

.reply-bar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.reply-bar-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.quote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f0f9ff;
  border-left: 3px solid #2563eb;
  border-radius: 6px;
}

.quote-bar-inner {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}

.quote-bar-tag {
  color: #2563eb;
  font-weight: 600;
  margin-right: 6px;
}

.quote-bar-author {
  color: #6b7280;
  margin-right: 4px;
}

.quote-bar-text {
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-bar-cancel {
  border: none;
  background: transparent;
  font-size: 18px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.quote-bar-cancel:hover { color: #dc2626; }

.pending-image-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}
.pending-image-bar img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: zoom-in;
}
.pending-image-info {
  flex: 1;
  min-width: 0;
}
.pending-image-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}
.pending-image-desc {
  margin-top: 2px;
  font-size: 12px;
  color: #6b7280;
}
.pending-image-preview-modal {
  position: relative;
  max-width: min(92vw, 900px);
  max-height: 90vh;
}
.pending-image-preview-modal img {
  max-width: 100%;
  max-height: 90vh;
  display: block;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.preview-close {
  position: absolute;
  right: -12px;
  top: -12px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 30px;
}

.msg-quote {
  padding: 6px 8px;
  margin-bottom: 6px;
  border-left: 3px solid #93c5fd;
  background: rgba(0,0,0,0.04);
  border-radius: 4px;
  font-size: 12px;
}
.msg-quote.clickable {
  cursor: pointer;
}
.msg-quote.clickable:hover {
  background: rgba(37, 99, 235, 0.10);
}
.msg-bubble.out .msg-quote {
  border-left-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.15);
}
.msg-bubble.out .msg-quote.clickable:hover {
  background: rgba(255,255,255,0.25);
}
.msg-quote-author {
  font-weight: 600;
  margin-right: 4px;
  opacity: 0.85;
}
.msg-quote-text {
  opacity: 0.9;
  word-break: break-word;
}

.msg-bubble {
  position: relative;
}
.msg-actions {
  position: absolute;
  top: -6px;
  right: -6px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}
.msg-bubble:hover .msg-actions,
.msg-actions.active { opacity: 1; }
.msg-bubble.out .msg-actions {
  left: -6px;
  right: auto;
}

.msg-action-trigger {
  min-width: 40px;
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}
.msg-action-trigger:hover {
  color: #2563eb;
  border-color: #93c5fd;
}
.msg-action-menu {
  position: absolute;
  top: 26px;
  right: 0;
  display: none;
  min-width: 96px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}
.msg-bubble.out .msg-action-menu {
  left: 0;
  right: auto;
}
.msg-actions:hover .msg-action-menu,
.msg-actions:focus-within .msg-action-menu,
.msg-actions.active .msg-action-menu {
  display: block;
}
.msg-action-item {
  width: 100%;
  display: block;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #374151;
  font-size: 12px;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.msg-action-item:hover {
  background: #f3f4f6;
  color: #2563eb;
}
.msg-bubble.pinned-message {
  box-shadow: 0 0 0 2px #fbbf24 inset;
}
.msg-bubble.pinned-flash {
  animation: pinnedFlash 1.2s ease;
}

@keyframes pinnedFlash {
  0%, 100% { box-shadow: 0 0 0 2px #fbbf24 inset; }
  45% { box-shadow: 0 0 0 5px #f59e0b inset; }
}
.msg-bubble.out .msg-action-trigger {
  background: #fff;
  border-color: #dbeafe;
  color: #2563eb;
}
.msg-action-item.danger {
  color: #dc2626;
}
.msg-action-item.danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.reply-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  background: #f9fafb;
}
.tool-btn:hover { background: #eff6ff; }

.inline-quick-panel {
  position: absolute;
  left: 12px;
  bottom: calc(100% - 4px);
  width: min(420px, calc(100% - 24px));
  max-height: 360px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  z-index: 20;
  overflow: hidden;
}

.inline-quick-head {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid #f3f4f6;
  font-weight: 700;
  font-size: 13px;
}

.inline-quick-head button {
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
}

.inline-quick-list {
  overflow-y: auto;
  padding: 6px;
}

.inline-quick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
}

.inline-quick-item:hover {
  background: #f9fafb;
}

.inline-quick-main {
  flex: 1;
  min-width: 0;
}

.inline-quick-title {
  font-weight: 700;
  font-size: 13px;
  color: #111827;
  margin-bottom: 2px;
}

.inline-quick-preview {
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-quick-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.inline-quick-actions button {
  border: 1px solid #dbeafe;
  border-radius: 6px;
  background: #eff6ff;
  color: #2563eb;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}

.inline-quick-actions button:hover {
  background: #dbeafe;
}

.inline-quick-empty {
  padding: 18px 12px;
  color: #9ca3af;
  text-align: center;
  font-size: 13px;
}

.reply-bar textarea {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 20px;
  min-height: 42px;
  max-height: 122px;
  overflow-y: hidden;
}
.reply-bar textarea:disabled { background: #f3f4f6; }

.btn-send {
  padding: 10px 20px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
.btn-send:hover:not(:disabled) { background: #1d4ed8; }
.btn-send:disabled { background: #93c5fd; cursor: not-allowed; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-wide { width: 600px; }
.modal-content h3 { margin-bottom: 16px; font-size: 16px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; margin-bottom: 4px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  background: #2563eb;
  color: #fff;
}
.modal-actions .btn-outline {
  background: #fff;
  border: 1px solid #d1d5db;
  color: #374151;
}
.expiry-warning-modal {
  border-top: 4px solid #f59e0b;
}
.expiry-warning-text {
  line-height: 1.6;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
}

.forward-msg-preview {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

#forward-target-search {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
}

.forward-target-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 12px;
}

.forward-target-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.forward-target-item:hover {
  background: #f1f5f9;
}

.forward-target-name {
  font-size: 14px;
  color: #1e293b;
  word-break: break-word;
}

.forward-target-empty {
  padding: 16px 10px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

.msg-document {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #334155;
  font-size: 13px;
  word-break: break-word;
}

.agent-create {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.register-notify-settings {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
}
.settings-title {
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 8px;
}
.settings-split {
  height: 1px;
  background: #bfdbfe;
  margin: 10px 0;
}
.notify-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.notify-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
}
.notify-row input[type="text"] {
  min-width: 160px;
  flex: 1;
  padding: 7px 9px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 12px;
}
.notify-row button {
  padding: 7px 10px;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  background: #fff;
  color: #1d4ed8;
  cursor: pointer;
  font-size: 12px;
}
.notify-row button:hover { background: #dbeafe; }
.notify-help {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}
.login-contact-tip {
  margin-top: 6px;
  font-size: 13px;
  color: #2563eb;
  word-break: break-word;
}
.agent-create input {
  flex: 1;
  min-width: 100px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}
.agent-create button {
  padding: 8px 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.agent-table th, .agent-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}
.agent-table th { background: #f9fafb; font-weight: 600; }
.agent-table button {
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.agent-table button:hover { background: #f3f4f6; }
.muted-text {
  color: #9ca3af;
  font-size: 12px;
}
.agent-time-window {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.agent-time-window input[type="date"] {
  padding: 3px 4px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
}
.agent-time-window input[type="date"] {
  width: 128px;
}
.agent-time-window button {
  white-space: nowrap;
}
