/* Публичный чат-консультант schoolvector.ru (спека 2026-11-20, §6.2).
 * Стили автономны (лендинг не подключает style.css), поэтому токены — свои, в .sv-chat,
 * но значения — из палитры сайта (style.css :root): navy #15386C, sky #6AB8E2, gold #EAC858.
 * Шрифт — Jost, грузим сами: SEO-страницы его не подключают, а локально установленная
 * Futura бывает в светлом начертании, и весь чат становится тонким.
 * Слой 900: выше липких шапок (100), ниже модалок сайта (.mo и карточка школы — 1000,
 * форма «Связаться с нами» — 2000). */
@import url('https://fonts.googleapis.com/css2?family=Jost:wght@400;500;600&display=swap');
.sv-chat {
  --svc-navy: #15386C;
  --svc-navy-hover: #0f2a52;
  --svc-sky: #6AB8E2;
  --svc-gold: #EAC858;
  --svc-ink: #111827;
  --svc-ink-2: #374151;
  --svc-muted: #6b7280;          /* 4.8:1 на белом */
  --svc-line: #e5e7eb;
  --svc-line-strong: #d1d5db;
  --svc-surface: #ffffff;
  --svc-canvas: #f6f8fb;
  --svc-tint: #eef3f9;
  --svc-tint-hover: #e1e9f4;
  --svc-ring: 0 0 0 3px rgba(106, 184, 226, .45);
  --svc-ease: cubic-bezier(.16, 1, .3, 1);   /* ease-out-expo, как --ease на сайте */
  --svc-radius: 16px;

  position: fixed; right: 20px; bottom: 20px; z-index: 900;
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--svc-ink);
  -webkit-font-smoothing: antialiased;
}
.sv-chat, .sv-chat *, .sv-chat *::before, .sv-chat *::after { box-sizing: border-box; }
:where(.sv-chat) button { font: inherit; }   /* :where — нулевая специфичность, не перебивает цвета кнопок */
.sv-chat svg { display: block; flex: none; }
.sv-chat [hidden] { display: none !important; }

/* ── Док в углу: [шар · Спросить ИИ] | [отзыв] ────────────── */
.sv-chat-dock {
  display: flex; align-items: center; gap: 2px; height: 56px; padding: 6px;
  border-radius: 999px; background: var(--svc-navy);
  box-shadow: 0 8px 20px -6px rgba(21, 56, 108, .5), 0 2px 4px rgba(21, 56, 108, .2);
}
.sv-chat-launcher {
  display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 4px;
  border: 0; border-radius: 999px; background: transparent; color: #fff; cursor: pointer;
  font-size: 15px; font-weight: 500; letter-spacing: .01em; white-space: nowrap;
  transition: background-color .15s var(--svc-ease);
}
.sv-chat-launcher:hover { background: rgba(255, 255, 255, .09); }
.sv-chat-launcher:active { background: rgba(255, 255, 255, .14); }
.sv-chat-launcher:focus-visible, .sv-chat-dock-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--svc-sky); }
.sv-chat-dock-sep { width: 1px; height: 22px; margin: 0 4px; background: rgba(255, 255, 255, .2); }
.sv-chat-dock-btn {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, .85); cursor: pointer;
  transition: background-color .15s var(--svc-ease), color .15s var(--svc-ease);
}
.sv-chat-dock-btn:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sv-chat-dock-btn:active { background: rgba(255, 255, 255, .14); }
.sv-chat-tip {                                  /* подпись к иконке отзыва — над доком */
  position: absolute; right: -6px; bottom: calc(100% + 14px);
  padding: 7px 11px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  background: var(--svc-ink); color: #fff; font-size: 13px; font-weight: 500; line-height: 1.2;
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .2s var(--svc-ease);
}
.sv-chat-dock-btn:hover .sv-chat-tip, .sv-chat-dock-btn:focus-visible .sv-chat-tip { opacity: 1; transform: none; }

/* ── Шар ИИ: живой перелив цветов логотипа — маркер «отвечает ИИ» ── */
.sv-chat-orb {
  position: relative; width: 36px; height: 36px; flex: none; border-radius: 50%; overflow: hidden; isolation: isolate;
  background: #1f4f8f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28), 0 0 14px rgba(106, 184, 226, .5);
}
.sv-chat-orb::before {
  content: ""; position: absolute; inset: -30%;
  background: conic-gradient(from 0deg, #4fa9e0, #EAC858 16%, #f6dc8a 24%, #6AB8E2 38%, #1d4b8a 56%, #3f8fd0 72%, #9ed6f3 86%, #4fa9e0);
  filter: blur(4px) saturate(1.15); animation: sv-orb-spin 7s linear infinite;
}
.sv-chat-orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .7) 0, rgba(255, 255, 255, 0) 28%),
              radial-gradient(circle at 72% 82%, rgba(21, 56, 108, .45), rgba(21, 56, 108, 0) 58%);
}
.sv-chat-orb-sm { width: 20px; height: 20px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3), 0 0 8px rgba(106, 184, 226, .5); }
.sv-chat-orb-sm::before { filter: blur(3px); }
.sv-chat-orb.is-thinking::before { animation-duration: 1.6s; }
.sv-chat-orb.is-thinking { animation: sv-orb-breathe 1.6s ease-in-out infinite; }

/* ── Панель ─────────────────────────────────────────────────── */
.sv-chat-panel {
  position: absolute; right: 0; bottom: 0;
  width: 392px; height: min(640px, calc(100vh - 40px)); height: min(640px, calc(100dvh - 40px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--svc-surface); border-radius: var(--svc-radius);
  box-shadow: 0 0 0 1px rgba(17, 24, 39, .06), 0 24px 48px -12px rgba(21, 56, 108, .28), 0 4px 8px rgba(17, 24, 39, .05);
  transform-origin: bottom right;
  transition: opacity .2s var(--svc-ease), transform .24s var(--svc-ease);
}
.sv-chat-panel.is-entering, .sv-chat-panel.is-leaving { opacity: 0; transform: translateY(12px) scale(.97); }
.sv-chat-panel.is-leaving { transition-duration: .14s; }

.sv-chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 10px 14px 16px; border-bottom: 1px solid var(--svc-line);
}
.sv-chat-heading { flex: 1; min-width: 0; }
.sv-chat-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.25; color: var(--svc-ink); }
.sv-chat-subtitle { margin: 2px 0 0; font-size: 12.5px; line-height: 1.3; color: var(--svc-muted); }
.sv-chat-icon-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--svc-muted); cursor: pointer;
  transition: background-color .15s var(--svc-ease), color .15s var(--svc-ease);
}
.sv-chat-icon-btn:hover { background: var(--svc-canvas); color: var(--svc-ink); }
.sv-chat-icon-btn:active { background: var(--svc-tint); }
.sv-chat-icon-btn:focus-visible { outline: none; box-shadow: var(--svc-ring); color: var(--svc-ink); }

/* ── Лента ──────────────────────────────────────────────────── */
.sv-chat-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px;
  background: var(--svc-canvas); scroll-behavior: smooth;
}
.sv-chat-row { display: flex; flex-direction: column; animation: sv-chat-in .22s var(--svc-ease) both; }
.sv-chat-row-user { align-self: flex-end; align-items: flex-end; max-width: 82%; }
.sv-chat-row-assistant { align-self: flex-start; align-items: flex-start; max-width: 94%; }
.sv-chat-bubble { padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; }
.sv-chat-row-user .sv-chat-bubble { background: var(--svc-navy); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.sv-chat-row-assistant .sv-chat-bubble {
  background: var(--svc-surface); color: var(--svc-ink); border: 1px solid var(--svc-line);
  border-bottom-left-radius: 6px;
}

/* Текст ответа: абзацы, списки, жирный, ссылки */
.sv-chat-bubble p { margin: 0; }
.sv-chat-bubble p + p, .sv-chat-bubble p + ul, .sv-chat-bubble p + ol,
.sv-chat-bubble ul + p, .sv-chat-bubble ol + p { margin-top: 8px; }
.sv-chat-bubble ul, .sv-chat-bubble ol { margin: 4px 0 0; padding-left: 20px; }
.sv-chat-bubble li + li { margin-top: 3px; }
.sv-chat-bubble li::marker { color: var(--svc-muted); }
.sv-chat-bubble strong { font-weight: 600; }
.sv-chat-bubble a { color: var(--svc-navy); text-decoration: underline; text-decoration-color: rgba(21, 56, 108, .35); text-underline-offset: 2px; }
.sv-chat-bubble a:hover { text-decoration-color: currentColor; }
.sv-chat-bubble a.sv-chat-chip { text-decoration: none; }

/* Источники и действия */
.sv-chat-sources { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--svc-line); }
.sv-chat-sources-label { margin: 0 0 6px; font-size: 12px; color: var(--svc-muted); }
.sv-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sv-chat-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  min-height: 30px; padding: 5px 10px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--svc-tint); color: var(--svc-navy);
  font-size: 13px; font-weight: 500; line-height: 1.3; text-decoration: none; text-align: left;
  transition: background-color .15s var(--svc-ease);
}
.sv-chat-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-chat-chip:hover { background: var(--svc-tint-hover); }
.sv-chat-chip:focus-visible { outline: none; box-shadow: var(--svc-ring); }
.sv-chat-chip svg { opacity: .7; }
.sv-chat-actions { margin-top: 10px; }

/* Сообщение о сбое / лимите */
.sv-chat-row-notice .sv-chat-bubble { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.sv-chat-row-notice .sv-chat-chip { background: #fef3c7; color: #78350f; }
.sv-chat-row-notice .sv-chat-chip:hover { background: #fde68a; }

/* «Печатает»: три точки + пояснение, если ответ идёт долго */
.sv-chat-typing .sv-chat-bubble { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.sv-chat-typing-text { font-size: 13.5px; color: var(--svc-muted); }

/* Пустое состояние: приветствие + примеры вопросов */
.sv-chat-welcome { padding: 6px 2px 4px; }
.sv-chat-welcome-title { margin: 0 0 6px; font-size: 17px; font-weight: 600; line-height: 1.3; color: var(--svc-ink); text-wrap: balance; }
.sv-chat-welcome-text { margin: 0 0 16px; color: var(--svc-ink-2); text-wrap: pretty; }
.sv-chat-suggest { display: flex; flex-direction: column; gap: 8px; }
.sv-chat-suggest button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  min-height: 44px; padding: 10px 14px; border: 1px solid var(--svc-line); border-radius: 12px; cursor: pointer;
  background: var(--svc-surface); color: var(--svc-ink); text-align: left; font-size: 14.5px; line-height: 1.35;
  transition: border-color .15s var(--svc-ease), background-color .15s var(--svc-ease);
}
.sv-chat-suggest button svg { color: var(--svc-muted); transition: transform .2s var(--svc-ease), color .15s; }
.sv-chat-suggest button:hover { border-color: var(--svc-sky); background: #fbfdff; }
.sv-chat-suggest button:hover svg { color: var(--svc-navy); transform: translateX(2px); }
.sv-chat-suggest button:focus-visible { outline: none; border-color: var(--svc-sky); box-shadow: var(--svc-ring); }

/* ── Поле ввода ─────────────────────────────────────────────── */
.sv-chat-form { padding: 12px 12px 10px; background: var(--svc-surface); border-top: 1px solid var(--svc-line); }
.sv-chat-field {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px;
  border: 1px solid var(--svc-line-strong); border-radius: 14px; background: var(--svc-surface);
  transition: border-color .15s var(--svc-ease), box-shadow .15s var(--svc-ease);
}
.sv-chat-field:focus-within { border-color: var(--svc-sky); box-shadow: var(--svc-ring); }
.sv-chat-input {
  flex: 1; min-width: 0; max-height: 132px; margin: 0; padding: 7px 0; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--svc-ink); font: inherit; font-size: 15px; line-height: 1.45;
}
.sv-chat-input::placeholder { color: var(--svc-muted); opacity: 1; }
.sv-chat-send {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 10px; cursor: pointer; background: var(--svc-navy); color: #fff;
  transition: background-color .15s var(--svc-ease), transform .15s var(--svc-ease), opacity .15s;
}
.sv-chat-send:hover { background: var(--svc-navy-hover); }
.sv-chat-send:active { transform: scale(.94); }
.sv-chat-send:focus-visible { outline: none; box-shadow: var(--svc-ring); }
.sv-chat-send:disabled { background: var(--svc-line); color: #9ca3af; cursor: default; transform: none; }
.sv-chat-foot { display: flex; justify-content: space-between; gap: 12px; margin: 8px 4px 0; font-size: 11.5px; line-height: 1.35; color: var(--svc-muted); }
.sv-chat-count { flex: none; font-variant-numeric: tabular-nums; }
.sv-chat-count.is-over { color: #b45309; }

.sv-chat-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@keyframes sv-chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sv-orb-spin { to { transform: rotate(360deg); } }
@keyframes sv-orb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ── Телефон: панель на весь экран ──────────────────────────── */
@media (max-width: 640px) {
  .sv-chat { right: 16px; bottom: 16px; }
  .sv-chat-dock { height: 54px; padding: 5px; }
  .sv-chat-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; box-shadow: none; }
  .sv-chat-panel.is-entering, .sv-chat-panel.is-leaving { transform: translateY(24px); }
  .sv-chat-header { padding-top: max(14px, env(safe-area-inset-top)); }
  .sv-chat-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .sv-chat-input { font-size: 16px; }          /* iOS не зумит поле */
  .sv-chat-row-assistant { max-width: 100%; }
}
@media (hover: none) { .sv-chat-tip { display: none; } }
@media (pointer: coarse) {
  .sv-chat-icon-btn { width: 44px; height: 44px; }
  .sv-chat-send { width: 40px; height: 40px; }
  .sv-chat-chip { min-height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .sv-chat-panel, .sv-chat-suggest button svg, .sv-chat-tip { transition: opacity .15s linear; }
  .sv-chat-tip { transform: none; }
  .sv-chat-orb, .sv-chat-orb::before { animation: none !important; }   /* шар статичный: перелив остаётся, движения нет */
  .sv-chat-panel.is-entering, .sv-chat-panel.is-leaving { transform: none; }
  .sv-chat-row { animation: none; }
  .sv-chat-log { scroll-behavior: auto; }
}
