/* fundament3 (09.09.2026, ночь): кружок связи справа снизу и чат школы — плавающее окно в духе мессенджера,
   без «ИИшных» градиентов и искр. Кружок: тёмный диск с латунным кольцом и знаком Φ; по нажатию — четыре пузырька
   (MAX, Telegram, VK, чат). Чат: окно 400×620 над кружком; на телефоне — шторка. Токены цвета — из style.css. */

/* ── кружок ── */
.fd-assist { position: fixed; right: 22px; bottom: 22px; z-index: 50; }
.fd-assist__fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #141b2b;
  color: var(--color-white);
  box-shadow: 0 16px 36px rgba(4, 7, 14, 0.55), inset 0 1px 0 rgba(250, 251, 254, 0.08);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
}
.fd-assist__fab:hover { transform: translateY(-2px); box-shadow: 0 20px 42px rgba(4, 7, 14, 0.6); }
.fd-assist__fab:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; }
.fd-assist__ring { position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid var(--color-accent); opacity: 0.85; transition: opacity 0.3s ease; }
.fd-assist__glyph {
  font-family: 'FD-B', 'Bounded', sans-serif;
  font-weight: 800;
  font-size: 29px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--color-white);
  transform: translateY(1px);
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.fd-assist__x { position: absolute; display: grid; place-items: center; opacity: 0; transform: rotate(-90deg) scale(0.5); transition: transform 0.3s ease, opacity 0.2s ease; }
.fd-assist__x svg { width: 22px; height: 22px; }
.fd-assist.is-open .fd-assist__glyph { opacity: 0; transform: scale(0.5); }
.fd-assist.is-open .fd-assist__ring { opacity: 0; }
.fd-assist.is-open .fd-assist__x { opacity: 1; transform: none; }
@keyframes fdPulse { 0% { box-shadow: 0 16px 36px rgba(4, 7, 14, 0.55), 0 0 0 0 rgba(245, 192, 74, 0.35); } 100% { box-shadow: 0 16px 36px rgba(4, 7, 14, 0.55), 0 0 0 20px rgba(245, 192, 74, 0); } }
.fd-assist:not(.is-open):not(.is-seen) .fd-assist__fab { animation: fdPulse 2.6s ease-out 3; }

/* пузырьки */
.fd-assist__menu { position: absolute; right: 4px; bottom: 78px; margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; pointer-events: none; }
.fd-assist.is-open .fd-assist__menu { pointer-events: auto; }
.fd-assist__menu li { display: flex; align-items: center; justify-content: flex-end; gap: 12px; opacity: 0; transform: translateY(14px) scale(0.92); transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); pointer-events: none; }
.fd-assist.is-open .fd-assist__menu li { opacity: 1; transform: none; pointer-events: auto; }
.fd-assist.is-open .fd-assist__menu li:nth-child(1) { transition-delay: 0.18s; }
.fd-assist.is-open .fd-assist__menu li:nth-child(2) { transition-delay: 0.13s; }
.fd-assist.is-open .fd-assist__menu li:nth-child(3) { transition-delay: 0.08s; }
.fd-assist.is-open .fd-assist__menu li:nth-child(4) { transition-delay: 0.03s; }
.fd-assist__label {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 20, 31, 0.94);
  border: 1px solid rgba(250, 251, 254, 0.12);
  box-shadow: 0 10px 26px rgba(4, 7, 14, 0.4);
  font-size: 13px;
  line-height: 18px;
  color: var(--color-light);
  white-space: nowrap;
}
.fd-assist__label--ai { color: var(--color-white); border-color: rgba(245, 192, 74, 0.45); }
.fd-assist__item {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(250, 251, 254, 0.12);
  border-radius: 50%;
  background: #141b2b;
  color: var(--color-white);
  text-decoration: none;
  box-shadow: 0 12px 30px rgba(4, 7, 14, 0.5);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.fd-assist__item:hover { transform: translateY(-3px); border-color: rgba(250, 251, 254, 0.35); }
.fd-assist__item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.fd-assist__item svg { width: 26px; height: 26px; }
.fd-assist__item--ai { background: var(--color-accent); color: var(--color-black); border-color: transparent; }
.fd-assist__item--tg { color: #69b8f2; }
.fd-assist__item--vk { color: #6f9cff; }
.fd-assist__maxlogo { display: block; width: 28px; height: 28px; background: linear-gradient(135deg, #3B9CFF 0%, #8E44F5 100%); -webkit-mask: url(/tpl/img/max-logo.png) center / contain no-repeat; mask: url(/tpl/img/max-logo.png) center / contain no-repeat; }   /* логотип MAX — картинка владельца */
.fd-assist__item[aria-disabled="true"] { opacity: 0.5; cursor: default; }

/* ── чат: окно мессенджера ── */
.fd-chat { display: none; }
.fd-chat.is-open { display: block; }
.fd-chat__back { display: none; }
.fd-chat__panel {
  position: fixed;
  right: 22px;
  bottom: 98px;
  z-index: 60;
  width: min(400px, calc(100vw - 44px));
  height: min(620px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: var(--color-black);
  border: 1px solid rgba(250, 251, 254, 0.12);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(4, 7, 14, 0.65);
  overflow: hidden;
  transform-origin: 100% 100%;
  animation: fdChatIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes fdChatIn { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
.fd-chat__head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: var(--color-dark); border-bottom: 1px solid rgba(250, 251, 254, 0.08); }
.fd-chat__avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-black);
  border: 1.5px solid var(--color-accent);
  color: var(--color-white);
  font-family: 'FD-B', 'Bounded', sans-serif;
  font-weight: 800;
  font-size: 19px;
  line-height: 1;
}
.fd-chat__who { min-width: 0; }
.fd-chat__title { display: block; font-size: 15px; line-height: 20px; font-weight: 600; color: var(--color-white); }
.fd-chat__sub { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--color-grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-chat__dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #4ad38a; }
.fd-chat__close { margin-left: auto; flex: 0 0 auto; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--color-grey); cursor: pointer; display: grid; place-items: center; transition: background-color 0.2s ease, color 0.2s ease; }
.fd-chat__close:hover { color: var(--color-white); background: rgba(250, 251, 254, 0.08); }
.fd-chat__close svg { width: 14px; height: 14px; }

.fd-chat__log { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--color-border) transparent; }
.fd-chat__msg {
  position: relative;
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 20px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: fdMsgIn 0.25s ease;
}
@keyframes fdMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fd-chat__msg--bot { align-self: flex-start; background: var(--color-dark); color: var(--color-white); border-bottom-left-radius: 5px; }
.fd-chat__msg.is-streaming::after { content: ""; display: inline-block; width: 6px; height: 14px; margin-left: 3px; vertical-align: -2px; background: var(--color-accent); animation: fdCaret 0.9s steps(2) infinite; }
@keyframes fdCaret { 50% { opacity: 0; } }
.fd-chat__msg--user { align-self: flex-end; background: rgba(245, 192, 74, 0.16); color: var(--color-white); border-bottom-right-radius: 5px; }
.fd-chat__msg--err { align-self: flex-start; background: rgba(224, 82, 82, 0.12); color: var(--color-light); }
.fd-chat__msg b { font-weight: 600; color: var(--color-white); }
.fd-chat__msg a { color: var(--color-accent); text-decoration: underline; text-underline-offset: 2px; }
.fd-chat__time { display: block; margin-top: 3px; font-size: 10px; line-height: 12px; color: var(--color-grey); text-align: right; opacity: 0.8; }
.fd-chat__typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 12px 14px; border-radius: 16px; border-bottom-left-radius: 5px; background: var(--color-dark); }
.fd-chat__typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--color-grey); animation: fdDot 1.1s ease-in-out infinite; }
.fd-chat__typing i:nth-child(2) { animation-delay: 0.15s; }
.fd-chat__typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes fdDot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

.fd-chat__hints[hidden] { display: none; }
.fd-chat__hints { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 14px 10px; }
.fd-chat__hints-label { flex-basis: 100%; font-size: 12px; color: var(--color-grey); margin-bottom: 2px; }
.fd-chat__hints button { padding: 6px 11px; border: 1px solid rgba(250, 251, 254, 0.14); border-radius: 999px; background: transparent; color: var(--color-light); font: inherit; font-size: 12.5px; cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease; }
.fd-chat__hints button:hover { color: var(--color-white); border-color: rgba(250, 251, 254, 0.4); }
.fd-chat__form { padding: 10px 12px; border-top: 1px solid rgba(250, 251, 254, 0.08); background: var(--color-black); }
.fd-chat__field { display: flex; align-items: flex-end; gap: 6px; padding: 4px 4px 4px 14px; border: 1px solid var(--color-border); border-radius: 22px; background: var(--color-dark); transition: border-color 0.2s ease; }
.fd-chat__field:focus-within { border-color: rgba(250, 251, 254, 0.4); }
.fd-chat__input { flex: 1 1 auto; min-height: 34px; max-height: 120px; padding: 7px 0; border: 0; background: transparent; color: var(--color-white); font: inherit; font-size: 14px; line-height: 20px; resize: none; }
.fd-chat__input:focus { outline: none; }
.fd-chat__input::placeholder { color: var(--color-grey); }
.fd-chat__send { flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--color-accent); color: var(--color-black); cursor: pointer; display: grid; place-items: center; transition: opacity 0.2s ease; }
.fd-chat__send[disabled] { opacity: 0.45; cursor: default; }
.fd-chat__send svg { width: 17px; height: 17px; }
.fd-chat__note { padding: 0 16px 10px; font-size: 11px; line-height: 15px; color: var(--color-grey); background: var(--color-black); }
.fd-chat__note a { color: var(--color-light); }

@media (max-width: 900px) {
  .fd-chat__back { display: block; position: fixed; inset: 0; z-index: 59; background: rgba(6, 9, 16, 0.55); animation: fdFadeIn 0.3s ease; }
  .fd-chat__panel { right: 0; bottom: 0; left: 0; width: auto; height: 90vh; height: 90dvh; border-radius: 18px 18px 0 0; border-left: 0; border-right: 0; border-bottom: 0; animation: fdSheetIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
  body.fd-assist-open { overflow: hidden; }
  body.fd-assist-open .fd-assist { display: none; }
  .fd-assist { right: 16px; bottom: 16px; }
  .fd-assist__fab { width: 56px; height: 56px; }
  .fd-assist__glyph { font-size: 26px; }
  .fd-assist__menu { bottom: 72px; }
}
@keyframes fdSheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fdFadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .fd-assist__fab, .fd-assist__menu li, .fd-chat__back, .fd-chat__panel, .fd-chat__msg { animation: none; transition: none; }
}
