#tte-openai-assistant-root,
#tte-openai-assistant-root * {
  box-sizing: border-box;
}

#tte-openai-assistant-root {
  --tte-primary: #174f2c;
  --tte-panel-width: 380px;
  position: fixed;
  bottom: 22px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

#tte-openai-assistant-root.tte-position-right { right: 22px; }
#tte-openai-assistant-root.tte-position-left { left: 22px; }

.tte-ai-toggle {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--tte-primary);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .24);
  cursor: pointer;
  transition: transform .2s ease, opacity .2s ease, box-shadow .2s ease;
}

.tte-ai-toggle:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 15px 35px rgba(0, 0, 0, .28); }
.tte-ai-toggle:focus-visible { outline: 3px solid rgba(23, 79, 44, .25); outline-offset: 3px; }
.tte-ai-toggle.is-hidden { opacity: 0; pointer-events: none; transform: scale(.85); }
.tte-ai-toggle svg { width: 29px; height: 29px; fill: currentColor; }

.tte-ai-panel {
  position: absolute;
  bottom: 0;
  width: var(--tte-panel-width);
  height: min(590px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(18px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

.tte-position-right .tte-ai-panel { right: 0; }
.tte-position-left .tte-ai-panel { left: 0; transform-origin: bottom left; }

.tte-ai-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.tte-ai-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
  background: var(--tte-primary);
}

.tte-ai-avatar {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .4px;
}

.tte-ai-title { min-width: 0; flex: 1; }
.tte-ai-title strong { display: block; overflow: hidden; font-size: 16px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.tte-ai-title span { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; opacity: .9; }
.tte-ai-title span i { width: 7px; height: 7px; border-radius: 50%; background: #8bf3a7; box-shadow: 0 0 0 3px rgba(139, 243, 167, .16); }

.tte-ai-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.tte-ai-close:hover { background: rgba(255, 255, 255, .14); }
.tte-ai-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.tte-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 15px;
  background: #f4f6f5;
  overscroll-behavior: contain;
}

.tte-ai-message-row { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 12px; }
.tte-ai-message-row.is-user { align-items: flex-end; }

.tte-ai-message {
  max-width: 84%;
  padding: 11px 13px;
  border-radius: 15px 15px 15px 4px;
  color: #202421;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .07);
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.is-user .tte-ai-message {
  color: #fff;
  background: var(--tte-primary);
  border-radius: 15px 15px 4px 15px;
}

.tte-ai-sources {
  max-width: 84%;
  margin-top: 5px;
  padding: 0 4px;
  color: #6a716c;
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.tte-ai-message.is-loading { min-width: 58px; display: flex; align-items: center; gap: 5px; min-height: 39px; }
.tte-ai-message.is-loading span { width: 7px; height: 7px; border-radius: 50%; background: #98a09a; animation: tte-dot 1.2s infinite ease-in-out; }
.tte-ai-message.is-loading span:nth-child(2) { animation-delay: .15s; }
.tte-ai-message.is-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes tte-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

.tte-ai-form {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 11px 12px;
  border-top: 1px solid #e5e9e6;
  background: #fff;
}

.tte-ai-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 43px;
  max-height: 110px;
  margin: 0;
  resize: none;
  border: 1px solid #d7ddd9;
  border-radius: 12px;
  padding: 11px 12px;
  color: #202421;
  background: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
  box-shadow: none;
}
.tte-ai-form textarea:focus { border-color: var(--tte-primary); box-shadow: 0 0 0 3px rgba(23, 79, 44, .1); }

.tte-ai-icon-button {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
}
.tte-ai-icon-button svg { width: 21px; height: 21px; fill: currentColor; }
.tte-ai-send { color: #fff; background: var(--tte-primary); }
.tte-ai-mic { color: var(--tte-primary); background: #eef3ef; }
.tte-ai-mic[hidden] { display: none !important; }
.tte-ai-mic.is-listening { color: #fff; background: #b42318; animation: tte-pulse 1.2s infinite; }
@keyframes tte-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .3); } 50% { box-shadow: 0 0 0 7px rgba(180, 35, 24, 0); } }
.tte-ai-icon-button:disabled { opacity: .45; cursor: not-allowed; }
.tte-ai-icon-button:focus-visible { outline: 3px solid rgba(23, 79, 44, .16); outline-offset: 2px; }

.tte-ai-disclaimer {
  padding: 0 12px 10px;
  color: #747b76;
  background: #fff;
  font-size: 10.5px;
  text-align: center;
}

#tte-openai-assistant-root .screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  #tte-openai-assistant-root,
  #tte-openai-assistant-root.tte-position-right,
  #tte-openai-assistant-root.tte-position-left {
    right: 12px;
    left: auto;
    bottom: 12px;
  }

  .tte-ai-panel,
  .tte-position-left .tte-ai-panel,
  .tte-position-right .tte-ai-panel {
    position: fixed;
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    height: min(690px, calc(100dvh - 16px));
    border-radius: 18px;
    transform-origin: bottom center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tte-ai-toggle,
  .tte-ai-panel,
  .tte-ai-message.is-loading span,
  .tte-ai-mic.is-listening {
    animation: none !important;
    transition: none !important;
  }
}
