#chatWidgetRoot {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1500;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
.chat-widget-btn {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-left: auto;
  border: 1px solid rgba(122, 180, 255, 0.45);
  border-radius: 18px;
  background: linear-gradient(145deg, #0B1830, #16294A 60%, #0D1A33);
  color: #7FB5FF;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.32), 0 0 0 3px rgba(59, 130, 246, 0.12), 0 0 22px rgba(59, 130, 246, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat-widget-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.38), 0 0 0 3px rgba(59, 130, 246, 0.18), 0 0 30px rgba(59, 130, 246, 0.32);
}
.chat-widget-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #D92D20;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(217, 45, 32, 0.4);
}
.chat-widget-panel {
  position: fixed;
  right: 18px;
  bottom: 88px;
  width: min(380px, calc(100vw - 36px));
  height: min(540px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(122, 180, 255, 0.3);
  border-radius: 18px;
  background: linear-gradient(165deg, #F8FBFF, #EDF4FF);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}
.chat-widget-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.chat-widget-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3B82F6, #D9B57E, transparent);
  z-index: 2;
}
.chat-widget-head {
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #0A1324, #14223A 58%, #1B2C4A);
  color: #fff;
  border-bottom: 1px solid rgba(122, 180, 255, 0.16);
}
.chat-widget-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chat-widget-head h3 {
  margin: 0;
  font-size: 17px;
  color: #F0D8AC;
}
.chat-widget-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}
.chat-widget-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.chat-widget-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.12);
  color: #7FDC9F;
  font-size: 11px;
  font-weight: 700;
}
.chat-widget-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.8);
}
.chat-widget-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-widget-name-form {
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid #E4E1E6;
}
.chat-widget-name-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #344057;
}
.chat-widget-name-row {
  display: flex;
  gap: 8px;
}
.chat-widget-name-row input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #C9D2DE;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
}
.chat-widget-name-row button {
  min-height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  background: linear-gradient(165deg, #F8FBFF, #EDF4FF);
}
.chat-widget-msg {
  max-width: 78%;
  margin-bottom: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.65;
  box-shadow: 0 6px 16px rgba(23, 35, 61, 0.06);
}
.chat-widget-msg .meta {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.72;
}
.chat-widget-msg.visitor {
  margin-left: auto;
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
}
.chat-widget-msg.admin {
  margin-right: auto;
  border: 1px solid #E4E1E6;
  border-bottom-left-radius: 4px;
  background: #fff;
  color: #17233D;
}
.chat-widget-composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid #E4E1E6;
  background: #fff;
}
.chat-widget-composer-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.chat-widget-composer input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #C9D2DE;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
}
.chat-widget-upload {
  flex: 0 0 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  display: grid;
  place-items: center;
  border: 1px solid #C9D2DE !important;
  border-radius: 10px !important;
  background: #F4F7FB !important;
  color: #3B82F6 !important;
  cursor: pointer;
  box-shadow: none !important;
}
.chat-widget-upload:hover {
  background: #E8F1FF !important;
  border-color: #3B82F6 !important;
}
.chat-widget-voice {
  flex: 0 0 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  display: grid;
  place-items: center;
  border: 1px solid #C9D2DE !important;
  border-radius: 10px !important;
  background: #F4F7FB !important;
  color: #3B82F6 !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: background .18s ease, color .18s ease, width .18s ease;
  overflow: hidden;
  white-space: nowrap;
}
.chat-widget-voice:hover { background: #E8F1FF !important; border-color: #3B82F6 !important; }
.chat-widget-voice.recording {
  background: #D92D20 !important;
  border-color: #D92D20 !important;
  color: #fff !important;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(217,45,32,.35) !important;
}
.chat-widget-audio {
  display: block;
  width: 210px;
  max-width: 100%;
  height: 38px;
  margin-bottom: 6px;
  border-radius: 8px;
}
.chat-widget-msg .chat-widget-attach {
  display: block;
  margin-bottom: 6px;
  line-height: 0;
}
.chat-widget-msg .chat-widget-attach img {
  display: block;
  max-width: 220px;
  max-height: 170px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #fff;
}
.chat-widget-msg .chat-widget-file {
  display: inline-block;
  margin-bottom: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  color: #2563EB;
  font-weight: 700;
  text-decoration: none;
}
.chat-widget-composer input:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
.chat-widget-composer button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(59, 130, 246, 0.22);
}
.chat-widget-hint {
  padding: 8px 14px;
  color: #8A93A0;
  font-size: 11px;
  text-align: center;
  background: #fff;
  border-top: 1px solid #F0F2F6;
}
.chat-widget-btn.notify {
  animation: zmWidgetPulse 0.9s ease-in-out 4;
}
@keyframes zmWidgetPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 16px 38px rgba(0,0,0,.32), 0 0 0 3px rgba(59,130,246,.12); }
  50% { transform: scale(1.14); box-shadow: 0 20px 48px rgba(0,0,0,.4), 0 0 0 12px rgba(59,130,246,.18), 0 0 32px rgba(59,130,246,.5); }
}
.chat-widget-pop {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 260px;
  padding: 12px 14px;
  border: 1px solid #E4E1E6;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(23,35,61,.2);
  color: #17233D;
  font-size: 13px;
  line-height: 1.6;
  z-index: 1501;
  animation: zmPopIn .25s ease;
}
.chat-widget-pop b { display: block; margin-bottom: 4px; color: #2563EB; font-size: 13px; }
@keyframes zmPopIn {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-widget-msg.new { animation: zmMsgIn .4s ease; }
@keyframes zmMsgIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 640px) {
  .chat-widget-composer input,
  .chat-widget-name-row input {
    font-size: 16px !important;
  }
  #chatWidgetRoot {
    right: 14px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .chat-widget-btn {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }
  .chat-widget-panel {
    right: 10px;
    left: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto;
    height: min(560px, calc(100vh - 110px));
    max-height: calc(100vh - 110px);
    min-height: 320px;
  }
  .chat-widget-pop {
    bottom: calc(70px + env(safe-area-inset-bottom));
  }
}
