/* Виджет-консультант mass: плавающая капсула + стеклянная панель-диалог.
   Дизайн-код сайта: молоко, графит, синий логотипа только на кнопках и цифрах, капсулы и мягкие скругления. */
.cw-fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 45;
  display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 22px 0 16px; border: 0; border-radius: var(--r-pill); cursor: pointer;
  font: 600 15px/1 var(--font); letter-spacing: -.005em; color: #fff; background: linear-gradient(180deg, var(--blue-2) 0%, var(--blue) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 14px 30px -12px rgba(48,63,144,.75), 0 2px 6px rgba(28,30,33,.18);
  transform: translateY(var(--cw-lift, 0px)); transition: transform .35s var(--ease), opacity .25s var(--ease), background .2s; }
@media (hover: hover) { .cw-fab:hover { background: linear-gradient(180deg, #4a5cc4 0%, var(--blue-2) 100%); } }
.cw-fab:active { transform: translateY(var(--cw-lift, 0px)) scale(.97); }
.cw-fab svg { width: 22px; height: 22px; flex: none; }
.cw-fab[hidden] { display: none; }
.cw-open .cw-fab, .menu-open .cw-fab, .pd-open .cw-fab { opacity: 0; pointer-events: none; }
/* «отошла»: первый экран, форма заявки, панель цены — уходит вниз и из порядка Tab */
.cw-fab.is-away { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(calc(var(--cw-lift, 0px) + 16px));
  transition: transform .35s var(--ease), opacity .25s var(--ease), visibility 0s linear .35s; }
/* мягкий «маячок» один раз после появления — без бесконечной пульсации */
.cw-fab__dot { position: absolute; top: 8px; left: 34px; width: 8px; height: 8px; border-radius: 50%; background: #9fe0b8; box-shadow: 0 0 0 2px var(--blue); }
@media (max-width: 760px) {
  .cw-fab { right: max(12px, env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); width: 56px; height: 56px; min-height: 0; padding: 0; justify-content: center; }
  .cw-fab__t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .cw-fab__dot { top: 12px; left: auto; right: 12px; }
}

/* Подложка: на телефоне — затемнение под шторкой, на десктопе — прозрачная (ловит клик мимо) */
.cw-back { position: fixed; inset: 0; z-index: 59; background: rgba(20,21,24,.46); opacity: 0; transition: opacity .3s var(--ease); }
.cw-back[hidden] { display: none; }
.cw-open .cw-back { opacity: 1; }
@media (min-width: 761px) { .cw-back { background: transparent; } }

.cw-panel { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px - env(safe-area-inset-bottom)));
  overflow: hidden; border-radius: var(--r-card); color: var(--ink); background: rgba(251,250,246,.96);
  -webkit-backdrop-filter: blur(26px) saturate(170%); backdrop-filter: blur(26px) saturate(170%);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.95), inset 0 0 0 1px rgba(255,255,255,.5), 0 2px 4px rgba(28,30,33,.06), 0 30px 70px -24px rgba(28,30,33,.45);
  transform-origin: 100% 100%; opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .28s var(--ease), transform .36s var(--ease); }
.cw-panel[hidden] { display: none; }
.cw-open .cw-panel { opacity: 1; transform: none; }
@media (max-width: 760px) {
  /* --cw-kb / --cw-vh ставит consultant.js из visualViewport: клавиатура iOS не прячет поле ввода */
  .cw-panel { left: 0; right: 0; bottom: var(--cw-kb, 0px); width: 100%; height: min(88dvh, calc(var(--cw-vh, 100dvh) - 24px)); border-radius: var(--r-card) var(--r-card) 0 0;
    padding-bottom: env(safe-area-inset-bottom); transform: translateY(40px); background: var(--paper); }
}

.cw-head { display: flex; align-items: center; gap: 10px; padding: 16px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.cw-head__txt { flex: 1; min-width: 0; }
.cw-title { font-family: var(--font-head); font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.cw-sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.cw-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer; color: var(--ink); background: transparent; transition: background .2s; }
@media (hover: hover) { .cw-icon:hover { background: rgba(28,30,33,.06); } }
.cw-icon svg { width: 18px; height: 18px; }

/* Темы разговора: переключение ветки в один клик */
/* все темы видны сразу: на узком экране переносятся во вторую строку, а не уезжают за край без подсказки */
.cw-topics { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.cw-topic { flex: none; min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-pill); cursor: pointer; font: 500 14px/1 var(--font); color: var(--ink);
  background: rgba(28,30,33,.05); transition: background .2s, color .2s; }
@media (max-width: 760px) {
  /* телефон: темы сеткой 2×2 — ровно две строки, всё видно сразу */
  .cw-topics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px 16px; }
  .cw-topic { min-height: 36px; padding: 0 10px; font-size: 13.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (hover: hover) { .cw-topic:hover { background: rgba(28,30,33,.09); } }
.cw-topic[aria-pressed="true"] { color: #fff; background: var(--graphite); }

.cw-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.cw-msg { max-width: 86%; padding: 11px 15px; border-radius: 18px; font-size: 15px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.cw-msg--bot { align-self: flex-start; border-bottom-left-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1px rgba(28,30,33,.06), 0 6px 16px -12px rgba(28,30,33,.35); }
.cw-msg--me { align-self: flex-end; border-bottom-right-radius: 6px; color: #fff; background: linear-gradient(180deg, var(--blue-2), var(--blue)); }
.cw-msg--note { align-self: stretch; max-width: none; padding: 0 4px; font-size: 13px; color: var(--muted); background: none; box-shadow: none; }
.cw-anim { animation: cw-in .32s var(--ease) both; }
@keyframes cw-in { from { opacity: 0; transform: translateY(8px); } }
.cw-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 14px 16px; border-radius: 18px; border-bottom-left-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1px rgba(28,30,33,.06); }
.cw-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .35; animation: cw-dot 1s infinite; }
.cw-typing i:nth-child(2) { animation-delay: .15s; } .cw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes cw-dot { 40% { opacity: 1; transform: translateY(-2px); } }

/* Итог расчёта — чек с синими цифрами */
.cw-est { align-self: stretch; padding: 16px 18px; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 1px rgba(28,30,33,.07), 0 10px 26px -18px rgba(28,30,33,.45); }
.cw-est__k { font-size: 13px; color: var(--muted); }
.cw-est__v { margin-top: 2px; font-family: var(--font-head); font-size: 28px; font-weight: 600; letter-spacing: -.015em; line-height: 1.1; color: var(--blue); font-variant-numeric: tabular-nums; }
.cw-est__v small { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--muted); }
.cw-est__row { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(28,30,33,.14); font-size: 14px; }
.cw-est__row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cw-est__fine { margin-top: 10px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }

/* Действия: варианты кнопками, поле ввода, контакт */
.cw-act { padding: 10px 16px 16px; border-top: 1px solid var(--line); background: rgba(251,250,246,.6); max-height: 52%; overflow-y: auto; }
.cw-act:empty { display: none; }
.cw-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.cw-opt { min-height: 42px; padding: 8px 16px; border: 0; border-radius: var(--r-pill); cursor: pointer; font: 500 15px/1.25 var(--font); color: var(--ink); text-align: left;
  background: #fff; box-shadow: inset 0 0 0 1px rgba(28,30,33,.1), 0 2px 6px -3px rgba(28,30,33,.2); transition: background .2s, color .2s, box-shadow .2s; }
@media (hover: hover) { .cw-opt:hover { box-shadow: inset 0 0 0 1.5px var(--blue); color: var(--blue); } }
.cw-opt--main { color: #fff; background: linear-gradient(180deg, var(--blue-2), var(--blue)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 8px 18px -8px rgba(48,63,144,.7); }
@media (hover: hover) { .cw-opt--main:hover { color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 8px 18px -8px rgba(48,63,144,.9); } }
.cw-form { display: grid; gap: 10px; }
.cw-row { display: flex; gap: 8px; }
.cw-in { flex: 1; min-width: 0; min-height: 48px; padding: 12px 16px; border: 0; border-radius: var(--r-field); font: 16px/1.3 var(--font); color: var(--ink);
  background: #fff; box-shadow: inset 0 0 0 1px rgba(28,30,33,.14); transition: box-shadow .2s; }
.cw-in:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--blue); }
.cw-in[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px #c4473a; }
textarea.cw-in { min-height: 84px; resize: none; }
.cw-send { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%; cursor: pointer; color: #fff; background: linear-gradient(180deg, var(--blue-2), var(--blue)); }
.cw-send svg { width: 18px; height: 18px; }
.cw-btn { min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--r-pill); cursor: pointer; font: 600 15px/1 var(--font); color: #fff;
  background: linear-gradient(180deg, var(--blue-2), var(--blue)); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 10px 22px -10px rgba(48,63,144,.8); }
.cw-btn:disabled { cursor: progress; opacity: .7; }
.cw-btn--ghost { color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px rgba(28,30,33,.14); }
.cw-err { font-size: 13.5px; line-height: 1.4; color: #b23b2f; }
.cw-err[hidden] { display: none; }
.cw-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--muted); cursor: pointer; }
.cw-check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--blue); }
.cw-check a { color: var(--ink); text-underline-offset: 3px; }
.cw-alt { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
.cw-alt a { display: inline-flex; align-items: center; min-height: 40px; color: var(--blue); font-weight: 500; text-underline-offset: 3px; }
.cw-done { display: grid; gap: 10px; }
.cw-done__t { font-family: var(--font-head); font-size: 20px; font-weight: 600; }
.cw-done p { font-size: 14.5px; color: var(--muted); }

.cw-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: var(--r-pill); font-size: 14.5px; font-weight: 600;
  color: var(--blue); text-decoration: none; background: #fff; box-shadow: inset 0 0 0 1.5px var(--blue); }
.cw-link svg { width: 14px; height: 14px; }
.cw-back-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; margin-top: 8px; padding: 0 10px 0 4px; border: 0; border-radius: var(--r-pill); cursor: pointer;
  font: 500 13.5px/1 var(--font); color: var(--muted); background: transparent; }
@media (hover: hover) { .cw-back-btn:hover { color: var(--ink); background: rgba(28,30,33,.05); } }
.cw-back-btn svg { width: 16px; height: 16px; }
.cw-confirm { font-size: 14.5px; line-height: 1.45; }
.cw-confirm b { font-weight: 600; overflow-wrap: anywhere; }
.cw-opts + .cw-form { margin-top: 10px; }
.cw-act > .cw-err { margin-bottom: 8px; }

.cw-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .cw-panel, .cw-open .cw-panel { transform: none; transition: opacity .01ms; }
  .cw-anim { animation: none; }
  .cw-typing i { animation: none; opacity: .6; }
  .cw-log { scroll-behavior: auto; }
  .cw-fab { transition: none; }
}
@media (prefers-reduced-transparency: reduce) { .cw-panel { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .cw-panel { background: var(--paper); } }
@media print { .cw-fab, .cw-panel, .cw-back { display: none !important; } }
@media (max-width: 760px) { html.cw-open, html.cw-open body { overflow: hidden; } }

.cw-brand { width:36px; height:36px; flex:none; border-radius:10px; }
