/* Окно чата «Подмостка»: тёмная сцена с тёплым светом рампы сверху, сообщения — «реплики» */
.ai-modal {
  position: fixed; inset: 0; z-index: 110; display: flex; align-items: flex-end; justify-content: flex-end; padding: 20px;
  background: rgba(5, 5, 7, 0.5); opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease-out);
}
.ai-modal.is-open { opacity: 1; pointer-events: auto; }
.ai-panel {
  position: relative; width: min(420px, 100%); height: min(660px, calc(100dvh - 40px)); display: flex; flex-direction: column;
  background: radial-gradient(130% 55% at 50% -12%, rgba(239, 125, 0, 0.32) 0%, rgba(239, 125, 0, 0.06) 45%, transparent 70%), #121214;
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 28px; overflow: hidden;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6); transform: translateY(18px) scale(0.96); transform-origin: bottom right; transition: transform 320ms var(--ease-spring);
}
.ai-modal.is-open .ai-panel { transform: none; }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 18px 16px 14px 18px; }
.ai-head .ai-ava { width: 46px; height: 46px; }
.ai-head .ai-ava svg { width: 34px; height: 34px; }
.ai-who { flex: 1; min-width: 0; }
.ai-who h2 { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.ai-who p { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 0.8125rem; color: rgba(255, 255, 255, 0.6); }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; background: #62ff00; box-shadow: 0 0 0 3px rgba(98, 255, 0, 0.18); }
.ai-close { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); color: #fff; border: 0; cursor: pointer; transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out); }
.ai-close:active { transform: scale(0.92); }
@media (hover: hover) and (pointer: fine) { .ai-close:hover { background: rgba(255, 255, 255, 0.16); } }

.ai-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
.ai-msg { max-width: 86%; padding: 11px 15px; font-size: 0.9375rem; line-height: 1.45; overflow-wrap: anywhere; animation: ai-msg-in 320ms var(--ease-spring) both; }
@keyframes ai-msg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.ai-msg p + p { margin-top: 8px; }
.ai-assistant { align-self: flex-start; background: #232327; border-radius: 20px 20px 20px 6px; }
.ai-user { align-self: flex-end; background: var(--c-orange); color: #0a0a0a; font-weight: 500; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; transform-origin: bottom right; }
.ai-assistant a { color: #ffb066; font-weight: 500; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.ai-assistant strong { color: #fff; font-weight: 700; }
.ai-msg.is-error { background: rgba(255, 107, 91, 0.14); color: #ffbdb3; }
.ai-msg.is-typing { display: inline-flex; gap: 5px; padding: 15px 17px; }
.ai-msg.is-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--c-orange); animation: ai-dot 1s infinite ease-in-out; }
.ai-msg.is-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-msg.is-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.ai-suggest { padding: 0 16px 12px; flex-direction: row; flex-wrap: wrap; }
.ai-suggest:empty { display: none; }
.ai-suggest .ai-chip { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: var(--r-pill); padding: 8px 14px; animation: ai-chip-in 360ms var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 60ms); }
@media (hover: hover) and (pointer: fine) { .ai-suggest .ai-chip:hover { background: var(--c-orange); border-color: var(--c-orange); color: #0a0a0a; } }

.ai-form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px; padding: 6px 6px 6px 16px; border-radius: 24px; background: #1d1d20; border: 1px solid rgba(255, 255, 255, 0.12); transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out); }
.ai-form:focus-within { border-color: var(--c-orange); box-shadow: 0 0 0 4px rgba(239, 125, 0, 0.16); }
.ai-form textarea { flex: 1; resize: none; max-height: 120px; padding: 9px 0; background: none; border: 0; outline: none; color: #fff; font: inherit; font-size: 0.9375rem; line-height: 1.4; }
.ai-form textarea::placeholder { color: rgba(255, 255, 255, 0.42); }
.ai-send { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--c-orange); color: #0a0a0a; border: 0; cursor: pointer; transition: transform 150ms var(--ease-out), opacity 150ms var(--ease-out); }
.ai-send:active { transform: scale(0.9); }
.ai-form:has(textarea:placeholder-shown) .ai-send { opacity: 0.45; }
.ai-foot { padding: 10px 18px 14px; font-size: 0.75rem; color: rgba(255, 255, 255, 0.4); text-align: center; }
@media (max-width: 767px) {
  .ai-dock { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .ai-fab { width: 56px; height: 56px; padding: 0; justify-content: center; border-radius: 50%; }
  .ai-fab .ai-ava { width: 44px; height: 44px; }
  .ai-fab-txt { display: none; }
  .ai-ping { left: 40px; top: 3px; }
  .ai-teaser { display: none; }
  .ai-modal { padding: 0; }
  .ai-panel { width: 100%; height: calc(100dvh - 32px); border-radius: 28px 28px 0 0; transform-origin: bottom center; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-msg, .ai-suggest .ai-chip, .ai-msg.is-typing span { animation: none; }
  .ai-panel { transform: none; }
}
