.ai-chat [hidden] { display: none !important; }
.ai-chat { position: fixed; right: 36px; bottom: 36px; z-index: 140; font-family: inherit; }
body:has(.cookie.is-visible) .ai-chat { bottom: 150px; }

.ai-chat__toggle { width: 56px; height: 56px; border: none; background: none; cursor: pointer; padding: 0; transition: transform 0.25s ease; }
.ai-chat__toggle:hover { transform: translateY(-2px); }
.ai-chat__sphere { position: relative; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #0a2418 0%, #020805 75%); box-shadow: inset 0 0 18px rgba(0, 224, 122, 0.18), 0 0 0 1px rgba(0, 224, 122, 0.25), 0 8px 24px rgba(4, 20, 12, 0.35); }
.ai-chat__sphere::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid transparent; border-top-color: #00e07a; border-right-color: rgba(0, 224, 122, 0.25); animation: aiSpin 3.6s linear infinite; }
.ai-chat__sphere::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle, #d1ffe0 0%, #00e07a 70%); box-shadow: 0 0 8px #00e07a, 0 0 18px rgba(0, 224, 122, 0.55); animation: aiCore 2.4s ease-in-out infinite; }
@keyframes aiSpin { to { transform: rotate(360deg); } }
@keyframes aiCore { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }

.ai-chat__panel { position: absolute; right: 0; bottom: 72px; width: 380px; height: 600px; max-height: calc(100vh - 120px); background: transparent; border: none; border-radius: 20px; box-shadow: 0 20px 50px rgba(4, 20, 12, 0.28), 0 4px 12px rgba(4, 20, 12, 0.08); display: flex; flex-direction: column; overflow: hidden; transform-origin: bottom right; animation: aiPanelIn 0.25s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes aiPanelIn { from { opacity: 0; transform: scale(0.94) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.ai-chat__header { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: linear-gradient(120deg, #041208 0%, #0b2418 20%, #0d3324 50%, #0b2418 80%, #041208 100%); background-size: 300% 100%; animation: aiHeaderShift 14s ease-in-out infinite; color: #fff; flex-shrink: 0; overflow: hidden; }
@keyframes aiHeaderShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.ai-chat__title { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 700; }
.ai-chat__dot { width: 7px; height: 7px; border-radius: 50%; background: #00e07a; box-shadow: 0 0 8px #00e07a; flex-shrink: 0; }
.ai-chat__close { background: none; border: none; color: rgba(255, 255, 255, 0.7); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; transition: color 0.2s; }
.ai-chat__close:hover { color: #fff; }

.ai-chat__body { flex: 1; overflow-y: auto; padding: 16px; background: #f8fcf9; display: flex; flex-direction: column; gap: 10px; }
.ai-chat__body > *:first-child { margin-top: auto; }
.ai-chat__msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.55; word-wrap: break-word; }
.ai-chat__msg--user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-chat__msg--bot { align-self: flex-start; background: #fff; color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-chat__msg strong { font-weight: 700; color: inherit; }
.ai-chat__msg em { font-style: italic; }
.ai-chat__msg code { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; background: rgba(4, 20, 12, 0.06); padding: 1px 5px; border-radius: 4px; color: #067a44; }
.ai-chat__msg--user code { background: rgba(255, 255, 255, 0.18); color: #fff; }
.ai-chat__msg p { margin: 0 0 8px; }
.ai-chat__msg p:last-child { margin-bottom: 0; }
.ai-chat__msg ul, .ai-chat__msg ol { margin: 8px 0; padding-left: 20px; }
.ai-chat__msg li { margin-bottom: 4px; }
.ai-chat__msg a { color: var(--accent); text-decoration: underline; }

.ai-chat__typing { padding: 6px 4px 2px; font-size: 13px; color: var(--ink-muted); display: flex; align-items: center; flex-shrink: 0; }
.ai-chat__typing-dots::after { content: ''; display: inline-block; width: 16px; text-align: left; animation: aiDots 1.4s steps(4, end) infinite; }
@keyframes aiDots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } 100% { content: ''; } }

.ai-chat__form { display: flex; gap: 8px; padding: 10px 14px 4px; border-top: 1px solid var(--line); background: #fff; flex-shrink: 0; }
.ai-chat__input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-family: inherit; font-size: 14px; line-height: 1.4; resize: none; max-height: 84px; overflow-y: hidden; outline: none; background: var(--bg-soft); transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; }
.ai-chat__input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(0, 184, 98, 0.1); }
.ai-chat__input:disabled { background: #f4f7f5; color: var(--ink-muted); cursor: not-allowed; }
.ai-chat__send { width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--accent); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; transition: background 0.2s, opacity 0.2s; flex-shrink: 0; }
.ai-chat__send:hover { background: #00a854; }
.ai-chat__send:disabled { opacity: 0.5; cursor: not-allowed; background: var(--accent); }
.ai-chat__counter { text-align: right; padding: 4px 16px 10px; font-size: 11px; color: var(--ink-muted); flex-shrink: 0; background: #fff; }

.ai-chat__hint { position: absolute; right: 68px; bottom: 10px; min-width: 240px; max-width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 38px 12px 16px; box-shadow: 0 10px 28px rgba(4, 20, 12, 0.16); font-size: 13.5px; line-height: 1.55; color: var(--ink); cursor: pointer; opacity: 0; transform: translateX(8px); transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.2s; pointer-events: none; }
.ai-chat__hint.is-visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
.ai-chat__hint:hover { box-shadow: 0 14px 34px rgba(4, 20, 12, 0.22); }
.ai-chat__hint::after { content: ''; position: absolute; right: -7px; bottom: 20px; width: 12px; height: 12px; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(-45deg); border-radius: 0 0 3px 0; }
.ai-chat__hint-text { display: block; }
.ai-chat__hint-close { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border: none; background: transparent; border-radius: 50%; cursor: pointer; color: var(--ink-muted); font-size: 16px; line-height: 1; transition: color 0.2s, background 0.2s; }
.ai-chat__hint-close:hover { color: var(--ink); background: var(--bg-soft); }

.ai-chat__contacts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ai-chat__contact-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; line-height: 1; color: #fff!important; text-decoration: none!important; transition: transform 0.2s, box-shadow 0.2s; }
.ai-chat__contact-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(4, 20, 12, 0.2); }
.ai-chat__contact-btn svg { flex-shrink: 0; }
.ai-chat__contact-btn--tg { background: #29A9EB; }
.ai-chat__contact-btn--tg:hover { background: #1e8fc9; }
.ai-chat__contact-btn--wa { background: #25D366; }
.ai-chat__contact-btn--wa:hover { background: #1fb457; }

.ai-chat__scroll-btn { position: absolute; right: 16px; bottom: 92px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--ink-soft); cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(4, 20, 12, 0.18); opacity: 0; transform: translateY(8px); transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s, color 0.2s; pointer-events: none; z-index: 3; }
.ai-chat__scroll-btn.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.ai-chat__scroll-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: #b6f0cf; }
.ai-chat__scroll-btn svg { display: block; }

@media (max-width: 768px) {
  body:has(.cookie.is-visible) .ai-chat { bottom: 220px; }
}

@media (max-width: 640px) {
  .ai-chat { right: 26px; bottom: 26px; z-index: 1100; }
  body:has(.cookie.is-visible) .ai-chat { bottom: 300px; }
  .ai-chat__panel { position: fixed; inset: 0; width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .ai-chat__header { padding: 18px 20px; padding-top: calc(18px + env(safe-area-inset-top)); }
  .ai-chat__hint { right: 68px; bottom: 8px; max-width: calc(100vw - 100px); min-width: 220px; }
  .ai-chat__scroll-btn { right: 14px; bottom: 96px; }
}
