.trinix-chat-launcher {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: 18px;
  z-index: 900;
  width: 52px;
  height: 52px;
  max-width: calc(100vw - 24px);
  border: 0;
  border-radius: 999px;
  background: var(--tx-brand, var(--blue, #003e89));
  color: #fff;
  box-shadow: 0 12px 28px rgba(0, 62, 137, 0.32);
  cursor: pointer;
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + (var(--fab-slot, 0) * 64px));
  box-sizing: border-box;
}

.trinix-whatsapp-fab {
  background: #25d366;
  box-shadow: 0 14px 36px rgba(37, 211, 102, 0.4);
  font-size: 1.55rem;
  z-index: 899;
}

.trinix-telegram-fab {
  background: #229ed9;
  box-shadow: 0 14px 36px rgba(34, 158, 217, 0.4);
  font-size: 1.45rem;
  z-index: 898;
}

.trinix-chat-menu a[data-trinix-telegram] i {
  color: #229ed9;
}

.trinix-chat-menu a i {
  margin-right: 8px;
  color: #25d366;
}

.trinix-chat-wa-tool {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #25d366;
  text-decoration: none;
  font-size: 1.15rem;
}

.trinix-chat-panel {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: 84px;
  z-index: 901;
  width: min(360px, calc(100% - 24px));
  max-width: min(360px, calc(100vw - 24px));
  height: min(640px, calc(100dvh - 110px));
  max-height: min(640px, calc(100dvh - 110px));
  display: none;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  overflow-x: hidden;
  background: #f0f2f5;
  border: 1px solid var(--line, #e5ebf5);
  box-shadow: 0 22px 60px rgba(2, 27, 66, 0.22);
  box-sizing: border-box;
}

.trinix-chat-panel.is-open {
  display: flex;
}

.trinix-chat-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--ink, #001a38);
  flex-shrink: 0;
}

.trinix-chat-back,
.trinix-chat-menu-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--blue, #003e89);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.trinix-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--blue-soft, #e7f0fa);
  flex-shrink: 0;
}

.trinix-chat-head-meta {
  min-width: 0;
  flex: 1;
}

.trinix-chat-head-meta strong {
  display: block;
  font-family: "Plus Jakarta Sans", Inter, sans-serif;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.trinix-chat-head-meta small {
  color: var(--muted, #718ebf);
  font-size: 0.78rem;
}

.trinix-chat-menu {
  position: absolute;
  top: 54px;
  right: 12px;
  z-index: 5;
  min-width: 160px;
  padding: 6px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line, #e5ebf5);
  box-shadow: 0 12px 30px rgba(2, 27, 66, 0.14);
  display: none;
}

.trinix-chat-menu.is-open {
  display: block;
}

.trinix-chat-menu button,
.trinix-chat-menu a {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink, #001a38);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.trinix-chat-menu button:hover,
.trinix-chat-menu a:hover {
  background: var(--blue-soft, #e7f0fa);
}

.trinix-chat-log {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f0f2f5;
}

.trinix-chat-pill {
  align-self: center;
  background: rgba(0, 0, 0, 0.08);
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.trinix-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}

.trinix-chat-row.is-me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.trinix-chat-row.is-them {
  align-self: flex-start;
}

.trinix-chat-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.trinix-chat-bubble {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}

.trinix-chat-bubble.is-them {
  background: #e4e6eb;
  color: #050505;
  border-bottom-left-radius: 6px;
}

.trinix-chat-bubble.is-me {
  background: var(--blue, #003e89);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.trinix-chat-bubble img,
.trinix-chat-bubble a.trinix-chat-img {
  display: block;
  max-width: 220px;
  width: 100%;
  border-radius: 12px;
  margin-top: 6px;
}

.trinix-chat-bubble a.trinix-chat-img {
  cursor: zoom-in;
  overflow: hidden;
}

.trinix-chat-bubble a.trinix-chat-img img {
  margin-top: 0;
  max-width: none;
  width: 100%;
  transition: transform 0.2s ease;
}

.trinix-chat-bubble a.trinix-chat-img:hover img {
  transform: scale(1.02);
}

.trinix-chat-bubble a.trinix-chat-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.trinix-chat-bubble.is-me a.trinix-chat-link {
  color: #fff;
}

.trinix-chat-bubble.is-them a.trinix-chat-link {
  color: var(--blue, #003e89);
}

.trinix-chat-quick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.trinix-chat-quick button {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: var(--blue, #003e89);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
}

.trinix-chat-quick button:hover {
  background: #f8fafc;
}

.trinix-chat-compose-wrap {
  position: relative;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 8px 10px 10px;
}

.trinix-chat-compose {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trinix-chat-tools {
  display: flex;
  align-items: center;
  gap: 2px;
}

.trinix-chat-tools button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--blue, #003e89);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.trinix-chat-input-shell {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  background: #f0f2f5;
}

.trinix-chat-input-shell input[type="text"] {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--ink, #001a38);
  min-width: 0;
  padding: 10px 0;
}

.trinix-chat-input-shell .trinix-chat-emoji-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--blue, #003e89);
  cursor: pointer;
  border-radius: 999px;
}

.trinix-chat-send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--blue, #003e89);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.trinix-chat-emoji-pop {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 58px;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  max-height: min(280px, 42vh);
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line, #e5ebf5);
  box-shadow: 0 12px 30px rgba(2, 27, 66, 0.14);
  z-index: 6;
}

.trinix-chat-emoji-pop.is-open {
  display: flex;
}

.trinix-chat-emoji-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line, #e5ebf5);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.86rem;
  background: #f0f2f5;
  color: var(--ink, #001a38);
  outline: none;
}

.trinix-chat-emoji-search:focus {
  border-color: var(--blue, #003e89);
  background: #fff;
}

.trinix-chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  max-height: 200px;
}

.trinix-chat-emoji-pop button {
  width: 100%;
  aspect-ratio: 1;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.trinix-chat-emoji-pop button:hover {
  background: var(--blue-soft, #e7f0fa);
}

.trinix-chat-emoji-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted, #718ebf);
  font-size: 0.82rem;
  padding: 12px 4px;
}

.trinix-chat-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 768px) {
  html.trinix-chat-open,
  html.trinix-chat-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
    height: 100%;
    height: 100dvh;
    max-width: 100%;
  }

  html.trinix-chat-open .trinix-chat-log {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .trinix-chat-panel {
    position: fixed;
    inset: 0;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0;
    border: 0;
    box-sizing: border-box;
    overflow-x: hidden !important;
  }

  .trinix-chat-panel > * {
    max-width: 100%;
    box-sizing: border-box;
  }

  html.trinix-chat-open .trinix-chat-launcher,
  html.trinix-chat-open .trinix-whatsapp-fab,
  html.trinix-chat-open .trinix-telegram-fab {
    display: none !important;
  }

  .trinix-chat-head {
    padding-top: max(10px, env(safe-area-inset-top));
    min-height: 52px;
    width: 100%;
  }

  .trinix-chat-head-meta strong {
    font-size: 0.92rem;
  }

  .trinix-chat-head-meta small {
    font-size: 0.72rem;
  }

  .trinix-chat-menu {
    right: 8px;
    left: auto;
    max-width: calc(100% - 16px);
  }

  .trinix-chat-compose-wrap {
    padding: 8px 8px max(10px, env(safe-area-inset-bottom));
    width: 100%;
  }

  .trinix-chat-bubble img,
  .trinix-chat-bubble a.trinix-chat-img {
    max-width: min(220px, 70vw);
  }

  .trinix-chat-row {
    max-width: 96%;
  }

  .trinix-chat-emoji-pop {
    left: 6px;
    right: 6px;
    width: auto;
    max-width: calc(100% - 12px);
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    max-height: min(46vh, 320px);
    box-sizing: border-box;
  }

  .trinix-chat-emoji-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    max-height: min(36vh, 240px);
  }

  .trinix-chat-compose {
    gap: 4px;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
  }

  .trinix-chat-tools {
    gap: 0;
    flex-shrink: 0;
  }

  .trinix-chat-input-shell {
    min-height: 44px;
    padding-left: 12px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  #trinixChatLike {
    display: none;
  }

  .trinix-chat-launcher,
  .trinix-whatsapp-fab,
  .trinix-telegram-fab {
    right: max(10px, env(safe-area-inset-right));
    width: 48px;
    height: 48px;
    font-size: 1.15rem;
  }

  .trinix-chat-quick button {
    padding: 10px;
    font-size: 0.85rem;
  }
}

html[data-theme="dark"] .trinix-chat-panel,
html[data-theme="dark"] .trinix-chat-head,
html[data-theme="dark"] .trinix-chat-compose-wrap,
html[data-theme="dark"] .trinix-chat-menu,
html[data-theme="dark"] .trinix-chat-emoji-pop,
html[data-theme="dark"] .trinix-chat-quick button {
  background: var(--card, #101b30);
  color: var(--ink, #f4f7ff);
  border-color: var(--line);
}

html[data-theme="dark"] .trinix-chat-log {
  background: var(--bg, #070d18);
}

html[data-theme="dark"] .trinix-chat-bubble.is-them {
  background: var(--bg-soft, #0d1524);
  color: var(--ink, #f4f7ff);
}

html[data-theme="dark"] .trinix-chat-input-shell {
  background: var(--bg-soft, #0d1524);
}

html[data-theme="dark"] .trinix-chat-emoji-search {
  background: var(--bg-soft, #0d1524);
  color: var(--ink, #f4f7ff);
  border-color: var(--line);
}

html[data-theme="dark"] .trinix-chat-emoji-search:focus {
  background: var(--card, #101b30);
}
