:root { --ai-header-h: var(--nav-height, 72px); }
body.ai-page {
  overflow-x: clip;
  background: var(--bg-primary,#040719);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.ai-page .site-header .nav-container { overflow: visible; align-items: center; }
body.ai-page .locale-banner, body.ai-page #locale-banner { display: none; }
body.ai-page .site-footer { flex-shrink: 0; }
.ai-shell {
  --ai-card: #0f172a;
  --ai-card2: #13203c;
  --ai-border: rgba(255,255,255,.08);
  --ai-b2: rgba(96,165,250,.35);
  --ai-mut: #9aa6c0;
  --ai-acc: #3b82f6;
  --ai-msg-user-bg: linear-gradient(135deg,#1d4ed8,#6d28d9);
  flex: 1;
  min-height: 0;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--ai-header-h, var(--nav-height, 72px)) + 14px) 16px 14px;
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: none;
  box-sizing: border-box;
}
.ai-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 10px;
  margin-bottom: 4px;
  min-height: 42px;
  flex-shrink: 0;
}
.ai-history-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ai-mut);
  background: transparent;
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 11px;
  cursor: pointer;
}
.ai-history-toggle:hover { color: #fff; border-color: var(--ai-b2); }
.ai-toolbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-mut);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.ai-newbtn {
  color: var(--ai-mut);
  background: transparent;
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
}
.ai-newbtn:hover { color: #fff; border-color: var(--ai-b2); }
.ai-sidebar {
  position: fixed;
  top: calc(var(--ai-header-h, var(--nav-height, 72px)) + 2px);
  bottom: 0;
  inset-inline-start: -100%;
  width: min(86vw, 320px);
  z-index: 1001;
  transition: inset-inline-start .25s ease;
  background: var(--bg-page,#040719);
  border-inline-end: 1px solid var(--ai-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ai-sidebar.open { inset-inline-start: 0; box-shadow: 0 0 40px rgba(0,0,0,.5); }
.ai-sidebar-head {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--ai-border);
}
.ai-sidebar-title {
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ai-mut);
  font-weight: 600;
  text-transform: uppercase;
}
.ai-sidebar-close {
  border: none;
  background: rgba(255,255,255,.08);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.ai-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
}
.ai-sidebar-backdrop.open { display: block; }
.ai-history-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.ai-history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ai-mut);
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.ai-history-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.ai-history-item.active { background: rgba(59,130,246,.12); color: #fff; border-color: rgba(96,165,250,.3); }
.ai-history-item .ai-h-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-history-item .ai-h-menu { opacity: 0; padding: 2px 6px; background: none; border: none; color: var(--ai-mut); cursor: pointer; border-radius: 4px; font-size: 14px; }
.ai-history-item:hover .ai-h-menu, .ai-history-item.active .ai-h-menu { opacity: 1; }
.ai-history-empty { padding: 20px 14px; color: var(--ai-mut); font-size: 12.5px; text-align: center; line-height: 1.55; }
.ai-sidebar-foot { padding: 10px 14px 14px; border-top: 1px solid var(--ai-border); }
.ai-foot-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ai-mut);
  font-size: 12.5px;
  cursor: pointer;
  background: none;
  border: none;
  text-align: start;
  width: 100%;
}
.ai-foot-link:hover { color: #fff; background: rgba(255,255,255,.04); }
.ai-stream { flex: 1; overflow-y: auto; padding: 8px 2px 10px; min-height: 0; }
.ai-hello { text-align: center; padding: 1vh 6px 2vh; }
.ai-hello h1 {
  font-size: clamp(26px, 5vw, 42px);
  margin: 0 0 10px;
  background: linear-gradient(120deg, #fff, #9ec5ff 60%, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.ai-hello p { color: var(--ai-mut); max-width: 600px; margin: 0 auto 22px; line-height: 1.6; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 720px; margin: 0 auto; }
.ai-chip {
  cursor: pointer;
  border: 1px solid var(--ai-border);
  background: var(--ai-card);
  color: #e6ebf5;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.35;
  text-align: start;
  transition: .18s;
  max-width: 330px;
}
.ai-chip:hover { border-color: var(--ai-b2); background: var(--ai-card2); transform: translateY(-1px); }
.ai-msg { display: flex; gap: 11px; margin: 0 0 20px; animation: aiIn .28s ease both; }
@keyframes aiIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ai-msg .ava { flex: 0 0 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg.user .ava { background: linear-gradient(135deg, #1d4ed8, #7c3aed); color: #fff; }
.ai-msg.bot .ava { background: var(--ai-card); border: 1px solid var(--ai-b2); }
.ai-wrap, .ai-msg-wrap { max-width: calc(100% - 56px); min-width: 0; }
.ai-bubble { padding: 12px 15px; border-radius: 14px; line-height: 1.62; font-size: 15px; overflow-wrap: anywhere; }
.ai-msg.user .ai-bubble { background: var(--ai-msg-user-bg); color: #fff; border-top-right-radius: 4px; }
.ai-msg.bot .ai-bubble { background: var(--ai-card); border: 1px solid var(--ai-border); border-top-left-radius: 4px; }
.ai-bubble p { margin: 0 0 10px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble a { color: #7eb0ff; text-decoration: underline; }
.ai-bubble strong { color: #fff; }
.ai-bubble ul, .ai-bubble ol { margin: 8px 0; padding-inline-start: 20px; }
.ai-bubble li { margin: 4px 0; }
.ai-bubble h3 { font-size: 16px; margin: 12px 0 6px; }
.ai-bubble code { background: rgba(255,255,255,.06); padding: 2px 6px; border-radius: 4px; font-size: 13.5px; }
.ai-src { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.ai-src a { font-size: 12px; color: #bcd0ff; background: rgba(59,130,246,.1); border: 1px solid var(--ai-b2); padding: 4px 10px; border-radius: 999px; text-decoration: none; }
.ai-rel { margin-top: 13px; }
.ai-rel-h { font-size: 12px; color: var(--ai-mut); margin: 0 0 7px; font-weight: 600; }
.ai-rel-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ai-rel-chip {
  cursor: pointer;
  font-size: 12.5px;
  color: #cdd9f5;
  background: var(--ai-card2);
  border: 1px solid var(--ai-border);
  padding: 6px 11px;
  border-radius: 999px;
  text-align: start;
  transition: .16s;
}
.ai-rel-chip:hover { border-color: var(--ai-b2); color: #fff; }
.ai-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; opacity: 0; transition: .2s; }
.ai-msg.bot:hover .ai-tools { opacity: 1; }
.ai-tool { cursor: pointer; background: none; border: none; color: var(--ai-mut); font-size: 12px; }
.ai-tool:hover { color: #fff; }
.ai-tool--retry { border: 1px solid rgba(251,191,36,.35); color: #fcd34d; border-radius: 999px; padding: 4px 10px; }
.ai-typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--ai-mut); animation: aiBlink 1.2s infinite both; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
.ai-cursor::after { content: "\2593"; color: var(--ai-acc); animation: aiBlink 1s infinite; margin-inline-start: 2px; }
.ai-inputwrap { flex-shrink: 0; background: transparent; padding: 10px 0 14px; }
.ai-input {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--ai-card);
  border: 1px solid var(--ai-border);
  border-radius: 16px;
  padding: 9px 9px 9px 16px;
  transition: border-color .2s;
}
.ai-input:focus-within { border-color: var(--ai-b2); }
.ai-input textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e6ebf5;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 170px;
  padding: 6px 0;
}
.ai-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .18s;
}
.ai-send:hover { filter: brightness(1.12); }
.ai-send:disabled { opacity: .45; cursor: not-allowed; }
.ai-disc { text-align: center; color: var(--ai-mut); font-size: 11.5px; margin: 9px 0 0; }
.ai-disc a { color: #7eb0ff; }
.ai-stop-btn {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 0 auto 10px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--ai-border);
  background: var(--ai-card);
  color: var(--ai-mut);
  font-size: 12.5px;
  cursor: pointer;
}
.ai-stop-btn:hover { color: #fff; }
.ai-contact-cta { margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(96,165,250,.28); border-radius: 12px; background: rgba(59,130,246,.08); }
.ai-contact-cta--emphasis { border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.08); }
.ai-contact-cta-lead { margin: 0 0 10px; font-size: 13px; color: #cbd5e1; }
.ai-contact-cta-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-contact-cta-btn { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; color: #fff; }
.ai-contact-cta-btn--tg { background: linear-gradient(135deg,#229ed9,#0b86c4); }
.ai-contact-cta-btn--wa { background: linear-gradient(135deg,#25d366,#128c4a); }
.ai-degraded-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(251,191,36,.35);
  background: rgba(251,191,36,.12);
  color: #fde68a;
  font-size: 13px;
  line-height: 1.45;
}
.ai-degraded-text { flex: 1; min-width: 0; }
.ai-degraded-dismiss { flex-shrink: 0; border: none; background: rgba(255,255,255,.08); color: #fff; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1; }
.ai-degraded-tag { display: block; margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(251,191,36,.25); background: rgba(251,191,36,.08); color: #fcd34d; font-size: 11.5px; line-height: 1.4; }
.ai-rate-note { display: none; text-align: center; color: #fcd34d; font-size: 12px; margin: 0 0 8px; }
.ai-rate-note.show { display: block; }
@media (max-width: 600px) {
  .ai-shell { padding: calc(var(--ai-header-h, var(--nav-height, 72px)) + 10px) 11px 8px; }
  .ai-bubble { font-size: 14.5px; }
  .ai-history-toggle-label { display: none; }
}
@media (max-width: 640px) {
  .ai-shell { min-height: min(520px, calc(100dvh - var(--nav-height, var(--ai-header-h, 72px)) - 120px)); }
}
html[dir="rtl"] .ai-msg.user { flex-direction: row; }
body.ai-page .ai-shell {
  padding-top: calc(var(--ai-header-h, var(--nav-height, 72px)) + 14px) !important;
  padding-inline: 16px !important;
  padding-bottom: 14px !important;
  box-sizing: border-box !important;
}
@media (max-width: 600px) {
  body.ai-page .ai-shell {
    padding-top: calc(var(--ai-header-h, var(--nav-height, 72px)) + 10px) !important;
    padding-inline: 11px !important;
    padding-bottom: 8px !important;
  }
}
body.ai-page .ai-sidebar {
  top: calc(var(--ai-header-h, var(--nav-height, 72px)) + 2px) !important;
}
