:root {
  --tv-chat-bottom: 88px;
  --tv-chat-height: 52px;
}

#tv-chat-greeting {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tv-chat-bottom) + var(--tv-chat-height) + 16px);
  z-index: 9998;
  padding: 14px 25px 12px 10px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 1px 2px 8px rgba(0, 0, 0, .14);
  color: #222;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

#tv-chat-greeting::after {
  content: '';
  position: absolute;
  right: 25px;
  bottom: -8px;
  border-top: 9px solid #fff;
  border-right: 9px solid transparent;
  border-left: 9px solid transparent;
}

#tv-chat-greeting strong,
#tv-chat-greeting span { display: block; }
#tv-chat-greeting strong { font-weight: 600; }
#tv-chat-greeting span { color: #666; font-size: 12px; }

.tv-chat-greeting-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ebebeb;
  color: #888;
  font-size: 17px;
  line-height: 20px;
  cursor: pointer;
}

#tv-chat-btn {
  position: fixed;
  right: 24px;
  bottom: 88px;
  height: 52px;
  padding: 0 20px 0 14px;
  border: 0;
  border-radius: 26px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.2px;
  background: linear-gradient(135deg, #6a5cff 0%, #2b6cff 55%, #23b6ff 100%);
  box-shadow: 0 6px 20px rgba(43, 108, 255, .38);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

#tv-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(43, 108, 255, .5);
}

#tv-chat-btn .ico {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  animation: tv-spark 2.4s ease-in-out infinite;
}

#tv-chat-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid rgba(43, 108, 255, .35);
  border-radius: 30px;
  animation: tv-ring 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes tv-spark {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.12); opacity: 1; }
}

@keyframes tv-ring {
  0% { transform: scale(1); opacity: .6; }
  70% { transform: scale(1.12); opacity: 0; }
  100% { opacity: 0; }
}

#tv-chat-dim {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(15, 23, 42, .35);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s ease;
}

#tv-chat-dim.open { opacity: 1; visibility: visible; }

#tv-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 37vw;
  min-width: 427px;
  max-width: 100vw;
  height: 100dvh;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -8px 0 30px rgba(20, 30, 60, .18);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  visibility: hidden;
}

#tv-chat-panel.open { transform: translateX(0); visibility: visible; }
#tv-chat-panel iframe { flex: 1; width: 100%; border: 0; }

#tv-chat-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  z-index: 2;
  background: rgba(255, 255, 255, .22);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

#tv-chat-close:hover { background: rgba(255, 255, 255, .38); }

@media (max-width: 768px) {
  :root { --tv-chat-bottom: 18.7692rem; --tv-chat-height: 46px; }
  #tv-chat-btn {
    right: 14px;
    bottom: 18.7692rem;
    height: 46px;
    padding: 0 16px 0 11px;
    font-size: 14px;
  }
  #tv-chat-btn .ico { width: 25px; height: 25px; font-size: 14px; }
  #tv-chat-panel { width: 100%; min-width: 0; box-shadow: none; }
}

@media (max-width: 320px) {
  #tv-chat-greeting { display: none; }
  #tv-chat-btn {
    right: 10px;
    bottom: 16px;
    width: 46px;
    padding: 0;
    justify-content: center;
  }
  #tv-chat-btn > span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #tv-chat-btn .ico, #tv-chat-btn::after { animation: none; }
  #tv-chat-panel, #tv-chat-dim, #tv-chat-btn { transition: none; }
}
