#teraspark-chatbot,
#teraspark-chatbot * {
  box-sizing: border-box;
}

#teraspark-chatbot {
  --teraspark-green: #087466;
  --teraspark-green-dark: #055d52;
  --teraspark-green-soft: #eaf7f4;
  --teraspark-bg: #f6f8f8;
  --teraspark-text: #15201f;
  --teraspark-muted: #6e7b79;
  --teraspark-border: #e6ecea;
  font-family: Arial, Helvetica, sans-serif;
}

#teraspark-chat-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--teraspark-green);
  color: #fff;
  cursor: pointer;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(8,116,102,.28);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

#teraspark-chat-button:hover {
  transform: translateY(-2px);
  background: var(--teraspark-green-dark);
  box-shadow: 0 15px 36px rgba(8,116,102,.34);
}

.teraspark-launcher-icon {
  font-size: 27px;
  line-height: 1;
}

.teraspark-launcher-dot {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 13px;
  height: 13px;
  background: #41d394;
  border: 3px solid #fff;
  border-radius: 50%;
}

#teraspark-chat-window {
  position: fixed;
  right: 24px;
  bottom: 98px;
  width: 370px;
  height: 470px;
  max-height: calc(100vh - 120px);
  min-height: 330px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.05);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(18,39,36,.24);
  z-index: 999999;
  display: none;
  flex-direction: column;
}

.teraspark-chat-header {
  flex: 0 0 auto;
  min-height: 72px;
  padding: 12px 14px 12px 15px;
  background: linear-gradient(135deg, var(--teraspark-green), var(--teraspark-green-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.teraspark-brand-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.teraspark-avatar {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}

.teraspark-title-wrap {
  min-width: 0;
}

.teraspark-title-wrap strong {
  display: block;
  margin: 0;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
}

.teraspark-title-wrap span {
  margin-top: 5px;
  color: rgba(255,255,255,.88);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.teraspark-status-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: #75edb6;
  box-shadow: 0 0 0 3px rgba(117,237,182,.13);
}

.teraspark-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

#teraspark-chat-clear,
#teraspark-chat-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.13);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s ease;
}

#teraspark-chat-clear:hover,
#teraspark-chat-close:hover {
  background: rgba(255,255,255,.23);
}

#teraspark-chat-clear {
  font-size: 18px;
}

#teraspark-chat-close {
  font-size: 26px;
  padding-bottom: 2px;
}

#teraspark-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 15px;
  background: var(--teraspark-bg);
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.teraspark-welcome-block {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--teraspark-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.04);
  color: var(--teraspark-text);
  margin-bottom: 12px;
}

.teraspark-welcome-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--teraspark-green-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.teraspark-welcome-block strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.teraspark-welcome-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--teraspark-muted);
}

.teraspark-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px;
}

.teraspark-quick-actions button {
  border: 1px solid #cfe2de;
  background: #fff;
  color: var(--teraspark-green-dark);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.teraspark-quick-actions button:hover {
  background: var(--teraspark-green-soft);
  border-color: #a9cec6;
}

.teraspark-message {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 15px;
  margin-bottom: 10px;
  line-height: 1.45;
  font-size: 14px;
  word-break: break-word;
  white-space: pre-wrap;
}

.teraspark-user-message {
  margin-left: auto;
  background: var(--teraspark-green);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 3px 10px rgba(8,116,102,.12);
}

.teraspark-bot-message {
  margin-right: auto;
  background: #fff;
  color: var(--teraspark-text);
  border: 1px solid var(--teraspark-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,.035);
}


.teraspark-bot-message a {
  color: var(--teraspark-green);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.teraspark-typing {
  color: var(--teraspark-muted);
  font-style: italic;
}

.teraspark-streaming::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  animation: terasparkBlink .8s steps(1) infinite;
  color: var(--teraspark-green);
}

@keyframes terasparkBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.teraspark-chat-input-area {
  flex: 0 0 auto;
  padding: 11px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-top: 1px solid var(--teraspark-border);
}

.teraspark-input-wrap {
  flex: 1;
  min-width: 0;
}

#teraspark-chat-input {
  width: 100%;
  height: 44px;
  border: 1px solid #cfdad7;
  border-radius: 13px;
  padding: 0 13px;
  outline: none;
  background: #fff;
  color: var(--teraspark-text);
  font-size: 14px;
  box-shadow: none;
}

#teraspark-chat-input:focus {
  border-color: var(--teraspark-green);
  box-shadow: 0 0 0 3px rgba(8,116,102,.08);
}

#teraspark-chat-send {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--teraspark-green);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#teraspark-chat-send:hover {
  background: var(--teraspark-green-dark);
}

#teraspark-chat-send:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.teraspark-chat-footer-note {
  flex: 0 0 auto;
  padding: 0 12px 9px;
  background: #fff;
  color: #98a19f;
  font-size: 10px;
  text-align: center;
}

@media (max-width: 480px) {
  #teraspark-chat-window {
    right: 10px;
    left: 10px;
    bottom: 82px;
    width: auto;
    height: min(66vh, 500px);
    max-height: calc(100vh - 100px);
    min-height: 320px;
    border-radius: 18px;
  }

  #teraspark-chat-button {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }

  .teraspark-chat-header {
    min-height: 66px;
  }

  .teraspark-avatar {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }
}
