.atlas-chat-ready {
  --atlas-chat-bottom: calc(16px + var(--compare-tray-height, 0px) + env(safe-area-inset-bottom, 0px));
  --atlas-chat-row-bottom: calc(var(--atlas-chat-bottom) + 8px);
  --atlas-chat-right: max(24px, env(safe-area-inset-right, 0px));
  --atlas-chat-scroll-size: 52px;
}

.atlas-chat {
  --chat-surface: #171d29;
  --chat-border: #384663;
  --chat-text: #f0f3fb;
  --chat-muted: #a7b3cd;
  --chat-blue: #8eb6ff;
  --chat-launch-size: 44px;
  --chat-panel-bottom: calc(var(--atlas-chat-row-bottom) + var(--atlas-chat-scroll-size) + 12px);
  position: fixed;
  right: calc(var(--atlas-chat-right) + var(--atlas-chat-scroll-size) + 12px);
  bottom: calc(var(--atlas-chat-row-bottom) + (var(--atlas-chat-scroll-size) - var(--chat-launch-size)) / 2);
  z-index: 76;
  color: var(--chat-text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.atlas-chat *, .atlas-chat *::before, .atlas-chat *::after { box-sizing: border-box; }
.atlas-chat [hidden] { display: none !important; }
.atlas-chat button, .atlas-chat input, .atlas-chat textarea { font: inherit; }
.atlas-chat button { cursor: pointer; }
.atlas-chat button:disabled { opacity: .58; cursor: wait; }
.atlas-chat :where(button, input, textarea, summary):focus-visible {
  outline: 2px solid #a6c5ff;
  outline-offset: 3px;
}
.atlas-chat h2, .atlas-chat h3, .atlas-chat p, .atlas-chat dl, .atlas-chat dd, .atlas-chat form { margin: 0; }
.atlas-chat-launch {
  --chat-launch-bg: #254a83;
  position: relative; display: grid; place-items: center;
  width: var(--chat-launch-size); height: var(--chat-launch-size); padding: 0;
  border: 1px solid #6889c1; border-radius: 50%; background: var(--chat-launch-bg); color: #fff;
  box-shadow: 0 6px 21px #050811af;
}
.atlas-chat-launch:hover, .atlas-chat-launch[aria-expanded="true"] { --chat-launch-bg: #2e5a9c; }
@media (prefers-reduced-motion: no-preference) {
  .atlas-chat-launch[aria-expanded="false"]::before, .atlas-chat-launch[aria-expanded="false"]::after {
    position: absolute; content: ""; inset: -1px; border: 2px solid currentColor; border-radius: inherit;
    box-shadow: 0 0 8px currentColor; opacity: 0; pointer-events: none;
    animation: atlas-chat-pulse 4.8s ease-out infinite;
  }
  .atlas-chat-launch::before { color: #ff526d; }
  .atlas-chat-launch[aria-expanded="false"]::after { color: #599bff; animation-delay: 2.4s; }
  @keyframes atlas-chat-pulse {
    0% { transform: scale(1); opacity: .8; }
    46%, 100% { transform: scale(1.36); opacity: 0; }
  }
}
.atlas-chat-icon { display: block; position: relative; width: 19px; height: 14px; border: 1.6px solid currentColor; border-radius: 4px; }
.atlas-chat-icon::after {
  position: absolute; content: ""; left: 3px; bottom: -3px; width: 5px; height: 5px;
  background: var(--chat-launch-bg); border: solid currentColor; border-width: 0 0 1.6px 1.6px; transform: skewY(-32deg);
}
.atlas-chat-unread {
  position: absolute; right: 3px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: #ff657e; box-shadow: 0 0 0 2px #1c3761;
}
.atlas-chat-panel {
  position: fixed; bottom: var(--chat-panel-bottom); right: var(--atlas-chat-right);
  width: min(390px, calc(100vw - var(--atlas-chat-right) - 12px));
  max-height: min(650px, calc(100dvh - var(--chat-panel-bottom) - 14px));
  overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--chat-surface); border: 1px solid var(--chat-border); border-radius: 16px; box-shadow: 0 20px 68px #040710c9;
}
.atlas-chat-head {
  display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 11px 14px;
  border-bottom: 1px solid var(--chat-border); background: #202b42;
}
.atlas-chat-head h2 { font-size: 15px; padding-left: 9px; border-left: 3px solid #ff627c; color: #fff; }
.atlas-chat-close {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--chat-text);
  border: 1px solid #4d5e7d; background: #283650; border-radius: 8px; line-height: 1;
  font-size: 22px !important;
}
.atlas-chat-close:hover { background: #3a4b67; }
.atlas-chat-body { overflow: auto; overscroll-behavior: contain; min-height: 0; padding: 12px 13px; }
.atlas-chat-intro { color: var(--chat-muted); margin-bottom: 12px !important; }
.atlas-chat-messages { display: grid; gap: 9px; }
.atlas-chat-bubble {
  max-width: 94%; padding: 8px 10px; border-radius: 10px; background: #252e40; border: 1px solid #394765;
  color: var(--chat-text); width: fit-content; overflow-wrap: anywhere;
}
.atlas-chat-mine { background: #263d62; border-color: #3b5681; justify-self: end; }
.atlas-chat-bubble p, .atlas-chat-bubble dd { white-space: pre-wrap; }
.atlas-chat-bubble time { font-size: .73rem; display: block; color: #bdc9df; margin-top: 5px; text-align: right; }
.atlas-chat-bubble dl { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 3px 8px; font-size: .8rem; margin-top: 7px; }
.atlas-chat-bubble dt { color: #c0cce2; }
.atlas-chat-bubble dd { min-width: 0; }
.atlas-chat-link {
  background: transparent; padding: 3px 0; color: var(--chat-blue); border: 0; border-radius: 3px; font-weight: 640 !important;
  white-space: normal; text-align: left;
}
.atlas-chat-link:hover { text-decoration: underline; }
.atlas-chat-add { margin-top: 7px; }
.atlas-chat-earlier { margin-bottom: 8px; }
.atlas-chat-history-tools { margin-top: 10px; color: var(--chat-muted); font-size: .78rem; }
.atlas-chat-history-tools summary { width: fit-content; cursor: pointer; color: #b6c4df; }
.atlas-chat-history-tools > * + * { margin-top: 8px !important; }
.atlas-chat-recover, .atlas-chat-code { display: grid; gap: 7px; }
.atlas-chat-application { display: grid; gap: 8px; margin-top: 9px !important; }
.atlas-chat-application h3 { font-size: 15px; }
.atlas-chat-logo-hint { color: var(--chat-muted); font-size: .75rem; }
.atlas-chat-logo-error { font-size: .82rem; }
.atlas-chat-logo-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.atlas-chat-logo-preview {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 72px;
  border-radius: 6px; background: #111724; object-fit: contain;
}
.atlas-chat-bubble .atlas-chat-logo-preview { margin-top: 7px; max-height: 96px; }
.atlas-chat label { display: grid; gap: 3px; color: #d3ddf0; font-size: .86rem; }
.atlas-chat :where(input, textarea) {
  min-width: 0; width: 100%; padding: 7px 8px; border: 1px solid #455475; border-radius: 7px;
  background: #111724; color: var(--chat-text);
}
.atlas-chat textarea { resize: vertical; }
.atlas-chat :where(input, textarea)::placeholder { color: #a4b1cc; }
.atlas-chat input[type="file"]::file-selector-button {
  margin-right: 8px; padding: 6px 8px; font: inherit; color: var(--chat-text);
  background: #283650; border: 1px solid #4d5e7d; border-radius: 5px; cursor: pointer;
}
.atlas-chat-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.atlas-chat-primary, .atlas-chat-secondary {
  border-radius: 7px; min-height: 36px; padding: 6px 11px; border: 1px solid #5777aa;
  background: #2a4f86; color: #fff; font-weight: 700 !important;
}
.atlas-chat-primary:hover { background: #3668ae; }
.atlas-chat-secondary { background: #252f44; border-color: #465777; }
.atlas-chat-secondary:hover { background: #354563; }
.atlas-chat-footer {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px;
  padding: 9px 12px 11px; background: #182030; border-top: 1px solid var(--chat-border);
}
.atlas-chat-compose { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 7px; }
.atlas-chat-compose textarea { min-height: 44px; max-height: 125px; }
.atlas-chat-compose button { min-height: 44px; }
.atlas-chat-footer > small { color: var(--chat-muted); font-size: .72rem; }
.atlas-chat-status { color: #bacdff; font-size: .82rem; }
.atlas-chat-error { color: #ffb6c5; }

@media (min-width: 761px) {
  .atlas-chat-ready #back-to-top {
    right: var(--atlas-chat-right); bottom: var(--atlas-chat-row-bottom);
    width: var(--atlas-chat-scroll-size); height: var(--atlas-chat-scroll-size);
  }
}

@media (max-width: 760px) {
  .atlas-chat-ready {
    --atlas-chat-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .atlas-chat {
    --chat-panel-bottom: var(--atlas-chat-bottom);
    right: var(--atlas-chat-right); bottom: var(--atlas-chat-bottom);
  }
  .atlas-chat-ready #back-to-top {
    right: calc(var(--atlas-chat-right) - 1px);
    bottom: calc(var(--atlas-chat-bottom) + 56px);
  }
  .atlas-chat-panel { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; }
  .atlas-chat-launch[aria-expanded="true"] { visibility: hidden; }
  .atlas-chat :where(input, textarea) { font-size: 16px; }
  .atlas-chat-bubble dl { grid-template-columns: minmax(0, auto) minmax(0, 1fr); }
}
