/* ШІ-асистент підбору (RITM). Кольори й шрифт — змінні з конфігу сайту (ui.theme). */
.ra, .ra * { box-sizing: border-box; }
.ra { font-family: var(--ra-font); color: var(--ra-text); font-size: 15px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
.ra [hidden] { display: none !important; }
.ra button { font: inherit; cursor: pointer; }

/* Кнопка (як на home.ritm.group). z-index нижче модалок і меню сайту (500, 999), вище шапки й банера cookie (100). */
.ra-launcher {
  position: fixed; z-index: 450; left: 20px; bottom: calc(20px + var(--ra-lift, 0px) + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 20px 0 8px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--ra-accent-hover) 0%, var(--ra-accent) 55%, var(--ra-accent-dark) 100%);
  color: #fff; font-weight: 700; font-size: 15px; line-height: 1; letter-spacing: .01em;
  box-shadow: 0 8px 24px var(--ra-shadow), 0 2px 6px rgba(0, 0, 0, .12);
  transition: transform .18s ease, box-shadow .18s ease, opacity .2s ease, bottom .2s ease;
  animation: ra-launch-in .4s ease-out both;
}
.ra-launcher .ra-ico {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, .2); flex: none;
}
.ra-launcher svg { width: 20px; height: 20px; }
.ra--right .ra-launcher { left: auto; right: 20px; }
.ra-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px var(--ra-shadow), 0 2px 6px rgba(0, 0, 0, .12); }
.ra-launcher:hover .ra-ico svg { animation: ra-spark .6s ease; }
.ra-launcher:active { transform: scale(.97); }
@media (min-width: 768px) {
  .ra-launcher { left: 30px; bottom: calc(30px + var(--ra-lift, 0px) + env(safe-area-inset-bottom)); }
  .ra--right .ra-launcher { right: 30px; }
}
@keyframes ra-launch-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ra-spark { 50% { transform: rotate(18deg) scale(1.15); } }
.ra-launcher:focus-visible, .ra-chip:focus-visible, .ra-send:focus-visible, .ra-close:focus-visible, .ra-submit:focus-visible {
  outline: 3px solid var(--ra-accent-hover); outline-offset: 3px;
}

/* Вікно: десктоп і планшет — у кутку */
.ra-panel {
  position: fixed; z-index: 490; bottom: 20px; left: 20px; width: 390px; height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden; background: #fff;
  border-radius: calc(var(--ra-radius) + 4px); box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
}
.ra--right .ra-panel { left: auto; right: 20px; }
@supports (height: 100dvh) { .ra-panel { height: min(640px, calc(100dvh - 40px)); } }

.ra-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px 12px 14px; background: linear-gradient(135deg, var(--ra-accent) 0%, var(--ra-accent-dark) 100%); color: #fff;
}
.ra-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ra-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .18); flex: none; }
.ra-title b { display: block; font-size: 16px; line-height: 1.2; }
.ra-title small { display: block; font-size: 12px; opacity: .85; margin-top: 2px; }
.ra-close { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: #fff; }
.ra-close:hover { background: rgba(255, 255, 255, .15); }

.ra-log {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: #f6f5f8;
}
.ra-block { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ra-msg { max-width: 88%; padding: 9px 13px; border-radius: var(--ra-radius); word-wrap: break-word; overflow-wrap: anywhere; }
.ra-bot { background: #fff; border: 1px solid #ebe8ee; border-bottom-left-radius: 4px; }
.ra-user { align-self: flex-end; background: var(--ra-accent); color: #fff; border-bottom-right-radius: 4px; }
.ra-msg a { color: var(--ra-accent); text-decoration: underline; }
.ra-done { border-color: #58eda0; }

.ra-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.ra-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ra-muted); opacity: .4; animation: ra-dot 1.2s infinite; }
.ra-typing span:nth-child(2) { animation-delay: .2s; }
.ra-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ra-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

/* Підказки-кнопки */
.ra-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ra-chip {
  padding: 7px 13px; border: 1px solid var(--ra-accent); border-radius: 999px; background: #fff;
  color: var(--ra-accent); font-size: 14px; line-height: 1.2; transition: background .15s, color .15s;
}
.ra-chip:hover { background: var(--ra-accent); color: #fff; }

/* Картки об'єктів */
.ra-cards { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.ra-card {
  display: flex; gap: 10px; padding: 8px; background: #fff; border: 1px solid #ebe8ee; border-radius: var(--ra-radius);
  color: inherit !important; text-decoration: none !important; transition: border-color .15s, box-shadow .15s;
}
.ra-card:hover { border-color: var(--ra-accent); box-shadow: 0 3px 12px rgba(0, 0, 0, .08); }
.ra-card-img { position: relative; flex: none; width: 104px; height: 84px; border-radius: calc(var(--ra-radius) - 4px); overflow: hidden; background: #e9e6ec; }
.ra-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ra-badge { position: absolute; left: 4px; top: 4px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px; }
.ra-card-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ra-price { font-weight: 700; color: var(--ra-accent); }
.ra-card-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ra-params { font-size: 12px; color: var(--ra-muted); }
.ra-more { margin-top: auto; font-size: 12px; color: var(--ra-accent); }

/* Форма контактів */
.ra-lead { width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: #fff; border: 1px solid #ebe8ee; border-radius: var(--ra-radius); }
.ra-lead label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--ra-muted); }
.ra-lead input:not([type=checkbox]) {
  width: 100%; padding: 9px 11px; border: 1px solid #d8d3dd; border-radius: 8px; font: inherit; font-size: 16px; color: var(--ra-text); background: #fff;
}
.ra-lead input:focus { outline: none; border-color: var(--ra-accent); }
.ra-lead .ra-consent { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 12px; }
.ra-consent input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--ra-accent); flex: none; }
.ra-consent a { color: var(--ra-accent); }
.ra-error { font-size: 13px; color: #c62828; min-height: 0; }
.ra-error:empty { display: none; }
.ra-submit { padding: 11px; border: 0; border-radius: 8px; background: var(--ra-accent); color: #fff; font-weight: 600; }
.ra-submit:hover { background: var(--ra-accent-hover); }
.ra-submit:disabled { opacity: .6; cursor: default; }

/* Поле вводу */
.ra-input { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #ebe8ee; background: #fff; }
.ra-input textarea {
  flex: 1; min-height: 42px; max-height: 120px; resize: none; padding: 10px 12px; border: 1px solid #d8d3dd; border-radius: 10px;
  font: inherit; font-size: 16px; line-height: 1.3; color: var(--ra-text); background: #fff;
}
.ra-input textarea:focus { outline: none; border-color: var(--ra-accent); }
.ra-send { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 10px; background: var(--ra-accent); color: #fff; }
.ra-send:hover { background: var(--ra-accent-hover); }

/* Телефон: на весь екран; висоту й зсув під клавіатуру ставить JS (visualViewport) */
@media (max-width: 600px) {
  .ra-launcher { left: 12px; bottom: calc(12px + var(--ra-lift, 0px) + env(safe-area-inset-bottom)); height: 48px; padding: 0 16px 0 6px; font-size: 14px; }
  .ra--right .ra-launcher { right: 12px; }
  .ra-panel, .ra--right .ra-panel {
    top: 0; left: 0; right: 0; bottom: auto; width: 100%; height: 100%; border-radius: 0;
  }
  @supports (height: 100dvh) { .ra-panel { height: 100dvh; } }
  .ra-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .ra-msg { max-width: 92%; }
}
html.ra-lock, html.ra-lock body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
  .ra-launcher, .ra-chip, .ra-card { transition: none; animation: none; }
  .ra-typing span { animation: none; opacity: .6; }
}
