.d2i-chat-host {
  --d2i-accent: #3057a6;
  --d2i-accent-foreground: #fff;
  --d2i-accent-ink: #3057a6;
  --d2i-accent-hover: #294a8f;
  --d2i-accent-active: #24417b;
  --d2i-accent-soft: color-mix(in srgb, var(--d2i-accent) 10%, white);
  --d2i-accent-border: color-mix(in srgb, var(--d2i-accent) 45%, #d7dce5);
  --d2i-launcher-y: 70vh;
  --d2i-font-size: 92%;
  --d2i-panel-width: 480px;
  --d2i-panel-height: 64vh;
  --d2i-panel-half-height: 32vh;
  color: #172033;
  font: inherit;
}

.d2i-chat-host[hidden],
.d2i-chat-panel[hidden],
.d2i-chatbot__suggestions[hidden] {
  display: none !important;
}

.d2i-chat-panel {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(6rem, 1fr) auto auto auto;
  width: min(100%, 48rem);
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d7dce5;
  border-radius: .85rem;
  background: #fff;
  box-shadow: 0 1rem 3rem rgb(23 32 51 / 18%);
  color: #172033;
  font-size: var(--d2i-font-size);
  line-height: 1.45;
}

.d2i-chat-host--floating .d2i-chat-panel {
  position: fixed;
  z-index: 10001;
  top: clamp(.5rem, calc(var(--d2i-launcher-y) - var(--d2i-panel-half-height)), calc(100dvh - var(--d2i-panel-height) - .5rem));
  width: min(var(--d2i-panel-width), calc(100vw - 1rem));
  height: min(var(--d2i-panel-height), 40rem, calc(100dvh - 1rem));
}

.d2i-chat-host--left .d2i-chat-panel { left: .5rem; }
.d2i-chat-host--right .d2i-chat-panel { right: .5rem; }

.d2i-chat-launcher {
  position: fixed;
  z-index: 10000;
  top: var(--d2i-launcher-y);
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: var(--d2i-accent);
  box-shadow: 0 .5rem 1.5rem rgb(23 32 51 / 28%);
  color: var(--d2i-accent-foreground);
  cursor: pointer;
  transform: translateY(-50%);
}

.d2i-chat-host--left .d2i-chat-launcher { left: .75rem; }
.d2i-chat-host--right .d2i-chat-launcher { right: .75rem; }
.d2i-chat-host.is-open .d2i-chat-launcher { display: none; }
.d2i-chat-launcher img { width: 100%; height: 100%; object-fit: cover; }
.d2i-chat-launcher span { font-size: 1.5rem; font-weight: 700; }
.d2i-chat-launcher:hover { background: var(--d2i-accent-hover); }
.d2i-chat-launcher:active { background: var(--d2i-accent-active); }

.d2i-chatbot__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: start;
  padding: .8rem .9rem .75rem 1rem;
  background: var(--d2i-accent-soft);
}

.d2i-chatbot__header > div { min-width: 0; }
.d2i-chatbot__header h2 { margin: .1em 0 .2em; font-size: 1.25em; line-height: 1.25; }
.d2i-chatbot__header p { margin: 0; }
.d2i-chatbot__eyebrow { color: var(--d2i-accent-ink); font-size: .78em; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }

.d2i-chat-close {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border: 1px solid var(--d2i-accent-border);
  border-radius: 50%;
  background: #fff;
  color: #172033;
  font: inherit;
  font-size: 1.55em;
  line-height: 1;
  cursor: pointer;
}

.d2i-chat-close:hover { border-color: var(--d2i-accent-ink); background: var(--d2i-accent-soft); }
.d2i-chat-close:active { background: color-mix(in srgb, var(--d2i-accent) 18%, white); }

.d2i-chatbot__messages {
  box-sizing: border-box;
  display: grid;
  min-width: 0;
  min-height: 0;
  max-height: 20rem;
  align-content: start;
  gap: .55rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .7rem 1rem;
}

.d2i-chat-host--floating .d2i-chatbot__messages { max-height: none; }

.d2i-chatbot__message {
  box-sizing: border-box;
  max-width: 88%;
  overflow-wrap: anywhere;
  border-radius: .75rem;
  background: #f1f4f8;
  padding: .58rem .75rem;
}

.d2i-chatbot__message p { margin: 0; white-space: pre-wrap; }
.d2i-chatbot__message--user { justify-self: end; background: var(--d2i-accent); color: var(--d2i-accent-foreground); }
.d2i-chatbot__message details { margin-top: .55rem; font-size: .9em; }
.d2i-chatbot__message ul { margin: .35rem 0 0; padding-left: 1.2rem; }

.d2i-chatbot__suggestions {
  display: flex;
  min-width: 0;
  max-height: 5rem;
  flex-wrap: wrap;
  gap: .35rem;
  overflow-y: auto;
  padding: .2rem 1rem .55rem;
}

.d2i-chatbot__suggestions button {
  max-width: 100%;
  border: 1px solid var(--d2i-accent-border);
  border-radius: 999px;
  background: #fff;
  padding: .28rem .6rem;
  color: #172033;
  font: inherit;
  font-size: .88em;
  line-height: 1.25;
  cursor: pointer;
}

.d2i-chatbot__suggestions button:hover { border-color: var(--d2i-accent-ink); background: var(--d2i-accent-soft); }
.d2i-chatbot__suggestions button:active { background: color-mix(in srgb, var(--d2i-accent) 18%, white); }

.d2i-chatbot__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .4rem;
  align-items: stretch;
  padding: .55rem 1rem .45rem;
  border-top: 1px solid #e3e7ee;
}

.d2i-chatbot__form textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  max-height: 6rem;
  border: 1px solid #aeb7c4;
  border-radius: .5rem;
  padding: .5rem .6rem;
  background: #fff;
  color: #172033;
  font: inherit;
  resize: vertical;
}

.d2i-chatbot__form button {
  align-self: stretch;
  border: 0;
  border-radius: .5rem;
  background: var(--d2i-accent);
  padding: .5rem .75rem;
  color: var(--d2i-accent-foreground);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.d2i-chatbot__form button:hover:not(:disabled) { background: var(--d2i-accent-hover); }
.d2i-chatbot__form button:active:not(:disabled) { background: var(--d2i-accent-active); }

.d2i-chatbot__form button:disabled { cursor: wait; opacity: .6; }
.d2i-chatbot__status { grid-column: 1 / -1; margin: 0; font-size: .82em; }
.d2i-chatbot__status:empty { display: none; }
.d2i-chatbot__status[data-state="loading"],
.d2i-chatbot__status[data-state="answered"] { color: var(--d2i-accent-ink); }
.d2i-chatbot__status[data-state="error"] { color: #9f1239; }

.d2i-chatbot__privacy {
  margin: 0;
  padding: 0 1rem .6rem;
  color: #5b6475;
  font-size: .78em;
}

.d2i-chatbot__privacy summary { width: fit-content; cursor: pointer; }
.d2i-chatbot__privacy p { margin: .35rem 0 0; }
.d2i-chatbot__handoff,
.d2i-chatbot__message a { color: var(--d2i-accent-ink); }
.d2i-chatbot__handoff { display: inline-block; margin-top: .55rem; font-weight: 700; }
.d2i-chatbot__handoff:hover,
.d2i-chatbot__message a:hover { text-decoration-thickness: .13em; }
.d2i-chat-host :focus-visible { outline: 3px solid var(--d2i-accent-ink); outline-offset: 2px; }

.d2i-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 640px) {
  .d2i-chat-host--floating .d2i-chat-panel {
    right: .5rem;
    left: .5rem;
    width: auto;
  }

  .d2i-chatbot__header { padding: .65rem .7rem .6rem .8rem; }
  .d2i-chatbot__messages { padding: .6rem .75rem; }
  .d2i-chatbot__suggestions { padding: .15rem .75rem .45rem; }
  .d2i-chatbot__form { padding: .45rem .75rem .4rem; }
  .d2i-chatbot__privacy { padding: 0 .75rem .5rem; }
}
