/* Виджет Терентия, вариант B «тихий минимализм» (выбор Любови 08.09.2026).
   Цвета и шрифт с podokonniki-online.ru: текст #221f1c, тёмно-бирюзовый #326276, акцент #2bb3c0,
   светлая подложка #dae6eb / #f4f6f7, шрифт Circe (на сайте подключён), запасной Arial. */
.terentiy-widget { --tw-ink: #221f1c; --tw-teal: #326276; --tw-cyan: #2bb3c0; --tw-mist: #f4f6f7; --tw-line: #e6ebee; --tw-muted: #8a8a8a;
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 2147483000;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; font: 15px/1.45 Circe, Arial, sans-serif; color: var(--tw-ink); }
.terentiy-widget, .terentiy-widget * { box-sizing: border-box; }
.terentiy-widget button, .terentiy-widget textarea, .terentiy-widget input { font: inherit; }
.terentiy-widget [hidden] { display: none !important; }

/* Тихая подсказка: кликабельный бабл рядом с кружком, без всплывающих окон */
.terentiy-widget__nudge { max-width: 280px; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; background: #fff;
  border: 1px solid var(--tw-line); border-radius: 12px; box-shadow: 0 8px 24px rgba(34, 31, 28, .10); font-size: 14px; line-height: 1.35; cursor: pointer;
  animation: terentiy-rise .35s ease-out; }
.terentiy-widget__nudge:hover { border-color: var(--tw-cyan); }
.terentiy-widget__nudge:focus-visible { outline: 2px solid var(--tw-cyan); outline-offset: 2px; }
.terentiy-widget__nudge-close { width: 24px; height: 24px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--tw-muted);
  background: transparent; border: 0; border-radius: 50%; cursor: pointer; }
.terentiy-widget__nudge-close:hover { color: var(--tw-ink); background: var(--tw-mist); }

/* Кружок с портретом Терентия */
.terentiy-widget__launcher { position: relative; width: 64px; height: 64px; padding: 0; background: transparent; border: 0; border-radius: 50%; cursor: pointer;
  box-shadow: 0 10px 28px rgba(34, 31, 28, .18); transition: transform .15s ease; }
.terentiy-widget__launcher:hover { transform: translateY(-2px); }
.terentiy-widget__launcher:focus-visible { outline: 2px solid var(--tw-cyan); outline-offset: 3px; }
.terentiy-widget__launcher img { width: 64px; height: 64px; object-fit: cover; object-position: 38% 13%; border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--tw-cyan); }
.terentiy-widget__badge { position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--tw-teal); border: 2px solid #fff; border-radius: 50%; }

/* Панель чата: белая, лёгкая, без тяжёлой шапки */
.terentiy-widget__panel { width: min(360px, calc(100vw - 24px)); height: min(600px, calc(100dvh - 24px)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto auto auto;
  background: #fff; border: 1px solid var(--tw-line); border-radius: 16px; box-shadow: 0 14px 40px rgba(34, 31, 28, .14); overflow: hidden; }
.terentiy-widget__header { display: grid; grid-template-columns: 40px minmax(0, 1fr) 30px 30px; gap: 10px; align-items: center; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--tw-line); }
.terentiy-widget__header img { width: 40px; height: 40px; object-fit: cover; object-position: 38% 13%; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tw-cyan); }
.terentiy-widget__header span { min-width: 0; display: grid; gap: 1px; }
.terentiy-widget__header b { font-size: 15px; }
.terentiy-widget__header small { overflow: hidden; color: var(--tw-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.terentiy-widget__close, .terentiy-widget__reset { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--tw-muted);
  background: transparent; border: 0; border-radius: 50%; cursor: pointer; }
.terentiy-widget__close:hover, .terentiy-widget__reset:hover { color: var(--tw-teal); background: var(--tw-mist); }

.terentiy-widget__messages { min-height: 0; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.terentiy-widget__message { max-width: 90%; font-size: 14px; line-height: 1.45; }
.terentiy-widget__message--assistant, .terentiy-widget__message--manager { align-self: flex-start; }
.terentiy-widget__message--user { max-width: 86%; align-self: flex-end; padding: 9px 12px; background: #eaf7f8; border-radius: 14px 14px 4px 14px; }
.terentiy-widget__message b { display: block; margin-bottom: 2px; color: var(--tw-muted); font-size: 10px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.terentiy-widget__message--user b { display: none; }
.terentiy-widget__message--manager b { color: var(--tw-teal); }
.terentiy-widget__message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.terentiy-widget__message a { color: var(--tw-teal); font-weight: 700; text-decoration: underline; text-decoration-color: var(--tw-cyan); text-underline-offset: 2px; }
.terentiy-widget__message a:hover { color: var(--tw-cyan); }

.terentiy-widget__typing { min-height: 26px; padding: 0 16px 8px; align-items: center; gap: 4px; color: var(--tw-muted); font-size: 11px; }
.terentiy-widget__typing:not([hidden]) { display: flex; }
.terentiy-widget__typing i { width: 5px; height: 5px; background: var(--tw-cyan); border-radius: 50%; animation: terentiy-pulse 1s infinite alternate; }
.terentiy-widget__typing i:nth-child(2) { animation-delay: .18s; }
.terentiy-widget__typing i:nth-child(3) { animation-delay: .36s; }
.terentiy-widget__typing span { margin-left: 4px; }
.terentiy-widget__contact { display: grid; gap: 8px; padding: 12px 16px; background: var(--tw-mist); border-top: 1px solid var(--tw-line); }
.terentiy-widget__contact:not([hidden]) { display: grid; }
.terentiy-widget__contact b { font-size: 13px; }
.terentiy-widget__contact input { height: 38px; padding: 0 12px; color: var(--tw-ink); background: #fff; border: 1px solid var(--tw-line); border-radius: 8px; outline: none; }
.terentiy-widget__contact input:focus { border-color: var(--tw-cyan); }
.terentiy-widget__contact button { height: 38px; color: #fff; background: var(--tw-teal); border: 0; border-radius: 8px; font-weight: 700; cursor: pointer; }
.terentiy-widget__contact button:disabled { opacity: .5; }
.terentiy-widget__contact-error { color: #b8232b; font-size: 12px; }
.terentiy-widget__handoff { padding: 8px 16px; color: var(--tw-teal); background: #eaf7f8; border-top: 1px solid var(--tw-line); font-size: 12px; }

.terentiy-widget__consent { padding: 10px 16px 4px; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; color: #5d6963; border-top: 1px solid var(--tw-line); font-size: 11px; line-height: 1.35; cursor: pointer; }
.terentiy-widget__consent input { margin: 2px 0 0; accent-color: var(--tw-cyan); }
.terentiy-widget__consent a { color: var(--tw-teal); }

.terentiy-widget__form { padding: 8px 12px 6px 16px; display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 8px; align-items: end; }
.terentiy-widget__form textarea { width: 100%; min-height: 36px; max-height: 104px; padding: 8px 0; resize: none; color: var(--tw-ink); background: transparent; border: 0; border-bottom: 1px solid var(--tw-line); border-radius: 0; outline: none; }
.terentiy-widget__form textarea::placeholder { color: var(--tw-muted); }
.terentiy-widget__form textarea:focus { border-bottom-color: var(--tw-cyan); }
.terentiy-widget__form button { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; padding: 0; color: #fff; background: var(--tw-cyan); border: 0; border-radius: 50%; cursor: pointer; }
.terentiy-widget__form button:hover { background: var(--tw-teal); }
.terentiy-widget__form button:disabled, .terentiy-widget__form textarea:disabled { opacity: .45; cursor: not-allowed; }
.terentiy-widget__note { padding: 0 16px 10px; color: var(--tw-muted); font-size: 10px; }

@keyframes terentiy-pulse { to { opacity: .25; transform: translateY(-2px); } }
@keyframes terentiy-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 520px) {
  .terentiy-widget { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; }
  .terentiy-widget__nudge { max-width: none; }
  .terentiy-widget__launcher { width: 58px; height: 58px; margin-left: auto; }
  .terentiy-widget__launcher img { width: 58px; height: 58px; }
  .terentiy-widget__panel { width: 100%; height: min(600px, calc(100dvh - 24px)); }
}
@media (prefers-reduced-motion: reduce) { .terentiy-widget__typing i, .terentiy-widget__nudge { animation: none; } .terentiy-widget__launcher { transition: none; } }
