#tn-chat {
  --tn-brand: #4f4cf2;
  --tn-brand-hover: #625ff5;
  --tn-brand-soft: #a9a7ff;
  --tn-live: #53fc18;
  --tn-panel: #121316;
  --tn-head: #0a0a0b;
  --tn-well: #0d0e10;
  --tn-bot: #1c1e22;
  --tn-line: #2a2b2e;
  --tn-field: #17181b;
  --tn-field-line: #3a3c42;
  --tn-text: #ececec;
  --tn-muted: #a2a5ab;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: var(--tn-text);
}
#tn-chat *, #tn-chat *::before, #tn-chat *::after { box-sizing: border-box; }

/* The website theme styles every <button> (padding, sizes, colours). Reset that for the chat
   so our buttons look and centre the same on every page. */
#tn-chat button {
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  line-height: 1;
  text-align: center;
  text-transform: none;
  letter-spacing: normal;
  text-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
#tn-chat button svg { display: block; flex: none; }

/* Pulsing green "live" dot */
#tn-chat .tn-live-dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tn-live);
  box-shadow: 0 0 0 0 rgba(83, 252, 24, .65);
  animation: tn-live-pulse 1.8s ease-out infinite;
}
@keyframes tn-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(83, 252, 24, .65); }
  70% { box-shadow: 0 0 0 7px rgba(83, 252, 24, 0); }
  100% { box-shadow: 0 0 0 0 rgba(83, 252, 24, 0); }
}

/* Launcher button */
#tn-chat .tn-chat-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  height: 54px;
  padding: 0 24px 0 76px;
  overflow: visible;
  border-radius: 999px;
  background: var(--tn-brand);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(79, 76, 242, .38), 0 2px 6px rgba(0, 0, 0, .5);
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
#tn-chat .tn-chat-launcher:hover { background: var(--tn-brand-hover); color: #fff; transform: translateY(-2px); box-shadow: 0 12px 30px rgba(79, 76, 242, .45), 0 2px 6px rgba(0, 0, 0, .5); }
#tn-chat .tn-chat-launcher:focus { color: #fff; }
#tn-chat .tn-chat-launcher:focus-visible { outline: 3px solid var(--tn-brand-soft); outline-offset: 3px; }
#tn-chat .tn-label { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }

/* The mascot sits on the left of the pill and peeks out above it. */
#tn-chat .tn-mascot {
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 70px;
  height: 68px;
  pointer-events: none;
  animation: tn-bob 2.6s ease-in-out infinite;
}
#tn-chat .tn-mascot img,
#tn-chat .tn-mascot video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
}
#tn-chat .tn-mascot.has-video img { opacity: 0; }
@keyframes tn-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Open state: the launcher becomes a round close button with a centred X */
#tn-chat .tn-x { display: none; }
#tn-chat .tn-x svg { width: 22px; height: 22px; }
#tn-chat.tn-open .tn-chat-launcher .tn-label,
#tn-chat.tn-open .tn-mascot { display: none; }
#tn-chat.tn-open .tn-x { display: flex; align-items: center; justify-content: center; }
#tn-chat.tn-open .tn-chat-launcher { width: 54px; padding: 0; }

/* Chat window */
#tn-chat .tn-chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 370px;
  height: 540px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  background: var(--tn-panel);
  border: 1px solid var(--tn-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .65), 0 0 0 1px rgba(79, 76, 242, .18);
}
#tn-chat .tn-chat-panel[hidden] { display: none; }

#tn-chat .tn-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--tn-head);
  border-bottom: 1px solid var(--tn-line);
  color: #fff;
}
#tn-chat .tn-chat-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
#tn-chat .tn-chat-avatar {
  position: relative;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #3d3ab8, #18173f);
  border: 1px solid rgba(169, 167, 255, .35);
  display: flex;
  align-items: center;
  justify-content: center;
}
#tn-chat .tn-chat-avatar img { width: 36px; height: auto; display: block; }
#tn-chat .tn-chat-avatar .tn-live-dot {
  position: absolute;
  right: -1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--tn-head);
}
#tn-chat .tn-chat-title { display: flex; flex-direction: column; min-width: 0; }
#tn-chat .tn-chat-title strong { font-size: 16px; font-weight: 700; letter-spacing: .2px; line-height: 1.3; }
#tn-chat .tn-chat-status { font-size: 12.5px; color: var(--tn-muted); line-height: 1.4; white-space: nowrap; }
#tn-chat .tn-chat-status b { color: var(--tn-live); font-weight: 600; }
#tn-chat .tn-chat-close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
#tn-chat .tn-chat-close svg { width: 18px; height: 18px; }
#tn-chat .tn-chat-close:hover { background: var(--tn-bot); color: #fff; }
#tn-chat .tn-chat-close:focus { color: #fff; }
#tn-chat .tn-chat-close:focus-visible { outline: 2px solid var(--tn-brand-soft); outline-offset: 1px; }

#tn-chat .tn-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--tn-well);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
  scrollbar-color: var(--tn-line) transparent;
}
#tn-chat .tn-msg { display: flex; }
#tn-chat .tn-msg-user { justify-content: flex-end; }
#tn-chat .tn-bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#tn-chat .tn-msg-bot .tn-bubble {
  background: var(--tn-bot);
  border: 1px solid var(--tn-line);
  color: var(--tn-text);
  border-bottom-left-radius: 5px;
}
#tn-chat .tn-msg-user .tn-bubble {
  background: var(--tn-brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}
#tn-chat .tn-bubble a { color: var(--tn-brand-soft); text-decoration: underline; }

#tn-chat .tn-typing .tn-bubble { display: flex; gap: 5px; align-items: center; padding: 13px 15px; }
#tn-chat .tn-typing .tn-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tn-brand-soft);
  animation: tn-dot 1.2s infinite ease-in-out;
}
#tn-chat .tn-typing .tn-bubble span:nth-child(2) { animation-delay: .15s; }
#tn-chat .tn-typing .tn-bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes tn-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Message box and Send button */
#tn-chat .tn-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--tn-line);
  background: var(--tn-panel);
}
#tn-chat .tn-chat-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--tn-field-line);
  border-radius: 22px;
  background: var(--tn-field);
  color: var(--tn-text);
  font: inherit;
  line-height: 1.4;
  resize: none;
  box-shadow: none;
}
#tn-chat .tn-chat-input::placeholder { color: var(--tn-muted); opacity: 1; }
#tn-chat .tn-chat-input:focus { outline: none; border-color: var(--tn-brand); box-shadow: 0 0 0 3px rgba(79, 76, 242, .28); }
#tn-chat .tn-chat-send {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 44px;
  padding: 0 16px 0 18px;
  border-radius: 999px;
  background: var(--tn-brand);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
#tn-chat .tn-chat-send svg { width: 16px; height: 16px; }
#tn-chat .tn-chat-send:hover { background: var(--tn-brand-hover); color: #fff; }
#tn-chat .tn-chat-send:focus { color: #fff; }
#tn-chat .tn-chat-send:disabled { opacity: .5; cursor: wait; }
#tn-chat .tn-chat-send:focus-visible { outline: 3px solid var(--tn-brand-soft); outline-offset: 2px; }

#tn-chat .tn-chat-hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

#tn-chat .tn-chat-note {
  margin: 0;
  padding: 0 14px 11px;
  background: var(--tn-panel);
  color: var(--tn-muted);
  font-size: 11.5px;
}
#tn-chat .tn-chat-note a { color: var(--tn-brand-soft); text-decoration: underline; white-space: nowrap; }
#tn-chat .tn-chat-note a:hover { color: #fff; }

@media (max-width: 480px) {
  #tn-chat { right: 12px; bottom: 12px; }
  #tn-chat .tn-chat-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
  #tn-chat.tn-open .tn-chat-launcher { display: none; }
  #tn-chat .tn-chat-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  #tn-chat .tn-chat-launcher, #tn-chat .tn-typing .tn-bubble span, #tn-chat .tn-mascot, #tn-chat .tn-live-dot { transition: none; animation: none; }
}
