.adela-chat {
  position: fixed;
  z-index: 1000;
  right: 20px;
  bottom: 20px;
  color: var(--ink, #171b22);
  font-family: var(--body, 'Avenir Next', 'Segoe UI', Arial, sans-serif);
  font-size: 16px;
  line-height: 1.45;
}

/* :where() keeps this reset at zero specificity, so the launcher and close button keep their own fonts. */
:where(.adela-chat) button,
:where(.adela-chat) textarea,
:where(.adela-chat) input {
  font: inherit;
}

.adela-chat button {
  cursor: pointer;
}

.adela-chat__launcher {
  display: grid;
  width: 72px;
  height: 72px;
  padding: 4px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #fff;
  box-shadow: 0 5px 20px rgb(23 27 34 / 32%);
  font-family: var(--sans, 'Barlow', 'Avenir Next', 'Segoe UI', Arial, sans-serif);
  font-weight: 700;
}

.adela-chat__launcher:hover {
  background: #eef2ff;
}

.adela-chat__avatar {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent, #204fdb);
  color: #fff;
  font: 700 16px/1 var(--sans, 'Barlow', 'Avenir Next', 'Segoe UI', Arial, sans-serif);
}

.adela-chat__avatar--launcher {
  width: 64px;
  height: 64px;
  font-size: 24px;
}

.adela-chat__avatar--message {
  width: 32px;
  height: 32px;
}

.adela-chat__avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.adela-chat__panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto;
  width: min(380px, calc(100vw - 24px));
  height: min(600px, calc(100dvh - 104px));
  min-height: min(360px, calc(100dvh - 104px));
  overflow: hidden;
  border: 1px solid var(--line, #cbd1db);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 52px rgb(23 27 34 / 25%);
}

.adela-chat__panel[hidden],
.adela-chat__typing[hidden],
.adela-chat__copy[hidden],
.adela-chat__copy-form[hidden],
.adela-chat__copy-action[hidden] {
  display: none;
}

.adela-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 14px 16px 20px;
  background: var(--ink, #171b22);
  color: #fff;
}

.adela-chat__header h2 {
  margin: 0 0 5px;
  color: inherit;
  font: 700 20px/1.25 var(--sans, 'Barlow', 'Avenir Next', 'Segoe UI', Arial, sans-serif);
  letter-spacing: -.01em;
}

.adela-chat__header p {
  max-width: 35ch;
  margin: 0;
  color: #dbe3f6;
  font-size: 13px;
  line-height: 1.4;
}

.adela-chat__note-short {
  display: none;
}

.adela-chat__close {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: -8px -6px 0 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

.adela-chat__close:hover {
  background: rgb(255 255 255 / 12%);
}

.adela-chat__messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: var(--surface, #f2f4f7);
}

.adela-chat__message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin-bottom: 14px;
}

.adela-chat__message-row--visitor {
  justify-content: flex-end;
}

.adela-chat__message {
  width: fit-content;
  max-width: calc(88% - 40px);
  padding: 10px 13px;
  border: 1px solid var(--line, #cbd1db);
  border-radius: 4px;
  background: #fff;
  overflow-wrap: anywhere;
}

.adela-chat__message--visitor {
  max-width: 88%;
  border-color: var(--accent, #204fdb);
  background: var(--accent, #204fdb);
  color: #fff;
}

.adela-chat__speaker {
  display: block;
  margin-bottom: 3px;
  font: 700 12px/1.2 var(--sans, 'Barlow', 'Avenir Next', 'Segoe UI', Arial, sans-serif);
}

.adela-chat__message p {
  margin: 0;
  color: inherit;
  white-space: pre-wrap;
}

.adela-chat__message a {
  color: var(--accent, #204fdb);
  font-weight: 700;
}

.adela-chat__message--visitor a {
  color: #fff;
}

.adela-chat__typing {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--secondary, #48515e);
  font-size: 13px;
}

.adela-chat__typing p,
.adela-chat__copy-status {
  margin: 0;
}

.adela-chat__copy {
  padding: 8px 12px;
  border-top: 1px solid var(--line, #cbd1db);
  background: #fff;
}

.adela-chat__copy-action {
  min-height: 44px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--accent, #204fdb);
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.adela-chat__copy-action:hover {
  color: var(--accent-hover, #153ba9);
}

.adela-chat__copy-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.adela-chat__copy-form input {
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #7a8492;
  border-radius: 4px;
  color: var(--ink, #171b22);
  background: #fff;
}

.adela-chat__copy-form button {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 4px;
  background: var(--accent, #204fdb);
  color: #fff;
  font-weight: 700;
}

.adela-chat__copy-form button:hover {
  background: var(--accent-hover, #153ba9);
}

.adela-chat__copy-form .adela-chat__copy-cancel {
  border: 1px solid #7a8492;
  background: #fff;
  color: var(--ink, #171b22);
}

.adela-chat__copy-form .adela-chat__copy-cancel:hover {
  background: var(--surface, #f2f4f7);
}

.adela-chat__copy-form input[aria-invalid="true"] {
  border-color: #a62b2b;
}

.adela-chat__copy-status {
  color: var(--secondary, #48515e);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.adela-chat__copy-form + .adela-chat__copy-status:not(:empty) {
  padding: 6px 2px 2px;
}

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

.adela-chat__form textarea {
  width: 100%;
  min-height: 48px;
  max-height: 112px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid #7a8492;
  border-radius: 4px;
  color: var(--ink, #171b22);
  background: #fff;
  line-height: 1.35;
}

.adela-chat__form button {
  min-width: 74px;
  min-height: 48px;
  padding: 8px 14px;
  border: 0;
  border-radius: 4px;
  background: var(--accent, #204fdb);
  color: #fff;
  font-weight: 700;
}

.adela-chat__form button:hover {
  background: var(--accent-hover, #153ba9);
}

.adela-chat__form button:disabled,
.adela-chat__form textarea:disabled {
  cursor: wait;
  opacity: .68;
}

.adela-chat :focus-visible {
  outline: 3px solid var(--accent, #204fdb);
  outline-offset: 3px;
}

.adela-chat__header :focus-visible {
  outline-color: #fff;
}

.adela-chat__launcher:focus-visible {
  outline-color: var(--accent, #204fdb);
}

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

@media (max-width: 480px) {
  .adela-chat {
    right: 12px;
    bottom: 12px;
  }

  .adela-chat__panel {
    bottom: 72px;
    height: min(600px, calc(100dvh - 88px));
    min-height: min(360px, calc(100dvh - 88px));
  }

  .adela-chat__header {
    padding-left: 16px;
  }

  .adela-chat__messages {
    padding: 14px;
  }

  .adela-chat__launcher {
    width: 68px;
    height: 68px;
  }

  .adela-chat__avatar--launcher {
    width: 60px;
    height: 60px;
  }
}

/* Short screens (a phone in landscape): a short header note and tighter rows, so the header,
   close button and send form stay visible and the messages keep at least 80 px. */
@media (max-height: 520px) {
  .adela-chat__panel {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  .adela-chat__header {
    padding: 6px 8px 6px 16px;
  }

  .adela-chat__header h2 {
    margin-bottom: 2px;
    font-size: 17px;
    line-height: 1.2;
  }

  .adela-chat__header p {
    max-width: none;
    font-size: 12px;
    line-height: 1.3;
  }

  .adela-chat__note-full {
    display: none;
  }

  .adela-chat__note-short {
    display: inline;
  }

  .adela-chat__close {
    margin: -4px -2px 0 0;
  }

  .adela-chat__messages {
    padding: 10px 14px;
  }

  .adela-chat__form {
    padding: 6px 8px;
  }

  .adela-chat__copy {
    padding: 4px 8px;
  }

  .adela-chat__copy-status {
    font-size: 12px;
    line-height: 1.3;
  }

  .adela-chat__copy-form + .adela-chat__copy-status:not(:empty) {
    padding: 4px 2px 0;
  }

  .adela-chat__copy-form {
    gap: 4px;
  }

  .adela-chat__copy-form input,
  .adela-chat__copy-form button {
    min-height: 36px;
    padding: 5px 8px;
  }

  .adela-chat__typing {
    min-height: 32px;
    margin-bottom: 8px;
  }

  .adela-chat__form textarea {
    height: 44px;
    min-height: 44px;
    padding: 9px 10px;
  }

  .adela-chat__form button {
    min-height: 44px;
  }
}

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