
*,
*::before,
*::after { box-sizing:border-box; }

:root {
  --red:#ff263b;
  --red-dark:#b91328;
  --blue:#49a9ff;
  --green:#38dc84;
  --panel:rgba(11,15,22,.98);
  --border:rgba(255,255,255,.10);
  --muted:#9da7b6;
  --wizard-mobile:86px;
  --wizard-tablet:98px;
  --wizard-desktop:112px;
}

html,body{
  margin:0;
  min-height:100%;
  overflow-x:hidden;
  font-family:Inter,Arial,sans-serif;
  color:#fff;
  background:
    radial-gradient(circle at 78% 18%,rgba(27,67,130,.25),transparent 34%),
    linear-gradient(135deg,#05070b,#0b111a);
}

button,input{font:inherit}
button{-webkit-tap-highlight-color:transparent}

.demo-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}

.demo-card{
  width:min(720px,100%);
  padding:34px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:24px;
  background:rgba(255,255,255,.035);
  box-shadow:0 30px 80px rgba(0,0,0,.48);
}

.demo-tag{
  color:#ff5265;
  font-size:12px;
  font-weight:900;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.demo-card h1{
  margin:10px 0;
  font-size:clamp(38px,8vw,68px);
}

.demo-card p{
  margin:0;
  color:#aeb7c6;
  line-height:1.6;
}

/* APP */
.mago-app{
  position:fixed;
  z-index:2147483000;
  right:max(8px,env(safe-area-inset-right));
  bottom:max(8px,env(safe-area-inset-bottom));
  width:calc(100vw - 16px);
  max-width:390px;
  pointer-events:none;
}

/* CHARACTER */
.wizard-trigger{
  position:relative;
  z-index:20;
  display:block;
  width:var(--wizard-mobile);
  height:calc(var(--wizard-mobile) * 1.34);
  margin-left:auto;
  padding:0;
  border:0;
  background:transparent;
  cursor:pointer;
  pointer-events:auto;
  animation:wizardFloat 3.2s ease-in-out infinite;
  transition:
    width .2s ease,
    height .2s ease,
    right .2s ease,
    bottom .2s ease,
    transform .2s ease;
}

.wizard-trigger img{
  position:relative;
  z-index:2;
  width:100%;
  height:100%;
  object-fit:contain;
  object-position:center bottom;
  filter:drop-shadow(0 10px 14px rgba(0,0,0,.58));
  transition:.18s ease;
}

.wizard-trigger.searching img{
  filter:
    drop-shadow(0 10px 14px rgba(0,0,0,.58))
    drop-shadow(0 0 12px rgba(73,169,255,.75))
    drop-shadow(0 0 28px rgba(80,83,255,.32));
}

.wizard-glow{
  position:absolute;
  left:50%;
  bottom:1px;
  z-index:1;
  width:72%;
  height:16%;
  transform:translateX(-50%);
  border-radius:50%;
  background:radial-gradient(ellipse,rgba(73,169,255,.5),rgba(73,169,255,0) 70%);
  filter:blur(2px);
}

.notify-badge{
  position:absolute;
  z-index:4;
  top:2px;
  right:-2px;
  min-width:21px;
  height:21px;
  display:grid;
  place-items:center;
  padding:0 6px;
  border:2px solid #090d14;
  border-radius:999px;
  background:var(--red);
  color:#fff;
  font-size:10px;
  font-weight:900;
}

/* BUBBLE */
.speech-bubble{
  position:absolute;
  right:calc(var(--wizard-mobile) - 4px);
  bottom:calc(var(--wizard-mobile) * .9);
  width:min(190px,calc(100vw - 108px));
  padding:10px 12px;
  border-radius:14px 14px 4px 14px;
  background:#fff;
  color:#171a20;
  font-size:12px;
  font-weight:750;
  line-height:1.35;
  box-shadow:0 14px 34px rgba(0,0,0,.35);
  transition:.18s;
  pointer-events:none;
}

.speech-bubble.hide{
  opacity:0;
  visibility:hidden;
  transform:translateY(5px) scale(.97);
}

/* PANEL */
.mago-panel{
  position:fixed;
  left:max(8px,env(safe-area-inset-left));
  right:max(8px,env(safe-area-inset-right));
  bottom:max(8px,env(safe-area-inset-bottom));
  width:auto;
  max-height:min(72dvh,calc(100dvh - 118px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border:1px solid var(--border);
  border-radius:20px;
  background:linear-gradient(180deg,rgba(18,24,35,.985),rgba(7,10,15,.99));
  box-shadow:0 24px 64px rgba(0,0,0,.62);
  backdrop-filter:blur(18px);
  opacity:0;
  visibility:hidden;
  transform:translateY(18px) scale(.98);
  transform-origin:bottom center;
  transition:.2s;
  pointer-events:none;
}

.mago-panel.open{
  opacity:1;
  visibility:visible;
  transform:none;
  pointer-events:auto;
}

/* IMPORTANT: character stays visible above panel on mobile */
.mago-panel.open ~ .wizard-trigger{
  position:fixed;
  right:max(18px,env(safe-area-inset-right));
  bottom:calc(
    min(72dvh,calc(100dvh - 118px - env(safe-area-inset-top) - env(safe-area-inset-bottom)))
    + max(12px,env(safe-area-inset-bottom))
  );
  width:92px;
  height:124px;
  opacity:1;
  visibility:visible;
  pointer-events:auto;
  animation:wizardFloatTop 3.2s ease-in-out infinite;
}

.mago-panel.open ~ .speech-bubble{
  opacity:0;
  visibility:hidden;
}

/* HEADER */
.mago-header{
  min-height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:10px 10px 10px 12px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.025);
}

.mago-brand{
  min-width:0;
  display:flex;
  align-items:center;
  gap:9px;
}

.online-dot{
  width:10px;
  height:10px;
  flex:0 0 auto;
  border-radius:50%;
  background:var(--green);
  box-shadow:0 0 0 4px rgba(56,220,132,.1),0 0 16px rgba(56,220,132,.32);
}

.brand-copy{
  min-width:0;
}

.brand-copy strong,
.brand-copy small{display:block}

.brand-copy strong{font-size:14px}

.brand-copy small{
  margin-top:2px;
  color:var(--muted);
  font-size:10px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.header-buttons{
  display:flex;
  gap:5px;
}

.icon-button{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  padding:0;
  border:1px solid var(--border);
  border-radius:9px;
  background:rgba(255,255,255,.045);
  color:#fff;
  cursor:pointer;
}

.lang-button{
  font-size:11px;
  font-weight:900;
}

/* BODY */
.mago-scroll{
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding:12px;
  scrollbar-width:thin;
}

.messages{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-bottom:12px;
}

.message{
  display:flex;
  align-items:flex-end;
  gap:7px;
}

.user-message{justify-content:flex-end}

.bot-avatar{
  width:25px;
  height:25px;
  flex:0 0 auto;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:#202a39;
  color:#63b9ff;
  font-size:11px;
}

.message-bubble{
  max-width:84%;
  padding:9px 11px;
  border-radius:13px 13px 13px 4px;
  background:#1a2230;
  color:#fff;
  font-size:12.5px;
  line-height:1.4;
}

.user-message .message-bubble{
  border-radius:13px 13px 4px 13px;
  background:linear-gradient(135deg,var(--red),var(--red-dark));
}

.primary-actions{
  display:grid;
  grid-template-columns:1fr;
  gap:7px;
}

.primary-action{
  min-height:56px;
  display:grid;
  grid-template-columns:32px 1fr 14px;
  align-items:center;
  gap:8px;
  width:100%;
  padding:9px 10px;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,.035);
  color:#fff;
  text-align:left;
  cursor:pointer;
}

.action-icon{
  width:30px;
  height:30px;
  display:grid;
  place-items:center;
  border-radius:9px;
  background:rgba(255,255,255,.06);
  font-size:15px;
}

.action-copy{min-width:0}
.action-copy strong,.action-copy small{display:block}
.action-copy strong{font-size:12.5px}
.action-copy small{margin-top:2px;color:var(--muted);font-size:10.5px}
.chevron{color:#8290a3;font-size:18px}

.submenu{
  display:grid;
  gap:6px;
  margin-top:9px;
}

.submenu:empty{display:none}

.submenu button{
  width:100%;
  min-height:46px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:9px 11px;
  border:1px solid var(--border);
  border-radius:11px;
  background:rgba(255,255,255,.045);
  color:#fff;
  text-align:left;
  cursor:pointer;
}

.composer{
  display:flex;
  gap:7px;
  padding:10px 10px max(10px,env(safe-area-inset-bottom));
  border-top:1px solid var(--border);
  background:rgba(6,9,14,.94);
}

.composer input{
  flex:1;
  min-width:0;
  height:44px;
  padding:0 12px;
  border:1px solid rgba(255,255,255,.11);
  border-radius:11px;
  outline:none;
  background:rgba(255,255,255,.055);
  color:#fff;
  font-size:13px;
}

.composer button{
  min-width:68px;
  height:44px;
  padding:0 12px;
  border:0;
  border-radius:11px;
  background:linear-gradient(135deg,var(--red),var(--red-dark));
  color:#fff;
  font-size:12px;
  font-weight:850;
  cursor:pointer;
}

.typing{
  display:inline-flex;
  gap:4px;
  padding:10px 12px;
}

.typing i{
  width:5px;
  height:5px;
  border-radius:50%;
  background:#8995a5;
  animation:typingDot 1s infinite ease-in-out;
}
.typing i:nth-child(2){animation-delay:.14s}
.typing i:nth-child(3){animation-delay:.28s}

/* Tablet */
@media (min-width:600px){
  .mago-app{
    right:16px;
    bottom:14px;
    width:370px;
  }

  .wizard-trigger{
    width:var(--wizard-tablet);
    height:calc(var(--wizard-tablet) * 1.34);
  }

  .speech-bubble{
    right:88px;
    bottom:94px;
    width:205px;
    font-size:12.5px;
  }

  .mago-panel{
    position:absolute;
    left:auto;
    right:54px;
    bottom:122px;
    width:350px;
    max-height:min(610px,calc(100vh - 40px));
    transform-origin:bottom right;
  }

  .mago-panel.open ~ .wizard-trigger{
    position:absolute;
    right:-2px;
    bottom:calc(122px + min(610px,calc(100vh - 40px)) - 120px);
    width:104px;
    height:140px;
  }
}

/* Desktop */
@media (min-width:1024px){
  .wizard-trigger{
    width:var(--wizard-desktop);
    height:calc(var(--wizard-desktop) * 1.34);
  }

  .mago-panel{width:365px}

  .primary-actions{
    grid-template-columns:1fr 1fr;
  }
}

@media (max-height:560px){
  .mago-panel{
    max-height:calc(100dvh - 105px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .mago-panel.open ~ .wizard-trigger{
    bottom:calc(
      calc(100dvh - 105px - env(safe-area-inset-top) - env(safe-area-inset-bottom))
      + max(8px,env(safe-area-inset-bottom))
    );
    width:72px;
    height:96px;
  }
}

@media (prefers-reduced-motion:reduce){
  *,
  *::before,
  *::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
  }
}

@keyframes wizardFloat{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-4px)}
}

@keyframes wizardFloatTop{
  0%,100%{transform:translateY(0) rotate(0deg)}
  50%{transform:translateY(-5px) rotate(-1deg)}
}

@keyframes typingDot{
  0%,70%,100%{opacity:.3;transform:translateY(0)}
  35%{opacity:1;transform:translateY(-3px)}
}
