:root {
  --chat-dock-height: 94px;
  --chat-dock-fade: 80px;
}

.home-chat-preview {
  padding-bottom: calc(var(--chat-dock-height) + var(--chat-dock-fade) + 16px);
}

.home-chat-preview .home-stack > .home-intro {
  animation: none;
}

.home-chat-preview .home-intro[hidden] {
  display: none;
}

.home-chat-preview.is-chat-mode {
  align-items: flex-start;
}

.home-chat-preview.is-chat-mode .page {
  min-height: calc(100svh - var(--chat-dock-height) - var(--chat-dock-fade) - 16px);
  padding-top: max(104px, calc(env(safe-area-inset-top) + 86px));
  padding-bottom: 32px;
}

.home-chat-preview .brand-slot {
  display: flex;
  align-items: center;
  min-height: 40px;
}

.home-chat-preview .home-stack > .home-chat {
  animation: none;
}

.home-chat {
  --chat-accent: #4a5b96;
  min-width: 0;
  color: var(--secondary);
}

.home-chat.chat-dock {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  isolation: isolate;
  padding: 28px 0 max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.chat-dock::before {
  position: absolute;
  z-index: -1;
  inset: calc(0px - var(--chat-dock-fade)) 0 0;
  content: '';
  pointer-events: none;
  background: linear-gradient(180deg, #ffffff00 0%, #ffffff8c 24%, #ffffffeb 52%, #fff 88%);
  -webkit-backdrop-filter: blur(28px);
  backdrop-filter: blur(28px);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 50%);
  mask-image: linear-gradient(180deg, transparent, #000 50%);
}

.chat-dock.is-expanded::after {
  position: fixed;
  z-index: 0;
  top: 0;
  right: 0;
  left: 0;
  height: 88px;
  content: '';
  pointer-events: none;
  background: linear-gradient(180deg, #fff, #ffffffe8 58%, #ffffff00);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}

.chat-dock__inner {
  position: relative;
  width: min(537.6px, calc(100% - 38.4px));
  margin: 0 auto;
  pointer-events: auto;
}

.home-chat .jump-latest {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  padding: 7px 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 10px #1a1a1a08;
  color: var(--secondary);
  font-size: 11px;
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  .home-chat .jump-latest:not([hidden]) { animation: chat-latest-reveal .16s ease-out; }
  .home-chat .thinking-dots i { animation: thinking-dot 1.2s ease-in-out infinite; }
  .home-chat .thinking-dots i:nth-child(2) { animation-delay: .15s; }
  .home-chat .thinking-dots i:nth-child(3) { animation-delay: .3s; }
  .home-chat .is-streaming .ai-answer::after { animation: chat-pending-breathe 1s ease-in-out infinite; }
}

@keyframes thinking-dot {
  0%, 65%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.home-chat .ai-pending[data-waiting] { display: flex; align-items: center; gap: 10px; min-height: 28px; font-size: 12px; color: var(--secondary); }
.home-chat .thinking-dots { display: inline-flex; align-items: center; gap: 4px; height: 18px; color: var(--secondary); }
.home-chat .thinking-dots i { display: block; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.home-chat .is-streaming .ai-answer::after { content: ''; display: inline-block; width: 5px; height: 12px; margin-left: 4px; vertical-align: baseline; border-radius: 2px; background: #929298; }
.home-chat .follow-up-questions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.home-chat .follow-up-questions button { padding: 8px 12px; border: 1px solid var(--stroke); border-radius: 16px; background: #fff; color: var(--secondary); font-size: 12px; line-height: 1.6; text-align: left; }
.home-chat .follow-up-questions button:hover { background: var(--fill); color: var(--primary); }

@keyframes chat-latest-reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chat-pending-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

.dock-topics {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-chat .contact-launch {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 3px 13px 3px 3px;
  border: 1px solid #e5e5e8;
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  line-height: 1.5;
}

.home-chat .contact-launch::after {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid #a8adb6;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
}

/* Only the outer ring moves; the capsule and portrait stay still. */
.home-chat .contact-launch:not(.is-active)::after {
  border: 1px solid #9ba8ba;
  background: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .home-chat .contact-launch:not(.is-active):not(:hover):not(:focus-within)::after {
    animation: chat-invitation-ripple 2s ease-out .5s infinite;
  }
}

@keyframes chat-invitation-ripple {
  0% { opacity: 0; inset: -1px; }
  8% { opacity: .4; inset: -1px; }
  65%, 100% { opacity: 0; inset: -7px; }
}

.home-chat .contact-launch:hover {
  border-color: #cfcfd4;
  background: #fafafa;
}

.home-chat .contact-launch.is-active {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: max(19.2px, calc((100vw - 537.6px) / 2));
  z-index: 1;
  border-color: #dedee2;
  box-shadow: 0 4px 20px #1a1a1a0b;
}

.contact-launch__status {
  display: grid;
  flex: none;
  width: 20px;
  height: 20px;
  margin-left: 3px;
  place-items: center;
  border-radius: 50%;
  background: var(--fill);
  color: var(--secondary);
}

@property --chat-border-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.home-chat .contact-launch.is-active::after {
  padding: 1.5px;
  border: 0;
  opacity: 1;
  background: conic-gradient(from var(--chat-border-angle), transparent 0deg 255deg, #a2b0ce50 285deg, #718abbd9 325deg, #b6c8e8 341deg, transparent 360deg);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
}

@media (prefers-reduced-motion: no-preference) {
  .home-chat .contact-launch.is-active::after {
    animation: chat-border-orbit 3.6s linear infinite;
  }
}

@keyframes chat-border-orbit {
  to { --chat-border-angle: 360deg; }
}

.contact-launch__status svg {
  width: 14px;
  height: 14px;
}

.contact-launch:hover .contact-launch__status {
  background: #e8e8eb;
  color: var(--primary);
}

.contact-launch__avatar {
  position: relative;
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
  background: #ececeb;
}

.contact-launch__avatar img {
  position: absolute;
  top: -25%;
  left: -40%;
  width: 180%;
  height: 180%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 43%;
}

.home-chat button,
.home-chat textarea {
  font: inherit;
}

.home-chat button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.home-chat button:focus-visible,
.home-chat a:focus-visible {
  outline: 2px solid #9b9b9b;
  outline-offset: 4px;
}

.home-chat [hidden] {
  display: none;
}

.home-chat .quick-topics {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 6px;
}

.home-chat .quick-topics::-webkit-scrollbar {
  display: none;
}

.home-chat .quick-topics.has-more {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
}

.home-chat .quick-topics button {
  flex: none;
  min-width: 60px;
  min-height: 28px;
  padding: 4px 16px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: #fff;
  color: var(--secondary);
  font-size: 11px;
  line-height: 18px;
  transition: border-color .15s, background .15s, color .15s;
}

@media (prefers-reduced-motion: no-preference) {
  .home-chat .quick-topics button { transition: border-color .15s, background .15s, color .15s, transform .12s ease-out; }
  .home-chat .quick-topics button:active:not(:disabled) { transform: scale(.95); }
}

.home-chat .composer-wrap {
  margin-top: 8px;
}

.home-chat .quick-topics button:hover {
  border-color: #d7d7dc;
  background: var(--fill);
  color: var(--primary);
}

.home-chat .composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 46px;
  margin: 0;
  padding: 6px 7px 6px 16px;
  border: 1px solid #dedee2;
  border-radius: 25px;
  background: #fff;
  box-shadow: 0 3px 14px #1a1a1a04;
  transition: border-color .15s, box-shadow .15s;
}

.home-chat .composer:focus-within {
  border-color: #aaaab5;
  box-shadow: 0 0 0 3px #1a1a1a04;
}

.home-chat .composer textarea {
  display: block;
  flex: 1;
  min-width: 0;
  max-height: 120px;
  margin: 0;
  padding: 6px 0;
  border: 0;
  outline: none;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  line-height: 20px;
}

.home-chat .composer textarea::placeholder {
  color: #929298;
}

.home-chat .send-button {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  transition: background .15s;
}

.home-chat .send-button svg {
  width: 20px;
  height: 20px;
}

.home-chat .send-button:hover {
  background: #444;
}

.home-chat .retry-answer {
  margin-top: 10px;
  padding: 7px 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: #fff;
  color: var(--chat-accent);
  font-size: 12px;
}

.home-chat .retry-answer:hover { background: var(--fill); }
.home-chat .retry-browse { margin-left: 16px; color: var(--chat-accent); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.home-chat .send-button:disabled { cursor: default; opacity: .3; }

.home-chat button:disabled {
  cursor: wait;
  opacity: .5;
}

.home-chat .conversation {
  padding: 10px 0 0;
}

.home-chat .message {
  min-width: 0;
  margin-bottom: 24px;
  scroll-margin-top: 82px;
  scroll-margin-bottom: calc(var(--chat-dock-height) + 24px);
  overflow-wrap: anywhere;
}

.home-chat .message--user {
  display: flex;
  justify-content: flex-end;
}

.home-chat .user-bubble {
  max-width: 88%;
  padding: 8px 13px;
  border-radius: 17px 17px 4px 17px;
  background: var(--fill);
  color: var(--primary);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.home-chat .message-heading {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.home-chat .message-body {
  font-size: 13px;
  line-height: 1.85;
}

.home-chat .message-body p + p {
  margin-top: 12px;
}

.home-chat .message-body strong {
  color: var(--primary);
  font-weight: 500;
}

.home-chat .ai-answer {
  white-space: pre-line;
}

.home-chat .ai-pending {
  color: var(--muted);
}

.home-chat .result-card {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #fff;
}

.home-chat .result-card__image {
  display: block;
  width: 100%;
  height: 180px;
  border-bottom: 1px solid var(--stroke);
  object-fit: cover;
  object-position: top;
  background: var(--fill);
}

.home-chat .result-card__image--case {
  height: auto;
  aspect-ratio: 1500 / 570;
}

.home-chat .result-card__body {
  padding: 18px;
}

.home-chat .result-eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
}

.home-chat .result-card h2 {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}

.home-chat .result-card p {
  font-size: 12px;
  line-height: 1.8;
}

.home-chat .result-links,
.home-chat .ai-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin-top: 14px;
  font-size: 11px;
}

.home-chat .result-links a,
.home-chat .ai-sources a,
.home-chat .text-links a,
.home-chat .source-line a {
  color: var(--chat-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.home-chat .ai-sources {
  color: var(--muted);
}

.home-chat .result-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 5px 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 10px;
}

.home-chat .result-card__footer a {
  color: var(--chat-accent);
}

.home-chat .project-list {
  margin-top: 14px;
  border-top: 1px solid var(--stroke);
}

.home-chat .project-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--stroke);
  color: var(--primary);
  font-size: 11px;
  line-height: 1.6;
}

.home-chat .project-list a:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.home-chat .project-list a span:last-child {
  flex: none;
  color: var(--muted);
}

.home-chat .project-list a:hover {
  color: var(--chat-accent);
}

.home-chat .result-card__body > .project-list:first-child {
  margin-top: 0;
  border-top: 0;
}

.home-chat .result-card__body > .project-list:first-child a:first-child {
  padding-top: 0;
}

.home-chat .mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.home-chat .mini-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px;
  border: 1px solid var(--stroke);
  border-radius: 9px;
}

.home-chat .mini-card strong {
  font-size: 12px;
}

.home-chat .mini-card small {
  font-size: 11px;
  line-height: 1.7;
}

.home-chat .mini-card span {
  margin-top: auto;
  color: var(--chat-accent);
  font-size: 11px;
}

.home-chat .mini-card:hover {
  background: #fafafa;
}

.home-chat .source-line {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 639px) {
  .home-chat .contact-launch { min-height: 44px; }
  .home-chat .quick-topics { padding-right: 12px; }
  .home-chat .send-button { width: 36px; height: 36px; }
  .home-chat .composer { min-height: 50px; }
  .home-chat .message-body { font-size: 14px; }
  .home-chat .ai-sources { gap: 6px 14px; font-size: 12px; }
  .home-chat .ai-sources a { padding-block: 6px; }
  .home-chat .composer textarea {
    font-size: 16px;
    line-height: 20px;
  }

}

@media (max-width: 390px) {
  .home-chat .mini-grid {
    grid-template-columns: 1fr;
  }
}
