.tr-chat {
  scroll-margin-top: 16px;
  margin: 0 0 20px;
}
.tr-chat-collapsed {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, #fff7ef, #eef4ff);
  border: 1px solid #ffd4b3;
  border-radius: 12px;
}
.tr-chat-btn {
  appearance: none;
  border: 0;
  background: #ff6a1a;
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
  text-align: center;
  flex: 0 0 auto;
}
.tr-chat-btn:hover { background: #e85d10; color: #fff; }
.tr-chat-hint {
  appearance: none;
  border: 0;
  background: transparent;
  color: #152238;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0 2px 0 0;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.45;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.tr-chat-hint:hover { color: #1e4fd6; }
.tr-chat-hint-copy {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tr-chat-hint-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #1e4fd6;
  background: rgba(30, 79, 214, 0.08);
}
.tr-chat-hint:hover .tr-chat-hint-icon {
  background: rgba(30, 79, 214, 0.14);
  color: #163db0;
}
.tr-chat-panel {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 640px);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}
.tr-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #edf2f7;
  background: #f8fafc;
}
.tr-chat-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.tr-chat-head-btn {
  appearance: none;
  border: 1px solid #cbd5e0;
  background: #fff;
  color: #4a5568;
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.tr-chat-head-btn:hover { border-color: #1e4fd6; color: #1e4fd6; }
.tr-chat-head-btn:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: #e2e8f0;
  color: #a0aec0;
}
.tr-chat-hint-type {
  display: inline;
  color: #1e4fd6;
  font-weight: 700;
  border-right: 2px solid #1e4fd6;
  white-space: nowrap;
  animation: tr-chat-caret 0.9s step-end infinite;
  padding-right: 1px;
}
@keyframes tr-chat-caret {
  50% { border-right-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .tr-chat-hint-type { animation: none; border-right: 0; }
}
.tr-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tr-chat-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.tr-chat-bubble.is-assistant {
  background: #edf2f7;
  color: #1a202c;
  align-self: flex-start;
}
.tr-chat-bubble.is-user {
  background: #1e4fd6;
  color: #fff;
  align-self: flex-end;
}
.tr-chat-bubble .tr-chat-plan {
  white-space: normal;
}
.tr-chat-plan ol { margin: 8px 0 0; padding-left: 1.2em; }
.tr-chat-plan li { margin: 0 0 8px; }
.tr-chat-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
}
.tr-chat-replies:empty {
  display: none;
  padding: 0;
  margin: 0;
}
.tr-chat-quota[hidden] {
  display: none !important;
  margin: 0;
  padding: 0;
}
.tr-chat-chip {
  appearance: none;
  border: 1px solid #cbd5e0;
  background: #fff;
  color: #2d3748;
  font: inherit;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.tr-chat-chip:hover { border-color: #1e4fd6; color: #1e4fd6; }
.tr-chat-form {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
  align-items: flex-end;
}
.tr-chat-input {
  flex: 1;
  resize: none;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  min-height: 44px;
}
.tr-chat-send {
  appearance: none;
  border: 0;
  background: #1e4fd6;
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.tr-chat-form[hidden],
.tr-chat-panel[hidden] { display: none !important; }
.tr-chat.is-open .tr-chat-collapsed { display: none; }
.tr-chat.is-open .tr-chat-panel { display: flex; }
.tr-chat.is-open {
  position: relative;
  z-index: 50;
}

.tr-chat.is-open .tr-chat-panel {
  border: 2px solid #1e4fd6;
  border-radius: 16px;
  background: #f5f8ff;
  box-shadow: 0 18px 48px rgba(30, 79, 214, 0.28);
}
.tr-chat.is-open .tr-chat-head {
  background: linear-gradient(90deg, #1740c4 0%, #1e56ef 55%, #1638a8 100%);
  border-bottom: 2px solid #ff6a1a;
  color: #fff;
}
.tr-chat.is-open .tr-chat-head strong {
  color: #fff;
  font-weight: 800;
}
.tr-chat.is-open .tr-chat-head-btn {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.tr-chat.is-open .tr-chat-head-btn:hover {
  border-color: #ffd400;
  color: #ffd400;
  background: rgba(255, 212, 0, 0.12);
}
.tr-chat.is-open .tr-chat-head-btn:disabled {
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.45);
  background: transparent;
}
.tr-chat.is-open .tr-chat-bubble.is-assistant {
  background: #e8efff;
  border: 1px solid #c9dbff;
  color: #152238;
}
.tr-chat.is-open .tr-chat-bubble.is-user {
  background: #ff6a1a;
  color: #fff;
}
.tr-chat.is-open .tr-chat-chip {
  border-color: #9db8f5;
  background: #fff;
  color: #1e4fd6;
  font-weight: 700;
}
.tr-chat.is-open .tr-chat-chip:hover {
  border-color: #ff6a1a;
  color: #ff6a1a;
  background: #fff7ef;
}
.tr-chat.is-open .tr-chat-input {
  border-color: #9db8f5;
  background: #fff;
}
.tr-chat.is-open .tr-chat-input:focus {
  outline: 2px solid rgba(255, 106, 26, 0.35);
  border-color: #ff6a1a;
}
.tr-chat.is-open .tr-chat-send {
  background: #ff6a1a;
}
.tr-chat.is-open .tr-chat-send:hover {
  background: #e85d10;
}
.tr-chat.is-open .tr-chat-quota {
  color: #1e4fd6;
}
.tr-chat.is-open .tr-chat-typing {
  color: #1e4fd6;
}

.tr-chat.is-busy .tr-chat-send,
.tr-chat.is-busy .tr-chat-chip,
.tr-chat.is-busy [data-tr-chat-back],
.tr-chat.is-busy [data-tr-chat-reset] { opacity: 0.6; pointer-events: none; }
.tr-chat-typing {
  align-self: flex-start;
  color: #718096;
  font-size: 0.9rem;
}
.tr-chat-error { color: #c53030; font-size: 0.9rem; padding: 0 14px 10px; }
.tr-chat-quota {
  margin: 0;
  padding: 0 14px 10px;
  font-size: 0.82rem;
  color: #718096;
}
.tr-chat-quota.is-exhausted {
  color: #9a3412;
  font-weight: 600;
  background: #fff1f2;
  margin: 0 12px 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #fecdd3;
  line-height: 1.45;
}
.tr-chat-bottom { margin: 28px 0 8px; }
.tr-chat-bottom .tr-chat-collapsed {
  margin: 0;
}
.tr-chat-bottom .tr-chat-btn { width: auto; }
.tr-chat-cta-wrap { margin: 0 0 20px; }

.tr-full-offer {
  margin: 16px 0 20px;
  padding: 18px 20px;
  border-radius: 14px;
  border: 2px solid #ffd4b3;
  background: linear-gradient(180deg, #fff7ef 0%, #f5f8ff 100%);
}
.tr-full-offer-lead { margin: 0 0 10px; color: #1e293b; font-size: 1.02rem; }
.tr-full-offer-body { margin: 0 0 10px; color: #334155; line-height: 1.55; }
.tr-full-offer-list { margin: 0 0 14px 18px; padding: 0; color: #334155; line-height: 1.55; }
.tr-full-offer-list li { margin-bottom: 6px; }
.tr-full-offer-btn {
  appearance: none; border: 0; cursor: pointer;
  background: #ff6a1a; color: #fff; font: inherit; font-weight: 700;
  padding: 12px 18px; border-radius: 10px;
  text-decoration: none; display: inline-block;
}
.tr-full-offer-btn:hover { background: #e85d10; color: #fff; }
.tr-full-offer-note { margin: 12px 0 0; font-size: 0.9rem; color: #64748b; }

.tr-order-grade-pick {
  margin: 10px 0;
  padding: 10px;
  background: #f8fafc;
  border-radius: 10px;
}
.tr-order-grade-pick .tr-chat-reply-btn { margin: 4px 6px 4px 0; }

@media (max-width: 768px) {
  .tr-chat-panel { max-height: min(78vh, 560px); }
  .tr-chat-hint { min-width: 0; }
  .tr-chat-hint-type { min-width: 0; }
}
