.tf-demo-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(420px, 1.22fr);
  gap: clamp(36px, 6vw, 88px);
  align-items: center;
  overflow: hidden;
  padding: clamp(28px, 5vw, 68px);
  border: 1px solid var(--line);
  border-radius: clamp(24px, 4vw, 40px);
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 106, 0, 0.19), transparent 34%),
    linear-gradient(145deg, rgba(18, 18, 20, 0.98), rgba(6, 6, 7, 0.98));
  box-shadow: var(--shadow);
  isolation: isolate;
}

.tf-demo-shell::before {
  position: absolute;
  z-index: -1;
  right: -18%;
  bottom: -46%;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(255, 106, 0, 0.16);
  border-radius: 50%;
  content: "";
}

.tf-demo-intro {
  max-width: 470px;
}

.tf-demo-title {
  max-width: 520px;
  margin: 18px 0 0;
  font-size: clamp(2.5rem, 5vw, 5.35rem);
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.tf-demo-copy {
  max-width: 440px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.16rem);
}

.tf-demo-fallback-link {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-top: 30px;
  padding: 12px 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-color: rgba(255, 154, 60, 0.55);
  text-underline-offset: 6px;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.tf-demo-fallback-link:hover {
  color: var(--orange-2);
  text-decoration-color: var(--orange-2);
}

.tf-demo-fallback-icon {
  width: 18px;
  height: 18px;
  transition: transform 180ms ease;
}

.tf-demo-fallback-link:hover .tf-demo-fallback-icon {
  transform: translate(2px, -2px);
}

.tf-demo-chat {
  min-width: 0;
  overflow: hidden;
  color-scheme: dark;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 28px;
  background: rgba(4, 4, 5, 0.88);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
}

.tf-demo-chat-header {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.tf-demo-avatar {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 154, 60, 0.45);
  border-radius: 13px;
  color: #160a02;
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
  box-shadow: 0 8px 24px rgba(255, 106, 0, 0.22);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.tf-demo-chat-heading {
  display: grid;
  gap: 1px;
}

.tf-demo-chat-heading strong {
  font-size: 0.98rem;
}

.tf-demo-chat-heading span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.tf-demo-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(141, 255, 189, 0.08);
}

.tf-demo-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
  height: clamp(280px, 34vw, 390px);
  overflow-y: auto;
  padding: 22px 20px 16px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(255, 154, 60, 0.45) transparent;
  scrollbar-width: thin;
}

.tf-demo-message {
  width: fit-content;
  max-width: min(84%, 520px);
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  animation: tf-demo-message-in 180ms ease-out both;
}

.tf-demo-message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.48;
}

.tf-demo-message-assistant {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.065);
}

.tf-demo-message-user {
  align-self: flex-end;
  border-color: rgba(255, 154, 60, 0.24);
  border-bottom-right-radius: 6px;
  color: #160a02;
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
}

.tf-demo-message-error {
  border-color: rgba(255, 154, 60, 0.28);
  background: rgba(255, 106, 0, 0.1);
}

.tf-demo-message-typing {
  color: var(--muted);
  font-style: italic;
}

.tf-demo-message-action {
  margin-top: 12px;
}

.tf-demo-contact-button,
.tf-demo-retry-button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 154, 60, 0.4);
  border-radius: 11px;
  color: var(--text);
  background: rgba(255, 106, 0, 0.14);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.tf-demo-contact-button:hover,
.tf-demo-retry-button:hover {
  border-color: var(--orange-2);
  background: rgba(255, 106, 0, 0.22);
  transform: translateY(-1px);
}

.tf-demo-quick-questions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 20px 16px;
  scrollbar-width: none;
}

.tf-demo-quick-questions::-webkit-scrollbar {
  display: none;
}

.tf-demo-quick-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.tf-demo-quick-button:hover {
  border-color: rgba(255, 154, 60, 0.45);
  color: var(--text);
  background: var(--orange-soft);
}

.tf-demo-form {
  padding: 16px 20px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}

.tf-demo-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.tf-demo-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.tf-demo-input {
  width: 100%;
  min-height: 48px;
  max-height: 130px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.tf-demo-input::placeholder {
  color: var(--muted-2);
}

.tf-demo-input:focus-visible {
  border-color: var(--orange-2);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.12);
}

.tf-demo-send-button {
  min-width: 92px;
  min-height: 48px;
  padding: 11px 17px;
  border: 0;
  border-radius: 14px;
  color: #160a02;
  background: linear-gradient(135deg, var(--orange-2), var(--orange));
  box-shadow: 0 9px 24px rgba(255, 106, 0, 0.18);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 900;
  transition: filter 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.tf-demo-send-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.tf-demo-send-button:disabled,
.tf-demo-quick-button:disabled,
.tf-demo-input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.tf-demo-privacy,
.tf-demo-status {
  margin: 8px 0 0;
  color: var(--muted-2);
  font-size: 0.72rem;
  line-height: 1.4;
}

.tf-demo-status {
  min-height: 1em;
}

.tf-demo-status-error {
  color: var(--orange-2);
}

.tf-demo-fallback-link:focus-visible,
.tf-demo-quick-button:focus-visible,
.tf-demo-contact-button:focus-visible,
.tf-demo-retry-button:focus-visible,
.tf-demo-send-button:focus-visible {
  outline: 2px solid var(--orange-2);
  outline-offset: 3px;
}

@keyframes tf-demo-message-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .tf-demo-shell {
    grid-template-columns: 1fr;
  }

  .tf-demo-intro {
    max-width: 620px;
  }

  .tf-demo-title {
    font-size: clamp(2.7rem, 10vw, 5rem);
  }
}

@media (max-width: 560px) {
  .tf-demo-shell {
    gap: 28px;
    padding: 20px 14px 14px;
    border-radius: 24px;
  }

  .tf-demo-intro {
    padding: 8px 8px 0;
  }

  .tf-demo-title {
    font-size: clamp(2.35rem, 13vw, 3.5rem);
  }

  .tf-demo-copy {
    margin-top: 18px;
  }

  .tf-demo-fallback-link {
    margin-top: 18px;
  }

  .tf-demo-chat {
    border-radius: 20px;
  }

  .tf-demo-messages {
    height: 330px;
    min-height: 250px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .tf-demo-message {
    max-width: 92%;
  }

  .tf-demo-quick-questions,
  .tf-demo-form {
    padding-right: 14px;
    padding-left: 14px;
  }

  .tf-demo-quick-questions {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .tf-demo-quick-button {
    flex: 1 1 160px;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .tf-demo-composer {
    grid-template-columns: 1fr;
  }

  .tf-demo-send-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tf-demo-message,
  .tf-demo-fallback-link,
  .tf-demo-fallback-icon,
  .tf-demo-quick-button,
  .tf-demo-contact-button,
  .tf-demo-retry-button,
  .tf-demo-input,
  .tf-demo-send-button {
    animation: none;
    scroll-behavior: auto;
    transition: none;
  }
}
