.lew-search-chat {
  margin: 0 auto 4rem;
}

.global-search-main {
  min-height: 42rem;
  padding-bottom: 6rem;
}

.global-search {
  max-width: 66rem;
  padding-top: 5rem;
}

.global-search__title {
  margin: 0;
  color: var(--primary-color-dark);
  font-size: 2.75rem;
  font-weight: bold;
  line-height: 1.08;
  text-align: center;
  overflow: visible;
  text-overflow: clip;
}

.search-chat,
.search-chat *,
.search-chat *::before,
.search-chat *::after {
  box-sizing: border-box;
}

.search-chat {
  --search-chat-ease: cubic-bezier(0.22, 1, 0.36, 1);
  width: min(100%, 36rem);
  margin: 1.5rem auto 0;
  color: var(--primary-color);
  font-family: var(--font-family);
  transform-origin: center top;
  animation: searchChatEnter 220ms var(--search-chat-ease) 80ms both;
}

.search-chat--active {
  display: flex;
  flex-direction: column;
  width: min(100%, 48rem);
}

.search-chat__messages {
  display: none;
}

.search-chat__messages--seeded,
.search-chat--active .search-chat__messages:not(:empty) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: min(42vh, 28rem);
  margin-bottom: 0.75rem;
  padding: 0 0.25rem 0.25rem 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  animation: searchChatMessagesIn 200ms var(--search-chat-ease) both;
}

.search-chat__message {
  display: flex;
}

.search-chat__message--user {
  justify-content: flex-end;
}

.search-chat__message--bot {
  justify-content: flex-start;
}

.search-chat__bubble {
  width: fit-content;
  max-width: min(720px, 88%);
  padding: 0.7rem 0.85rem;
  border-radius: var(--standard-border-radius);
  font-size: 1rem;
  line-height: 1.55;
  text-align: left;
  overflow-wrap: anywhere;
}

.search-chat__message--user .search-chat__bubble {
  border: var(--checkbox-border-width) var(--standard-border-style) var(--secondary-color);
  background: var(--secondary-color-transparent);
  color: var(--primary-color);
  font-weight: var(--font-weight-medium);
  transform-origin: right bottom;
  animation: searchChatSend 160ms var(--search-chat-ease) both;
}

.search-chat__message--bot .search-chat__bubble {
  max-width: min(720px, 94%);
  border: var(--checkbox-border-width) var(--standard-border-style) var(--grey);
  background: var(--white);
  color: var(--primary-color);
  transform-origin: left bottom;
  animation: searchChatAnswerIn 180ms var(--search-chat-ease) both;
}

.search-chat__bubble--pending {
  min-width: 5.5rem;
}

.search-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.55em;
}

.search-chat__typing-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--secondary-color);
  opacity: 0.45;
  animation: searchChatTyping 960ms ease-in-out infinite;
}

.search-chat__typing-dot:nth-child(2) {
  animation-delay: 120ms;
}

.search-chat__typing-dot:nth-child(3) {
  animation-delay: 240ms;
}

.search-chat__markdown,
.search-chat__sources {
  display: grid;
  gap: 0.5rem;
}

.search-chat__markdown > * {
  margin: 0;
}

.search-chat__markdown ul,
.search-chat__markdown ol,
.search-chat__source-list {
  margin: 0;
  padding-left: 1.25rem;
}

.search-chat__source-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--on-bg-light);
  font-size: 0.78rem;
  line-height: 1.3;
}

.search-chat__markdown--plain {
  white-space: pre-wrap;
}

.search-chat__bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.search-chat__sources {
  margin-top: 0.75rem;
}

.search-chat__sources-title {
  color: var(--on-bg-light);
  font-size: 0.9rem;
  font-weight: var(--font-weight-medium);
}

.search-chat__loader {
  min-height: 1.4rem;
  margin: 0 0 0.5rem;
  text-align: center;
}

.search-chat__loader[hidden] {
  display: none;
}

.search-chat__actions {
  display: none;
  justify-content: center;
  margin-top: 0.6rem;
}

.search-chat--active .search-chat__actions {
  display: flex;
}

.search-chat__new-chat {
  min-height: 2.5rem;
  margin: 0;
  white-space: nowrap;
}

.search-chat__new-chat:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.search-chat__composer {
  max-width: 36rem;
  margin: 0 auto;
  transform-origin: center top;
  animation: searchChatFieldIn 220ms var(--search-chat-ease) 110ms both;
}

.search-chat--active .search-chat__composer {
  max-width: none;
}

.search-chat__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 0.5rem;
  align-items: stretch;
  position: relative;
}

.search-chat__disclaimer {
  max-width: none;
  margin: 0.45rem 0 0;
  color: var(--on-bg-light);
  font-size: 0.68rem;
  font-weight: var(--font-weight-medium);
  line-height: 1.25;
  text-align: center;
}

.search-chat__input {
  width: 100%;
  min-height: 48px;
  margin: 0;
  font-size: 1rem;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.search-chat__input:focus {
  background-color: var(--white);
}

.search-chat__input::placeholder {
  color: var(--primary-color);
}

.search-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 48px;
  margin: 0;
  padding: 0 1rem;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.search-chat__send::after {
  content: "";
  width: 1rem;
  height: 1rem;
  background: currentColor;
  -webkit-mask: url("../icons/send.svg") center / contain no-repeat;
  mask: url("../icons/send.svg") center / contain no-repeat;
}

.search-chat__send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.search-chat__new-chat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 2.75rem;
  min-height: 2.5rem;
}

.search-chat__new-chat::after {
  content: "";
  width: 1rem;
  height: 1rem;
  background: currentColor;
  -webkit-mask: url("../icons/refresh_simple.svg") center / contain no-repeat;
  mask: url("../icons/refresh_simple.svg") center / contain no-repeat;
}

.search-chat__quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.search-chat--active .search-chat__quick-actions {
  display: none;
}

.search-chat__quick-action {
  margin: 0;
}

.lew-search-chat--guided {
  max-width: 48rem;
  margin-bottom: 4.5rem;
}

.search-chat--guided {
  --search-chat-panel-border: #c6d0e4;
  --search-chat-panel-bg: #ffffff;
  --search-chat-field-bg: #eef2fc;
  --search-chat-action: var(--primary-color);
  --search-chat-action-dark: #733512;
  display: flex;
  flex-direction: column;
  gap: 2.15rem;
  width: min(100%, 48rem);
  margin-top: 0;
  overflow: visible;
}

.search-chat--guided .search-chat__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem;
  order: 0;
}

.search-chat--guided .search-chat__title {
  grid-column: 2;
}

.search-chat--guided.search-chat--active {
  width: min(100%, 48rem);
}

.search-chat--guided .search-chat__messages {
  order: 3;
}

.search-chat--guided .search-chat__messages--seeded,
.search-chat--guided.search-chat--active .search-chat__messages:not(:empty) {
  max-height: min(56vh, 34rem);
  margin-bottom: 0;
  padding: 0.1rem 0.15rem 0.15rem;
}

.search-chat--guided .search-chat__intro {
  order: 2;
  min-height: 10.75rem;
  padding: 1.9rem 1.8rem;
  border: 1px solid var(--search-chat-panel-border);
  border-radius: 0.85rem;
  background: var(--search-chat-panel-bg);
  box-shadow: 0 0.9rem 1.8rem rgba(40, 66, 105, 0.1);
  color: #202c42;
}

.search-chat--guided.search-chat--active .search-chat__intro {
  min-height: 0;
  padding: 1.05rem 1.15rem;
}

.search-chat--guided.search-chat--active .search-chat__intro-header {
  margin-bottom: 0.75rem;
}

.search-chat--guided .search-chat__intro-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.search-chat--guided .search-chat__intro-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: #edf2fb;
}

.search-chat--guided .search-chat__intro-avatar::before,
.search-chat--guided .search-chat__intro-avatar::after {
  content: "";
  position: absolute;
  background: var(--primary-color-dark);
  transform: rotate(45deg);
}

.search-chat--guided .search-chat__intro-avatar::before {
  top: 0.58rem;
  left: 0.72rem;
  width: 0.55rem;
  height: 0.55rem;
  box-shadow: 0.55rem 0.55rem 0 -0.12rem var(--primary-color-dark);
}

.search-chat--guided .search-chat__intro-avatar::after {
  top: 1.08rem;
  left: 1.23rem;
  width: 0.28rem;
  height: 0.28rem;
}

.search-chat--guided .search-chat__intro-kicker {
  display: grid;
  gap: 0.05rem;
  margin: 0;
  color: var(--primary-color-dark);
  font-size: 0.74rem;
  line-height: 1.15;
  text-transform: uppercase;
  overflow: visible;
  text-overflow: clip;
}

.search-chat--guided .search-chat__intro-kicker strong {
  font-weight: bold;
}

.search-chat--guided .search-chat__intro-kicker span {
  color: #29364e;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0;
  overflow: visible;
  text-overflow: clip;
}

.search-chat--guided .search-chat__intro-text {
  max-width: none;
  margin: 0;
  color: #202c42;
  font-size: 0.9rem;
  font-weight: var(--font-weight-medium);
  line-height: 1.55;
  overflow: visible;
  text-overflow: clip;
}

.search-chat--guided .search-chat__quick-actions {
  order: 1;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0;
}

.search-chat--guided .search-chat__quick-action {
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0.86rem 1.42rem;
  border: 0;
  border-radius: 0.82rem;
  background: var(--search-chat-action);
  box-shadow: 0 0.28rem 0.7rem rgba(74, 40, 23, 0.18);
  color: var(--white);
  font-size: 0.95rem;
  line-height: 1.15;
  text-transform: none;
  text-decoration: none;
}

.search-chat--guided .search-chat__quick-action:hover,
.search-chat--guided .search-chat__quick-action:focus-visible {
  background: var(--search-chat-action-dark);
  color: var(--white);
}

.search-chat--guided .search-chat__loader {
  order: 4;
  margin: 0;
}

.search-chat--guided .search-chat__actions {
  order: 5;
  justify-content: flex-end;
  margin: 0;
  padding-right: 0.15rem;
}

.search-chat--guided .search-chat__header .search-chat__actions {
  grid-column: 3;
  justify-content: flex-start;
  order: 0;
  padding-right: 0;
}

.search-chat--guided .search-chat__new-chat {
  min-height: 2.45rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: var(--font-weight-medium);
  line-height: 1;
  box-shadow: none;
}

.search-chat--guided .search-chat__new-chat:hover,
.search-chat--guided .search-chat__new-chat:focus-visible {
  background: transparent;
  color: var(--search-chat-action);
}

.search-chat--guided .search-chat__composer {
  order: 6;
  width: 100%;
  max-width: none;
  margin: 0;
}

.search-chat--guided .search-chat__form {
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 0.6rem;
  width: 100%;
  max-width: none;
  min-height: 4.2rem;
  margin: 0;
  padding: 0.45rem;
  border: 1px solid var(--search-chat-panel-border);
  border-radius: 0.85rem;
  background: var(--search-chat-field-bg);
  box-shadow: 0 0.5rem 1rem rgba(40, 66, 105, 0.08);
}

.search-chat--guided .search-chat__disclaimer {
  margin: 0.45rem 0 0.05rem;
  color: #6f7b91;
  font-size: 0.68rem;
}

.search-chat--guided .search-chat__input {
  min-height: 3rem;
  padding: 0 1.05rem;
  border: 0;
  background: transparent;
  color: #202c42;
  font-size: 0.95rem;
}

.search-chat--guided .search-chat__input:focus {
  background: transparent;
}

.search-chat--guided .search-chat__input::placeholder {
  color: #202c42;
}

.search-chat--guided .search-chat__send {
  min-width: 2.75rem;
  min-height: 3rem;
  margin: 0;
  border: 0;
  border-radius: 0.75rem;
  background: var(--search-chat-action);
  color: var(--white);
  font-size: 0.78rem;
  line-height: 1;
}

.search-chat--guided .search-chat__send::after {
  width: 1.1rem;
  height: 1.1rem;
  margin-left: 0;
}

.search-chat--guided .search-chat__send:hover,
.search-chat--guided .search-chat__send:focus-visible {
  background: var(--search-chat-action-dark);
  color: var(--white);
}

.search-chat--guided .search-chat__send:disabled {
  background: var(--secondary-color);
  color: var(--white);
  opacity: 1;
}

.search-chat--guided .search-chat__message--user .search-chat__bubble {
  border: 0;
  border-radius: 0.82rem;
  background: var(--search-chat-action);
  color: var(--white);
}

.search-chat--guided .search-chat__message--bot .search-chat__bubble {
  max-width: min(720px, 100%);
  border: 1px solid var(--search-chat-panel-border);
  border-radius: 0.85rem;
  background: var(--white);
  box-shadow: 0 0.9rem 1.8rem rgba(40, 66, 105, 0.1);
}

.global-search .search-results {
  margin: 4.5rem 0 0;
}

.global-search .not-found__title {
  margin-top: 4.5rem;
}

@keyframes searchChatEnter {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes searchChatMessagesIn {
  from {
    opacity: 0;
    transform: translateY(0.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes searchChatFieldIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes searchChatSend {
  from {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes searchChatAnswerIn {
  from {
    opacity: 0;
    transform: translateY(0.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes searchChatTyping {
  0%,
  70%,
  100% {
    opacity: 0.42;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-0.2rem);
  }
}

@media (max-width: 42rem) {
  .lew-search-chat {
    margin-bottom: 3rem;
  }

  .global-search-main {
    min-height: 36rem;
    padding-bottom: 4.5rem;
  }

  .global-search {
    padding-top: 2.7rem;
  }

  .global-search__title {
    font-size: 2.15rem;
  }

  .search-chat {
    width: 100%;
  }

  .search-chat__form {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-chat__disclaimer {
    margin-right: 0;
  }

  .search-chat__send {
    width: 100%;
  }

  .search-chat--guided {
    gap: 1.45rem;
  }

  .search-chat--guided .search-chat__header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.7rem;
  }

  .search-chat--guided .search-chat__title {
    grid-column: 1;
    text-align: left;
  }

  .search-chat--guided .search-chat__quick-actions {
    justify-content: center;
  }

  .search-chat--guided .search-chat__intro {
    min-height: auto;
    padding: 1.45rem 1.25rem;
  }

  .search-chat--guided .search-chat__intro-header {
    margin-bottom: 1.25rem;
  }

  .search-chat--guided .search-chat__form {
    grid-template-columns: minmax(0, 1fr) max-content;
  }

  .search-chat--guided .search-chat__send {
    width: auto;
    min-width: 2.75rem;
    font-size: 0.75rem;
  }

  .search-chat--guided .search-chat__actions {
    justify-content: flex-end;
    margin: 0;
    padding-right: 0;
  }

  .search-chat--guided .search-chat__header .search-chat__actions {
    grid-column: 2;
  }

  .search-chat--guided .search-chat__input {
    font-size: 0.86rem;
  }

  .search-chat__messages--seeded,
  .search-chat--active .search-chat__messages:not(:empty) {
    max-height: 52vh;
  }

  .search-chat--guided .search-chat__messages--seeded,
  .search-chat--guided.search-chat--active .search-chat__messages:not(:empty) {
    max-height: 58vh;
    padding: 0.05rem;
  }

  .global-search .search-results,
  .global-search .not-found__title {
    margin-top: 3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-chat,
  .search-chat__composer,
  .search-chat__messages--seeded,
  .search-chat--active .search-chat__messages:not(:empty),
  .search-chat__bubble,
  .search-chat__typing-dot {
    animation: none;
  }
}
