/* ==========================================================================
   Apsite AI — стилі віджета. Концепт A «Консьєрж» (затверджено 26.08.2026)
   + поле вводу й аватар бота з концепту B. Прототипи: ai-assistant/design/.

   Файл підключається у двох місцях:
     1) на сторінці сайту — працює лише правило .apai-frame*;
     2) всередині iframe  — усе, що вкладено в .apai-doc.

   Чат живе в <iframe srcdoc>, тому стилі сайту не можуть його зламати, а він
   не може зачепити сайт.

   Палітра — з дизайн-системи редизайну (redesign/STATUS.md).
   ========================================================================== */

/* ---------- контейнер на сторінці сайту ---------- */
/* Рамка згорнутого стану — рівно під пігулку лончера (аудит 28.08: прозора
   рамка 290×100 перехоплювала тапи навколо кнопки і закривала «Контакти»
   в копірайті на телефоні). Тінь трохи обрізається — це свідомо. */
.apai-frame {
  position: fixed;
  right: 8px;
  bottom: 8px;
  width: 250px;
  height: 78px;
  border: 0;
  background: transparent;
  z-index: 2147483000;
  color-scheme: dark;
}

/* Відкрите мобільне меню теми (body.nav-open) — лончер ховаємо, щоб не лягав
   на нижні пункти меню. */
body.nav-open .apai-frame:not(.apai-frame--open) { display: none; }

.apai-frame--open {
  width: 440px;
  height: calc(100vh - 40px);
  max-height: 700px;
}

@media (max-width: 520px) {
  .apai-frame--open {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100%;
    max-height: none;
  }
}

/* ==========================================================================
   Документ усередині iframe
   ========================================================================== */

.apai-doc {
  --violet: #733A98;  --violet-300: #9b63c4;  --violet-bright: #8b46c0;
  --orange: #F3863B;  --orange-600: #f06a2a;  --green: #2EC664;
  --ink: #15101c;     --ink-2: #211830;
  --card: rgba(255,255,255,.06);  --line: rgba(255,255,255,.13);
  --muted: rgba(255,255,255,.68); --text: #ece7f2;
  --grad-cta: linear-gradient(135deg,#F3863B 0%,#f06a2a 100%);
  --grad-violet: linear-gradient(135deg,#8b46c0 0%,#733A98 45%,#4a2566 100%);
  --grad-hl: linear-gradient(120deg,#c79bf0,#F3863B);
  --head: 'Montserrat', sans-serif;
}

.apai-doc,
.apai-doc * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Manrope, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html.apai-html,
body.apai-doc,
.apai-doc {
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
}

/* Має збігатися з color-scheme на .apai-frame — інакше рамка стає непрозорою. */
html.apai-html { color-scheme: dark; }

.apai-doc button { font-family: inherit; }
.apai-doc :focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ---------- монограма-знак (лончер і шапка) ---------- */
.apai-doc .apai-fab__ic,
.apai-doc .apai-head__logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--grad-violet);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 10px 22px -10px rgba(139,70,192,.9);
}

.apai-doc .apai-fab__ic b,
.apai-doc .apai-head__logo b {
  font-family: var(--head);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
  transform: translateY(-.5px);
}

.apai-doc .apai-spark {
  position: absolute;
  fill: var(--orange);
  filter: drop-shadow(0 2px 5px rgba(243,134,59,.7));
}

/* ---------- лончер ---------- */
.apai-doc .apai-fab {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 20px 8px 8px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 40px;
  background: rgba(33,24,48,.92);
  color: #fff;
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 44px -16px rgba(0,0,0,.8), 0 0 0 1px rgba(139,70,192,.18), inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.apai-doc .apai-fab:hover {
  transform: translateY(-2px);
  border-color: rgba(243,134,59,.55);
  box-shadow: 0 24px 48px -16px rgba(0,0,0,.85), 0 12px 30px -12px rgba(243,134,59,.5), inset 0 1px 0 rgba(255,255,255,.1);
}

.apai-doc .apai-fab__ic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.apai-doc .apai-fab__ic b { font-size: 15px; }
.apai-doc .apai-fab__ic .apai-spark { width: 13px; height: 13px; top: -4px; right: -4px; }

.apai-doc .apai-fab__txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.apai-doc .apai-fab__txt b { font-size: 14.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.apai-doc .apai-fab__txt small { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }

.apai-doc .apai-fab__dot {
  position: absolute;
  left: 37px;
  top: 36px;
  width: 12px;
  height: 12px;
  border: 2px solid #211830;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(46,198,100,.8);
}

.apai-doc .apai-fab__badge {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--grad-cta);
  color: #fff;
  font-family: var(--head);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 6px 14px -4px rgba(243,134,59,.7);
}

.apai-doc .apai-fab--alert .apai-fab__badge { display: flex; }
.apai-doc .apai-fab--alert { animation: apai-pulse 1.8s ease-out infinite; }

@keyframes apai-pulse {
  0%   { box-shadow: 0 20px 44px -16px rgba(0,0,0,.8), 0 0 0 0 rgba(243,134,59,.55); }
  70%  { box-shadow: 0 20px 44px -16px rgba(0,0,0,.8), 0 0 0 16px rgba(243,134,59,0); }
  100% { box-shadow: 0 20px 44px -16px rgba(0,0,0,.8), 0 0 0 0 rgba(243,134,59,0); }
}

/* ---------- панель ---------- */
.apai-doc .apai-panel {
  position: absolute;
  inset: 10px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  background:
    radial-gradient(460px 340px at 90% -10%, rgba(139,70,192,.5), transparent 62%),
    radial-gradient(400px 320px at 4% 110%, rgba(243,134,59,.22), transparent 62%),
    radial-gradient(320px 240px at 50% 55%, rgba(115,58,152,.10), transparent 70%),
    #15101c;
  color: var(--text);
  box-shadow: 0 44px 96px -30px rgba(0,0,0,.85), 0 0 0 1px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.1);
  opacity: 0;
  transform: translateY(18px) scale(.97);
  transition: opacity .24s ease, transform .28s cubic-bezier(.2,.8,.2,1);
}

.apai-doc .apai-panel.apai-on  { display: flex; }
.apai-doc .apai-panel.apai-vis { opacity: 1; transform: none; }

/* ---------- шапка ---------- */
.apai-doc .apai-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(21,16,28,.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.apai-doc .apai-head__logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.apai-doc .apai-head__logo b { font-size: 16px; }
.apai-doc .apai-head__logo .apai-spark { width: 14px; height: 14px; top: -5px; right: -5px; }

.apai-doc .apai-head__t { min-width: 0; flex: 1; cursor: pointer; }
.apai-doc .apai-head__t:hover b { color: #fff; text-decoration: underline; text-decoration-color: rgba(243,134,59,.6); text-underline-offset: 3px; }
.apai-doc .apai-head__t b {
  display: block;
  font-family: var(--head);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: #fff;
}

.apai-doc .apai-head__st {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apai-doc .apai-head__st i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(46,198,100,.18), 0 0 8px var(--green);
  flex-shrink: 0;
}

.apai-doc .apai-head__brand {
  flex-shrink: 0;
  padding-right: 2px;
  opacity: .75;
  display: flex;
  align-items: center;
}

/* Вордмарк теми 120×56 із прозорими полями: на 20px «site» майже зникало. */
.apai-doc .apai-head__brand img { height: 28px; width: auto; max-width: none; display: block; }
.apai-doc .apai-head__brand { opacity: .9; }

.apai-doc .apai-head__x { display: flex; gap: 4px; flex-shrink: 0; }

.apai-doc .apai-head__x button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.8);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background .14s, color .14s, transform .14s;
}

.apai-doc .apai-head__x button:hover { background: rgba(255,255,255,.14); color: #fff; }
.apai-doc .apai-head__x button svg { width: 15px; height: 15px; }

/* Обертається лише хрестик — на решті іконок це виглядало б випадково. */
.apai-doc .apai-head__x button:last-child:hover { transform: rotate(90deg); }

/* ---------- стрічка ---------- */
.apai-doc .apai-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}

.apai-doc .apai-body::-webkit-scrollbar { width: 6px; }
.apai-doc .apai-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }

@keyframes apai-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- стартовий екран (пропозиція) ---------- */
.apai-doc .apai-hello { margin: 0 0 14px; animation: apai-in .3s ease both; }

.apai-doc .apai-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--violet-300);
}

.apai-doc .apai-eyebrow::before { content: ""; width: 20px; height: 2px; border-radius: 2px; background: var(--orange); }

.apai-doc .apai-hello h2 {
  margin: 9px 0 6px;
  font-family: var(--head);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.02em;
  color: #fff;
}

.apai-doc .apai-hl {
  background: var(--grad-hl);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.apai-doc .apai-hello p { font-size: 13.5px; line-height: 1.5; color: var(--muted); }

.apai-doc .apai-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
  animation: apai-in .3s ease both;
}

.apai-doc .apai-tile {
  --c: #8b46c0;
  --cs: rgba(139,70,192,.18);
  position: relative;
  display: block;
  padding: 12px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: #fff;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.apai-doc .apai-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(140px 90px at 0% 0%, var(--cs), transparent 70%);
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}

.apai-doc .apai-tile:hover { transform: translateY(-2px); border-color: var(--c); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 14px 28px -16px var(--c); }
.apai-doc .apai-tile:hover::after { opacity: 1; }

.apai-doc .apai-tile i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: var(--cs);
  color: var(--c);
}

.apai-doc .apai-tile svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.apai-doc .apai-tile b { display: block; font-size: 14px; font-weight: 700; line-height: 1.25; }
.apai-doc .apai-tile span { display: block; margin-top: 3px; font-size: 13px; line-height: 1.35; color: var(--muted); }

.apai-doc .apai-chips-t { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: rgba(255,255,255,.5); }

/* ---------- повідомлення ---------- */
.apai-doc .apai-m {
  position: relative;
  max-width: 84%;
  margin: 0 0 10px 34px;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: apai-in .28s ease both;
}

.apai-doc .apai-m--bot {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-bottom-left-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 14px 30px -22px rgba(0,0,0,.9);
}

.apai-doc .apai-m--bot::before,
.apai-doc .apai-m--mgr::before,
.apai-doc .apai-typing::before {
  /* Аватар з концепту B: 26px, по верхньому краю репліки. */
  content: "ap";
  position: absolute;
  left: -34px;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--grad-violet);
  color: #fff;
  font-family: var(--head);
  font-size: 10px;
  font-weight: 800;
  line-height: 26px;
  letter-spacing: -.04em;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(21,16,28,.9), 0 6px 12px -6px rgba(139,70,192,.9);
}

.apai-doc .apai-m--me {
  margin-left: auto;
  background: var(--grad-violet);
  border: 1px solid rgba(255,255,255,.14);
  border-bottom-right-radius: 6px;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 16px 32px -16px rgba(139,70,192,.75);
}

.apai-doc .apai-m--mgr {
  background: rgba(46,198,100,.08);
  border: 1px solid rgba(46,198,100,.32);
  border-bottom-left-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.apai-doc .apai-m--mgr::before {
  content: "";
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'><circle cx='12' cy='8' r='3.6'/><path d='M5 20a7 7 0 0 1 14 0'/></svg>") center / 13px no-repeat, linear-gradient(135deg,#2EC664,#1f9e4e);
  box-shadow: 0 0 0 2px rgba(21,16,28,.9), 0 6px 12px -6px rgba(46,198,100,.9);
}

.apai-doc .apai-m a { color: var(--orange); font-weight: 600; text-decoration: underline; text-decoration-color: rgba(243,134,59,.45); text-underline-offset: 2px; }
.apai-doc .apai-m a:hover { text-decoration-color: var(--orange); }
.apai-doc .apai-m b { font-weight: 700; color: #fff; }
.apai-doc .apai-m ul { margin: 6px 0 2px; list-style: none; }
.apai-doc .apai-m li { position: relative; padding-left: 16px; margin-bottom: 4px; }
.apai-doc .apai-m li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--grad-hl); }

.apai-doc .apai-tag {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border: 1px solid rgba(46,198,100,.4);
  border-radius: 20px;
  background: rgba(46,198,100,.16);
  color: #8ff0b6;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.apai-doc .apai-note {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(236,231,242,.5);
  text-align: center;
  animation: apai-in .28s ease both;
}

.apai-doc .apai-note::before,
.apai-doc .apai-note::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* друкує… */
.apai-doc .apai-typing {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 10px 34px;
  padding: 15px 17px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  animation: apai-in .28s ease both;
}

.apai-doc .apai-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet-300);
  animation: apai-bounce 1.1s ease-in-out infinite;
}

.apai-doc .apai-typing i:nth-child(2) { animation-delay: .15s; }
.apai-doc .apai-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes apai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; background: var(--violet-300); }
  30% { transform: translateY(-4px); opacity: 1; background: var(--orange); }
}

/* ---------- чіпси ---------- */
.apai-doc .apai-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 14px; animation: apai-in .3s ease both; }

.apai-doc .apai-chips button {
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .14s, color .14s;
}

.apai-doc .apai-chips button:hover {
  background: rgba(139,70,192,.26);
  border-color: rgba(155,99,196,.7);
  color: #fff;
  transform: translateY(-1px);
}

/* ---------- «покликати менеджера» ---------- */
.apai-doc .apai-call { margin: -2px 0 14px 34px; animation: apai-in .28s ease both; }

.apai-doc .apai-call button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 11px;
  border: 1px solid rgba(46,198,100,.45);
  border-radius: 999px;
  background: rgba(46,198,100,.1);
  color: #8ff0b6;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .14s, transform .14s;
}

.apai-doc .apai-call button:hover { background: rgba(46,198,100,.2); transform: translateY(-1px); }
.apai-doc .apai-call button:disabled { opacity: .55; cursor: default; transform: none; }
.apai-doc .apai-call svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- форма заявки ---------- */
.apai-doc .apai-lead {
  margin: 0 0 14px 34px;
  padding: 16px;
  border: 1px solid rgba(243,134,59,.38);
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(243,134,59,.14), rgba(243,134,59,.04)), var(--ink-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 20px 40px -28px rgba(243,134,59,.6);
  animation: apai-in .3s ease both;
}

.apai-doc .apai-lead p { margin-bottom: 12px; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.apai-doc .apai-lead p b { color: #fff; }

.apai-doc .apai-lead input {
  width: 100%;
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(0,0,0,.32);
  color: #fff;
  font-size: 14px;
  transition: border-color .14s, box-shadow .14s;
}

.apai-doc .apai-lead input::placeholder { color: rgba(236,231,242,.4); }
.apai-doc .apai-lead input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(243,134,59,.18); }

.apai-doc .apai-lead button {
  width: 100%;
  margin-top: 2px;
  padding: 13px;
  border: none;
  border-radius: 999px;
  background: var(--grad-cta);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 30px -10px rgba(243,134,59,.55);
  transition: transform .14s, box-shadow .14s;
}

.apai-doc .apai-lead button:hover { transform: translateY(-1px); box-shadow: 0 18px 34px -10px rgba(243,134,59,.7); }
.apai-doc .apai-lead button:disabled { opacity: .6; transform: none; cursor: default; }

.apai-doc .apai-lead__err,
.apai-doc .apai-lead__ok {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
}

.apai-doc .apai-lead__err::before,
.apai-doc .apai-lead__ok::before {
  content: "!";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  margin-top: 1px;
}

.apai-doc .apai-lead__err { border: 1px solid rgba(225,71,138,.4); background: rgba(225,71,138,.12); color: #ffb6d1; }
.apai-doc .apai-lead__err::before { background: #E1478A; color: #fff; }
.apai-doc .apai-lead__ok { margin-bottom: 0; border: 1px solid rgba(46,198,100,.4); background: rgba(46,198,100,.12); color: #a6f4c4; }
.apai-doc .apai-lead__ok::before { content: "✓"; background: var(--green); color: #0c2a17; }

/* ---------- картки в стрічці (пропозиція: послуга / розрахунок) ---------- */
.apai-doc .apai-card {
  --c: #8b46c0;
  --cs: rgba(139,70,192,.22);
  position: relative;
  max-width: 100%;
  margin: 0 0 14px 34px;
  padding: 15px 16px 14px 19px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: radial-gradient(220px 120px at 0% 0%, var(--cs), transparent 70%), var(--card);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 20px 40px -28px rgba(0,0,0,.9);
  overflow: hidden;
  animation: apai-in .3s ease both;
}

.apai-doc .apai-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c);
  box-shadow: 0 0 14px var(--c);
}

.apai-doc .apai-card__eb {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c);
}

.apai-doc .apai-card__t {
  font-family: var(--head);
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.01em;
  color: #fff;
}

.apai-doc .apai-card__price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 8px 0 6px;
  font-family: var(--head);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
}

.apai-doc .apai-card__price em {
  font-style: normal;
  background: var(--grad-hl);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.apai-doc .apai-card__price small { font-family: Manrope, sans-serif; font-size: 13px; font-weight: 600; color: var(--muted); }
.apai-doc .apai-card__d { font-size: 13.5px; line-height: 1.5; color: var(--muted); }

.apai-doc .apai-card__a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--orange);
  text-decoration: none;
  transition: gap .14s;
}

.apai-doc .apai-card__a:hover { gap: 10px; }
.apai-doc .apai-card__a svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.apai-doc .apai-card--calc .apai-card__price { font-size: 26px; margin: 6px 0 10px; }

.apai-doc .apai-card__rows { margin-bottom: 10px; }
.apai-doc .apai-card__rows div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}

.apai-doc .apai-card__rows span { color: var(--muted); }
.apai-doc .apai-card__rows b { font-weight: 700; color: #fff; text-align: right; }

.apai-doc .apai-card__n {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(236,231,242,.55);
}

.apai-doc .apai-card__n::before { content: "≈"; flex-shrink: 0; font-weight: 800; color: var(--violet-300); }

.apai-doc .apai-card__btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 999px;
  background: var(--grad-cta);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 30px -10px rgba(243,134,59,.55);
  transition: transform .14s, box-shadow .14s;
}

.apai-doc .apai-card__btn:hover { transform: translateY(-1px); box-shadow: 0 18px 34px -10px rgba(243,134,59,.7); }

/* ---------- картки кейсів у стрічці ---------- */
.apai-doc .apai-cases {
  display: grid;
  gap: 10px;
  margin: 0 0 14px 34px;
  animation: apai-in .3s ease both;
}

.apai-doc .apai-case {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.apai-doc a.apai-case:hover {
  transform: translateY(-2px);
  border-color: rgba(155,99,196,.65);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 18px 34px -20px rgba(139,70,192,.9);
}

.apai-doc .apai-case__img {
  display: block;
  height: 96px;
  overflow: hidden;
  background: var(--ink-2);
  border-bottom: 1px solid var(--line);
}

.apai-doc .apai-case__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.apai-doc .apai-case__b { display: block; padding: 12px 14px 13px; }

.apai-doc .apai-case__t {
  display: block;
  font-family: var(--head);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: #fff;
}

.apai-doc .apai-case__u {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--violet-300);
}

/* Опис — рівно два рядки: чотири картки поспіль інакше перетворюють
   стрічку на довгий сувій. Повний текст — на сторінці кейса. */
.apai-doc .apai-case__d {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.apai-doc .apai-case__st { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.apai-doc .apai-case__st span {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(236,231,242,.72);
  white-space: nowrap;
}

.apai-doc .apai-case__a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
  transition: gap .14s;
}

.apai-doc .apai-case__a svg { width: 14px; height: 14px; }
.apai-doc a.apai-case:hover .apai-case__a { gap: 10px; }

/* ---------- шторка: мої розмови / початковий екран ---------- */
.apai-doc .apai-sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: 71px;      /* під шапкою */
  bottom: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  background:
    radial-gradient(420px 300px at 90% 0%, rgba(139,70,192,.35), transparent 65%),
    rgba(21,16,28,.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: apai-sheet-in .2s ease both;
}

@keyframes apai-sheet-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.apai-doc .apai-sheet--on { display: flex; }
.apai-doc .apai-sheet__in { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 10px; }

.apai-doc .apai-sheet__h {
  margin-bottom: 12px;
  font-family: var(--head);
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.apai-doc .apai-sheet__empty { font-size: 13.5px; color: var(--muted); }

.apai-doc .apai-sheet__foot {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
}

.apai-doc .apai-sheet__foot button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .14s, border-color .14s;
}

.apai-doc .apai-sheet__foot button svg { width: 15px; height: 15px; }
.apai-doc .apai-sheet__foot button:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.28); }

.apai-doc .apai-sheet__new {
  border-color: rgba(243,134,59,.5) !important;
  background: rgba(243,134,59,.12) !important;
  color: #ffc79a !important;
}

.apai-doc .apai-sheet__new:hover { background: rgba(243,134,59,.2) !important; }

.apai-doc .apai-dlgs { display: grid; gap: 7px; }

.apai-doc .apai-dlg {
  display: block;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.04);
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: background .14s, border-color .14s;
}

.apai-doc .apai-dlg:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.26); }

.apai-doc .apai-dlg--on {
  border-color: rgba(155,99,196,.75);
  background: rgba(139,70,192,.18);
}

.apai-doc .apai-dlg__t {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apai-doc .apai-dlg__d { display: block; margin-top: 3px; font-size: 11.5px; color: rgba(236,231,242,.5); }

/* ---------- поле вводу ---------- */
.apai-doc .apai-foot {
  flex-shrink: 0;
  padding: 12px 14px 12px;
  border-top: 1px solid var(--line);
  background: rgba(21,16,28,.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.apai-doc .apai-in {
  display: flex;
  align-items: flex-end;
  /* Поле вводу — з концепту B: більше повітря, крупніший текст. */
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  background: rgba(0,0,0,.32);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
  transition: border-color .16s, box-shadow .16s;
}

.apai-doc .apai-in:focus-within { border-color: rgba(155,99,196,.8); box-shadow: inset 0 1px 2px rgba(0,0,0,.4), 0 0 0 3px rgba(139,70,192,.22); }

.apai-doc .apai-in textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.apai-doc .apai-in textarea::placeholder { color: rgba(236,231,242,.4); }

.apai-doc .apai-in button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--grad-cta);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 20px -8px rgba(243,134,59,.8), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .14s, opacity .14s, box-shadow .14s;
}

.apai-doc .apai-in button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.apai-doc .apai-in button:hover { transform: translateY(-1px) scale(1.04); }
.apai-doc .apai-in button:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }

.apai-doc .apai-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(236,231,242,.42);
  text-align: center;
}

.apai-doc .apai-hint::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--orange);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  opacity: .8;
}

/* ---------- мобільний ---------- */
.apai-doc.apai-mob .apai-panel { inset: 0; border-radius: 0; border: 0; box-shadow: none; }
.apai-doc.apai-mob .apai-head { padding-top: calc(14px + env(safe-area-inset-top)); }
.apai-doc.apai-mob .apai-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.apai-doc.apai-mob .apai-in textarea { font-size: 16px; }
.apai-doc.apai-mob .apai-m { max-width: 88%; }
.apai-doc.apai-mob .apai-hello h2 { font-size: 22px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .apai-doc *, .apai-doc *::before, .apai-doc *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
