#chetty-chatbot-button, .chetty-animation-button {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 40px;
  width: 80px;
  height: 80px;
  border: none;
  border-radius: 50%;
  filter: none;
  box-shadow: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 9997;  /* Ensure it's always on top */
  transition: width 0.2s, height 0.2s, opacity 0.22s ease, filter 0.22s ease;
  background-color: transparent;
  margin-left: -100px;
  overflow: visible;
  padding-block-end: 1px;
  padding-block-start: 1px;
  padding-inline-end: 6px;
  padding-inline-start: 6px;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* Keep the icon shadow separate from the keyboard focus ring. */
#chetty-chatbot-button > svg,
#chetty-chatbot-button > img,
.chetty-animation-button > svg,
.chetty-animation-button > img {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.28));
}

#chetty-chatbot-button:focus:not(:focus-visible) {
  outline: none;
}

#chetty-chatbot-button:focus-visible {
  outline: 2px solid var(--chetty-accent, #00539f);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px #fff;
}

html.chetty-light-motion #chetty-chatbot-button,
html.chetty-light-motion .chetty-animation-button {
  transition: width 0.2s, height 0.2s, opacity 0.18s ease;
}

#chetty-logoContainer, #chetty-crossContainer {
  animation: chetty-pulse 1.5s infinite;  /* Makes them pulse by default */
}

#chetty-logoContainer:active, #chetty-crossContainer:active {
  animation: chetty-click 0.2s;  /* Applies the 'click' animation when pressed */
}

#chetty-chatbot-button.chetty-displayed, .chetty-animation-button.chetty-displayed {
  animation: chetty-bubblePop 0.36s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes chetty-bubblePop {
  0% {
      opacity: 0;
      transform: translate3d(0, 16px, 0) scale(0.92);
  }
  68% {
      opacity: 1;
      transform: translate3d(0, -2px, 0) scale(1.02);
  }
  100% {
      opacity: 1;
      transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes chetty-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.chetty-pulse {
  animation: chetty-pulse 1.5s infinite;
}

/* Endless pulsing distracts users who asked the system for less motion (WCAG 2.2.2). */
@media (prefers-reduced-motion: reduce) {
  .chetty-pulse,
  #chetty-logoContainer,
  #chetty-crossContainer {
    animation: none;
  }
}

@keyframes chetty-click {
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes chetty-grow {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes chetty-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#chetty-chatbot-button:active {
  animation: chetty-click 0.2s;
}

@media (max-width: 768px) {
  #chetty-chatbot-button {
    bottom: 10px;
    right: 10px;
    width: 60px;    
    height: 60px;
    font-size: 12px;
    margin-left: 0;
  }

  #chetty-chatbot-iframe {
    bottom: 0 !important;
    right: 0 !important;
    top: 0 !important; 
    left: 0 !important;  
    width: 100vw !important;  /* Corrected to viewport width */
    max-width: 100% !important;
    margin: 0 !important;
    /*height: 88vh !important;  Keeps as viewport height */
    height: 100% !important;
    /*max-height: 1500px!important;*/
    border-radius: 0 !important;  /* No rounded corners */
  }
}

#chetty-chatbot-iframe {
  background-size: cover;
  position: fixed;
  bottom: 20px;
  right: 20px;  /* adjusted back to original */
  width: 477px;
  height: 711px;
  box-sizing: border-box;
  border: none;
  box-shadow:
    0 26px 70px rgba(15, 23, 42, 0.18),
    0 14px 28px rgba(15, 23, 42, 0.14),
    0 4px 10px rgba(15, 23, 42, 0.08);
  z-index: 9998;
  display: none;
  border-radius: 22px;
  opacity: 0;
  transform: translate3d(0, 28px, 0) scale(0.94);
  transform-origin: bottom right;
  transition:
    opacity 180ms ease,
    transform 420ms cubic-bezier(0.2, 0.9, 0.2, 1.03),
    box-shadow 220ms ease;
  will-change: transform, opacity;
}

/* Reduce height for smaller screens */
@media (max-height: 710px) {
  #chetty-chatbot-iframe {
    height: 600px;
  }
}

@media (max-height: 620px) {
  #chetty-chatbot-iframe {
    height: 520px;
  }
}

@media (max-height: 540px) {
  #chetty-chatbot-iframe {
    height: 400px;
  }
}

#chetty-chatbot-iframe.visible, #chetty-chatbot-iframe.chetty-visible {
  transition:
    width 200ms ease,
    height 200ms ease,
    max-height 200ms ease,
    transform 420ms cubic-bezier(0.2, 0.9, 0.2, 1.03),
    opacity 180ms ease,
    box-shadow 220ms ease;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

#chetty-chatbot-iframe.chetty-resizing {
  transition: none !important;
}

#chetty-chatbot-loading-overlay {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 477px;
  height: 711px;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.96)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.94));
  box-shadow:
    0 26px 70px rgba(15, 23, 42, 0.18),
    0 14px 28px rgba(15, 23, 42, 0.14),
    0 4px 10px rgba(15, 23, 42, 0.08);
  opacity: 0;
  transform: translate3d(0, 28px, 0) scale(0.94);
  transform-origin: bottom right;
  transition:
    opacity 180ms ease,
    transform 420ms cubic-bezier(0.2, 0.9, 0.2, 1.03),
    box-shadow 220ms ease;
  pointer-events: auto;
}

#chetty-chatbot-loading-overlay.chetty-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.chetty-chatbot-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  color: #0f172a;
}

.chetty-chatbot-loading-mark {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chetty-chatbot-loading-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--chetty-accent, #00539f);
  box-shadow: 0 0 0 6px rgba(0, 83, 159, 0.12);
}

.chetty-chatbot-loading-spinner {
  position: absolute;
  inset: 0;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 3px solid rgba(15, 23, 42, 0.08);
  border-top-color: var(--chetty-accent, rgba(0, 83, 159, 0.88));
  animation: chetty-spin 0.8s linear infinite;
}

.chetty-chatbot-loading-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 260px;
}

.chetty-chatbot-loading-copy strong {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.chetty-chatbot-loading-copy span {
  font-size: 14px;
  line-height: 1.45;
  color: rgba(15, 23, 42, 0.72);
}

/* Chetty shell polish: isolated visual layer for easy revert. */
#chetty-chatbot-shell-backdrop {
  display: none !important;
}

html.chetty-shell-open #chetty-chatbot-button,
html.chetty-shell-open .chetty-animation-button {
  opacity: 0;
  filter: saturate(0.9);
  pointer-events: none;
}

html.chetty-light-motion.chetty-shell-open #chetty-chatbot-button,
html.chetty-light-motion.chetty-shell-open .chetty-animation-button {
  filter: none;
}

html.chetty-shell-open #chetty-chatbot-iframe {
  box-shadow:
    0 42px 110px rgba(15, 23, 42, 0.26),
    0 18px 42px rgba(15, 23, 42, 0.2);
}

html.chetty-shell-open #chetty-chatbot-loading-overlay {
  box-shadow:
    0 42px 110px rgba(15, 23, 42, 0.22),
    0 18px 42px rgba(15, 23, 42, 0.18);
}

html.chetty-light-motion #chetty-chatbot-iframe {
  transform: translate3d(0, 18px, 0);
  transition:
    opacity 160ms ease,
    transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.chetty-light-motion #chetty-chatbot-iframe.visible,
html.chetty-light-motion #chetty-chatbot-iframe.chetty-visible {
  transition:
    width 160ms ease,
    height 160ms ease,
    max-height 160ms ease,
    transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 160ms ease;
  transform: translate3d(0, 0, 0);
}

html.chetty-light-motion #chetty-chatbot-loading-overlay {
  transform: translate3d(0, 18px, 0);
  transition:
    opacity 160ms ease,
    transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.chetty-light-motion #chetty-chatbot-loading-overlay.chetty-visible {
  transform: translate3d(0, 0, 0);
}

#chetty-chatbot-resize-handle {
  position: fixed;
  display: none;
  width: 52px;
  height: 16px;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  cursor: grab;
  opacity: 0;
  transition: opacity 160ms ease;
  touch-action: none;
  user-select: none;
}

#chetty-chatbot-resize-handle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 1);
  box-shadow:
    -8px 0 0 rgba(255, 255, 255, 1),
    8px 0 0 rgba(255, 255, 255, 1);
  opacity: 0.2;
  transition: opacity 160ms ease;
}

#chetty-chatbot-resize-handle::after {
  display: none;
}

#chetty-chatbot-resize-handle.chetty-visible {
  opacity: 1;
}

#chetty-chatbot-resize-handle:hover::before {
  opacity: 1;
}

#chetty-chatbot-resize-handle.chetty-resizing {
  cursor: grabbing;
  transition: none;
}

#chetty-chatbot-resize-handle.chetty-resizing::before {
  opacity: 1;
}

html.chetty-resize-active,
html.chetty-resize-active body {
  cursor: grabbing !important;
  user-select: none !important;
}

@media (max-width: 768px) {
  #chetty-chatbot-resize-handle {
    display: none !important;
  }
}

@media (max-width: 768px) {
  #chetty-chatbot-loading-overlay {
    bottom: 0 !important;
    right: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    border-radius: 0 !important;
    padding: 24px;
  }
}

/* Chatbot notification bubble */
#chetty-notice-bubble {
  position: fixed;
  bottom: 122px; /* 30px bottom + 80px button + 12px gap */
  right: 40px;
  max-width: 280px;
  padding: 12px 38px 12px 14px; /* extra right space for close button */
  background: #ffffff;
  color: #0b1220;
  border-radius: 14px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.06),
    0 10px 20px rgba(0, 0, 0, 0.06),
    0 20px 40px rgba(0, 0, 0, 0.04);
  font-size: 14px;
  line-height: 1.35;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  z-index: 10000;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 280ms ease, transform 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
  user-select: none;
  cursor: pointer;
  display: none;
  backdrop-filter: saturate(1.15) blur(2px);
  transform-origin: bottom right;
  will-change: transform, opacity;
}

#chetty-notice-bubble.chetty-visible {
  opacity: 1;
  transform: translateY(0);
}

#chetty-notice-bubble:hover {
  transform: translateY(0) scale(1.01);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.06),
    0 16px 32px rgba(0, 0, 0, 0.07),
    0 28px 48px rgba(0, 0, 0, 0.05);
}

#chetty-notice-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg) translateY(4px);
  opacity: 0;
  border-right: 1px solid rgba(17, 24, 39, 0.08);
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
  transition: opacity 280ms ease, transform 320ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

#chetty-notice-bubble.chetty-visible::after {
  opacity: 1;
  transform: rotate(45deg) translateY(0);
}

@media (max-width: 768px) {
  #chetty-notice-bubble {
    bottom: 82px; /* 10px bottom + 60px button + 12px gap */
    right: 10px;
    max-width: 76vw;
    font-size: 13px;
  }
}

.chetty-notice-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chetty-notice-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: var(--chetty-accent, #00539f);
  box-shadow: 0 0 0 4px rgba(0, 83, 159, 0.12);
  position: relative;
}

.chetty-notice-text {
  color: #0b1220;
}

.chetty-notice-text strong {
  font-weight: 650;
}

/* Typing caret for streaming part */
#chetty-notice-stream {
  position: relative;
}

#chetty-notice-stream::after {
  display: none;
}

.chetty-notice-link {
  text-decoration: underline;
  color: inherit;
}

@keyframes chetty-caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.chetty-notice-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 9999px;
  box-shadow: 0 0 0 0 rgba(0, 83, 159, 0.22);
  animation: chetty-dot-ping 1.8s ease-out infinite;
}

#chetty-notice-bubble.chetty-visible .chetty-notice-dot::after {
  animation-delay: 280ms;
}

@keyframes chetty-dot-ping {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 83, 159, 0.22);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 83, 159, 0.0);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(0, 83, 159, 0.0);
  }
}

/* Entrance animation for the notice bubble: fade + spring slide + subtle 3D tilt */
@keyframes chetty-notice-in {
  0% {
    opacity: 0;
    transform: perspective(900px) translateY(12px) scale(0.96) rotateX(8deg);
  }
  60% {
    opacity: 1;
    transform: perspective(900px) translateY(-2px) scale(1.02) rotateX(0deg);
  }
  100% {
    opacity: 1;
    transform: perspective(900px) translateY(0) scale(1) rotateX(0deg);
  }
}

/* Entrance animation for the little tail */
@keyframes chetty-tail-in {
  0% {
    opacity: 0;
    transform: rotate(45deg) translateY(6px) scale(0.9);
  }
  60% {
    opacity: 1;
    transform: rotate(45deg) translateY(-1px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: rotate(45deg) translateY(0) scale(1);
  }
}

/* Close (X) button inside the bubble */
.chetty-notice-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 80ms ease, border-color 140ms ease;
}

.chetty-notice-close:hover {
  background: rgba(17, 24, 39, 0.05);
  color: #374151;
  border-color: rgba(17, 24, 39, 0.08);
}

.chetty-notice-close:active {
  transform: scale(0.96);
}

.chetty-notice-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 83, 159, 0.25);
}

/* Ensure the close icon always uses the intended color, regardless of host CSS */
#chetty-notice-bubble .chetty-notice-close svg,
#chetty-notice-bubble .chetty-notice-close svg * {
  stroke: currentColor !important;
  fill: none !important;
}

/* Reset host/CMS overrides on close button thoroughly */
#chetty-notice-bubble .chetty-notice-close {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
}
#chetty-notice-bubble .chetty-notice-close::before,
#chetty-notice-bubble .chetty-notice-close::after {
  content: none !important;
  display: none !important;
}

/* Strong visibility and sizing enforcement for the close button */
#chetty-notice-bubble .chetty-notice-close {
  color: #6b7280 !important;
  opacity: 1 !important;
  visibility: visible !important;
  z-index: 1 !important;
  display: grid !important;
  place-items: center !important;
  width: 26px !important;
  height: 26px !important;
  padding: 0 !important;
  line-height: 1 !important;
  border: 1px solid transparent !important;
  top: 8px !important;
  right: 8px !important;
}

#chetty-notice-bubble .chetty-notice-close:hover {
  color: #374151 !important;
}

#chetty-notice-bubble .chetty-notice-close svg {
  display: block !important;
  width: 12px !important;
  height: 12px !important;
}

#chetty-notice-bubble .chetty-notice-close svg path {
  stroke-width: 2 !important;
}
