/* בינה: the chat agent widget */
.bina-fab {
  position: fixed; z-index: 40; inset-inline-end: 16px; bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 18px 8px 8px; padding-inline-start: 8px;
  background: var(--ink); color: var(--cream); border: 2.5px solid var(--ink); border-radius: 999px;
  font: inherit; font-weight: 800; font-size: 16px; cursor: pointer; box-shadow: 0 6px 0 rgba(29, 26, 43, .25);
  transition: transform .2s var(--ease-out);
}
.bina-fab img { width: 40px; height: 40px; border-radius: 50%; background: var(--lime); object-fit: contain; padding: 3px; }
.bina-fab .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(200, 240, 74, .25); }
@media (hover: hover) and (pointer: fine) { .bina-fab:hover { transform: translateY(-2px); } }
.bina-fab:active { transform: scale(.97); }
.bina-fab[hidden] { display: none; }

.bina {
  position: fixed; z-index: 60; inset: 0; display: flex; flex-direction: column; background: #efe7d6;
  opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none;
  transition: opacity .22s var(--ease-out), transform .26s var(--ease-out);
}
.bina.open { opacity: 1; transform: none; pointer-events: auto; }
.bina-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--ink); color: var(--cream); }
.bina-head img { width: 42px; height: 42px; border-radius: 50%; background: var(--lime); object-fit: contain; padding: 3px; flex: none; }
.bina-head b { display: block; font-size: 18px; line-height: 1.2; }
.bina-head small { font-size: 13px; opacity: .8; }
.bina-head .bina-x { margin-inline-start: auto; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--cream); background: transparent; color: var(--cream); font-size: 24px; line-height: 1; cursor: pointer; }
.bina-log {
  flex: 1; overflow-y: auto; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 8px;
  background-image: radial-gradient(rgba(29, 26, 43, .05) 1px, transparent 1px); background-size: 18px 18px;
  overscroll-behavior: contain;
}
.msg { max-width: 84%; padding: 9px 13px 10px; border-radius: 14px; font-size: 16px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 0 rgba(29, 26, 43, .12); }
.msg a { color: inherit; font-weight: 700; }
.msg.bot { align-self: flex-start; background: #fff; border-start-start-radius: 4px; }
.msg.me { align-self: flex-end; background: #dff5a6; border-start-end-radius: 4px; }
.msg.enter { animation: msgIn .24s var(--ease-out); }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
.typing { align-self: flex-start; background: #fff; border-radius: 14px; padding: 12px 14px; display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8e8a97; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 12px 10px; }
.chips button { font: inherit; font-size: 15px; font-weight: 700; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 6px 14px; min-height: 40px; cursor: pointer; }
.handoff { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; background: #25d366; color: #0b2e17; font-weight: 800; border-radius: 999px; padding: 10px 18px; border: 2px solid #0b2e17; }
.bina-form { display: flex; gap: 8px; padding: 10px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #f6f1e6; border-top: 1px solid var(--line); }
.bina-form textarea { flex: 1; font: inherit; font-size: 16px; resize: none; max-height: 120px; min-height: 46px; padding: 11px 14px; border-radius: 22px; border: 2px solid var(--ink); background: #fff; color: var(--ink); }
.bina-form button { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--ink); background: var(--lime); font-size: 20px; font-weight: 800; cursor: pointer; }
.bina-form button:disabled { opacity: .5; }
.bina-note { font-size: 12px; color: var(--muted); text-align: center; padding: 0 12px 6px; background: #f6f1e6; }

@media (min-width: 900px) {
  .bina-fab { bottom: 24px; inset-inline-end: 24px; }
  .bina { inset: auto; inset-inline-end: 24px; bottom: 24px; width: 400px; height: min(640px, calc(100vh - 48px)); border: 2.5px solid var(--ink); border-radius: 22px; overflow: hidden; box-shadow: 0 12px 0 var(--ink); transform-origin: bottom left; }
}
@media (prefers-reduced-motion: reduce) {
  .bina, .bina-fab { transition: opacity .2s ease; transform: none; }
  .msg.enter { animation: none; }
  .typing i { animation: none; opacity: .6; }
}
