.behtaryar-shell{
  --bt-navy:#385385;
  --bt-teal:#5aa8a1;
  --bt-assistant:#f2f8f7;
  --bt-border:#dfe8e7;
  max-width:760px;
  border:1px solid var(--bt-border);
  border-radius:24px;
  background:#fff;
  box-shadow:0 12px 38px rgba(30,55,80,.08);
  overflow:hidden;
  font-family:inherit;
}
.behtaryar-head{display:flex;gap:12px;align-items:center;padding:18px 20px;border-bottom:1px solid #edf2f1}
.behtaryar-head strong{display:block;color:var(--bt-navy);font-size:18px}
.behtaryar-head small{color:#63707c}
.behtaryar-mark{width:38px;height:38px;border-radius:13px;background:#e9f7f5;color:var(--bt-teal);display:grid;place-items:center}
.behtaryar-messages{padding:22px 20px;min-height:220px;max-height:520px;overflow:auto;background:#fbfdfd;direction:rtl}
.behtaryar-message{
  width:fit-content;
  max-width:min(82%,620px);
  padding:11px 15px;
  margin-bottom:12px;
  border-radius:18px;
  line-height:1.9;
  text-align:right;
  direction:rtl;
  overflow-wrap:anywhere;
}
/* Behtaryar = physical LEFT side, while Persian text remains RTL. */
.behtaryar-message.is-assistant{
  margin-right:auto;
  margin-left:0;
  background:var(--bt-assistant);
  color:#263742;
  border:1px solid #e1ecea;
  border-bottom-left-radius:7px;
}
/* User = physical RIGHT side. */
.behtaryar-message.is-user{
  margin-left:auto;
  margin-right:0;
  background:var(--bt-navy);
  color:#fff;
  border:1px solid rgba(0,0,0,.03);
  border-bottom-right-radius:7px;
}
.behtaryar-message.is-pending{opacity:.62;font-size:13px}
.behtaryar-form{display:flex;gap:10px;padding:14px 16px;border-top:1px solid #edf2f1;background:#fff}
.behtaryar-form textarea{flex:1;resize:vertical;min-height:52px;border:1px solid #d8e1e0;border-radius:14px;padding:10px 12px;font:inherit;text-align:right;direction:rtl;background:#fff}
.behtaryar-form textarea:focus{outline:2px solid rgba(56,83,133,.14);border-color:var(--bt-navy)}
.behtaryar-form button{border:0;border-radius:14px;padding:0 20px;background:var(--bt-teal);color:#fff;font:inherit;font-weight:700;cursor:pointer}
.behtaryar-form button:disabled{opacity:.5}
.behtaryar-note,.behtaryar-status{padding:0 18px 14px;margin:0;color:#7a858f;font-size:12px}
.behtaryar-status{color:#51626d;text-align:right}
.behtaryar-product-link{color:var(--bt-navy);font-weight:700}
.behtaryar-recommendations{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-start;direction:rtl;margin:0 20px 14px}
.behtaryar-recommendations a,.behtaryar-end-cta a{display:inline-block;padding:8px 12px;border-radius:999px;background:#e9f7f5;color:#315b61;text-decoration:none;font-weight:700}
.behtaryar-assessment-cta{margin:12px 20px 14px;padding:14px 15px;border:1px solid #d4e7e4;border-radius:15px;background:#f4fbfa;text-align:right;direction:rtl}.behtaryar-assessment-cta p{margin:0 0 11px!important;color:#455b63!important;font-size:13px!important;line-height:1.9!important}.behtaryar-assessment-cta strong{color:#244f55}.behtaryar-assessment-cta .behtaryar-assessment-link{background:#2f6f6a;color:#fff;padding:9px 15px}
.behtaryar-end-cta{margin-top:12px}.behtaryar-end-cta p{margin:0 0 10px;color:#51626d;font-size:13px;line-height:1.9}.behtaryar-selfhelps-cta{padding:0 20px 14px;text-align:right;direction:rtl}
.behtaryar-crisis-card{max-width:560px;text-align:right;direction:rtl}
.behtaryar-crisis-card p{margin:0 0 12px}
.behtaryar-crisis-link{display:inline-flex;align-items:center;justify-content:center;padding:10px 14px;border-radius:12px;background:var(--bt-navy);color:#fff!important;text-decoration:none;font-weight:750}
.behtaryar-dashboard-block{display:grid;gap:16px}
.behtaryar-member-intro{padding:18px 20px;border-radius:20px;background:linear-gradient(135deg,#eef8f7,#f7f9fd);border:1px solid #dfeae8}
.behtaryar-member-intro span{color:#4c9992;font-size:12px;font-weight:700}
.behtaryar-member-intro h3{margin:5px 0;color:#385385}
.behtaryar-member-intro p{margin:0;color:#63707c}
@media(max-width:680px){
  .behtaryar-shell{border-radius:18px}
  .behtaryar-messages{padding:18px 14px}
  .behtaryar-message{max-width:88%}
  .behtaryar-form{align-items:flex-end}
  .behtaryar-form button{height:48px;padding:0 16px}
}
.behtaryar-welcome-main{display:block}
.behtaryar-welcome-limit{display:block;margin-top:5px;color:#8a969e;font-size:11px;font-weight:400;line-height:1.6}

/* -------------------------------------------------------------------------
 * Public floating launcher — v0.5.3
 * ---------------------------------------------------------------------- */
.behtaryar-launcher{
  position:fixed;
  right:24px!important;
  left:auto!important;
  bottom:24px!important;
  z-index:99980;
  font-family:inherit;
  opacity:1!important;
  transform:none!important;
  pointer-events:auto!important;
  transition:none;
}
.behtaryar-launcher.is-visible{opacity:1!important;transform:none!important;pointer-events:auto!important}
.behtaryar-launcher [hidden]{display:none!important}
.behtaryar-launcher-prompt{
  position:relative;
  display:flex;
  align-items:stretch;
  width:min(340px,calc(100vw - 32px));
  border:1px solid rgba(56,83,133,.14);
  border-radius:20px;
  background:rgba(255,255,255,.98);
  box-shadow:0 16px 42px rgba(31,49,70,.16);
  overflow:hidden;
  direction:rtl;
}
.behtaryar-launcher-question{
  appearance:none;
  flex:1;
  border:0;
  background:transparent;
  text-align:right;
  direction:rtl;
  padding:15px 17px 14px 42px;
  cursor:pointer;
  color:#263742;
  font:inherit;
}
.behtaryar-launcher-question span{display:block;font-size:15px;font-weight:750;line-height:1.8}
.behtaryar-launcher-question small{display:block;margin-top:2px;color:#579b95;font-size:11px;font-weight:700}
.behtaryar-launcher-question:hover{background:#fbfdfd}
.behtaryar-launcher-panel{
  position:relative;
  width:min(430px,calc(100vw - 32px));
  max-height:min(720px,calc(100vh - 48px));
  border-radius:22px;
  box-shadow:0 22px 64px rgba(25,42,61,.24);
}
.behtaryar-launcher-panel .behtaryar-shell{
  width:100%;
  max-width:none;
  max-height:min(720px,calc(100vh - 48px));
  border-radius:22px;
  box-shadow:none;
}
.behtaryar-launcher-panel .behtaryar-messages{
  min-height:260px;
  max-height:min(460px,calc(100vh - 280px));
}
.behtaryar-launcher-close{
  appearance:none;
  position:absolute;
  left:12px;
  top:12px;
  z-index:5;
  width:30px;
  height:30px;
  border:1px solid #e3e9e9;
  border-radius:999px;
  background:#fff;
  color:#65727c;
  font:21px/1 Arial,sans-serif;
  cursor:pointer;
  box-shadow:0 4px 12px rgba(25,42,61,.06);
}
.behtaryar-launcher-close:hover{background:#f5f8f8;color:#263742}

@media(max-width:680px){
  .behtaryar-launcher{
    right:12px!important;
    left:auto!important;
    bottom:var(--bt-mobile-prompt-bottom,max(12px,env(safe-area-inset-bottom)))!important;
  }
  .behtaryar-launcher-prompt{width:min(340px,calc(100vw - 24px))}
  .behtaryar-launcher-panel{
    width:min(430px,calc(100vw - 24px));
    max-height:calc(100vh - 24px - env(safe-area-inset-bottom));
  }
  .behtaryar-launcher-panel .behtaryar-shell{
    max-height:calc(100vh - 24px - env(safe-area-inset-bottom));
    border-radius:20px;
  }
  .behtaryar-launcher-panel .behtaryar-messages{max-height:calc(100vh - 280px)}
}

/* -------------------------------------------------------------------------
 * Mobile keyboard / conversation viewport — v0.5.9
 * Keep the composer visible above Android/iOS virtual keyboards and make the
 * message history a true independent scroll region.
 * ---------------------------------------------------------------------- */
.behtaryar-messages{
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:contain;
  scroll-behavior:smooth;
  scrollbar-gutter:stable;
}
.behtaryar-form textarea{
  box-sizing:border-box;
  overflow-y:auto;
}

@media(max-width:680px){
  .behtaryar-form textarea{
    resize:none;
    min-height:48px;
    max-height:112px;
    line-height:1.75;
  }

  /* JS supplies --bt-vv-top/--bt-vv-height from window.visualViewport. */
  .behtaryar-launcher.is-open{
    top:var(--bt-vv-top,8px)!important;
    bottom:auto!important;
  }
  .behtaryar-launcher.is-open .behtaryar-launcher-panel{
    height:var(--bt-vv-height,calc(100dvh - 16px));
    max-height:var(--bt-vv-height,calc(100dvh - 16px));
    min-height:0;
    display:flex;
  }
  .behtaryar-launcher.is-open .behtaryar-shell{
    height:100%;
    max-height:none;
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }
  .behtaryar-launcher.is-open .behtaryar-head,
  .behtaryar-launcher.is-open .behtaryar-form,
  .behtaryar-launcher.is-open .behtaryar-status,
  .behtaryar-launcher.is-open .behtaryar-note{
    flex:0 0 auto;
  }
  .behtaryar-launcher.is-open .behtaryar-messages{
    flex:1 1 auto;
    min-height:0;
    max-height:none;
    overflow-y:auto;
    touch-action:pan-y;
    scroll-padding-bottom:18px;
  }

  /* When the keyboard consumes a large part of the visual viewport, reserve
     space for the actual conversation + composer and collapse secondary copy. */
  .behtaryar-launcher.is-keyboard-open .behtaryar-head{
    padding:10px 14px;
  }
  .behtaryar-launcher.is-keyboard-open .behtaryar-head small{
    display:none;
  }
  .behtaryar-launcher.is-keyboard-open .behtaryar-status,
  .behtaryar-launcher.is-keyboard-open .behtaryar-note{
    display:none;
  }
  .behtaryar-launcher.is-keyboard-open .behtaryar-form{
    padding:8px 10px max(8px,env(safe-area-inset-bottom));
    gap:8px;
  }
  .behtaryar-launcher.is-keyboard-open .behtaryar-form button{
    height:46px;
  }
}

/* 0.5.16 — mobile hardening only; conversation/AI/session logic unchanged. */
@media(max-width:680px){
  .behtaryar-shell{max-width:100%;border-radius:18px;-webkit-text-size-adjust:100%}
  .behtaryar-head{padding:13px 48px 13px 14px;min-height:58px}.behtaryar-head strong{font-size:16px}.behtaryar-head small{font-size:11px;line-height:1.5}
  .behtaryar-messages{padding:14px 12px;scroll-padding-bottom:22px}
  .behtaryar-message{max-width:92%;padding:10px 12px;font-size:14.5px;line-height:1.85;border-radius:16px}
  .behtaryar-message.is-pending{font-size:13px}
  .behtaryar-form{padding:9px 10px max(9px,env(safe-area-inset-bottom));gap:8px;align-items:flex-end}
  .behtaryar-form textarea{min-height:48px;max-height:120px;font-size:16px;line-height:1.65;padding:10px 11px}
  .behtaryar-form button{min-width:64px;height:48px;padding:0 14px;font-size:13px;touch-action:manipulation}
  .behtaryar-note,.behtaryar-status{font-size:11px;padding-left:12px;padding-right:12px}
  .behtaryar-assessment-cta,.behtaryar-recommendations,.behtaryar-selfhelps-cta{margin-left:12px;margin-right:12px}
  .behtaryar-assessment-cta .behtaryar-assessment-link,.behtaryar-recommendations a,.behtaryar-end-cta a,.behtaryar-crisis-link{min-height:44px;display:inline-flex;align-items:center;justify-content:center}
  .behtaryar-launcher{right:max(8px,env(safe-area-inset-right))!important}
  .behtaryar-launcher-prompt{width:calc(100vw - max(16px,env(safe-area-inset-left)) - max(16px,env(safe-area-inset-right)));max-width:360px;min-height:58px}
  .behtaryar-launcher-question{min-height:58px;padding:12px 16px 12px 48px;touch-action:manipulation}.behtaryar-launcher-question span{font-size:15px}.behtaryar-launcher-question small{font-size:11px}
  .behtaryar-launcher-panel{width:calc(100vw - max(16px,env(safe-area-inset-left)) - max(16px,env(safe-area-inset-right)));max-width:430px}
  .behtaryar-launcher-close{width:44px;height:44px;left:8px;top:8px;font-size:24px;touch-action:manipulation}
}
@media(max-width:359px){
  .behtaryar-message{max-width:94%;font-size:14px}.behtaryar-head{padding-right:44px}.behtaryar-form button{min-width:58px;padding:0 10px}
}
