/* Чат-виджет reloway.es — «Помощник команды Reloway».
   Общий файл для главной и блога; токены — из Footer.*.css (--navy, --sand,
   --brass, --terracotta, --hairline, --font-display, --ease). */
.cw{position:fixed;right:22px;bottom:22px;z-index:60;font-family:var(--font-text,Inter,sans-serif);
  --cw-paper:#fff;--cw-shadow:0 18px 60px rgba(14,27,44,.28)}
.cw *{box-sizing:border-box}
.cw-fab{width:56px;height:56px;border-radius:50%;border:0;padding:0;cursor:pointer;
  background:var(--navy,#14263f);color:var(--sand,#f4f1ea);display:flex;align-items:center;justify-content:center;
  box-shadow:0 6px 24px rgba(14,27,44,.30);
  transition:transform .2s var(--ease,ease),background .2s var(--ease,ease),box-shadow .2s var(--ease,ease)}
.cw-fab:hover{background:var(--navy-deep,#0e1b2c);transform:translateY(-2px);box-shadow:0 10px 30px rgba(14,27,44,.36)}
.cw-fab:active{transform:scale(.96)}
.cw-fab svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.cw-fab .cw-ic-x{display:none}
.cw.is-open .cw-fab .cw-ic-chat{display:none}
.cw.is-open .cw-fab .cw-ic-x{display:block}

/* меню под кнопкой: «Спросить здесь» / «Написать в Telegram» */
.cw-menu{display:none;position:absolute;right:0;bottom:70px;width:264px;background:var(--sand,#f4f1ea);
  border:1px solid var(--hairline,#d8d2c6);box-shadow:var(--cw-shadow)}
.cw.is-menu .cw-menu{display:block}
.cw-menu__item{display:grid;grid-template-columns:22px 1fr;column-gap:12px;align-items:center;width:100%;
  padding:13px 16px;text-align:left;border:0;background:none;color:var(--ink,#1e2833);font:inherit;
  cursor:pointer;text-decoration:none;transition:background .15s var(--ease,ease)}
.cw-menu__item:hover{background:var(--sand-2,#eae5db)}
.cw-menu__item+.cw-menu__item{border-top:1px solid var(--hairline,#d8d2c6)}
.cw-menu__item svg{width:22px;height:22px;grid-row:span 2;fill:none;stroke:var(--brass-text,#856a3f);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.cw-menu__item svg.cw-ic-tg{fill:var(--brass-text,#856a3f);stroke:none}
.cw-menu__item b{font-weight:500;font-size:.95rem;line-height:1.3}
.cw-menu__item small{grid-column:2;color:var(--warm-grey,#6e6a64);font-size:.8rem;line-height:1.3}

/* пульс кнопки, пока чат ни разу не открыт (механика «Советника») */
.cw.is-pulse .cw-fab{animation:cw-pulse 2.4s var(--ease,ease) infinite}
@keyframes cw-pulse{0%,100%{transform:scale(1);box-shadow:0 6px 24px rgba(14,27,44,.30)}
  50%{transform:scale(1.05);box-shadow:0 8px 28px rgba(14,27,44,.36),0 0 0 10px rgba(20,38,63,.10)}}

/* подсказка рядом с кнопкой: первая через 8 с, повтор каждые 45 с, крестик гасит */
.cw-teaser{display:none;position:absolute;right:68px;bottom:9px;white-space:nowrap;cursor:pointer;
  background:var(--navy,#14263f);color:var(--sand,#f4f1ea);padding:10px 34px 10px 14px;font-size:.9rem;line-height:1.3;
  box-shadow:0 8px 24px rgba(14,27,44,.25)}
.cw-teaser::after{content:"";position:absolute;right:-6px;top:50%;margin-top:-6px;border:6px solid transparent;border-left-color:var(--navy,#14263f);border-right:0}
.cw-teaser__x{position:absolute;right:6px;top:6px;width:22px;height:22px;border:0;background:none;color:inherit;opacity:.65;
  font:inherit;font-size:18px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center}
.cw-teaser__x:hover{opacity:1}
.cw-teaser__act{display:none;gap:8px;margin-top:12px}
.cw-teaser__btn{flex:1;padding:9px 10px;border:1px solid var(--navy,#14263f);background:var(--navy,#14263f);color:var(--sand,#f4f1ea);
  font:inherit;font-size:.85rem;line-height:1.2;text-align:center;text-decoration:none;cursor:pointer}
.cw-teaser__btn--tg{background:none;color:var(--navy,#14263f)}
.cw.is-teaser .cw-teaser{display:block;animation:cw-in .35s var(--ease,ease)}
/* карточка с приветствием — автооткрытие на телефоне вместо окна во весь экран */
.cw.is-card .cw-teaser{display:block;white-space:normal;cursor:default;right:0;bottom:66px;width:min(330px,calc(100vw - 32px));
  padding:14px 36px 14px 16px;background:var(--sand,#f4f1ea);color:var(--ink,#1e2833);border:1px solid var(--hairline,#d8d2c6);
  box-shadow:var(--cw-shadow);animation:cw-in .35s var(--ease,ease)}
.cw.is-card .cw-teaser::after{display:none}
.cw.is-card .cw-teaser__text{display:block;font-size:.95rem;line-height:1.5;min-height:1.5em;cursor:pointer}
.cw.is-card .cw-teaser__x{color:var(--warm-grey,#6e6a64)}
.cw.is-card .cw-teaser__act{display:flex}
.cw-dots--inline{display:inline-flex;gap:4px;padding:0;min-height:0;vertical-align:middle}
.cw-dots--inline i{width:6px;height:6px}

/* окно */
.cw-win{display:none;position:absolute;right:0;bottom:70px;width:384px;height:min(640px,calc(100vh - 110px));
  background:var(--sand,#f4f1ea);border:1px solid var(--hairline,#d8d2c6);box-shadow:var(--cw-shadow);
  flex-direction:column;overflow:hidden;animation:cw-in .3s var(--ease,ease)}
.cw.is-open .cw-win{display:flex}
/* компактное окно — так открывается автооткрытие на десктопе; действие человека разворачивает */
.cw.is-compact .cw-win{height:min(470px,calc(100vh - 110px))}
html.cw-lock,html.cw-lock body{overflow:hidden;overscroll-behavior:none}
.cw-head{display:flex;align-items:flex-start;gap:12px;padding:16px 18px 14px;background:var(--navy,#14263f);color:var(--sand,#f4f1ea);flex:none}
.cw-head b{display:block;font-family:var(--font-display,Georgia,serif);font-weight:400;font-size:1.15rem;line-height:1.2}
.cw-head span{display:block;font-size:.8rem;line-height:1.35;color:rgba(244,241,234,.72);margin-top:4px}
.cw-close{margin-left:auto;flex:none;width:32px;height:32px;margin-top:-4px;margin-right:-8px;background:none;border:0;
  color:var(--sand,#f4f1ea);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:.8}
.cw-close:hover{opacity:1}
.cw-close svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.cw-log{flex:1;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:16px 16px 6px;
  display:flex;flex-direction:column;gap:10px}
.cw-msg{max-width:88%;padding:10px 14px;font-size:.95rem;line-height:1.5;white-space:pre-wrap;word-break:break-word;
  animation:cw-in .25s var(--ease,ease)}
.cw-msg--ai{align-self:flex-start;background:var(--cw-paper);border:1px solid var(--hairline,#d8d2c6)}
.cw-msg--me{align-self:flex-end;background:var(--navy,#14263f);color:var(--sand,#f4f1ea)}
.cw-msg--sys{align-self:center;max-width:100%;padding:4px 8px;font-size:.8rem;line-height:1.4;color:var(--warm-grey,#6e6a64);text-align:center}
.cw-msg a{color:var(--terracotta,#a84b35);text-decoration:underline;text-underline-offset:2px}
.cw-msg--me a{color:var(--brass-on-dark,#c8a268)}
.cw-dots{display:flex;gap:5px;align-items:center;padding:14px 16px;min-height:42px}
.cw-dots i{width:7px;height:7px;border-radius:50%;background:var(--warm-grey,#6e6a64);opacity:.35;animation:cw-dot 1.1s infinite}
.cw-dots i:nth-child(2){animation-delay:.18s}
.cw-dots i:nth-child(3){animation-delay:.36s}
.cw-suggest{display:flex;flex-wrap:wrap;gap:8px;padding:4px 16px 10px;flex:none}
.cw-suggest:empty{display:none}
.cw-chip{border:1px solid var(--brass,#b08d57);background:none;color:var(--brass-text,#856a3f);padding:7px 12px;
  font:inherit;font-size:.85rem;line-height:1.2;cursor:pointer;transition:background .15s var(--ease,ease),color .15s var(--ease,ease)}
.cw-chip:hover{background:var(--brass,#b08d57);color:#fff}
.cw-tg{display:none;align-items:center;justify-content:center;gap:8px;margin:0 16px 10px;padding:10px 14px;flex:none;
  border:1px solid var(--brass,#b08d57);color:var(--brass-text,#856a3f);text-decoration:none;font-size:.9rem;line-height:1.3;
  transition:background .15s var(--ease,ease),color .15s var(--ease,ease)}
.cw-tg svg{width:18px;height:18px;fill:currentColor;flex:none}
.cw-tg:hover{background:var(--brass,#b08d57);color:#fff}
.cw.has-tg .cw-tg{display:flex}
.cw-tg.is-hot{background:var(--terracotta,#a84b35);border-color:var(--terracotta,#a84b35);color:#fff}
.cw-tg.is-hot:hover{background:#95412d}
.cw-form{display:flex;gap:8px;align-items:flex-end;padding:10px 12px 8px 16px;border-top:1px solid var(--hairline,#d8d2c6);background:var(--cw-paper);flex:none}
.cw-form textarea{flex:1;min-width:0;resize:none;border:0;background:none;font:inherit;font-size:.95rem;line-height:1.45;
  max-height:120px;outline:none;padding:8px 0;color:var(--ink,#1e2833)}
.cw-form textarea::placeholder{color:var(--warm-grey,#6e6a64)}
.cw-form button{flex:none;width:40px;height:40px;border:0;background:var(--navy,#14263f);color:var(--sand,#f4f1ea);cursor:pointer;
  display:flex;align-items:center;justify-content:center;transition:background .15s var(--ease,ease)}
.cw-form button:hover{background:var(--navy-deep,#0e1b2c)}
.cw-form button:disabled{opacity:.4;cursor:default}
.cw-form button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}

@keyframes cw-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cw-dot{0%,80%,100%{opacity:.35;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}

@media (max-width:900px){.cw{right:16px;bottom:16px}.cw-fab{width:52px;height:52px}.cw-menu,.cw-win{bottom:66px}}
@media (max-width:640px){
  /* ширина — по видимой области, а не по раскладке: если какой-то блок
     страницы шире экрана, окно всё равно не должно уезжать за край */
  .cw-win{position:fixed;left:var(--cw-left,0px);right:auto;top:var(--cw-top,0px);bottom:auto;width:var(--cw-vw,100vw);height:var(--cw-vh,100dvh);border:0;animation:none}
  .cw.is-open .cw-fab,.cw.is-open .cw-menu,.cw.is-open .cw-teaser{display:none}
  .cw-head{padding-top:calc(16px + env(safe-area-inset-top,0px))}
  .cw-form{padding-bottom:calc(8px + env(safe-area-inset-bottom,0px))}
  .cw-teaser{max-width:calc(100vw - 100px);white-space:normal}
  .cw.is-card .cw-teaser{bottom:62px}
}
@media (prefers-reduced-motion:reduce){
  .cw-win,.cw-msg,.cw.is-teaser .cw-teaser,.cw.is-card .cw-teaser,.cw.is-pulse .cw-fab{animation:none}
  .cw-dots i{animation:none;opacity:.7}
  .cw-fab,.cw-menu__item,.cw-chip,.cw-tg{transition:none}
}

/* --- v6: живой портрет, как у «Советника» (владелец 02.10.2026) ---------- */
.cw-ava{position:relative;display:block;flex:none;border-radius:50%;background:var(--cw-ava) center/cover no-repeat,var(--sand-2,#eae5db)}
.cw-ava video{display:block;width:100%;height:100%;border-radius:50%;object-fit:cover}
.cw-ava::after{content:"";position:absolute;right:1px;bottom:1px;width:12px;height:12px;border-radius:50%;
  background:#4cc36a;border:2px solid var(--navy,#14263f)}
/* кнопка: портрет в тонком песочном ободке, точка «онлайн» */
.cw-fab{width:64px;height:64px;padding:3px;background:var(--sand,#f4f1ea);box-shadow:0 0 0 1px rgba(14,27,44,.10),0 8px 26px rgba(14,27,44,.30)}
.cw-fab:hover{background:var(--sand,#f4f1ea)}
.cw-fab .cw-ava{width:100%;height:100%}
.cw-fab .cw-ava::after{right:0;bottom:0;width:14px;height:14px;border-color:var(--sand,#f4f1ea)}
.cw.is-open .cw-fab{background:var(--navy,#14263f)}
.cw.is-open .cw-fab .cw-ava{display:none}
/* шапка: портрет, имя, подпись, Telegram и «свернуть» в одну строку */
.cw-head{align-items:center;gap:12px;padding:14px 12px 14px 16px}
.cw-head .cw-ava{width:46px;height:46px;box-shadow:0 0 0 2px rgba(244,241,234,.28)}
.cw-head>div{min-width:0;flex:1}
.cw-head span{margin-top:2px}
.cw-head__tg{flex:none;display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;
  color:var(--sand,#f4f1ea);opacity:.78;transition:opacity .2s var(--ease,ease),background .2s var(--ease,ease)}
.cw-head__tg:hover{opacity:1;background:rgba(244,241,234,.10)}
.cw-head__tg:focus-visible,.cw-close:focus-visible{outline:2px solid var(--brass-on-dark,#c8a268);outline-offset:2px}
.cw-head__tg svg{width:19px;height:19px;fill:currentColor}
.cw-head .cw-close{margin:0}
/* у ответов — маленький аватар того же человека */
.cw-msg--ai{position:relative;margin-left:34px}
.cw-msg--ai::before{content:"";position:absolute;left:-34px;bottom:0;width:26px;height:26px;border-radius:50%;
  background:var(--cw-ava) center/cover no-repeat,var(--sand-2,#eae5db)}
/* в серии ответов подряд аватар — только у последнего, как в мессенджерах */
.cw-msg--ai:has(+.cw-msg--ai)::before{display:none}
@media (max-width:900px){.cw-fab{width:60px;height:60px}}
@media (prefers-reduced-motion:reduce){.cw-head__tg{transition:none}}
