.tt-chat-widget {
  --tt-chat-navy: #0b2f6b;
  --tt-chat-ink: #111827;
  --tt-chat-muted: #6b7280;
  --tt-chat-line: #e6e8ee;
  --tt-chat-soft: #f4f6fa;
  --tt-chat-paper: #fff;
  --tt-chat-gold: #e4c56a;
  position: fixed;
  z-index: 55;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 24px);
  font-family: inherit;
  line-height: 1.45;
  color: var(--tt-chat-ink);
  pointer-events: none;
}

.tt-chat-widget > * { pointer-events: auto; }

.tt-chat-widget,
.tt-chat-widget * { box-sizing: border-box; }

body.page-panel .tt-chat-widget { bottom: max(18px, env(safe-area-inset-bottom)); }

body.page-panel .to-top { bottom: 84px; }

.tt-chat-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--tt-chat-navy);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.3rem;
  box-shadow: 0 12px 28px rgba(11, 47, 107, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tt-chat-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(11, 47, 107, 0.35);
  animation: tt-chat-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.tt-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(11, 47, 107, 0.36);
}

.tt-chat-widget.is-open .tt-chat-launcher::after,
.tt-chat-widget.is-inviting .tt-chat-launcher::after { animation: none; }

.tt-chat-dock {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  max-width: calc(100vw - 24px);
}

.tt-chat-invite {
  display: none;
  position: relative;
  align-items: flex-start;
  max-width: min(280px, calc(100vw - 108px));
}

.tt-chat-widget.is-inviting:not(.is-open) .tt-chat-invite {
  display: flex;
  animation: tt-chat-invite-in 0.45s ease;
}

.tt-chat-invite-open {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 12px 34px 12px 12px;
  border: 1px solid var(--tt-chat-line);
  border-radius: 18px 18px 6px 18px;
  background: var(--tt-chat-paper);
  color: var(--tt-chat-ink);
  text-align: left;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.14);
  font-family: inherit;
  cursor: pointer;
}

.tt-chat-invite-open:hover { border-color: #c9d3e4; }

.tt-chat-invite-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--tt-chat-navy);
  color: var(--tt-chat-gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tt-chat-invite-copy { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.tt-chat-invite-name { font-size: 0.72rem; font-weight: 700; color: var(--tt-chat-navy); }
.tt-chat-invite-text { font-size: 0.92rem; font-weight: 600; line-height: 1.35; }

.tt-chat-invite-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--tt-chat-muted);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
}

.tt-chat-invite-x:hover { background: var(--tt-chat-soft); color: var(--tt-chat-ink); }

.tt-chat-pointer {
  display: none;
  position: absolute;
  right: 16px;
  bottom: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  color: var(--tt-chat-navy);
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(11, 47, 107, 0.28));
}

.tt-chat-widget.is-inviting:not(.is-open) .tt-chat-pointer {
  display: block;
  animation: tt-chat-tap 2.8s ease-in-out infinite;
}

.tt-chat-widget.is-inviting:not(.is-open) .tt-chat-launcher {
  animation: tt-chat-press 2.8s ease-in-out infinite;
}

.tt-chat-launcher:focus-visible,
.tt-chat-iconbtn:focus-visible,
.tt-chat-send:focus-visible,
.tt-chat-chip:focus-visible,
.tt-chat-input:focus-visible {
  outline: 2px solid var(--tt-chat-gold);
  outline-offset: 2px;
}

.tt-chat-window {
  width: min(380px, calc(100vw - 36px));
  height: min(560px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--tt-chat-paper);
  border: 1px solid var(--tt-chat-line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.16);
}

.tt-chat-window[hidden] { display: none !important; }

.tt-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: var(--tt-chat-navy);
  color: #fff;
}

.tt-chat-id { display: flex; flex-direction: column; min-width: 0; }
.tt-chat-id strong { font-size: 0.98rem; font-weight: 700; letter-spacing: 0; }
.tt-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.92;
}

.tt-chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tt-chat-gold);
  box-shadow: 0 0 0 4px rgba(228, 197, 106, 0.2);
}

.tt-chat-header-actions { display: flex; gap: 6px; }

.tt-chat-iconbtn,
.tt-chat-send,
.tt-chat-chip {
  font-family: inherit;
  cursor: pointer;
}

.tt-chat-iconbtn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}

.tt-chat-iconbtn:hover { background: rgba(255, 255, 255, 0.22); }

.tt-chat-log {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--tt-chat-soft);
}

.tt-chat-msg { display: flex; flex-direction: column; max-width: 86%; }
.tt-chat-msg:has(.tt-chat-cards) { align-self: stretch; width: 100%; max-width: 100%; }
.tt-chat-msg:has(.tt-chat-cards) .tt-chat-bubble { max-width: 86%; }
.tt-chat-msg.is-user { align-self: flex-end; align-items: flex-end; }
.tt-chat-msg.is-ai { align-self: flex-start; align-items: flex-start; }

.tt-chat-bubble {
  margin: 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.tt-chat-msg.is-user .tt-chat-bubble {
  background: var(--tt-chat-navy);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.tt-chat-msg.is-ai .tt-chat-bubble {
  background: var(--tt-chat-paper);
  color: var(--tt-chat-ink);
  border: 1px solid var(--tt-chat-line);
  border-radius: 16px 16px 16px 4px;
}

.tt-chat-msg.is-error .tt-chat-bubble {
  background: #fff7f8;
  border-color: #f3c3cd;
}

.tt-chat-bubble a { color: inherit; }

.tt-chat-time {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--tt-chat-muted);
}

.tt-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tt-chat-dots { display: inline-flex; gap: 4px; }
.tt-chat-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tt-chat-navy);
  animation: tt-chat-blink 1.2s infinite ease-in-out;
}
.tt-chat-dots span:nth-child(2) { animation-delay: 0.15s; }
.tt-chat-dots span:nth-child(3) { animation-delay: 0.3s; }

.tt-chat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px 0;
  background: var(--tt-chat-paper);
  scrollbar-width: none;
}
.tt-chat-chips::-webkit-scrollbar { display: none; }

.tt-chat-chip {
  flex: 0 0 auto;
  border: 1px solid var(--tt-chat-line);
  background: var(--tt-chat-paper);
  color: var(--tt-chat-ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.tt-chat-chip:hover { border-color: var(--tt-chat-navy); color: var(--tt-chat-navy); }
.tt-chat-chip:disabled { opacity: 0.5; cursor: default; }

.tt-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--tt-chat-paper);
}

.tt-chat-input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  max-height: 120px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--tt-chat-line);
  border-radius: 16px;
  background: var(--tt-chat-soft);
  color: var(--tt-chat-ink);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
}

.tt-chat-send {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--tt-chat-navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.tt-chat-send:hover { background: #08244f; }
.tt-chat-send:disabled { opacity: 0.45; cursor: default; }

.tt-chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes tt-chat-pulse {
  70% { box-shadow: 0 0 0 12px rgba(11, 47, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(11, 47, 107, 0); }
}

@keyframes tt-chat-invite-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes tt-chat-tap {
  0%, 12% { transform: translate(-34px, -26px) rotate(-12deg); }
  38% { transform: translate(0, 0) rotate(0); }
  46% { transform: translate(1px, 5px) scale(0.92); }
  58% { transform: translate(0, 0) rotate(0); }
  100% { transform: translate(-34px, -26px) rotate(-12deg); }
}

@keyframes tt-chat-press {
  0%, 36% { transform: none; }
  46% { transform: scale(0.94); }
  58%, 100% { transform: none; }
}

@keyframes tt-chat-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

html[data-theme="dark"] .tt-chat-widget {
  --tt-chat-ink: #e8edf5;
  --tt-chat-muted: #a8b3c7;
  --tt-chat-line: #314056;
  --tt-chat-soft: #1a2436;
  --tt-chat-paper: #121a2b;
}

html[data-theme="dark"] .tt-chat-msg.is-user .tt-chat-bubble { background: #1d4e9e; }
html[data-theme="dark"] .tt-chat-msg.is-error .tt-chat-bubble {
  background: #2a1620;
  border-color: #6e3142;
}
html[data-theme="dark"] .tt-chat-send:hover,
html[data-theme="dark"] .tt-chat-chip:hover { color: #fff; }
html[data-theme="dark"] .tt-chat-invite-name,
html[data-theme="dark"] .tt-chat-pointer { color: #e4c56a; }
html[data-theme="dark"] .tt-chat-invite-avatar { color: #0b2f6b; background: #e4c56a; }

@media (max-width: 767.98px) {
  .tt-chat-widget.is-open .tt-chat-window {
    position: fixed;
    top: var(--tt-chat-top, 0px);
    right: 0;
    left: 0;
    bottom: var(--tt-chat-keyboard, 0px);
    width: 100%;
    height: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .tt-chat-widget.is-open .tt-chat-header { border-radius: 0; }
  .tt-chat-widget.is-open .tt-chat-dock { display: none; }
  .tt-chat-widget.is-open .tt-chat-form {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

.tt-chat-query {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--tt-chat-muted);
}

.tt-chat-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.tt-chat-card-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--tt-chat-muted);
}

.tt-chat-card {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--tt-chat-line);
  border-radius: 16px;
  background: var(--tt-chat-paper);
}

.tt-chat-card-img,
.tt-chat-card-ph {
  width: 100%;
  height: 132px;
  display: block;
}

.tt-chat-card-img { object-fit: cover; background: var(--tt-chat-soft); }

.tt-chat-card-ph {
  display: grid;
  place-items: center;
  background: #eef2f6;
  color: var(--tt-chat-navy);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tt-chat-card-body { min-width: 0; padding: 12px; }
.tt-chat-card-title,
.tt-chat-card-agency,
.tt-chat-card-place,
.tt-chat-card-meta,
.tt-chat-card-copy { overflow-wrap: anywhere; }
.tt-chat-card-title { margin: 0; font-size: 0.98rem; line-height: 1.3; }
.tt-chat-card-agency,
.tt-chat-card-place,
.tt-chat-card-meta,
.tt-chat-card-copy { margin: 4px 0 0; font-size: 0.82rem; color: var(--tt-chat-muted); }
.tt-chat-card-copy { color: var(--tt-chat-ink); }

.tt-chat-card-price {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px 0 0;
}
.tt-chat-card-price span { font-size: 0.75rem; color: var(--tt-chat-muted); }
.tt-chat-card-price strong { font-size: 1.05rem; color: var(--tt-chat-navy); }

.tt-chat-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.tt-chat-card-btn {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--tt-chat-soft);
  color: var(--tt-chat-navy);
  text-decoration: none;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.tt-chat-card-btn.is-sale { background: var(--tt-chat-navy); color: #fff; }

html[data-theme="dark"] .tt-chat-card-ph { background: #1a2436; color: #e4c56a; }
html[data-theme="dark"] .tt-chat-card-price strong { color: #e4c56a; }

@media (prefers-reduced-motion: reduce) {
  .tt-chat-launcher,
  .tt-chat-launcher::after,
  .tt-chat-pointer,
  .tt-chat-invite,
  .tt-chat-dots span { animation: none; transition: none; }
}
