:root {
  --k77-c-em: #059669;
  --k77-c-em-dark: #047857;
  --k77-c-em-lt: #ecfdf5;
  --k77-c-tx: #0f172a;
  --k77-c-mu: #64748b;
  --k77-c-bg: #f8fafc;
  --k77-c-bd: #e2e8f0;
}
.k77-chat-trigger {
  position: fixed; bottom: 16px; right: 16px; width: 54px; height: 54px;
  border-radius: 50%; background: var(--k77-c-em); color: #fff; border: none;
  box-shadow: 0 8px 24px rgba(5,150,105,0.36), 0 2px 6px rgba(0,0,0,0.08);
  cursor: pointer; z-index: 999; display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease, background-color .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.k77-chat-trigger:hover { background: var(--k77-c-em-dark); transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 28px rgba(5,150,105,0.45); }
.k77-chat-trigger:active { transform: scale(0.96); }
.k77-chat-trigger svg { width: 26px; height: 26px; fill: currentColor; }
.k77-chat-trigger__status {
  position: absolute; top: 2px; right: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #10b981; border: 2px solid #fff;
}
.k77-chat-trigger__status::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%;
  background: rgba(16,185,129,0.5); animation: k77-p 2s infinite ease-out;
}
@keyframes k77-p { 0% { transform: scale(1); opacity: 1; } 70%, 100% { transform: scale(2.2); opacity: 0; } }

.k77-chat-bubble {
  position: fixed; bottom: 78px; right: 16px; max-width: 270px; background: #fff;
  border: 1px solid var(--k77-c-bd); border-radius: 14px; box-shadow: 0 12px 32px rgba(15,23,42,0.14);
  padding: 10px 30px 10px 12px; z-index: 998; font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: 13px; line-height: 1.4; color: var(--k77-c-tx); cursor: pointer; opacity: 0; visibility: hidden;
  transform: translateY(8px) scale(0.96); transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.k77-chat-bubble--visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.k77-chat-bubble strong { color: var(--k77-c-em-dark); font-weight: 600; display: block; margin-bottom: 2px; }
.k77-chat-bubble__close {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
  border: none; background: transparent; color: var(--k77-c-mu); font-size: 16px;
  line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.k77-chat-bubble::after {
  content: ''; position: absolute; bottom: -6px; right: 22px; width: 12px; height: 12px;
  background: #fff; border-right: 1px solid var(--k77-c-bd); border-bottom: 1px solid var(--k77-c-bd);
  transform: rotate(45deg);
}

.k77-chat-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); z-index: 998; opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s;
}
.k77-chat-backdrop--open { opacity: 1; visibility: visible; }

.k77-chat-container {
  position: fixed; bottom: 0; left: 0; right: 0; width: 100%; height: 70dvh; max-height: 85dvh;
  background: #fff; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgba(15,23,42,0.18);
  z-index: 999; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(105%); transition: transform .3s cubic-bezier(0.16,1,0.3,1);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
}
.k77-chat-container--open { transform: translateY(0); }

.k77-chat-header {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  background: #fff; border-bottom: 1px solid var(--k77-c-bd); flex-shrink: 0;
}
.k77-chat-header__profile { display: flex; align-items: center; gap: 10px; }
.k77-chat-header__avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--k77-c-em-lt);
  color: var(--k77-c-em); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; border: 1.5px solid rgba(5,150,105,0.25); flex-shrink: 0;
}
.k77-chat-header__info h4 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--k77-c-tx); line-height: 1.25; }
.k77-chat-header__badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--k77-c-em); font-weight: 500; margin-top: 2px; }
.k77-chat-header__badge-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }
.k77-chat-header__close {
  width: 34px; height: 34px; border-radius: 50%; border: none; background: #f1f5f9;
  color: var(--k77-c-mu); font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}

.k77-chat-feed {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px; background: #fff;
}

.k77-chat-msg { display: flex; flex-direction: column; max-width: 86%; animation: k77-fu .2s ease; }
@keyframes k77-fu { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.k77-chat-msg--bot { align-self: flex-start; }
.k77-chat-msg--user { align-self: flex-end; }
.k77-chat-msg__bubble { padding: 9px 13px; font-size: 13.5px; line-height: 1.45; }
.k77-chat-msg--bot .k77-chat-msg__bubble { background: var(--k77-c-bg); border: 1px solid var(--k77-c-bd); color: var(--k77-c-tx); border-radius: 16px 16px 16px 4px; }
.k77-chat-msg--user .k77-chat-msg__bubble { background: var(--k77-c-em); color: #fff; border-radius: 16px 16px 4px 16px; }
.k77-chat-msg__time { font-size: 10px; color: var(--k77-c-mu); margin-top: 3px; padding: 0 4px; }
.k77-chat-msg--user .k77-chat-msg__time { align-self: flex-end; }

.k77-chat-typing {
  display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px;
  background: var(--k77-c-bg); border: 1px solid var(--k77-c-bd); border-radius: 16px 16px 16px 4px; align-self: flex-start;
}
.k77-chat-typing span {
  width: 5px; height: 5px; background: #94a3b8; border-radius: 50%; animation: k77-b 1.3s infinite ease-in-out both;
}
.k77-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.k77-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes k77-b { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.k77-chat-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; width: 100%; }
.k77-chat-chip {
  background: #fff; border: 1.5px solid #cbd5e1; color: #1e293b; border-radius: 12px;
  padding: 9px 12px; font-size: 13px; font-weight: 500; text-align: left; cursor: pointer;
  transition: all .15s ease; display: flex; align-items: center; justify-content: space-between; line-height: 1.35;
}
.k77-chat-chip:hover, .k77-chat-chip:focus-visible { border-color: var(--k77-c-em); background: var(--k77-c-em-lt); color: var(--k77-c-em-dark); }
.k77-chat-chip:active { transform: scale(0.985); }
.k77-chat-chip--accent { background: var(--k77-c-em); color: #fff; border-color: var(--k77-c-em); font-weight: 600; justify-content: center; }
.k77-chat-chip--accent:hover { background: var(--k77-c-em-dark); color: #fff; }

.k77-chat-contact-box {
  background: #f8fafc; border: 1.5px solid #cbd5e1; border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
}
.k77-chat-channels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.k77-chat-channel-btn {
  background: #fff; border: 1.5px solid #cbd5e1; border-radius: 8px;
  padding: 7px 2px; font-size: 11px; font-weight: 500; color: #334155; cursor: pointer; text-align: center;
}
.k77-chat-channel-btn--active {
  border-color: var(--k77-c-em); background: var(--k77-c-em-lt); color: var(--k77-c-em-dark); font-weight: 600;
}
.k77-chat-phone-row { display: flex; gap: 6px; }
.k77-chat-phone-input {
  flex: 1; height: 42px; border: 1.5px solid #cbd5e1; border-radius: 8px;
  padding: 0 10px; font-size: 14px; color: var(--k77-c-tx); outline: none; background: #fff;
}
.k77-chat-phone-input:focus { border-color: var(--k77-c-em); }
.k77-chat-submit-btn {
  height: 42px; background: var(--k77-c-em); color: #fff; border: none;
  border-radius: 8px; padding: 0 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.k77-chat-submit-btn:hover { background: var(--k77-c-em-dark); }
.k77-chat-disclaimer { font-size: 10.5px; color: var(--k77-c-mu); line-height: 1.3; text-align: center; margin: 0; }

.k77-chat-footer {
  padding: 8px 12px; background: #fff; border-top: 1px solid var(--k77-c-bd);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.k77-chat-footer__input {
  flex: 1; height: 38px; border: 1.5px solid #cbd5e1; border-radius: 19px;
  padding: 0 14px; font-size: 13.5px; color: var(--k77-c-tx); outline: none; background: #f8fafc;
}
.k77-chat-footer__input:focus { border-color: var(--k77-c-em); background: #fff; }
.k77-chat-footer__send {
  width: 38px; height: 38px; border-radius: 50%; background: var(--k77-c-em);
  color: #fff; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.k77-chat-footer__send svg { width: 16px; height: 16px; fill: currentColor; }

@media (min-width: 769px) {
  .k77-chat-container {
    left: auto; right: 20px; bottom: 84px; width: 380px; height: 540px;
    border-radius: 18px; box-shadow: 0 20px 48px rgba(15,23,42,0.2);
    border: 1px solid var(--k77-c-bd); transform: translateY(20px) scale(0.96);
    opacity: 0; pointer-events: none;
  }
  .k77-chat-container--open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
  .k77-chat-backdrop { display: none; }
}
