#kefu-root { position: relative; z-index: 45; }
body.script-waiting #kefu-root { display: none; }
@keyframes kefu-breathe {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.35), 0 10px 24px rgba(15, 40, 32, 0.10); }
  70% { box-shadow: 0 0 0 14px rgba(5, 150, 105, 0), 0 10px 24px rgba(15, 40, 32, 0.10); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0), 0 10px 24px rgba(15, 40, 32, 0.10); }
}
.kefu-launch {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  left: auto;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: calc(100vw - 24px);
  padding: 0 14px 0 10px;
  border: 1px solid rgba(5, 150, 105, 0.28);
  border-radius: 999px;
  background: #fff;
  color: #047857;
  font-size: 14px;
  font-weight: 650;
  animation: kefu-breathe 2.4s ease-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .kefu-launch { animation: none; box-shadow: 0 10px 24px rgba(15, 40, 32, 0.10); }
}
.kefu-launch.ping {
  animation: kefu-ping 0.9s ease-out infinite;
}
.kefu-launch.shake {
  animation: kefu-shake 0.48s ease-in-out 0s 4, kefu-ping 0.9s ease-out 2s infinite;
}
@keyframes kefu-ping {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.45), 0 10px 24px rgba(15, 40, 32, 0.10); }
  70% { box-shadow: 0 0 0 16px rgba(5, 150, 105, 0), 0 10px 24px rgba(15, 40, 32, 0.10); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0), 0 10px 24px rgba(15, 40, 32, 0.10); }
}
@keyframes kefu-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-8px, 0, 0) rotate(-7deg); }
  30% { transform: translate3d(8px, 0, 0) rotate(7deg); }
  45% { transform: translate3d(-7px, 0, 0) rotate(-5deg); }
  60% { transform: translate3d(7px, 0, 0) rotate(5deg); }
  75% { transform: translate3d(-4px, 0, 0) rotate(-2deg); }
}
.kefu-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}
.kefu-toast {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  z-index: 47;
  display: grid;
  gap: 2px;
  width: min(260px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(5, 150, 105, 0.22);
  border-radius: 14px;
  background: #fff;
  color: #15241e;
  box-shadow: 0 14px 32px rgba(15, 40, 32, 0.14);
  cursor: pointer;
}
.kefu-toast[hidden] { display: none; }
.kefu-toast b {
  font-size: 13px;
  font-weight: 750;
  color: #047857;
}
.kefu-toast span {
  color: #5c6d67;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kefu-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='white' d='M5 7.5A2.5 2.5 0 0 1 7.5 5h9A2.5 2.5 0 0 1 19 7.5v6A2.5 2.5 0 0 1 16.5 16H12l-3.2 2.4A.8.8 0 0 1 7.5 17.7V16H7.5A2.5 2.5 0 0 1 5 13.5z'/></svg>") center / 14px no-repeat;
}
.kefu-panel {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 46;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(320px, calc(100vw - 24px));
  height: min(460px, calc(100dvh - 92px));
  border: 1px solid rgba(21, 36, 30, 0.08);
  border-radius: 16px;
  background: #fff;
  color: #15241e;
  box-shadow: 0 16px 40px rgba(15, 40, 32, 0.14);
  overflow: hidden;
}
.kefu-panel[hidden] { display: none; }
.kefu-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 6px 4px 6px 12px;
  border-bottom: 1px solid rgba(21, 36, 30, 0.06);
  background: #fff;
}
.kefu-panel header b {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.kefu-panel header b::before {
  content: "";
  grid-row: 1 / span 2;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}
.kefu-panel header small {
  color: #6b7c75;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kefu-close {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7c75;
}
.kefu-close:hover { background: rgba(21, 36, 30, 0.05); }
.kefu-close::before {
  content: "";
  display: block;
  width: 12px;
  height: 1.5px;
  margin: 0 auto;
  border-radius: 1px;
  background: currentColor;
}
.kefu-log {
  overflow: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(16, 185, 129, 0.07), transparent 46%),
    #f6f8f7;
}
.kefu-log::-webkit-scrollbar { width: 8px; }
.kefu-log::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: rgba(21, 36, 30, 0.18);
  background-clip: padding-box;
}
.kefu-log p {
  max-width: min(78%, 230px);
  margin: 0;
  padding: 6px 10px;
  border-radius: 13px;
  line-height: 1.45;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.kefu-log .theirs {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: #fff;
  border: 1px solid rgba(21, 36, 30, 0.06);
}
.kefu-log .mine {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: #059669;
  color: #fff;
}
.kefu-log .mine + .mine,
.kefu-log .theirs + .theirs { margin-top: -2px; }
.kefu-log .mine:has(+ .mine) { border-bottom-right-radius: 5px; }
.kefu-log .mine + .mine { border-top-right-radius: 5px; }
.kefu-log .theirs:has(+ .theirs) { border-bottom-left-radius: 5px; }
.kefu-log .theirs + .theirs { border-top-left-radius: 5px; }
.kefu-panel form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgba(21, 36, 30, 0.06);
  background: #fff;
}
.kefu-panel textarea {
  width: auto;
  min-height: 34px;
  max-height: 84px;
  margin: 0;
  padding: 7px 12px;
  border-radius: 17px;
  border: 1px solid rgba(21, 36, 30, 0.10);
  background: #f4f7f5;
  color: #15241e;
  resize: none;
  font-size: 14px;
  line-height: 1.4;
}
.kefu-panel form button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #059669;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.kefu-panel form button:hover { background: #047857; }
@media (max-width: 640px) {
  .kefu-launch {
    right: max(12px, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    min-height: 44px;
    padding: 0 12px 0 8px;
    font-size: 14px;
  }
  .kefu-toast {
    right: max(12px, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }
  .kefu-panel {
    right: max(10px, env(safe-area-inset-right, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: auto;
    height: min(68dvh, calc(100dvh - 28px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  }
  .kefu-panel textarea { font-size: 16px; }
}
