.imr-chat-root{
  position:fixed;
  z-index:280;
  right:max(20px,env(safe-area-inset-right,0px));
  bottom:max(20px,env(safe-area-inset-bottom,0px));
  left:auto;
  top:auto;
  touch-action:none;
  user-select:none;
  width:min(92vw,392px);
}
.imr-chat-root.is-positioned{right:auto;bottom:auto}
.imr-chat-root.is-dragging{cursor:grabbing}
.imr-chat-root.is-open .imr-chat-launcher-wrap,
.imr-chat-root.is-open .imr-chat-fab{display:none!important}
.imr-chat-root.is-open{width:min(92vw,392px)}

/* Keep open panel bottom-anchored so growth never pushes it off-screen */
.imr-chat-root.is-open:not(.is-positioned){
  right:max(20px,env(safe-area-inset-right,0px));
  bottom:max(20px,env(safe-area-inset-bottom,0px));
  left:auto;
  top:auto;
}

/* ── Launcher card ── */
.imr-chat-launcher-wrap{
  position:relative;
  width:100%;
}
.imr-chat-root.is-compact .imr-chat-launcher-wrap{display:none}

.imr-chat-launcher{
  display:flex;
  align-items:center;
  gap:14px;
  width:100%;
  padding:15px 18px 15px 15px;
  border:none;
  border-radius:18px;
  cursor:grab;
  text-align:left;
  color:#1a1206;
  background:linear-gradient(135deg,#f0d48a 0%,#e3b262 42%,#d4a84a 100%);
  box-shadow:0 14px 36px rgba(200,147,63,.34),0 0 0 1px rgba(255,255,255,.45),inset 0 1px 0 rgba(255,255,255,.55);
  transition:transform .22s cubic-bezier(.16,1,.3,1),box-shadow .22s ease;
  animation:imr-chat-float 4.5s ease-in-out infinite;
  position:relative;
}
.imr-chat-launcher:hover{transform:translateY(-2px);box-shadow:0 18px 44px rgba(200,147,63,.42),0 0 0 1px rgba(255,255,255,.55),inset 0 1px 0 rgba(255,255,255,.62)}
.imr-chat-launcher:focus-visible{outline:2px solid #1a1206;outline-offset:3px}
.imr-chat-launcher-mark{width:46px;height:46px;border-radius:13px;padding:5px}
.imr-chat-launcher-mark img{width:100%;height:100%;object-fit:contain;border-radius:8px;display:block}
.imr-chat-launcher-copy{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1;padding-right:28px}
.imr-chat-launcher-title{font-family:'Space Grotesk',sans-serif;font-size:16px;font-weight:800;line-height:1.15;letter-spacing:-.01em;color:#1a1206}
.imr-chat-launcher-sub{font-size:13px;line-height:1.35;color:rgba(26,18,6,.72);font-weight:600}
.imr-chat-launcher-pulse{
  position:absolute;top:-3px;right:-3px;width:12px;height:12px;border-radius:50%;
  background:#fff;border:2px solid #d4a84a;box-shadow:0 0 0 0 rgba(255,255,255,.55);
  animation:imr-chat-pulse 2.4s ease-out infinite;
}

.imr-chat-minimize{
  display:none;
  position:absolute;
  top:8px;
  right:8px;
  width:30px;
  height:30px;
  border-radius:8px;
  border:1px solid rgba(26,18,6,.16);
  background:rgba(255,255,255,.78);
  color:#1a1206;
  cursor:pointer;
  align-items:center;
  justify-content:center;
  z-index:4;
  touch-action:manipulation;
  box-shadow:0 2px 8px rgba(120,80,20,.12);
  transition:background .18s ease,transform .18s ease;
}
.imr-chat-minimize:hover{background:rgba(255,255,255,.88);transform:translateY(-1px)}
.imr-chat-minimize svg{width:14px;height:14px;stroke:currentColor;stroke-width:2.4;fill:none;pointer-events:none}

/* ── Compact FAB (mobile) ── */
.imr-chat-fab{
  display:none;
  position:relative;
  width:56px;
  height:56px;
  border:none;
  border-radius:50%;
  cursor:pointer;
  color:#1a1206;
  background:linear-gradient(135deg,#f0d48a 0%,#e3b262 48%,#d4a84a 100%);
  box-shadow:0 12px 32px rgba(200,147,63,.36),0 0 0 1px rgba(255,255,255,.45),inset 0 1px 0 rgba(255,255,255,.55);
  align-items:center;
  justify-content:center;
  transition:transform .22s cubic-bezier(.16,1,.3,1),box-shadow .22s ease;
  animation:imr-chat-float 4.5s ease-in-out infinite;
}
.imr-chat-root.is-compact .imr-chat-fab{display:flex}
.imr-chat-root.is-compact{width:auto}
.imr-chat-fab:hover{transform:translateY(-2px) scale(1.03);box-shadow:0 16px 40px rgba(200,147,63,.42),0 0 0 1px rgba(255,255,255,.55)}
.imr-chat-fab:focus-visible{outline:2px solid #1a1206;outline-offset:3px}
.imr-chat-fab-mark{
  width:40px;height:40px;border-radius:11px;padding:4px;
}

@keyframes imr-chat-float{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-2px)}
}
@keyframes imr-chat-pulse{
  0%{box-shadow:0 0 0 0 rgba(255,255,255,.45)}
  70%{box-shadow:0 0 0 9px rgba(255,255,255,0)}
  100%{box-shadow:0 0 0 0 rgba(255,255,255,0)}
}

/* ── Panel: fixed viewport height, internal scroll only ── */
.imr-chat-panel{
  width:100%;
  height:min(560px,calc(100dvh - 48px));
  max-height:min(560px,calc(100dvh - 48px));
  display:flex;flex-direction:column;
  border-radius:22px;overflow:hidden;
  background:rgba(255,252,245,.98);
  backdrop-filter:blur(20px) saturate(1.35);
  -webkit-backdrop-filter:blur(20px) saturate(1.35);
  border:1px solid rgba(227,178,98,.38);
  box-shadow:0 22px 56px rgba(120,80,20,.18),0 0 0 1px rgba(255,255,255,.65);
}
.imr-chat-panel[hidden]{display:none!important}

.imr-chat-head{
  display:flex;align-items:center;gap:12px;padding:15px 16px;
  background:linear-gradient(135deg,#f7e3b0 0%,#efcf7a 48%,#e3b262 100%);
  color:#1a1206;border-bottom:1px solid rgba(212,168,74,.28);
  flex-shrink:0;
}
.imr-chat-head-mark{width:38px;height:38px;border-radius:11px;padding:4px}
.imr-chat-head-copy{flex:1;min-width:0}
.imr-chat-head-title{font-family:'Space Grotesk',sans-serif;font-size:15px;font-weight:800;line-height:1.15;letter-spacing:-.01em;color:#1a1206}
.imr-chat-head-sub{font-size:12px;line-height:1.35;color:rgba(26,18,6,.68);margin-top:2px;font-weight:600}
.imr-chat-head-actions{display:flex;align-items:center;gap:6px;flex-shrink:0}
.imr-chat-grip{width:16px;height:16px;opacity:.45;display:grid;grid-template-columns:repeat(2,4px);grid-template-rows:repeat(3,4px);gap:3px;justify-content:center;align-content:center;cursor:grab;touch-action:none}
.imr-chat-root.is-dragging .imr-chat-grip{cursor:grabbing}
.imr-chat-grip span{width:4px;height:4px;border-radius:50%;background:rgba(26,18,6,.55);display:block;pointer-events:none}
.imr-chat-close{
  width:32px;height:32px;border-radius:9px;border:1px solid rgba(26,18,6,.12);
  background:rgba(255,255,255,.55);color:#1a1206;cursor:pointer;display:flex;align-items:center;justify-content:center;
  transition:background .18s ease;flex-shrink:0;position:relative;z-index:3;
  touch-action:manipulation;
}
.imr-chat-close:hover{background:rgba(255,255,255,.82)}
.imr-chat-close svg{width:15px;height:15px;stroke:currentColor;stroke-width:2.2;fill:none;pointer-events:none}

.imr-chat-suggestions{display:flex;flex-wrap:wrap;gap:7px;padding:12px 14px 8px;flex-shrink:0}
.imr-chat-sug{
  border:1px solid rgba(212,168,74,.32);background:rgba(255,248,232,.92);color:#1a1206;
  border-radius:999px;padding:7px 13px;font-size:12px;font-weight:700;line-height:1.3;cursor:pointer;
  transition:background .18s ease,border-color .18s ease,color .18s ease,transform .18s ease;
}
.imr-chat-sug:hover{background:linear-gradient(135deg,#efcf7a,#e3b262);border-color:#d4a84a;color:#1a1206;transform:translateY(-1px)}

.imr-chat-messages{
  flex:1 1 auto;
  min-height:0; /* critical: allow flex child to scroll instead of growing panel */
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding:4px 14px 10px;
  display:flex;
  flex-direction:column;
  gap:10px;
  scroll-behavior:smooth;
}
.imr-chat-messages::-webkit-scrollbar{width:4px}
.imr-chat-messages::-webkit-scrollbar-thumb{background:rgba(212,168,74,.35);border-radius:99px}

.imr-chat-mark{
  flex-shrink:0;display:flex;align-items:center;justify-content:center;
  background:rgba(18,20,26,.92);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.12),0 4px 12px rgba(12,13,16,.16);
}
.imr-chat-mark img{width:100%;height:100%;object-fit:contain;display:block;border-radius:6px}

.imr-chat-msg{display:flex;gap:9px;align-items:flex-end;max-width:100%}
.imr-chat-msg.is-user{flex-direction:row-reverse}
.imr-chat-msg-av{
  width:30px;height:30px;border-radius:9px;flex-shrink:0;display:flex;align-items:center;justify-content:center;
  font-family:'Space Grotesk',sans-serif;font-size:9px;font-weight:800;padding:3px;
}
.imr-chat-msg.is-user .imr-chat-msg-av{background:linear-gradient(135deg,#efcf7a,#e3b262);color:#1a1206;box-shadow:none;padding:0}
.imr-chat-msg.is-ai .imr-chat-msg-av{background:rgba(18,20,26,.92);box-shadow:inset 0 0 0 1px rgba(255,255,255,.1),0 2px 8px rgba(12,13,16,.14)}
.imr-chat-bubble{
  max-width:calc(100% - 40px);padding:11px 13px;border-radius:15px;font-size:14px;line-height:1.6;
  white-space:pre-wrap;word-break:break-word;
}
.imr-chat-msg.is-ai .imr-chat-bubble{background:#fff;border:1px solid rgba(212,168,74,.18);color:var(--ink,#12141a);border-bottom-left-radius:5px}
.imr-chat-msg.is-user .imr-chat-bubble{background:linear-gradient(135deg,#efcf7a,#e3b262);color:#1a1206;border-bottom-right-radius:5px}

.imr-chat-typing{display:flex;gap:9px;align-items:center;padding:0 14px 8px;flex-shrink:0}
.imr-chat-typing[hidden]{display:none!important}
.imr-chat-typing-dots{display:flex;gap:5px;padding:11px 13px;background:#fff;border:1px solid rgba(212,168,74,.18);border-radius:15px;border-bottom-left-radius:5px}
.imr-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:rgba(212,168,74,.65);animation:imr-chat-dot 1.2s ease-in-out infinite}
.imr-chat-typing-dots span:nth-child(2){animation-delay:.15s}
.imr-chat-typing-dots span:nth-child(3){animation-delay:.3s}
@keyframes imr-chat-dot{0%,80%,100%{transform:translateY(0);opacity:.45}40%{transform:translateY(-3px);opacity:1}}

.imr-chat-foot{border-top:1px solid rgba(212,168,74,.2);padding:11px 13px 13px;background:rgba(255,250,240,.88);flex-shrink:0}
.imr-chat-form{display:flex;gap:8px;align-items:center}
.imr-chat-input{
  flex:1;min-width:0;border:1.5px solid rgba(212,168,74,.28);border-radius:13px;padding:11px 13px;
  font-family:'Manrope',sans-serif;font-size:14px;line-height:1.4;color:var(--ink,#12141a);background:#fff;outline:none;
  transition:border-color .18s ease,box-shadow .18s ease;
}
.imr-chat-input:focus{border-color:rgba(212,168,74,.65);box-shadow:0 0 0 3px rgba(227,178,98,.18)}
.imr-chat-send{
  width:44px;height:44px;border-radius:13px;border:none;cursor:pointer;flex-shrink:0;
  background:linear-gradient(135deg,#efcf7a,#e3b262);color:#1a1206;
  display:flex;align-items:center;justify-content:center;box-shadow:0 6px 16px rgba(200,147,63,.26);
  transition:transform .18s ease,opacity .18s ease;
}
.imr-chat-send:hover{transform:translateY(-1px)}
.imr-chat-send:disabled{opacity:.55;cursor:not-allowed;transform:none}
.imr-chat-send svg{width:17px;height:17px;stroke:currentColor;stroke-width:2.3;fill:none}
.imr-chat-disclaimer{margin:8px 2px 0;font-size:10px;line-height:1.45;color:rgba(26,18,6,.52)}

@media(max-width:900px){
  .imr-chat-root{
    right:max(14px,env(safe-area-inset-right,0px));
    bottom:max(14px,env(safe-area-inset-bottom,0px));
    width:min(94vw,360px);
  }
  .imr-chat-root.is-open:not(.is-positioned){
    right:max(14px,env(safe-area-inset-right,0px));
    bottom:max(14px,env(safe-area-inset-bottom,0px));
  }
  .imr-chat-minimize{display:flex}
  .imr-chat-launcher{padding:13px 15px 13px 13px}
  .imr-chat-launcher-title{font-size:15px}
  .imr-chat-launcher-sub{font-size:12px}
  .imr-chat-launcher-mark{width:42px;height:42px}
  .imr-chat-panel{
    height:min(520px,calc(100dvh - 36px));
    max-height:min(520px,calc(100dvh - 36px));
  }
  .imr-chat-root.is-open{width:min(94vw,360px)}
}

@media(prefers-reduced-motion:reduce){
  .imr-chat-launcher,.imr-chat-launcher-pulse,.imr-chat-fab,.imr-chat-fab-pulse{animation:none}
  .imr-chat-messages{scroll-behavior:auto}
}