.ai-toggle{
  position:fixed;
  right:max(20px,env(safe-area-inset-right));
  bottom:max(20px,env(safe-area-inset-bottom));
  z-index:1200;
  width:58px;
  height:58px;
  border:1px solid rgba(255,241,189,.62);
  border-radius:50%;
  background:
    radial-gradient(circle at 32% 26%,rgba(255,255,255,.78),rgba(255,255,255,0) 34%),
    linear-gradient(145deg,var(--cinema-gold-soft,#fff1bd),var(--cinema-gold,#e7bd70) 62%,#9c6a2f);
  color:#140e07;
  box-shadow:0 18px 46px rgba(0,0,0,.46),0 0 30px rgba(231,189,112,.32);
  cursor:pointer;
  display:grid;
  place-items:center;
  font:900 15px/1 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  letter-spacing:0;
  transition:transform .22s ease,box-shadow .22s ease,border-color .22s ease;
}
.ai-toggle:hover,
.ai-toggle.active{
  transform:translateY(-2px);
  border-color:#fff7d8;
  box-shadow:0 22px 58px rgba(0,0,0,.54),0 0 42px rgba(231,189,112,.48);
}
.ai-toggle:focus-visible{
  outline:3px solid #fff1bd;
  outline-offset:4px;
}
.ai-toggle .ai-toggle-dot{
  position:absolute;
  right:9px;
  top:8px;
  width:9px;
  height:9px;
  border-radius:50%;
  background:#5df0b0;
  box-shadow:0 0 14px rgba(93,240,176,.9);
}
.ai-panel{
  position:fixed;
  right:max(20px,env(safe-area-inset-right));
  bottom:92px;
  z-index:1199;
  width:min(426px,calc(100vw - 34px));
  max-height:min(720px,calc(100dvh - 118px));
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.14);
  border-radius:8px;
  background:
    linear-gradient(160deg,rgba(20,25,35,.98),rgba(6,10,16,.98) 58%),
    radial-gradient(circle at 85% 0,rgba(231,189,112,.18),rgba(231,189,112,0) 36%);
  box-shadow:0 34px 90px rgba(0,0,0,.62),0 0 0 1px rgba(231,189,112,.08);
  color:var(--text,#f7f3ea);
  opacity:0;
  visibility:hidden;
  transform:translateY(14px) scale(.98);
  transform-origin:bottom right;
  transition:opacity .22s ease,visibility .22s ease,transform .22s ease;
}
.ai-panel.open{
  opacity:1;
  visibility:visible;
  transform:translateY(0) scale(1);
}
.ai-panel *{
  box-sizing:border-box;
  letter-spacing:0;
}
.ai-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:16px 16px 13px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.ai-header-info{
  display:flex;
  align-items:center;
  min-width:0;
  gap:11px;
}
.ai-avatar{
  width:36px;
  height:36px;
  flex:0 0 36px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:linear-gradient(145deg,var(--cinema-gold-soft,#fff1bd),var(--cinema-gold,#e7bd70));
  color:#171007;
  font-weight:900;
  box-shadow:0 0 26px rgba(231,189,112,.3);
}
.ai-kicker{
  margin-bottom:2px;
  color:rgba(255,241,189,.72);
  font-size:10px;
  font-weight:800;
  text-transform:uppercase;
}
.ai-header h3{
  margin:0;
  color:#fffaf0;
  font-size:17px;
  line-height:1.15;
}
.ai-header small{
  display:block;
  margin-top:3px;
  color:rgba(221,228,238,.7);
  font-size:12px;
  line-height:1.35;
}
.ai-close{
  width:32px;
  height:32px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:8px;
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.72);
  cursor:pointer;
  display:grid;
  place-items:center;
  font-size:18px;
  line-height:1;
  transition:background .18s ease,color .18s ease,border-color .18s ease;
}
.ai-close:hover{
  background:rgba(255,255,255,.09);
  color:#fff;
  border-color:rgba(255,255,255,.22);
}
.ai-context{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:12px 14px 0;
  padding:10px 11px;
  border:1px solid rgba(231,189,112,.2);
  border-radius:8px;
  background:linear-gradient(135deg,rgba(231,189,112,.1),rgba(255,255,255,.035));
}
.ai-context strong{
  display:block;
  color:#fff5d3;
  font-size:13px;
  line-height:1.25;
}
.ai-context small{
  display:block;
  margin-top:3px;
  color:rgba(221,228,238,.7);
  font-size:11px;
  line-height:1.35;
}
.ai-status{
  flex:0 0 auto;
  min-width:64px;
  padding:5px 8px;
  border-radius:999px;
  background:rgba(93,240,176,.12);
  border:1px solid rgba(93,240,176,.32);
  color:#baf7d9;
  font-size:11px;
  font-weight:800;
  text-align:center;
}
.ai-status.thinking{
  background:rgba(231,189,112,.14);
  border-color:rgba(231,189,112,.38);
  color:#fff1bd;
}
.ai-actions{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;
  padding:12px 14px 8px;
}
.ai-action{
  min-height:42px;
  padding:8px 7px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:8px;
  background:rgba(255,255,255,.045);
  color:#ede8dd;
  font-size:12px;
  font-weight:800;
  line-height:1.2;
  cursor:pointer;
  transition:background .18s ease,border-color .18s ease,color .18s ease,transform .18s ease;
}
.ai-action:hover{
  transform:translateY(-1px);
  background:rgba(231,189,112,.13);
  border-color:rgba(231,189,112,.36);
  color:#fff6d7;
}
.ai-action:focus-visible{
  outline:2px solid #fff1bd;
  outline-offset:2px;
}
.ai-messages{
  flex:1 1 auto;
  min-height:238px;
  max-height:390px;
  overflow-y:auto;
  padding:10px 14px 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
  scroll-behavior:smooth;
}
.ai-messages::-webkit-scrollbar{
  width:6px;
}
.ai-messages::-webkit-scrollbar-track{
  background:transparent;
}
.ai-messages::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.16);
  border-radius:999px;
}
.ai-msg{
  width:fit-content;
  max-width:92%;
  padding:10px 12px;
  border-radius:8px;
  font-size:13px;
  line-height:1.58;
  animation:aiMsgIn .18s ease both;
}
.ai-msg p{
  margin:0;
  white-space:pre-line;
}
.ai-msg.bot{
  align-self:flex-start;
  background:rgba(255,255,255,.055);
  border:1px solid rgba(255,255,255,.1);
  color:#ebe6dc;
}
.ai-msg.user{
  align-self:flex-end;
  background:linear-gradient(135deg,rgba(231,189,112,.28),rgba(231,189,112,.15));
  border:1px solid rgba(231,189,112,.34);
  color:#fff4cc;
}
.ai-msg-label{
  display:block;
  margin-bottom:4px;
  color:rgba(255,241,189,.76);
  font-size:10px;
  font-weight:900;
  text-transform:uppercase;
}
.ai-source{
  display:block;
  margin-top:8px;
  color:rgba(221,228,238,.55);
  font-size:10px;
}
.ai-typing{
  display:flex;
  align-items:center;
  gap:5px;
  min-width:58px;
  min-height:20px;
}
.ai-typing span{
  width:6px;
  height:6px;
  border-radius:50%;
  background:#fff1bd;
  opacity:.38;
  animation:aiTyping 1s ease-in-out infinite;
}
.ai-typing span:nth-child(2){
  animation-delay:.15s;
}
.ai-typing span:nth-child(3){
  animation-delay:.3s;
}
.ai-input-wrap{
  display:flex;
  gap:8px;
  padding:11px 14px 14px;
  border-top:1px solid rgba(255,255,255,.08);
}
.ai-input-wrap input{
  min-width:0;
  flex:1 1 auto;
  height:42px;
  border:1px solid rgba(255,255,255,.14);
  border-radius:8px;
  background:rgba(255,255,255,.055);
  color:#fffaf0;
  padding:0 12px;
  font-size:13px;
  outline:0;
  transition:border-color .18s ease,background .18s ease;
}
.ai-input-wrap input::placeholder{
  color:rgba(221,228,238,.48);
}
.ai-input-wrap input:focus{
  border-color:rgba(255,241,189,.7);
  background:rgba(255,255,255,.08);
}
.ai-send{
  flex:0 0 44px;
  width:44px;
  height:42px;
  border:0;
  border-radius:8px;
  display:grid;
  place-items:center;
  background:linear-gradient(145deg,var(--cinema-gold-soft,#fff1bd),var(--cinema-gold,#e7bd70));
  color:#140e07;
  font-size:18px;
  font-weight:900;
  cursor:pointer;
  transition:transform .18s ease,opacity .18s ease;
}
.ai-send:hover{
  transform:translateY(-1px);
}
.ai-send:disabled{
  opacity:.46;
  cursor:default;
  transform:none;
}
.ai-powered{
  padding:0 14px 12px;
  color:rgba(221,228,238,.36);
  font-size:10px;
  text-align:center;
}
@keyframes aiMsgIn{
  from{opacity:0;transform:translateY(7px)}
  to{opacity:1;transform:translateY(0)}
}
@keyframes aiTyping{
  0%,100%{opacity:.35;transform:translateY(0)}
  50%{opacity:1;transform:translateY(-3px)}
}
@media(max-width:640px){
  .ai-panel{
    right:12px;
    left:12px;
    bottom:86px;
    width:auto;
    max-height:min(74dvh,620px);
  }
  .ai-toggle{
    right:16px;
    bottom:16px;
    width:54px;
    height:54px;
  }
  .ai-actions{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .ai-messages{
    min-height:210px;
  }
}
