.faq-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 180;
  display: grid;
  justify-items: end;
  gap: 10px;
  pointer-events: none;
}

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

.faq-chat-toggle,
.faq-chat-panel,
.faq-chat-action,
.faq-chat-topic,
.faq-chat-send {
  pointer-events: auto;
}

.faq-chat-toggle {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(244, 126, 31, 0.44);
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  padding: 12px 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 16px 36px rgba(42, 36, 28, 0.22);
}

.faq-chat-toggle .ui-icon {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.faq-chat-toggle:hover {
  background: #cf5f1c;
}

.faq-chat-panel {
  width: min(370px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  scroll-margin-top: 0;
  border: 1px solid rgba(27, 45, 39, 0.14);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 68px rgba(18, 31, 28, 0.28);
}

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

.faq-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  background: #1f342e;
  color: #fff;
}

.faq-chat-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.faq-chat-title strong {
  font-size: 15px;
  line-height: 1.2;
}

.faq-chat-title span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.3;
}

.faq-chat-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.faq-chat-body {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  min-height: 0;
  overflow-y: auto;
  background: #f7f8f4;
}

.faq-chat-body[hidden],
.faq-chat-form[hidden],
.faq-chat-intro[hidden] {
  display: none;
}

.faq-chat-intro {
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  padding: 14px;
  background: #f7f8f4;
}

.faq-chat-intro-title {
  color: var(--dark);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
}

.faq-chat-intro-note {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.faq-chat-intro-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.faq-chat-intro-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(227, 107, 37, 0.12);
}

.faq-chat-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}

.faq-chat-consent input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--green);
}

.faq-chat-consent a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.faq-chat-consent.is-error {
  color: #b91c1c;
}

.faq-chat-intro-submit {
  min-height: 42px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.faq-chat-intro-submit:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.faq-chat-intro-error {
  display: none;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.4;
}

.faq-chat-intro-error.active {
  display: block;
}

.faq-chat-message {
  max-width: 92%;
  display: grid;
  gap: 10px;
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.48;
  word-break: break-word;
}

.faq-chat-message-user {
  justify-self: end;
  background: #e3f0ea;
  color: var(--dark);
}

.faq-chat-message-bot {
  justify-self: start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.faq-chat-topics,
.faq-chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.faq-chat-topic,
.faq-chat-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--dark);
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.faq-chat-topic:hover,
.faq-chat-action:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.faq-chat-action-primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.faq-chat-action-primary:hover {
  background: #315e51;
  border-color: #315e51;
  color: #fff;
}

.faq-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.faq-chat-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.faq-chat-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(227, 107, 37, 0.12);
}

.faq-chat-send {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--orange);
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

@media (max-width: 760px) {
  .faq-chat-widget {
    right: 14px;
    bottom: 78px;
  }

  .faq-chat-toggle {
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .faq-chat-panel {
    max-height: calc(100dvh - 150px);
  }
}

@media (max-width: 480px) {
  .faq-chat-widget {
    left: 8px;
    right: 8px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    justify-items: stretch;
  }

  .faq-chat-toggle {
    justify-self: end;
    min-height: 44px;
    padding: 9px 11px;
  }

  .faq-chat-panel {
    width: 100%;
    max-height: calc(100dvh - 138px);
    border-radius: 10px;
  }

  .faq-chat-body,
  .faq-chat-intro {
    padding: 12px;
  }

  .faq-chat-message {
    max-width: 100%;
  }

  .faq-chat-topics,
  .faq-chat-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .faq-chat-topic,
  .faq-chat-action {
    width: 100%;
    text-align: center;
  }

  .faq-chat-form {
    padding: 10px;
  }
}

@media (max-width: 360px) {
  .faq-chat-widget {
    left: auto;
    right: 8px;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .faq-chat-toggle {
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    justify-content: center;
  }

  .faq-chat-toggle span {
    display: none;
  }
}
