
  :root{
    color-scheme: light;
    --miriam1-teal:#4ab4af;
    --miriam1-bg:#ffffff;
    --miriam1-surface:#f9f9f9;
    --miriam1-text:#222;
    --miriam1-muted:#6b7280;
    --miriam1-font:"Montserrat",system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,"Helvetica Neue",Arial,"Apple Color Emoji","Segoe UI Emoji";
    --radius:12px;
    --shadow:0 10px 30px rgba(0,0,0,.15);
  }

  #chat-bubble{
    position:fixed; inset:auto 20px 20px auto;
    width:65px; height:65px; border-radius:50%;
    display:inline-flex; align-items:center; justify-content:center;
    font-size:26px; color:#fff; background:var(--miriam1-teal);
    box-shadow:var(--shadow); z-index:9998; cursor:pointer; border:none;
    transition:transform .15s ease, box-shadow .15s ease; outline:0;
  }
  #chat-bubble:hover{
    transform:translateY(-2px);
    box-shadow:0 14px 34px rgba(0,0,0,.2);
    animation-play-state: paused;
  }
  #chat-bubble:active{ transform:translateY(0); }
  #chat-bubble .badge{
    position:absolute; top:-4px; right:-4px; min-width:20px; height:20px;
    padding:0 6px; border-radius:999px; background:#ef4444; color:#fff; font-size:12px;
    display:none; align-items:center; justify-content:center; font-weight:700; box-shadow:var(--shadow);
  }
  #chat-bubble[data-unread]:not([data-unread="0"]) .badge{ display:flex; }

  #chat-window{
    position:fixed; right:20px; bottom:95px;
    width:420px; max-width:90vw; height:620px; max-height:75vh;
    background:var(--miriam1-bg); border:1px solid #e5e7eb; border-radius:var(--radius);
    display:none; flex-direction:column; z-index:9999; box-shadow:var(--shadow); overflow:hidden;
    font-family:var(--miriam1-font);
  }
  @media (max-width: 640px){
    #chat-window{
      inset:auto 0 0 0; width:100vw; height:calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
      max-height:none; border-radius:16px 16px 0 0;
    }
  }

  #chat-header{
    background:var(--miriam1-teal);
    color:#fff; padding:12px 14px; display:flex; align-items:center; gap:10px;
  }
  #chat-header .avatar{
    width:32px; height:32px; border-radius:50%;
    background:rgba(255,255,255,.25);
    font-weight:700; font-size:16px;
    line-height:32px;
    text-align:center;
    display:block;
  }
  #chat-header .title{ font-weight:700; line-height:1.2; }
  #chat-header .subtitle{ font-size:12px; opacity:.9; }
  #chat-tools{ margin-left:auto; display:flex; gap:6px; align-items:center; }
  #chat-clear, #chat-close{
    background:transparent; border:0; color:#fff; cursor:pointer;
    font-size:18px; line-height:1; display:grid; place-items:center;
  }

  #chat-messages{
    flex:1; padding:14px; overflow:auto; background:var(--miriam1-surface); scroll-behavior:smooth;
  }
  .msg{ max-width:85%; margin:8px 0; padding:10px 14px; border-radius:18px; font-size:14px; line-height:1.5; word-wrap:break-word; }
  .msg p,.msg ul,.msg ol{ margin:0 0 10px 0; }
  .msg p:last-child{ margin:0; }
  .msg ul,.msg ol{ padding-left:20px; }
  .msg time{ display:block; margin-top:6px; font-size:11px; color:var(--miriam1-muted); }
  .msg.user{ margin-left:auto; background:#e9e9eb; color:#333; border-bottom-right-radius:6px; }
  .msg.bot{ margin-right:auto; background:var(--miriam1-teal); color:#fff; border-bottom-left-radius:6px; }
  .msg.bot a{ color:#fff; text-decoration:underline; font-weight:600; }
  .msg.bot a:hover{ text-decoration:none; }

  .typing{ display:inline-flex; gap:6px; align-items:center; }
  .dot{ width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.6; animation:blink 1s infinite; }
  .dot:nth-child(2){ animation-delay:.15s } .dot:nth-child(3){ animation-delay:.3s }
  @keyframes blink{ 0%,80%,100%{ opacity:.2 } 40%{ opacity:1 } }

  #chat-input-bar{
    display:flex; gap:8px; align-items:flex-end; padding:10px; background:var(--miriam1-bg); border-top:1px solid #e5e7eb;
  }
  #chat-input{
    flex:1; resize:none; border:1px solid #cfd4dc; border-radius:10px; padding:10px 12px; min-height:42px; max-height:120px;
    font:14px/1.4 var(--miriam1-font); box-sizing:border-box; transition:border-color .15s, box-shadow .15s;
  }
  #chat-input:focus{ outline:none; border-color:var(--miriam1-teal); box-shadow:0 0 0 .2rem rgba(74,180,175,.25); }
  #send-btn{
    height:42px; padding:0 14px; border-radius:10px; border:0; cursor:pointer; font-weight:700; color:#fff; background:var(--miriam1-teal);
    transition:filter .15s, transform .1s; display:inline-grid; place-items:center;
  }
  #send-btn:hover{ filter:brightness(1.05) }
  #send-btn:active{ transform:translateY(1px) }
  #send-btn[disabled]{ opacity:.6; cursor:not-allowed }

  .sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; white-space:nowrap; }

  @keyframes bubble-bounce {
    0%, 75%, 100% { transform: translateY(0); }
    85% { transform: translateY(-16px); }
    95% { transform: translateY(2px); }
  }

  #chat-bubble.is-animating {
    animation: bubble-bounce 4s ease-in-out infinite;
  }

  #chat-bubble .proactive-message {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background-color: var(--miriam1-bg);
    color: var(--miriam1-text);
    padding: 10px 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    visibility: hidden;
    transition: opacity .3s, transform .3s, visibility .3s;
    z-index: -1;
  }

  #chat-bubble .proactive-message::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border-width: 6px;
    border-style: solid;
    border-color: var(--miriam1-bg) transparent transparent transparent;
  }

  #chat-bubble .proactive-message.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    z-index: 9997;
  }
