﻿* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Microsoft YaHei", Arial, sans-serif;
  color: #1f2937;
  background: #f4f7fb;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.admin-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #edf4ff 0%, #f8fafc 52%, #eef2ff 100%);
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  color: white;
  background: linear-gradient(180deg, #2f66f5 0%, #1f3f95 100%);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 42px;
}

.brand-icon,
.service-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 16px;
  font-weight: 800;
  color: #2f66f5;
  background: white;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  font-size: 12px;
  opacity: .75;
}

.menu {
  display: grid;
  gap: 12px;
}

.menu-item {
  padding: 14px 16px;
  text-align: left;
  color: rgba(255, 255, 255, .78);
  border-radius: 14px;
  background: transparent;
}

.menu-item.active,
.menu-item:hover {
  color: white;
  background: rgba(255, 255, 255, .16);
}

.panel {
  padding: 30px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.admin-header h1,
.chat-header h1 {
  margin: 0;
  font-size: 30px;
}

.admin-header p,
.chat-header p,
.card-title span,
.chat-top p {
  margin: 8px 0 0;
  color: #6b7280;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-name {
  padding: 10px 14px;
  color: #475569;
  border-radius: 999px;
  background: white;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}

.circle-add {
  width: 56px;
  height: 56px;
  border-radius: 20px;
  font-size: 34px;
  line-height: 1;
  color: white;
  background: #2f66f5;
  box-shadow: 0 14px 28px rgba(47, 102, 245, .3);
}

.circle-add:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stats article,
.room-list-card,
.chat-card,
.modal-card,
.mobile-chat {
  border: 1px solid rgba(148, 163, 184, .18);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(14px);
}

.stats article {
  padding: 18px;
  border-radius: 22px;
}

.stats span {
  display: block;
  color: #64748b;
}

.stats strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 22px;
  min-height: 650px;
}

.room-list-card,
.chat-card {
  border-radius: 28px;
}

.room-list-card {
  padding: 22px;
  min-width: 0;
}

.card-title {
  margin-bottom: 18px;
}

.card-title h2,
.chat-top h2 {
  margin: 0;
  font-size: 20px;
}

.room-list {
  display: grid;
  gap: 12px;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.room-list.empty {
  padding: 32px 16px;
  text-align: center;
  color: #94a3b8;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
}

.room-item {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 16px;
  text-align: left;
  border-radius: 18px;
  color: #334155;
  background: #f8fafc;
}

.room-item.active,
.room-item:hover {
  color: white;
  background: #2f66f5;
}

.room-item strong,
.room-item span {
  display: block;
}

.room-item span {
  margin-top: 6px;
  font-size: 13px;
  opacity: .72;
}
.chat-card.room-switching { animation: panelEnter .28s cubic-bezier(.22, 1, .36, 1); }
.chat-card.room-loading { opacity: .82; }
@keyframes panelEnter { from { opacity: .35; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.room-item-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}
.room-item-meta {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  white-space: nowrap;
}

.chat-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  overflow: hidden;
}

.chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.ghost-btn {
  padding: 10px 16px;
  color: #2f66f5;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
}

.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.visitor-list {
  display: flex;
  gap: 10px;
  min-height: 62px;
  padding: 12px 24px;
  overflow-x: auto;
  border-bottom: 1px solid #e5e7eb;
}

.visitor-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  color: #475569;
  background: #f1f5f9;
  white-space: nowrap;
}

.visitor-chip img,
.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  overflow-y: auto;
}

.admin-messages {
  min-height: 420px;
  max-height: calc(100vh - 330px);
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 78%;
}

.message-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-bubble {
  padding: 12px 14px;
  border-radius: 18px;
  color: #334155;
  background: #f1f5f9;
}

.message-row.mine .message-bubble {
  color: white;
  background: #2f66f5;
}

.message-meta {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  opacity: .72;
}

.message-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 18px 24px 24px;
  border-top: 1px solid #e5e7eb;
}

/* 客服端聊天输入栏（含表情+附件按钮）改用 flex，避免任何按钮被 1fr 拉伸 */
.chat-card .message-form {
  display: flex;
  align-items: flex-end;
}
.chat-card .message-form textarea {
  flex: 1 1 auto;
}
.chat-card .message-form .file-btn,
.chat-card .message-form button[type="submit"] {
  flex: 0 0 auto;
}

.message-form input,
.message-form textarea,
.modal-card input {
  width: 100%;
  border: 1px solid #dbe3ef;
  outline: 0;
  background: white;
}

.message-form input,
.message-form textarea {
  min-width: 0;
  padding: 13px 16px;
  border-radius: 18px;
}

.message-form textarea {
  min-height: 46px;
  max-height: 118px;
  resize: none;
  line-height: 1.45;
  overflow-y: auto;
}

.message-form button,
.modal-card button {
  color: white;
  background: #2f66f5;
}

.message-form button {
  padding: 0 22px;
  border-radius: 999px;
}

.message-form button:disabled,
.message-form input:disabled,
.message-form textarea:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.chat-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #dbeafe 0%, #eef2ff 40%, #f8fafc 100%);
}

.mobile-chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(100%, 460px);
  height: min(780px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 32px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px;
  color: white;
  background: linear-gradient(135deg, #2f66f5, #1d4ed8);
}

.chat-header h1 {
  font-size: 22px;
}

.chat-header p {
  color: rgba(255, 255, 255, .78);
}

.visitor-messages {
  background: #f8fafc;
}

.visitor-form {
  background: white;
  display: flex;
  align-items: flex-end;
}
.visitor-form textarea {
  flex: 1 1 auto;
}
.visitor-form .file-btn,
.visitor-form button[type="submit"] {
  flex: 0 0 auto;
}

.modal-mask {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, .42);
}

.modal-mask.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 390px);
  padding: 28px;
  border-radius: 28px;
}

.modal-card h2 {
  margin: 0 0 10px;
}

.modal-card label {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: #475569;
  font-size: 14px;
}

.modal-card small {
  display: block;
  margin-top: 12px;
  color: #94a3b8;
  line-height: 1.5;
}

.modal-card p {
  margin: 0 0 20px;
  color: #64748b;
  line-height: 1.6;
}

.modal-card input {
  padding: 14px 16px;
  border-radius: 14px;
}

.modal-card button {
  width: 100%;
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 14px;
}

.error-text {
  display: block;
  min-height: 20px;
  margin-top: 10px;
  color: #dc2626;
  font-size: 13px;
}

.service-preview {
  width: 72px;
  height: 72px;
  margin-top: 12px;
  border-radius: 22px;
  object-fit: cover;
  border: 1px solid #e5e7eb;
}

.image-avatar {
  object-fit: cover;
  padding: 0;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.room-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.tab-btn,
.file-btn,
.danger-btn {
  padding: 10px 14px;
  border-radius: 999px;
}

.tab-btn {
  color: #64748b;
  background: #f1f5f9;
}

.tab-btn.active {
  color: white;
  background: #2f66f5;
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.danger-btn {
  color: #dc2626;
  border: 1px solid #fecaca;
  background: #fef2f2;
}

.danger-btn:disabled,
.file-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.file-btn {
  color: white;
  background: #0f172a;
}

.chat-image {
  display: block;
  max-width: min(260px, 60vw);
  max-height: 260px;
  margin-top: 8px;
  border-radius: 14px;
  object-fit: cover;
}
.chat-video { display: block; width: min(420px, 72vw); max-width: 100%; max-height: 360px; border-radius: 12px; background: #0f172a; }

.file-link {
  display: grid;
  gap: 4px;
  min-width: 190px;
  margin-top: 8px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, .24);
  border: 1px solid rgba(148, 163, 184, .3);
}

.file-link span,
.file-link small {
  opacity: .75;
  font-size: 12px;
}

.message-link {
  color: #2563eb;
  text-decoration: underline;
  word-break: break-all;
}

.message-row.mine .message-link {
  color: #dbeafe;
}

.delete-message {
  display: block;
  margin-top: 8px;
  padding: 4px 8px;
  color: #ef4444;
  border-radius: 999px;
  background: rgba(239, 68, 68, .1);
}

.message-bubble p {
  margin: 0 0 8px;
}

@media (max-width: 760px) {
  body.admin-mobile {
    background: #f4f7fb;
  }

  .admin-mobile .admin-shell {
    display: block;
    min-height: 100vh;
  }

  .admin-mobile .sidebar {
    display: none;
  }

  .admin-mobile .panel {
    padding: 12px;
  }

  .admin-mobile .admin-header {
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: flex-start;
    gap: 12px;
    margin: -12px -12px 14px;
    padding: 14px 12px;
    background: rgba(244, 247, 251, .96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #e5e7eb;
  }

  .admin-mobile .admin-header h1 {
    font-size: 22px;
  }

  .admin-mobile .admin-header p {
    display: none;
  }

  .admin-mobile .admin-actions {
    justify-content: flex-end;
    gap: 8px;
  }

  .admin-mobile .admin-name {
    display: none;
  }

  .admin-mobile .circle-add {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    font-size: 28px;
  }

  .admin-mobile .ghost-btn,
  .admin-mobile .danger-btn,
  .admin-mobile .tab-btn,
  .admin-mobile .file-btn {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 13px;
  }

  .admin-mobile .stats {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .admin-mobile .stats article {
    min-width: 118px;
    padding: 13px;
    border-radius: 18px;
  }

  .admin-mobile .stats strong {
    font-size: 24px;
  }

  .admin-mobile .workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: auto;
  }

  .admin-mobile .room-list-card,
  .admin-mobile .chat-card {
    border-radius: 20px;
  }

  .admin-mobile .room-list-card {
    padding: 16px;
    max-height: 310px;
    overflow: hidden;
  }

  .admin-mobile .room-list {
    max-height: 210px;
    overflow-y: auto;
  }

  .admin-mobile .room-item {
    padding: 13px;
    border-radius: 15px;
  }

  .admin-mobile .chat-card {
    min-height: 560px;
  }

  .admin-mobile .chat-top {
    display: grid;
    gap: 12px;
    padding: 16px;
  }

  .admin-mobile .chat-top h2 {
    font-size: 18px;
  }

  .admin-mobile .chat-top p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  .admin-mobile .chat-actions {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .admin-mobile .visitor-list {
    min-height: 54px;
    padding: 10px 16px;
  }

  .admin-mobile .messages {
    padding: 16px;
  }

  .admin-mobile .admin-messages {
    min-height: 360px;
    max-height: 52vh;
  }

  .admin-mobile .message-row {
    max-width: 92%;
  }

  .admin-mobile .message-bubble {
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
  }

  .admin-mobile .message-form {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 12px;
  }

  .admin-mobile .message-form input,
  .admin-mobile .message-form textarea {
    min-width: 0;
    padding: 11px 13px;
  }

  .admin-mobile .message-form button[type="submit"] {
    padding: 0 14px;
  }

  .admin-mobile .chat-image {
    max-width: 68vw;
    max-height: 220px;
  }

  .admin-mobile .modal-card {
    padding: 22px;
    border-radius: 22px;
  }
}

/* ============ 涓婚鍙橀噺 + 澶氬 UI 閰嶈壊 ============ */
:root {
  --accent: #2f66f5;
  --accent-deep: #1d4ed8;
  --page-bg: linear-gradient(135deg, #edf4ff 0%, #f8fafc 52%, #eef2ff 100%);
  --card-bg: rgba(255, 255, 255, .9);
  --card-border: rgba(148, 163, 184, .18);
  --bubble-bg: #f1f5f9;
  --bubble-text: #334155;
  --room-bg: #f8fafc;
  --text-main: #1f2937;
}

body { color: var(--text-main); }
.admin-body { background: var(--page-bg); }
.sidebar { background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%); }
.brand-icon, .service-avatar { color: var(--accent); }
.circle-add { background: var(--accent); box-shadow: 0 14px 28px color-mix(in srgb, var(--accent) 35%, transparent); }
.stats article, .room-list-card, .chat-card, .modal-card, .mobile-chat { background: var(--card-bg); border-color: var(--card-border); }
.room-item { background: var(--room-bg); color: var(--bubble-text); }
.room-item.active, .room-item:hover,
.tab-btn.active,
.message-row.mine .message-bubble,
.message-form button, .modal-card button { background: var(--accent); color: #fff; }
.chat-header { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); }
.ghost-btn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 42%, #fff); background: color-mix(in srgb, var(--accent) 8%, #fff); }
.message-bubble { background: var(--bubble-bg); color: var(--bubble-text); }
.message-link { color: var(--accent); }

/* 鏆楀榛?*/
body.theme-dark {
  --page-bg: #0f172a;
  --card-bg: rgba(30, 41, 59, .92);
  --card-border: rgba(148, 163, 184, .22);
  --bubble-bg: #334155;
  --bubble-text: #e2e8f0;
  --room-bg: #1e293b;
  --text-main: #e2e8f0;
}
body.theme-dark .chat-body { background: #0f172a; }
body.theme-dark .visitor-messages { background: #1e293b; }
body.theme-dark .visitor-form { background: #0f172a; }
body.theme-dark .message-form input,
body.theme-dark .message-form textarea,
body.theme-dark .modal-card input { background: #1e293b; color: #e2e8f0; border-color: #334155; }
body.theme-dark .visitor-chip,
body.theme-dark .admin-name { background: #1e293b; color: #cbd5e1; }
body.theme-dark .card-title span,
body.theme-dark .chat-top p,
body.theme-dark .stats span,
body.theme-dark .admin-header p { color: #94a3b8; }

/* 妯辫姳绮?/ 妫灄缁?/ 鏃ヨ惤姗?/ 娣辨捣闈?*/
body.theme-sakura { --accent: #e94f8a; --accent-deep: #c2266b; --page-bg: linear-gradient(135deg, #fff0f6, #fde8f0 60%, #ffeef7); }
body.theme-forest { --accent: #2f9e60; --accent-deep: #1d7a45; --page-bg: linear-gradient(135deg, #eafaf0, #f2fbf5 60%, #e6f7ec); }
body.theme-sunset { --accent: #f4732f; --accent-deep: #d1541a; --page-bg: linear-gradient(135deg, #fff3ec, #fde9dc 60%, #fff1e8); }
body.theme-ocean  { --accent: #0ea5b7; --accent-deep: #0b7d8c; --page-bg: linear-gradient(135deg, #e6fbfd, #effcfd 60%, #e0f7fa); }

/* 液态玻璃：半透明层、柔和高光和背景模糊，电脑/手机共用。 */
body.theme-liquid {
  --accent: #536dfe;
  --accent-deep: #304ffe;
  --page-bg: linear-gradient(135deg, #e7edff 0%, #f8fbff 48%, #e4f7ff 100%);
  --card-bg: rgba(255, 255, 255, .48);
  --card-border: rgba(255, 255, 255, .72);
  --bubble-bg: rgba(255, 255, 255, .58);
  --bubble-text: #26324d;
  --room-bg: rgba(255, 255, 255, .38);
  --text-main: #202b45;
}
body.theme-liquid .admin-shell,
body.theme-liquid .panel,
body.theme-liquid .phone-app { background: var(--page-bg); }
body.theme-liquid .sidebar,
body.theme-liquid .phone-topbar,
body.theme-liquid .room-tabs-mobile,
body.theme-liquid .chat-topbar,
body.theme-liquid .phone-inputbar {
  background: rgba(255, 255, 255, .34);
  border-color: rgba(255, 255, 255, .58);
  box-shadow: 0 12px 38px rgba(77, 91, 150, .12), inset 0 1px rgba(255, 255, 255, .78);
  backdrop-filter: blur(24px) saturate(145%);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
}
body.theme-liquid .sidebar { background: linear-gradient(145deg, rgba(75, 96, 210, .74), rgba(92, 63, 180, .58)); }
body.theme-liquid .stats article,
body.theme-liquid .room-list-card,
body.theme-liquid .chat-card,
body.theme-liquid .modal-card,
body.theme-liquid .mobile-chat,
body.theme-liquid .favorite-item,
body.theme-liquid .note-message-card,
body.theme-liquid .forward-card {
  background: var(--card-bg);
  border-color: var(--card-border);
  box-shadow: 0 22px 55px rgba(75, 91, 145, .14), inset 0 1px rgba(255, 255, 255, .86);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}
body.theme-liquid .room-item,
body.theme-liquid .conv-item,
body.theme-liquid .phone-messages,
body.theme-liquid .conv-list { background: rgba(255, 255, 255, .24); }
body.theme-liquid .room-item.active,
body.theme-liquid .room-item:hover,
body.theme-liquid .tab-btn.active,
body.theme-liquid .message-row.mine .message-bubble,
body.theme-liquid .message-form button,
body.theme-liquid .modal-card button,
body.theme-liquid .seg-btn.active,
body.theme-liquid .phone-inputbar #sendBtn { background: linear-gradient(135deg, #6578ff, #536dfe); box-shadow: 0 10px 24px rgba(83, 109, 254, .26); }
body.theme-liquid input,
body.theme-liquid textarea,
body.theme-liquid select,
body.theme-liquid .phone-inputbar textarea,
body.theme-liquid .phone-inputbar .file-btn,
body.theme-liquid .plus-cell .plus-ico { background: rgba(255, 255, 255, .48); border-color: rgba(255, 255, 255, .75); }
body.theme-liquid .modal-mask { background: rgba(63, 76, 125, .2); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
body.theme-liquid .message-bubble { box-shadow: inset 0 1px rgba(255, 255, 255, .62), 0 8px 22px rgba(74, 89, 145, .08); }
body.theme-liquid .chat-header { background: linear-gradient(135deg, rgba(83, 109, 254, .82), rgba(48, 79, 254, .68)); }
body.theme-liquid .tabbar-item.active { color: var(--accent-deep); }

/* ============ 澶嶅埗 / 鍒犻櫎 鎿嶄綔鎸夐挳 ============ */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  opacity: .55;
  transition: opacity .2s ease;
}
.message-bubble:hover .msg-actions { opacity: 1; }
.copy-message, .quote-message, .delete-message {
  display: inline-block;
  margin: 0;
  padding: 3px 11px;
  font-size: 12px;
  line-height: 1.7;
  border-radius: 999px;
  transition: transform .12s ease, background .2s ease;
}
.copy-message { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.copy-message:active, .quote-message:active, .delete-message:active { transform: scale(.9); }
.message-row.mine .msg-actions { justify-content: flex-end; }
.message-row.mine .copy-message,
.message-row.mine .quote-message,
.message-row.mine .delete-message { color: #fff; background: rgba(255, 255, 255, .22); }

/* 绯荤粺璁剧疆锛氬紑鍏宠 */
.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}
.switch-row input { width: auto; }

/* ============ 涓濇粦鍔ㄧ敾 ============ */
.messages { scroll-behavior: auto; -webkit-overflow-scrolling: touch; }
.message-row.msg-in { animation: msgIn .3s cubic-bezier(.22, 1, .36, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
button { transition: transform .12s ease, background .2s ease, box-shadow .25s ease, color .2s ease; }
button:active:not(:disabled) { transform: scale(.95); }
.room-item, .visitor-chip, .stats article { transition: transform .2s ease, box-shadow .25s ease, background .2s ease; }
.room-item:hover { transform: translateY(-2px); }
.room-item-preview, .room-item-meta { transition: color .2s ease, opacity .2s ease; }
.stats article:hover { transform: translateY(-3px); box-shadow: 0 22px 55px rgba(15, 23, 42, .12); }
.circle-add:hover:not(:disabled) { transform: rotate(90deg) scale(1.05); }
.ghost-btn:hover:not(:disabled), .file-btn:hover:not(:disabled), .danger-btn:hover:not(:disabled) { transform: translateY(-1px); }
.visitor-chip:hover { transform: translateY(-2px); }
.chat-image { transition: transform .25s ease; }
.chat-image:hover { transform: scale(1.03); }
.modal-mask:not(.hidden) { animation: maskIn .22s ease; }
.modal-card { animation: cardPop .32s cubic-bezier(.22, 1.2, .36, 1); }
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardPop { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }

/* ============ 绉诲姩绔祦鐣呬紭鍖栵細鍘绘帀鏄傝吹鐨勬ā绯婂眰锛屾彁楂樻粴鍔ㄥ抚鐜?============ */
@media (max-width: 760px) {
  .stats article, .room-list-card, .chat-card, .modal-card, .mobile-chat {
    backdrop-filter: none;
    background: #fff;
  }
  body.theme-dark .stats article,
  body.theme-dark .room-list-card,
  body.theme-dark .chat-card,
  body.theme-dark .modal-card,
  body.theme-dark .mobile-chat { background: #1e293b; }
  .message-row { animation-duration: .2s; }
  .stats article:hover, .room-item:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============ 鏂版秷鎭孩鐐广€佸娉ㄥ悕銆佺瑷€鎸夐挳 ============ */
.room-item {
  position: relative;
  padding-right: 58px;
}

.room-name {
  cursor: text;
  user-select: text;
}

.unread-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  background: #ef4444;
  box-shadow: 0 8px 18px rgba(239, 68, 68, .35);
}

.visitor-chip.muted {
  background: #fff7ed;
  color: #9a3412;
}

.visitor-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: 4px;
}

.mini-btn {
  padding: 4px 8px;
  border-radius: 999px;
  color: #2f66f5;
  background: #dbeafe;
  font-size: 12px;
}

.visitor-chip.muted .mini-btn {
  color: #9a3412;
  background: #ffedd5;
}

/* ============ 骞虫澘 / 鎶樺彔灞忛€傞厤 ============ */
@media (min-width: 761px) and (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 88px 1fr;
  }

  .sidebar {
    padding: 22px 14px;
  }

  .brand {
    justify-content: center;
    margin-bottom: 24px;
  }

  .brand div:last-child,
  .menu-item:not(.active)::after {
    display: none;
  }

  .menu-item {
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
  }

  .panel {
    padding: 22px;
  }

  .admin-header {
    align-items: flex-start;
    gap: 14px;
  }

  .admin-header h1 {
    font-size: 26px;
  }

  .stats {
    gap: 12px;
  }

  .workspace {
    grid-template-columns: minmax(280px, 34vw) 1fr;
    gap: 16px;
    min-height: calc(100vh - 210px);
  }

  .room-list-card,
  .chat-card {
    border-radius: 22px;
  }

  .room-list-card {
    padding: 18px;
  }

  .chat-top {
    display: grid;
    align-items: start;
    padding: 18px;
  }

  .chat-actions {
    justify-content: flex-start;
  }

  .visitor-list {
    padding: 10px 18px;
  }

  .messages {
    padding: 18px;
  }

  .admin-messages {
    min-height: 420px;
    max-height: calc(100vh - 360px);
  }

  .message-row {
    max-width: 86%;
  }

  .mobile-chat {
    width: min(100%, 720px);
    height: min(860px, calc(100vh - 32px));
    border-radius: 30px;
  }

  .chat-body {
    padding: 16px;
  }

  .chat-header {
    padding: 20px 24px;
  }

  .visitor-messages {
    padding: 22px;
  }

  .visitor-form {
    padding: 16px 20px 20px;
  }

  .visitor-form input,
  .visitor-form textarea {
    min-height: 46px;
  }
}

@media (max-width: 560px) {
  .chat-body {
    padding: 0;
    place-items: stretch;
  }

  .mobile-chat {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    border-radius: 0;
  }

  .chat-header {
    padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 18px;
  }

  .visitor-messages {
    padding: 16px 12px;
  }

  .visitor-form {
    gap: 8px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .visitor-form button {
    padding: 0 14px;
  }

  .message-row {
    max-width: 92%;
  }
}

/* ============ 鍚庡彴鑱婂ぉ鍖哄幓澶х櫧鍧楋細娑堟伅鍖轰笌鍥炲鍖哄垎灞?============ */
.chat-card {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.admin-messages {
  min-height: 0;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

.message-form {
  align-items: center;
  background: #ffffff;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .04);
}

.admin-mobile .admin-messages {
  min-height: 260px;
  max-height: 48vh;
}

@media (min-width: 761px) and (max-width: 1180px) {
  .admin-messages {
    min-height: 0;
    max-height: none;
  }
}

body.theme-dark .admin-messages {
  background: #111827;
  border-color: #334155;
}

body.theme-dark .message-form {
  background: #0f172a;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .22);
}

/* ============ 寮曠敤娑堟伅锛圦Q/寰俊寮忥級 ============ */
.quote-block {
  display: grid;
  gap: 3px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border-left: 3px solid color-mix(in srgb, var(--accent) 65%, #94a3b8);
  border-radius: 10px;
  color: #64748b;
  background: rgba(255, 255, 255, .65);
  max-width: 100%;
}

.quote-block strong {
  font-size: 12px;
  color: #475569;
}

.quote-block span {
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row.mine .quote-block {
  color: rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .18);
  border-left-color: rgba(255, 255, 255, .75);
}

.message-row.mine .quote-block strong {
  color: #fff;
}

.quote-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.quote-preview.hidden {
  display: none;
}

.quote-preview div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.quote-preview strong {
  color: #334155;
  font-size: 13px;
}

.quote-preview span {
  color: #64748b;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-cancel {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #64748b;
  background: #e2e8f0;
  font-size: 18px;
  line-height: 1;
}

.quote-message {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}

.message-row.mine .quote-message {
  color: #fff;
  background: rgba(255, 255, 255, .22);
}

body.theme-dark .quote-block {
  color: #cbd5e1;
  background: rgba(15, 23, 42, .5);
}

body.theme-dark .quote-block strong,
body.theme-dark .quote-preview strong {
  color: #e2e8f0;
}

body.theme-dark .quote-preview {
  background: #111827;
  border-color: #334155;
}

body.theme-dark .quote-preview span {
  color: #94a3b8;
}

body.theme-dark .quote-cancel {
  color: #cbd5e1;
  background: #334155;
}


/* ============ admin extra panels & cards ============ */
@media (min-width: 761px) {
  .workspace {
    min-height: calc(100vh - 235px);
  }

  .chat-card {
    height: calc(100vh - 235px);
    min-height: 520px;
  }

  .admin-messages {
    min-height: 0 !important;
    max-height: none !important;
    background: #f3f6fb;
  }

  .message-form {
    padding: 12px 18px 16px;
  }

  .message-form textarea {
    height: 46px;
  }
}

.message-form textarea::placeholder {
  color: #94a3b8;
}

/* ============ 瑕嗙洊淇锛氱數鑴戠涓嶅啀璁╄亰澶╁崱鐗囨拺鍑哄法澶х┖鐧?============ */
@media (min-width: 761px) {
  .workspace {
    min-height: 0 !important;
    align-items: start;
  }

  .chat-card {
    height: auto !important;
    min-height: 0 !important;
    background: #f8fafc;
  }

  .chat-top,
  .visitor-list,
  .message-form,
  .quote-preview {
    background-color: #fff;
  }

  .admin-messages {
    min-height: 220px !important;
    max-height: 55vh !important;
    background: #f3f6fb !important;
  }

  .admin-messages:empty::before {
    content: "鏆傛棤娑堟伅锛岄€夋嫨鑱婂ぉ瀹ゅ悗寮€濮嬫帴寰?;
    margin: auto;
    color: #94a3b8;
    font-size: 14px;
  }
}

body.theme-dark .chat-card {
  background: #111827;
}

body.theme-dark .chat-top,
body.theme-dark .visitor-list,
body.theme-dark .message-form,
body.theme-dark .quote-preview {
  background-color: #0f172a;
}

/* ============ 鏈€缁堣鐩栵細鐢佃剳绔亰澶╁尯鍚冩弧鍓╀綑绌洪棿锛屼絾涓嶅啀鏄埡鐪肩櫧鍧?============ */
@media (min-width: 761px) {
  .workspace {
    min-height: calc(100vh - 235px) !important;
    align-items: stretch !important;
  }

  .chat-card {
    height: calc(100vh - 235px) !important;
    min-height: 560px !important;
    display: grid !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    background: #f8fafc !important;
  }

  .admin-messages {
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow-y: auto !important;
    background: #f3f6fb !important;
  }

  .message-form {
    flex-shrink: 0;
  }
}

/* ============ 鎭㈠鍙戦€?闄勪欢鎸夐挳鍦嗘鼎楂樺害 ============ */
.message-form button,
.message-form .file-btn {
  min-height: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px !important;
  line-height: 1;
  white-space: nowrap;
}

.message-form button[type="submit"] {
  min-width: 72px;
}

@media (max-width: 760px) {
  .message-form button,
  .message-form .file-btn {
    min-height: 42px;
    height: 42px;
  }
}

.menu-link {
  display: block;
  text-decoration: none;
}

.admin-toolbar,
.god-top-actions,
.god-form,
.god-admin-item,
.god-room-item,
.favorite-item,
.forward-card,
.note-message-card {
  display: grid;
  gap: 12px;
}

.admin-toolbar {
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.admin-toolbar input,
.god-form input,
.god-form select,
.god-form textarea,
.god-admin-item input,
.god-admin-item select,
.god-admin-item textarea,
.note-card-editor input,
.note-card-editor textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #dbe3f0;
  border-radius: 14px;
  background: #fff;
}

.god-shell {
  display: grid;
  gap: 22px;
  width: min(1380px, calc(100% - 40px));
  margin: 32px auto;
}

.god-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 22px;
}

.god-grid-bottom {
  grid-template-columns: 1fr 360px;
}

.god-card,
.god-header-card,
.favorites-card {
  padding: 24px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 28px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}

.god-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.god-admin-list,
.god-room-list,
.favorites-list {
  display: grid;
  gap: 14px;
  max-height: 70vh;
  overflow: auto;
}

.god-admin-item,
.god-room-item,
.favorite-item {
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #f8fafc;
}

.god-admin-item-top,
.god-room-top,
.god-admin-meta,
.god-room-meta,
.favorite-tools,
.message-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.god-tip-list {
  margin: 0;
  padding-left: 20px;
  color: #475569;
  display: grid;
  gap: 10px;
}

.message-tools button {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2f66f5;
}

.message-selected {
  outline: 2px solid #60a5fa;
}

.forward-card,
.note-message-card {
  padding: 14px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #dbeafe;
}

.note-message-card {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #ffffff 0%, #f7f7ff 100%);
}

.forward-card-items {
  display: grid;
  gap: 8px;
}

.forward-line {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
}

.note-title {
  font-weight: 700;
  color: #334155;
}

.note-content {
  color: #475569;
  line-height: 1.6;
}

.visitor-card {
  background: #fffef7;
  border-color: #fde68a;
}

.visitor-note-card {
  background: #f7fcff;
  border-color: #bae6fd;
}

@media (max-width: 980px) {
  .god-grid,
  .god-grid-bottom {
    grid-template-columns: 1fr;
  }

  .god-header-card {
    display: grid;
    gap: 16px;
  }
}

.favorites-card {
  width: min(960px, calc(100vw - 32px));
  max-height: 86vh;
  overflow: auto;
}

.note-card-editor {
  width: min(720px, calc(100vw - 32px));
}

.god-form label,
.god-admin-item label,
.god-room-item label,
.note-card-editor label {
  display: grid;
  gap: 8px;
}

.god-form span,
.god-admin-item span,
.god-room-item span,
.note-card-editor span {
  color: #475569;
  font-size: 13px;
}

.favorite-item small,
.god-admin-meta span,
.god-room-meta span {
  color: #64748b;
  font-size: 12px;
}

.bundle-card {
  border-left: 4px solid #60a5fa;
}

.single-card {
  border-left: 4px solid #34d399;
}

.message-tools {
  margin-top: 10px;
}

.message-tools button:hover {
  filter: brightness(.98);
}

.favorite-item .message-tools,
.forward-card-items,
.note-message-card {
  max-width: 100%;
}

.note-message-card .note-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.forward-line span {
  color: #475569;
  word-break: break-word;
}

.visitor-tools {
  margin-top: 10px;
}

.god-body .modal-mask.hidden,
.admin-body .modal-mask.hidden {
  display: none;
}

.god-body .modal-mask,
.admin-body .modal-mask {
  align-items: center;
  justify-content: center;
}

@media (max-width: 760px) {
  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  .favorites-card,
  .note-card-editor {
    width: calc(100vw - 20px);
  }
}


.favorite-item strong {
  font-size: 15px;
  color: #0f172a;
}

.favorite-item > div {
  color: #334155;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.favorite-tools {
  justify-content: flex-end;
}

.forward-card strong,
.note-message-card strong {
  display: block;
  font-size: 13px;
  letter-spacing: .02em;
  color: #475569;
}

.forward-card .forward-line b {
  color: #0f172a;
}

.note-message-card .note-title {
  margin-top: 2px;
  font-size: 15px;
}

.note-message-card .note-content {
  margin-top: 4px;
}

body.theme-dark .favorite-item,
body.theme-dark .god-admin-item,
body.theme-dark .god-room-item,
body.theme-dark .forward-card,
body.theme-dark .note-message-card,
body.theme-dark .forward-line {
  background: #0f172a;
  border-color: #334155;
}

body.theme-dark .favorite-item strong,
body.theme-dark .forward-card .forward-line b,
body.theme-dark .note-title {
  color: #e2e8f0;
}

body.theme-dark .favorite-item > div,
body.theme-dark .forward-line span,
body.theme-dark .note-content,
body.theme-dark .god-admin-meta span,
body.theme-dark .god-room-meta span,
body.theme-dark .favorite-item small {
  color: #94a3b8;
}



.room-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .14);
}

.room-item.active .room-unread-dot {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .18);
}


.visitor-chip-detail {
  height: auto;
  align-items: flex-start;
  padding: 8px 12px 8px 6px;
}

.visitor-chip-text {
  display: grid;
  gap: 2px;
}

.visitor-chip-text strong {
  font-size: 13px;
  color: #334155;
}

.visitor-chip-text small {
  font-size: 11px;
  color: #64748b;
}

.message-toolbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.toolbox-trigger {
  width: 24px;
  height: 24px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  background: #eff6ff;
  color: #2563eb;
}

.message-toolbox .message-tools {
  display: none;
  margin-top: 0;
}

.message-toolbox.open .message-tools {
  display: inline-flex;
}


.visitor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.visitor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.visitor-row .visitor-chip {
  flex: 1;
  min-width: 0;
}

.visitor-row .visitor-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitor-ip {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #64748b;
  font-family: 'Consolas', 'SFMono-Regular', monospace;
  text-align: right;
}

.visitor-chip-detail,
.visitor-chip-text {
  display: contents;
}


.room-item-top strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-item-top .room-unread-dot {
  margin-left: 8px;
}


.visitor-strip {
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.visitor-toggle {
  margin: 12px 24px 0;
}

.visitor-list.hidden {
  display: none !important;
}

.visitor-empty {
  padding: 12px 24px 18px;
  color: #64748b;
  font-size: 13px;
}

/* ============================================================
   新增：微信风格笔记卡片 / 表情面板 / 未读角标 / 在线圆点
   ============================================================ */

/* 微信风格笔记卡片 */
.wx-note-card {
  width: 240px;
  max-width: 72vw;
  padding: 0 !important;
  border-radius: 8px !important;
  overflow: hidden;
  background: #fff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.wx-note-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
}
.wx-note-icon { font-size: 18px; }
.wx-note-head strong {
  font-size: 15px;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wx-note-body {
  padding: 0 14px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #4b5563;
  max-height: 120px;
  overflow: hidden;
  word-break: break-word;
}
.wx-note-foot {
  padding: 8px 14px;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  color: #9ca3af;
}
body.theme-dark .wx-note-card { background: #1e232b !important; border-color: #2a2f38 !important; }
body.theme-dark .wx-note-head strong { color: #e5e7eb; }
body.theme-dark .wx-note-body { color: #b6bdc9; }
body.theme-dark .wx-note-foot { border-top-color: #2a2f38; color: #7c8595; }

/* 表情面板（PC + 访客 + 手机共用） */
.emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
}
.emoji-panel.hidden { display: none; }
.emoji-panel span {
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 5px;
  border-radius: 8px;
  user-select: none;
}
.emoji-panel span:hover { background: #f1f5f9; }
body.theme-dark .emoji-panel { background: #1e232b; border-color: #2a2f38; }
body.theme-dark .emoji-panel span:hover { background: #2a2f38; }

/* 未读消息数字角标（PC 房间项） */
.room-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  margin-left: 8px;
  flex: 0 0 auto;
}
.room-item.active .room-unread-badge { background: #fff; color: #2f66f5; }

/* 访客在线圆点 */
.visitor-presence.online { color: #16a34a; }
.visitor-presence.away { color: #f59e0b; }
.visitor-presence.offline { color: #94a3b8; }
.presence-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  background: #94a3b8;
}
.presence-dot.online { background: #16a34a; }
.presence-dot.away { background: #f59e0b; }

/* 世界大厅房间项高亮 */
.room-item.hall-room, .conv-item.hall-room { position: relative; }
.hall-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #f59e0b;
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}

/* 回收站操作条 */
.recycle-actions {
  margin: 10px 0 4px;
  display: flex;
  justify-content: flex-end;
}
.recycle-actions.hidden { display: none; }
.visitor-ban-btn { margin-left: 6px; }

/* 弹窗内头像预览：限制尺寸，避免原图撑爆弹窗 */
.service-avatar-preview {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f1f5f9;
  margin: 4px 0 8px;
}
body.theme-dark .service-avatar-preview { border-color: #334155; background: #1e293b; }


body.theme-dark .visitor-strip {
  background: #0f172a;
  border-color: #334155;
}


.stats-clickable {
  cursor: pointer;
}

.stats-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}

.visitor-modal-card {
  width: min(680px, calc(100vw - 24px));
}

.visitor-modal-top {
  align-items: center;
}

.visitor-modal-top h2 {
  margin: 0;
}

.visitor-modal-list {
  max-height: 60vh;
  overflow-y: auto;
  padding-top: 8px;
}


.visitor-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.visitor-mute-btn {
  padding: 6px 10px;
  min-height: auto;
  font-size: 12px;
}


.visitor-mute-countdown {
  font-size: 12px;
  color: #dc2626;
  white-space: nowrap;
}

.visitor-unmute-btn {
  padding: 6px 10px;
  min-height: auto;
  font-size: 12px;
}


.room-unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .14);
}

.room-item.active .room-unread-badge {
  color: #2f66f5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.18);
}

.visitor-presence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #64748b;
}

.visitor-presence::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.visitor-presence.online::before { background: #22c55e; }
.visitor-presence.away::before { background: #f59e0b; }
.visitor-presence.offline::before { background: #94a3b8; }

.message-status {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  font-weight: 700;
}

.message-status.sent { color: #94a3b8; }
.message-status.delivered { color: #94a3b8; }
.message-status.read { color: #3b82f6; }

/* DND 开关激活态 */
.ghost-btn.active{background:var(--accent,#2f66f5);color:#fff;border-color:var(--accent,#2f66f5);}

/* ============ 文件站 / 快捷消息 / 公告 / 评价 ============ */
.primary-btn { border: none; border-radius: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer; background: var(--accent, #2f66f5); color: #fff; }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; }
.modal-msg { min-height: 18px; margin-top: 8px; font-size: 13px; color: var(--accent, #2f66f5); }
.file-station-card, .quick-msg-card, .announce-edit-card, .reviews-card { width: min(560px, 92vw); max-height: 82vh; overflow-y: auto; }

/* 文件站 */
.fs-upload { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.fs-progress { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 140px; }
.fs-progress-bar { height: 8px; border-radius: 6px; background: var(--accent, #2f66f5); width: 0; transition: width .2s ease; flex: 1; }
.fs-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.fs-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--accent, #2f66f5) 16%, #e5e7eb); border-radius: 10px; }
.fs-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; flex: none; }
.fs-file-ico { font-size: 30px; width: 42px; text-align: center; flex: none; }
.fs-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fs-meta strong { font-size: 14px; word-break: break-all; }
.fs-meta small { color: #94a3b8; font-size: 12px; }
.fs-actions { display: flex; gap: 6px; flex: none; }

/* 快捷消息 */
.qm-new { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.qm-new input, .qm-new textarea { width: 100%; padding: 8px 10px; border: 1px solid #d7dce5; border-radius: 8px; font: inherit; box-sizing: border-box; }
.qm-new-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qm-img-preview { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.qm-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.qm-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--accent, #2f66f5) 16%, #e5e7eb); border-radius: 10px; }
.qm-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.qm-thumb { max-width: 120px; border-radius: 8px; }
.qm-text { font-size: 13px; color: #374151; word-break: break-word; }
.qm-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* 公告编辑 */
.announce-edit-card textarea { width: 100%; padding: 10px; border: 1px solid #d7dce5; border-radius: 10px; font: inherit; box-sizing: border-box; resize: vertical; }

/* 评价列表 */
.reviews-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.review-item { padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent, #2f66f5) 16%, #e5e7eb); border-radius: 10px; background: color-mix(in srgb, var(--accent, #2f66f5) 4%, #fff); }
.review-item-body { font-size: 14px; color: #1f2937; word-break: break-word; }
.review-item small { display: block; margin-top: 4px; color: #94a3b8; font-size: 12px; }

/* 访客端公告弹窗 */
.announce-card { width: min(460px, 90vw); text-align: center; }
.announce-head { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.announce-body { white-space: pre-wrap; text-align: left; margin: 6px 0 14px; font-size: 15px; line-height: 1.6; color: #1f2937; max-height: 50vh; overflow-y: auto; word-break: break-word; }
.announce-close { width: 100%; border: none; border-radius: 10px; padding: 10px; font-weight: 600; color: #fff; background: var(--accent, #2f66f5); cursor: pointer; }
.announce-close:disabled { opacity: .5; cursor: not-allowed; }

/* 访客端评价弹窗 */
.review-card { width: min(460px, 90vw); }
.review-head { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.review-text { width: 100%; min-height: 96px; padding: 10px; border: 1px solid #d7dce5; border-radius: 10px; font: inherit; box-sizing: border-box; resize: vertical; }
.review-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.review-foot #reviewCount { color: #94a3b8; font-size: 13px; }
.review-btns { display: flex; gap: 8px; }
.review-msg { min-height: 18px; margin-top: 8px; font-size: 13px; color: var(--accent, #2f66f5); }

/* ============ 修复：移动端访客登录弹窗点不动 ============ */
/* 原因1：.mobile-chat 与 .modal-mask 均为 position:fixed 且都没有 z-index，
          层叠只靠 DOM 顺序，iOS Safari 合成层顺序不可靠，
          不透明的聊天容器会盖在登录弹窗上面，导致点不到输入框。
   原因2：弹窗垂直居中且不可滚动，手机键盘弹出后输入框/按钮被键盘遮挡。 */
.chat-body .mobile-chat {
  z-index: 1;
}

.chat-body .modal-mask {
  z-index: 1000;
  display: flex;
  /* 配合子元素 margin:auto 实现居中；不用 align-items:center，
     因为内容超高时 center 会把顶部裁掉且滚不上去。 */
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  pointer-events: auto;
}

.chat-body .modal-mask.hidden {
  display: none;
}
.chat-body .modal-card {
  pointer-events: auto;
  flex: 0 0 auto;
  max-height: none;
  /* 关键：margin auto 让它在空间充足时真正居中，
     空间不足（键盘弹出）时自动贴顶并可滚动，不会错位。 */
  margin: auto;
}

/* 输入框 16px 以上，避免 iOS 聚焦时自动放大页面导致错位点不中 */
.chat-body .modal-card input,
.chat-body .modal-card button {
  font-size: 16px;
  touch-action: manipulation;
}

.chat-body .modal-card input {
  -webkit-user-select: text;
  user-select: text;
}

@media (max-width: 560px) {
  .chat-body .modal-mask {
    /* dvh 跟随移动端浏览器工具栏/键盘变化，避免 100vh 算高导致错位；
       vh 作为 iOS Safari < 15.4 的兜底 */
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px 14px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* margin:auto 已负责居中，这里只收窄宽度，不覆盖 margin */
  .chat-body .modal-card {
    width: 100%;
    max-width: 400px;
    padding: 22px 18px;
    border-radius: 22px;
  }

  .chat-body .modal-card h2 {
    font-size: 19px;
  }

  .chat-body .modal-card p {
    margin-bottom: 16px;
    font-size: 14px;
  }
}

/* 极矮屏（横屏/键盘占满）时压缩留白，保证按钮可达 */
@media (max-height: 460px) {
  .chat-body .modal-mask {
    padding-top: 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .chat-body .modal-card {
    padding: 16px 16px 18px;
  }

  .chat-body .modal-card h2 {
    margin-bottom: 6px;
    font-size: 17px;
  }

  .chat-body .modal-card p {
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.45;
  }
}
