#chat{width:min(820px,calc(100% - 32px));height:min(660px,calc(100dvh - 32px));max-height:none;padding:0;overflow:hidden;background:var(--white)}
#chat[open]{display:flex;flex-direction:column}
#chat [hidden],#chat-badge[hidden]{display:none}
.chat-top,.chat-peer,.chat-compose{display:flex;align-items:center;gap:8px}
.chat-top{padding:8px 14px 8px 18px;justify-content:space-between;border-bottom:1px solid var(--line)}
.chat-top h2{font-size:1.16rem}
.chat-layout{display:grid;grid-template-columns:minmax(205px,30%) minmax(0,1fr);min-height:0;flex:1}
#chat-people{overflow:auto;border-right:1px solid var(--line);padding:8px}
.chat-person{width:100%;display:flex;align-items:center;gap:10px;border:0;border-radius:12px;background:none;text-align:left;padding:9px 8px;min-height:60px}
.chat-person:hover,.chat-person[aria-current="true"]{background:#e6eee7}
.chat-person span:nth-child(2){flex:1;min-width:0;overflow-wrap:anywhere}
.chat-person small{display:block;font-size:.75rem}
.chat-avatar{display:grid;place-items:center;border-radius:50%;flex:0 0 38px;height:38px;background:#dcebe1;color:#215b43;font-size:.8rem;font-weight:750}
#chat-launch{display:inline-flex;align-items:center;gap:5px}
#chat-badge,.chat-unread{display:inline-grid;place-items:center;min-width:21px;height:21px;border-radius:11px;background:#23734f;color:white;font-size:.72rem;padding:0 4px;font-weight:700}
#chat-badge{background:#d9f3e3;color:#154a33}
#chat-thread{min-height:0;min-width:0;display:grid;grid-template-rows:minmax(0,1fr)}
#chat-thread-content{display:grid;grid-template-rows:auto minmax(0,1fr) auto;min-height:0}
.chat-peer{border-bottom:1px solid var(--line);min-height:55px;padding:7px 15px}
.chat-peer h3{font-size:.98rem}
.chat-peer .muted{font-size:.75rem}
#chat-back{display:none;font-size:1.7rem}
#chat-scroll{overflow:auto;overscroll-behavior:contain;padding:12px 16px;background:#f0f4ef}
#chat-empty,#chat-no-messages{text-align:center;color:var(--muted);margin:auto;padding:20px;font-size:.9rem}
.chat-older{display:block;margin:0 auto 10px;border:0;border-radius:10px;background:white;padding:0 12px;color:var(--green);font-size:.8rem}
#chat-messages{display:flex;flex-direction:column;gap:8px;min-width:0}
.chat-bubble{align-self:flex-start;max-width:min(88%,430px);min-width:0;border:1px solid #dae3dc;border-radius:3px 14px 14px;padding:8px 11px;background:white}
.chat-bubble.mine{align-self:flex-end;border-color:#cee4d4;border-radius:14px 3px 14px 14px;background:#def0e3}
.chat-bubble p{white-space:pre-wrap;overflow-wrap:anywhere;font-size:.94rem}
.chat-bubble time{display:block;text-align:right;font-size:.69rem;color:var(--muted);margin-top:4px}
.chat-attachment{display:grid;gap:4px;margin-top:5px;min-width:0}
.chat-attachment img,.chat-attachment video{display:block;max-width:100%;width:260px;max-height:230px;object-fit:contain;border-radius:8px}
.chat-attachment a{font-size:.8rem;overflow-wrap:anywhere}
#chat-form{min-width:0;border-top:1px solid var(--line);padding:8px 10px;background:white}
.chat-compose textarea{flex:1;width:0;min-height:44px;max-height:115px;resize:none;border:1px solid #cad8cc;border-radius:12px;padding:10px;background:#f6f8f5}
.chat-icon,.chat-send{display:inline-grid;place-items:center;flex:none;height:44px;width:44px;min-height:44px;border:0;border-radius:12px;background:#edf3ec;color:#1d5740;font-size:1.4rem}
.chat-send{background:#236043;color:white}
.chat-icon svg,.chat-send svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
#chat-emojis{display:grid;grid-template-columns:repeat(auto-fit,minmax(44px,1fr));gap:3px;margin-bottom:8px;max-height:136px;overflow:auto}
#chat-emojis button{min-height:44px;border:0;border-radius:10px;background:#eef3ee;font-size:1.2rem}
#chat-files{display:flex;gap:5px;overflow:auto;margin-bottom:8px}
#chat-files button{max-width:150px;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:1px solid var(--line);background:#f8faf8;border-radius:8px;padding:0 8px;font-size:.75rem}
#chat-feedback{padding:8px 14px;border-top:1px solid var(--line);background:#eef5ec;font-size:.82rem}
#chat-feedback.error{color:var(--warn);background:#fff0e9}
@media(max-width:600px){
  #chat{width:100%;max-width:100%;height:100dvh;margin:0;border-radius:0}
  .chat-layout{grid-template-columns:minmax(0,1fr)}
  #chat-people{border:0}
  #chat:not(.thread-open) #chat-thread,#chat.thread-open #chat-people{display:none}
  #chat-back{display:inline-grid}
  #chat-scroll{padding:10px}
  #chat-form{padding-bottom:max(8px,env(safe-area-inset-bottom))}
  .chat-compose{gap:5px}
}
