:root {
  --tc-chat-accent: #2d6cdf;
  --tc-chat-bg: #ffffff;
  --tc-chat-muted: #6f7b8c;
  --tc-chat-border: #e6ebf3;
  --tc-chat-shadow: 0 18px 45px rgba(27, 48, 78, 0.2);
}

#tc-ai-chatbot-root,
#tc-ai-chatbot-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: normal;
}

#tc-ai-chatbot-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147483000;
}

#tc-ai-chatbot-root .tc-chat-launcher,
#tc-ai-chatbot-root .tc-chat-panel {
  pointer-events: auto;
}

.tc-chat-launcher {
  position: fixed;
  right: 18px;
  right: calc(18px + env(safe-area-inset-right, 0px));
  right: calc(18px + constant(safe-area-inset-right));
  bottom: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  bottom: calc(18px + constant(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--tc-chat-accent), #1e4fa8);
  box-shadow: var(--tc-chat-shadow);
  z-index: 2147483001;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: visible;
  opacity: 1;
}

.tc-launcher-icon {
  display: inline-block;
  transform-origin: center;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
}

.tc-launcher-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tc-chat-launcher.is-spin-1 .tc-launcher-icon {
  animation: tcSpin1 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

.tc-chat-launcher.is-spin-5 .tc-launcher-icon {
  animation: tcSpin5 1.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes tcSpin1 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes tcSpin5 {
  from { transform: rotate(0deg); }
  to { transform: rotate(1800deg); }
}

.tc-chat-panel {
  position: fixed;
  right: 18px;
  right: calc(18px + env(safe-area-inset-right, 0px));
  right: calc(18px + constant(safe-area-inset-right));
  bottom: 88px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  bottom: calc(88px + constant(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 20px));
  height: min(520px, calc(100dvh - 110px));
  max-height: calc(100dvh - 110px);
  background: var(--tc-chat-bg);
  border: 1px solid var(--tc-chat-border);
  border-radius: 18px;
  box-shadow: var(--tc-chat-shadow);
  overflow: hidden;
  transform: translateY(10px) scale(0.985);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 2147483001;
  display: flex;
  flex-direction: column;
}

.tc-chat-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.tc-chat-head {
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--tc-chat-accent), #1e4fa8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tc-chat-title {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
}

.tc-chat-sub {
  font-size: 12px;
  opacity: 0.95;
}

.tc-chat-close {
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.tc-chat-body {
  flex: 1;
  overflow: auto;
  background: radial-gradient(circle at 0% 0%, #f4f8ff 0%, #ffffff 45%);
  padding: 14px;
}

.tc-msg {
  max-width: 94%;
  padding: 11px 13px;
  margin-bottom: 10px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-line;
  word-break: break-word;
}

.tc-msg-bot {
  background: #fff;
  border: 1px solid var(--tc-chat-border);
  color: #12233f;
  border-bottom-left-radius: 6px;
}

.tc-msg-user {
  margin-left: auto;
  background: linear-gradient(135deg, var(--tc-chat-accent), #2f58b0);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.tc-rich {
  display: block;
}

.tc-rich-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  margin: 2px 0 8px;
}

.tc-rich-row {
  margin: 2px 0;
  line-height: 1.45;
}

.tc-rich-key {
  font-weight: 700;
  font-size: 15px;
}

.tc-rich-value {
  font-size: 15px;
}

.tc-rich-text {
  margin: 3px 0;
}

.tc-rich-spacer {
  height: 8px;
}

.tc-chat-quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}

.tc-chat-quick button {
  border: 1px solid var(--tc-chat-border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.tc-chat-foot {
  border-top: 1px solid var(--tc-chat-border);
  padding: 10px;
  background: #fff;
}

.tc-chat-form {
  display: flex;
  gap: 8px;
}

.tc-chat-input {
  flex: 1;
  min-height: 60px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--tc-chat-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.35;
  outline: none;
  font-family: inherit;
}

.tc-chat-input:focus {
  border-color: #9ab4ec;
}

.tc-chat-send {
  min-width: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--tc-chat-accent), #1e4fa8);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
}

.tc-chat-send:disabled {
  opacity: 0.6;
  cursor: wait;
}

.tc-chat-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--tc-chat-muted);
}

@media (max-width: 768px) {
  .tc-chat-launcher {
    right: 12px;
    right: calc(12px + env(safe-area-inset-right, 0px));
    right: calc(12px + constant(safe-area-inset-right));
    bottom: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    bottom: calc(12px + constant(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
  }

  .tc-chat-panel {
    right: 10px;
    right: calc(10px + env(safe-area-inset-right, 0px));
    right: calc(10px + constant(safe-area-inset-right));
    bottom: 76px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    bottom: calc(76px + constant(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    height: min(70dvh, calc(100dvh - 100px));
    max-height: calc(100dvh - 100px);
    border-radius: 14px;
  }

  .tc-msg {
    max-width: 97%;
    font-size: 15px;
  }

  .tc-rich-title {
    font-size: 17px;
  }
}
