/* Чат-виджет: кнопка справа снизу + окошко. Только токены. */
.cw { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3); }
.cw[hidden] { display: none; }
.cw-fab { position: relative; display: inline-flex; align-items: center; gap: 10px; height: 58px; padding: 0 22px 0 18px; border: 0; border-radius: var(--radius-pill); background: linear-gradient(135deg, var(--ink-2), var(--ink)); color: #fff; font: 700 16px var(--font-sans); cursor: pointer; box-shadow: 0 16px 34px -12px rgba(var(--shadow-tint), .75), inset 0 1px 0 rgba(255, 255, 255, .12); transition: transform var(--dur-base) var(--ease-standard), box-shadow var(--dur-base) var(--ease-standard); }
.cw-fab:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -12px rgba(var(--shadow-tint), .85), inset 0 1px 0 rgba(255, 255, 255, .12); }
.cw-fab:active { transform: translateY(0); }
.cw.is-open .cw-fab-label { display: none; }
.cw.is-open .cw-fab { padding: 0 17px; }

.cw-hint { display: flex; align-items: stretch; margin: 0; background: var(--surface-card); border-radius: 18px 18px 6px 18px; box-shadow: 0 16px 36px -14px rgba(var(--shadow-tint), .6), 0 0 0 1px var(--line); animation: cw-in var(--dur-base) var(--ease-standard); }
.cw-hint[hidden] { display: none; }
.cw-hint-text { border: 0; background: none; font: 600 15.5px var(--font-sans); color: var(--ink); padding: 14px 6px 14px 16px; text-align: left; cursor: pointer; }
.cw-wave { display: inline-block; transform-origin: 70% 70%; animation: cw-wave 2.2s ease-in-out 1s 2; }
.cw-hint-x { border: 0; background: none; color: var(--ink-3); padding: 0 12px; cursor: pointer; }

.cw-panel { position: relative; width: min(390px, calc(100vw - 2 * var(--space-4))); height: min(600px, calc(100svh - 110px)); display: flex; flex-direction: column; background: var(--surface-card); border-radius: 22px; box-shadow: 0 34px 80px -22px rgba(var(--shadow-tint), .65), 0 0 0 1px var(--line); overflow: hidden; animation: cw-in var(--dur-base) var(--ease-standard); transform-origin: bottom right; }
.cw-panel[hidden] { display: none; }
.cw-panel.is-drop::after { content: 'Отпустите, чтобы приложить фото'; position: absolute; inset: 8px; border: 2px dashed var(--ink-3); border-radius: 16px; background: rgba(255, 255, 255, .9); display: grid; place-items: center; font: 600 15px var(--font-sans); color: var(--ink); pointer-events: none; }

.cw-head { display: flex; align-items: center; gap: 12px; padding: 16px 12px 16px 16px; background: linear-gradient(135deg, var(--ink-2), var(--ink)); color: #fff; }
.cw-ava { position: relative; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .14); display: grid; place-items: center; }
.cw-dot { position: absolute; right: 0; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 2px var(--ink); }
.cw-title { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.cw-title b { font-size: 16.5px; }
.cw-title span { font-size: 12.5px; color: rgba(255, 255, 255, .72); }
.cw-close { border: 0; background: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; transition: background var(--dur-base) var(--ease-standard); }
.cw-close:hover { background: rgba(255, 255, 255, .14); }

.cw-log { flex: 1; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-sheet); overscroll-behavior: contain; scrollbar-width: thin; }
.cw-msg { max-width: 82%; padding: 9px 13px 7px; border-radius: 18px; font-size: 15px; line-height: 1.42; animation: cw-msg var(--dur-base) var(--ease-standard); }
.cw-msg p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.cw-msg time { display: block; text-align: right; font: 500 11px var(--font-mono); opacity: .55; margin-top: 2px; }
.cw-msg.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.cw-msg.bot { align-self: flex-start; background: var(--surface-card); box-shadow: 0 1px 2px rgba(var(--shadow-tint), .16), 0 0 0 1px var(--line); border-bottom-left-radius: 6px; }
.cw-msg + .cw-msg.me:not(.cw-typing), .cw-msg.bot + .cw-msg.bot { margin-top: -2px; }
.cw-msg.has-img { padding: 4px 4px 6px; }
.cw-msg.has-img p { padding: 6px 9px 0; }
.cw-msg.has-img time { padding: 0 8px; }
.cw-img { display: block; border-radius: 14px; overflow: hidden; }
.cw-img img { display: block; width: 100%; max-width: 260px; max-height: 280px; object-fit: cover; }

.cw-typing { display: flex; gap: 4px; padding: 12px 14px; }
.cw-typing span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; animation: cw-dots 1s infinite ease-in-out; }
.cw-typing span:nth-child(2) { animation-delay: .15s; }
.cw-typing span:nth-child(3) { animation-delay: .3s; }

.cw-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; background: var(--surface-card); }
.cw-quick[hidden] { display: none; }
.cw-quick button { border: 1px solid var(--line-strong); background: var(--surface-card); border-radius: var(--radius-pill); padding: 7px 13px; font: 600 13.5px var(--font-sans); color: var(--ink); cursor: pointer; transition: background var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard); }
.cw-quick button:hover { background: var(--surface-plaque); border-color: var(--ink-3); }

.cw-form { display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--surface-card); }
.cw-quick:not([hidden]) + .cw-form { border-top: 0; }
.cw-email-wrap { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--surface-sheet); color: var(--ink-3); transition: box-shadow var(--dur-base) var(--ease-standard); }
.cw-email-wrap[hidden] { display: none; }
.cw-email-wrap:focus-within { box-shadow: 0 0 0 2px var(--ink); color: var(--ink); }
.cw-email { flex: 1; min-width: 0; height: 100%; border: 0; background: none; font: 400 14.5px var(--font-sans); color: var(--ink); }
.cw-email:focus { outline: none; }

.cw-preview { position: relative; justify-self: start; }
.cw-preview[hidden] { display: none; }
.cw-preview img { display: block; height: 72px; max-width: 160px; object-fit: cover; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.cw-preview-x { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border: 2px solid var(--surface-card); border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }

.cw-row { display: flex; gap: 6px; align-items: flex-end; padding: 4px; border-radius: 24px; background: var(--surface-sheet); transition: box-shadow var(--dur-base) var(--ease-standard); }
.cw-row:focus-within { box-shadow: 0 0 0 2px var(--ink); }
.cw-attach { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); cursor: pointer; transition: background var(--dur-base) var(--ease-standard), color var(--dur-base) var(--ease-standard); }
.cw-attach:hover { background: var(--surface-plaque); color: var(--ink); }
.cw-form textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 120px; resize: none; border: 0; padding: 9px 4px; font: 400 16px/1.35 var(--font-sans); background: none; color: var(--ink); }
.cw-form textarea:focus { outline: none; }
.cw-send { flex: 0 0 40px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--action); color: var(--action-fg); display: grid; place-items: center; cursor: pointer; transition: background var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-standard); }
.cw-send:hover { background: var(--action-hover); transform: scale(1.05); }
.cw-send:disabled { opacity: .6; cursor: default; transform: none; }

@keyframes cw-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes cw-msg { from { opacity: 0; transform: translateY(6px); } }
@keyframes cw-dots { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-4px); opacity: .9; } }
@keyframes cw-wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } }

/* Не перекрываем куки и нижнее поле поиска на телефоне */
@media (max-width: 699px) {
  body:has([data-cookie]:not([hidden])) .cw { bottom: 190px; }
  body:has(.dock.is-shown) .cw { bottom: 92px; }
  .cw-fab-label { display: none; }
  .cw-fab { padding: 0 17px; }
}
@media (prefers-reduced-motion: reduce) { .cw-hint, .cw-panel, .cw-msg, .cw-wave, .cw-typing span { animation: none; } .cw-fab, .cw-send { transition: none; } }

/* Кнопка-ссылка «Написать в чат» внутри страниц */
button.dc-contact { font: inherit; text-align: left; width: 100%; cursor: pointer; }
button[data-chat-open].link-btn { font: inherit; }
