  /* Chat widget */
  .chat{
    position:fixed;
    right:18px;
    top:calc(var(--headerH) + 22px);
    bottom:24px;
    width:440px;
    max-width:calc(100vw - 36px);
    border-radius:24px;
    overflow:hidden;
    box-shadow:var(--shadow);
    border:1px solid var(--border);
    background:rgba(253,253,251,.98);
    height:auto;
    max-height:calc(100vh - var(--headerH) - 46px);
    z-index:1200;
    opacity:0;
    transform:translateY(10px) scale(.98);
    transform-origin:bottom right;
    pointer-events:none;
    transition:opacity .16s ease, transform .16s ease;
    display:flex;
    flex-direction:column;
  }
  .chat.is-open{
    opacity:1;
    transform:translateY(0) scale(1);
    pointer-events:auto;
  }
  .chatHeader{
    background:var(--primary);
    color:#fff;
    padding:12px 14px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
  }
  .chatHeader .left{ display:flex; flex-direction:column; gap:4px; min-width:0; }
  .chatHeader .name{ font-weight:700; font-size:13px; }
  .chatHeader .sub{
    font-size:11px;
    color:rgba(255,255,255,.82);
    background:transparent;
    border:none;
    padding:0;
    display:inline-flex;
    align-items:center;
    gap:6px;
    cursor:pointer;
    text-align:left;
  }
  .chatHeader .sub[disabled]{
    cursor:default;
    opacity:.9;
  }
  .chatHeader .subCaret{
    display:none;
    font-size:16px;
    line-height:1;
    opacity:.85;
    transform:none;
  }
  .chatHeader .sub.has-caret .subCaret{
    display:inline-block;
  }
  .chatHeader .sub[aria-expanded="true"] .subCaret{
    transform:rotate(180deg);
  }
  .chatSourcePanel{
    margin-top:2px;
    border:1px solid rgba(255,255,255,.18);
    border-radius:14px;
    background:rgba(255,255,255,.08);
    padding:8px 10px;
    display:grid;
    gap:6px;
  }
  .chatSourceItem{
    font-size:11px;
    line-height:1.35;
    color:rgba(255,255,255,.92);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .chatHeader .toggle{
    background:rgba(255,255,255,.12);
    color:#fff;
    border:none;
    border-radius:12px;
    padding:6px 10px;
    cursor:pointer;
    font-weight:700;
  }
  .chatBody{
    flex:1 1 auto;
    min-height:260px;
    padding:14px;
    overflow:auto;
    background:#fbfaf7;
  }
  .bubble{
    max-width:85%;
    padding:10px 10px;
    border-radius:14px;
    margin:8px 0;
    font-size:13px;
    line-height:1.45;
    white-space:normal;
  }
  .bubbleText{
    white-space:pre-wrap;
    word-break:break-word;
    max-width:64ch;
    line-height:1.62;
  }
  .bubble.user{
    margin-left:auto;
    background:var(--accent-soft);
    border:1px solid #ead8b0;
  }
  .bubble.assistant{
    margin-right:auto;
    background:#fff;
    border:1px solid var(--border);
  }
  .typingDots{
    display:inline-flex;
    align-items:center;
    gap:5px;
    min-height:16px;
  }
  .typingDots span{
    width:6px;
    height:6px;
    border-radius:999px;
    background:#8f97a5;
    opacity:.45;
    animation:typingPulse 1s ease-in-out infinite;
  }
  .typingDots span:nth-child(2){ animation-delay:.16s; }
  .typingDots span:nth-child(3){ animation-delay:.32s; }
  .chatInput{
    display:flex;
    gap:8px;
    padding:14px;
    border-top:1px solid var(--border);
    background:var(--surface);
    align-items:center;
    flex:0 0 auto;
  }
  .chatInput textarea{
    min-height:52px;
    max-height:108px;
    flex:1 1 auto;
    width:auto;
    min-width:0;
    resize:none;
    overflow-y:auto;
    line-height:1.55;
    padding:12px 14px;
    scrollbar-width:thin;
    scrollbar-color:#b7ab8d transparent;
  }
  .chatInput .btn{
    height:42px;
    flex:0 0 74px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    white-space:nowrap;
    text-align:center;
    padding:0;
  }
  #chatSend.is-loading{
    font-size:12px;
    gap:4px;
    letter-spacing:0;
  }
  #chatSend.is-loading::after{
    width:10px;
    height:10px;
    border-width:1.5px;
  }
  .chatEmpty{
    border:1px solid var(--border);
    border-radius:20px;
    background:var(--surface);
    padding:16px 18px;
    color:var(--text);
    line-height:1.75;
  }
  .chatEmpty strong{
    display:block;
    margin-bottom:8px;
    color:var(--primary);
  }
  .chatBody{
    scrollbar-width:thin;
    scrollbar-color:#b7ab8d transparent;
  }
  .chatBody::-webkit-scrollbar,
  .chatInput textarea::-webkit-scrollbar{
    width:6px;
  }
  .chatBody::-webkit-scrollbar-track,
  .chatInput textarea::-webkit-scrollbar-track{
    background:transparent;
  }
  .chatBody::-webkit-scrollbar-thumb,
  .chatInput textarea::-webkit-scrollbar-thumb{
    background:#b7ab8d;
    border-radius:999px;
  }
  .chatBody::-webkit-scrollbar-thumb:hover,
  .chatInput textarea::-webkit-scrollbar-thumb:hover{
    background:#988a68;
  }
  .md-h{
    margin:4px 0 8px;
    font-weight:700;
    color:var(--primary);
    font-size:14px;
  }
  .md-p{
    margin:0 0 10px;
    white-space:pre-wrap;
  }
  .md-ul, .md-ol{
    margin:2px 0 10px;
    padding-left:20px;
  }
  .md-ul li, .md-ol li{
    margin:0 0 6px;
  }
  .md-ol{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  }
  .md-strong{
    font-weight:700;
  }
  .md-code{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    background:#f3f0e8;
    border:1px solid #e2dccf;
    border-radius:6px;
    padding:0 4px;
    font-size:12px;
  }
  .chatLauncher{
    position:fixed;
    right:18px;
    bottom:18px;
    width:410px;
    max-width:calc(100vw - 36px);
    height:64px;
    border:1px solid rgba(255,255,255,.08);
    border-radius:999px;
    background:var(--primary);
    color:#fff;
    cursor:pointer;
    box-shadow:var(--shadow);
    padding:0 14px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    text-align:left;
    z-index:1190;
  }
  .chatLauncher:hover{
    background:var(--primary2);
  }
  .chatLauncher .t1{
    font-size:13px;
    font-weight:700;
    line-height:1.05;
  }
  .chatLauncher .t2{
    font-size:11px;
    line-height:1.05;
    color:rgba(255,255,255,.86);
  }
  .chatLauncher .plus{
    width:34px;
    height:34px;
    border-radius:999px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:rgba(255,255,255,.12);
    font-size:22px;
    font-weight:700;
    line-height:1;
  }
  .hidden{display:none}
  @media (max-width: 1180px){
    .chat{
      right:14px;
      top:calc(var(--headerH) + 18px);
      bottom:18px;
      width:380px;
      max-height:calc(100vh - var(--headerH) - 36px);
    }
    .chatLauncher{
      right:14px;
      bottom:14px;
      width:340px;
      height:60px;
    }
  }
  @media (max-width: 768px){
    .chat{
      left:0;
      right:0;
      top:var(--headerH);
      bottom:0;
      width:100vw;
      max-width:none;
      max-height:calc(100dvh - var(--headerH));
      border-radius:0;
      border-left:none;
      border-right:none;
      border-bottom:none;
      transform:translateY(100%);
      transform-origin:center bottom;
    }
    .chat.is-open{
      transform:translateY(0);
    }
    .chatHeader{
      padding:12px 14px;
    }
    .chatHeader .left{
      min-width:0;
      flex:1 1 auto;
    }
    .chatHeader .sub{
      white-space:nowrap;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .chatSourcePanel{
      max-height:132px;
      overflow:auto;
    }
    .chatBody{
      min-height:0;
      padding:10px;
    }
    .bubble{
      max-width:92%;
    }
    .bubbleText{
      max-width:none;
      line-height:1.58;
    }
    .chatInput{
      gap:10px;
      padding:10px;
      align-items:flex-end;
    }
    .chatInput textarea{
      min-height:48px;
      max-height:132px;
      padding:10px 12px;
    }
    .chatInput .btn{
      flex:0 0 78px;
      height:44px;
    }
    .chatLauncher{
      left:12px;
      right:12px;
      bottom:12px;
      width:auto;
      max-width:none;
      height:58px;
      padding:0 12px;
      border-radius:18px;
    }
    .chatLauncher .t1{
      font-size:12px;
    }
    .chatLauncher .t2{
      font-size:10px;
    }
    .chatLauncher .plus{
      width:32px;
      height:32px;
      font-size:20px;
    }
  }
