.sac-chat {
  --sac-green: #66A633;
  --sac-green-dark: #4F9423;
  --sac-header: #10271d;
  --sac-ink: #13190A;
  --sac-muted: #54655E;
  --sac-line: #D6E2D9;
  --sac-surface: #ffffff;
  --sac-soft: #E7F0E9;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999999;
  font-family: inherit;
  color: var(--sac-ink);
  text-align: left;
}

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

.sac-chat__trigger {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: var(--sac-green);
  color: #fff;
  box-shadow: 0 12px 30px rgba(22, 35, 27, 0.2);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.sac-chat__trigger:hover {
  background: var(--sac-green-dark);
  transform: translateY(-2px);
  box-shadow: 0 15px 34px rgba(22, 35, 27, 0.25);
}

.sac-chat__trigger:focus-visible,
.sac-chat button:focus-visible,
.sac-chat textarea:focus-visible,
.sac-chat a:focus-visible {
  outline: 3px solid #F5B71E;
  outline-offset: 3px;
}

.sac-chat__trigger-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.sac-chat__trigger svg,
.sac-chat__send svg,
.sac-chat__close svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.sac-chat__panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(390px, calc(100vw - 28px));
  height: min(668px, calc(100vh - 104px));
  min-height: 440px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid var(--sac-line);
  border-radius: 22px;
  background: var(--sac-surface);
  box-shadow: 0 24px 70px rgba(20, 34, 25, 0.24);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.sac-chat[data-state="open"] .sac-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.sac-chat[data-state="open"] .sac-chat__trigger {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sac-chat__header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 11px 15px;
  background: var(--sac-header);
  color: #fff;
}

.sac-chat__identity {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--sac-green);
  font-size: 20px;
  font-weight: 800;
}

.sac-chat__header h2,
.sac-chat__header p {
  margin: 0;
  color: inherit;
}

.sac-chat__header h2 {
  font-family: inherit;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 750;
}

.sac-chat__header p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.74;
}

.sac-chat__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8fd35b;
  box-shadow: 0 0 0 3px rgba(143, 211, 91, 0.15);
}

.sac-chat__close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  justify-content: center;
  align-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.sac-chat__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sac-chat__messages {
  overflow-y: auto;
  padding: 15px 14px 12px;
  background: linear-gradient(180deg, #fbfcfa 0%, var(--sac-soft) 100%);
  scrollbar-width: thin;
  scrollbar-color: #aebba9 transparent;
}

.sac-chat__message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 12px;
}

.sac-chat__message--user {
  align-items: flex-end;
}

.sac-chat__bubble {
  max-width: 88%;
  padding: 11px 13px;
  border: 1px solid var(--sac-line);
  border-radius: 6px 16px 16px 16px;
  background: #fff;
  color: var(--sac-ink);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sac-chat__message--user .sac-chat__bubble {
  border-color: var(--sac-green);
  border-radius: 16px 6px 16px 16px;
  background: var(--sac-green);
  color: #fff;
}

.sac-chat__actions {
  max-width: 88%;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.sac-chat__actions a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border: 1px solid var(--sac-green);
  border-radius: 999px;
  background: var(--sac-green);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.sac-chat__actions a::after {
  content: ' →';
  margin-left: 5px;
}

.sac-chat__actions a:hover {
  border-color: var(--sac-green-dark);
  background: var(--sac-green-dark);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.sac-chat__sources {
  max-width: 88%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.35;
}

.sac-chat__sources span {
  width: 100%;
  color: var(--sac-muted);
}

.sac-chat__sources a {
  padding: 4px 8px;
  border: 1px solid #ced9ca;
  border-radius: 999px;
  background: #fff;
  color: var(--sac-green-dark);
  text-decoration: none;
}

.sac-chat__sources a:hover {
  border-color: var(--sac-green);
  text-decoration: underline;
}

.sac-chat__quote-prompt {
  display: grid;
  gap: 9px;
  margin: 6px 0 12px;
  padding: 12px;
  border: 1px solid #cad6c6;
  border-radius: 14px;
  background: #fff;
  color: var(--sac-ink);
  font-size: 12px;
  line-height: 1.4;
}

.sac-chat__quote-prompt[hidden] {
  display: none;
}

.sac-chat__quote-prompt > span {
  font-weight: 700;
}

.sac-chat__quote-prompt > div,
.sac-chat__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.sac-chat__quote-prompt button,
.sac-chat__quote-prompt a,
.sac-chat__choices button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #cad6c6;
  border-radius: 999px;
  background: #fff;
  color: var(--sac-green-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.sac-chat__quote-prompt .sac-chat__primary-action,
.sac-chat__choices button:first-child {
  border-color: var(--sac-green);
  background: var(--sac-green);
  color: #fff;
}

.sac-chat__quote-prompt button:hover,
.sac-chat__quote-prompt a:hover,
.sac-chat__choices button:hover {
  border-color: var(--sac-green-dark);
}

.sac-chat__quote-prompt .sac-chat__primary-action:hover,
.sac-chat__choices button:first-child:hover {
  background: var(--sac-green-dark);
}

.sac-chat__choices {
  max-width: 88%;
  margin-top: 8px;
}

.sac-chat__choices button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.sac-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
  margin-bottom: 9px;
}

.sac-chat__suggestions[hidden] {
  display: none;
}

.sac-chat__suggestions-label {
  width: 100%;
  color: var(--sac-muted);
  font-size: 11px;
  line-height: 1.35;
}

.sac-chat__suggestions button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #cad6c6;
  border-radius: 999px;
  background: #fff;
  color: var(--sac-green-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.sac-chat__suggestions button:hover {
  border-color: var(--sac-green);
  background: #f8fbf6;
}

.sac-chat__message--loading .sac-chat__bubble {
  display: flex;
  gap: 5px;
  padding: 15px 16px;
}

.sac-chat__message--loading span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sac-green);
  animation: sac-pulse 1.1s infinite ease-in-out;
}

.sac-chat__message--loading span:nth-child(2) {
  animation-delay: 0.14s;
}

.sac-chat__message--loading span:nth-child(3) {
  animation-delay: 0.28s;
}

.sac-chat__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--sac-line);
  background: #fff;
}

.sac-chat__form textarea {
  width: 100%;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 112px;
  resize: none;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid #cbd5c7;
  border-radius: 14px;
  background: #fff;
  color: var(--sac-ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.sac-chat__form textarea::placeholder {
  color: #79857d;
}

.sac-chat__send {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  display: grid;
  place-items: center;
  justify-content: center;
  align-content: center;
  padding: 0 !important;
  border: 0;
  border-radius: 13px;
  background: var(--sac-green);
  color: #fff;
  cursor: pointer;
}

.sac-chat__send:hover {
  background: var(--sac-green-dark);
}

.sac-chat__send:disabled,
.sac-chat__form textarea:disabled {
  cursor: wait;
  opacity: 0.58;
}

.sac-chat__footer {
  padding: 8px 14px 10px;
  background: #fff;
  color: var(--sac-muted);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.sac-chat__footer a {
  color: var(--sac-green-dark);
  font-weight: 700;
}

.sac-chat__honeypot,
.sac-chat__sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes sac-pulse {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.35; }
  35% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 600px) {
  .sac-chat {
    right: 14px;
    bottom: 14px;
  }

  .sac-chat__panel {
    position: fixed;
    inset: 10px;
    width: auto;
    height: auto;
    min-height: 0;
    border-radius: 18px;
  }

  .sac-chat__trigger-label {
    display: none;
  }

  .sac-chat__trigger {
    width: 58px;
    height: 58px;
    justify-content: center;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sac-chat *,
  .sac-chat *::before,
  .sac-chat *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
