#chat-track {
  position:fixed; z-index:9; pointer-events:none;
  inset:max(76px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(22px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));
}
#chat-launcher {
  pointer-events:auto; position:absolute; top:0; left:0; width:58px; height:58px; touch-action:none; user-select:none; cursor:grab;
  display:grid; align-content:center; justify-items:center; gap:1px; padding:0; border:2px solid white; border-radius:19px;
  background:var(--purple); color:white; font-family:inherit; box-shadow:0 5px 20px #383b4038;
}
#chat-launcher > span { pointer-events:none; line-height:1.2; font-size:11px; font-weight:650; }
#chat-launcher:active, .chat-window-bar:active { cursor:grabbing; }
.launcher-unread { position:absolute; right:-4px; top:-4px; padding:2px 5px; background:#bb3951; border-radius:20px; font-size:11px; }
body:has(#chat-window[open], #main > #chat-page) #chat-track { visibility:hidden; }
#chat-window {
  position:fixed; z-index:18; inset:auto 20px 20px auto; margin:0; padding:0;
  width:min(1030px,calc(100vw - 70px)); height:min(710px,calc(100dvh - 106px));
  max-width:none; max-height:none; overflow:hidden; border:1px solid #d3d5d9; border-radius:16px;
  color:var(--ink); background:white; box-shadow:0 20px 70px #292b2f38,0 3px 12px #26282c12;
}
#chat-window[data-edge="left"] { left:20px; right:auto; }
#chat-window[open] { display:flex; flex-direction:column; }
#chat-window::backdrop { background:#282a2d30; }
body:has(#main > #chat-page) { height:100dvh; display:flex; flex-direction:column; }
body:has(#chat-page) #header { flex:none; }
#main:has(> #chat-page) { flex:1; min-height:0; display:flex; flex-direction:column; margin:0 auto; padding:18px 0; }
#chat-page { display:flex; flex-direction:column; flex:1; min-height:0; overflow:hidden; border:1px solid var(--line); border-radius:14px; background:white; }
.chat-workspace { display:grid; flex:1; min-height:0; grid-template-columns:66px clamp(215px,25vw,280px) minmax(0,1fr); grid-template-rows:minmax(0,1fr); }
.chat-workspace [hidden] { display:none !important; }
.chat-window-bar {
  flex:0 0 35px; display:flex; align-items:center; justify-content:space-between; padding:0 7px 0 17px;
  background:#f7f7f5; border-bottom:1px solid #ebeae6; user-select:none; touch-action:none; cursor:grab;
}
.chat-window-bar > span { display:flex; align-items:center; gap:8px; font-size:12px; font-weight:620; color:#5e636d; }
.chat-window-bar > span .ic { color:var(--purple); }
.chat-icon { display:inline-grid; place-items:center; flex:none; height:34px; width:34px; padding:0; border:0; border-radius:8px; color:#545860; background:transparent; cursor:pointer; }
.chat-icon:hover, .chat-icon:focus-visible { background:#f0efec; color:var(--purple); }
.minimize-chat { height:28px; font-size:24px; line-height:1; }
.chat-rail { display:flex; align-items:center; flex-direction:column; gap:6px; padding:18px 6px; background:#f3f3f1; border-right:1px solid #e8e8e4; }
.rail-avatar { display:flex; margin-bottom:15px; }
.chat-rail button { display:grid; place-items:center; gap:3px; width:50px; padding:8px 3px; background:transparent; color:#696574; border:0; border-radius:9px; font-size:10px; cursor:pointer; }
.chat-rail button[aria-pressed=true] { background:#ebeae7; color:var(--purple); font-weight:680; }
.chat-directory { min-width:0; min-height:0; display:flex; flex-direction:column; background:#fcfcfb; border-right:1px solid #e7e6e2; }
.chat-directory > header { display:flex; align-items:center; justify-content:space-between; padding:14px 14px 9px 18px; }
.chat-directory h2, .thread-title h2 { margin:0; letter-spacing:0; font-size:19px; line-height:1.35; overflow-wrap:anywhere; }
.chat-directory header .chat-icon { background:#f2f1ee; color:#535760; width:29px; height:29px; }
.chat-sign-in { color:var(--purple); font-size:13px; }
.chat-search { display:flex; align-items:center; gap:7px; min-width:0; border-radius:7px; background:#f2f1ee; padding:0 9px; color:#797482; }
.chat-directory > .chat-search { margin:0 14px; }
.chat-search input { flex:1; min-width:0; padding:7px 0; border:0; outline:0; color:var(--ink); background:transparent; font-size:13px; }
.chat-search:focus-within { outline:2px solid #808590; outline-offset:1px; }
.chat-filters { display:flex; gap:3px; margin:10px 12px 7px; }
.chat-filters button { flex:1; padding:4px 1px; border:0; border-radius:5px; background:transparent; color:#666170; font-size:12px; cursor:pointer; }
.chat-filters button[aria-pressed=true] { color:var(--purple); font-weight:680; background:#f1f0ee; }
#conversation-list { min-height:0; flex:1; overflow:auto; margin-top:5px; padding:2px 6px 10px; overscroll-behavior:contain; }
.conversation-row { display:grid; grid-template-columns:42px minmax(0,1fr) auto; align-items:center; gap:10px; padding:10px 8px; border-radius:8px; color:var(--ink); text-decoration:none; }
.conversation-row:hover { background:#f2f2f0; }
.conversation-row.current { background:#eeedea; box-shadow:inset 3px 0 var(--purple); }
.row-avatar, .thread-face, .bubble-avatar { display:flex; }
.chat-workspace .avatar, .service-avatar, .group-face, .group-mosaic { border-radius:9px; flex:none; }
.group-face, .group-mosaic { width:var(--size); height:var(--size); overflow:hidden; background:#e7e6e1; color:#626770; display:grid; place-content:center; }
.group-mosaic { grid-template-columns:repeat(2,1fr); align-content:center; gap:1px; padding:1px; }
.group-mosaic .avatar { border-radius:3px; font-size:10px; }
.conversation-copy { display:flex; flex-direction:column; min-width:0; gap:3px; }
.conversation-copy b, .conversation-preview { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conversation-copy b { font-size:14px; font-weight:640; }
.conversation-preview { font-size:12px; color:#706b7a; }
.conversation-preview em { font-style:normal; color:#a04459; }
.row-meta { display:flex; align-self:stretch; align-items:flex-end; justify-content:space-between; flex-direction:column; color:#736d7e; font-size:10px; padding:2px 0; }
.row-meta > span { display:flex; gap:3px; align-items:center; }
.room-unread { padding:0 5px; min-width:17px; text-align:center; line-height:17px; font-size:11px; color:white; background:#b93452; border-radius:12px; }
.room-unread.muted-unread { background:#767380; }
.chat-list-empty { padding:22px 6px; text-align:center; color:var(--muted); font-size:13px; }
.chat-invite { display:grid; gap:3px; margin:5px; padding:10px; border:1px solid var(--line); border-radius:8px; font-size:13px; }
.chat-invite .btn,.greeting-actions .btn { margin-right:5px; }
.pinned-toggle { display:flex; align-items:center; gap:5px; width:100%; padding:6px 8px; border:0; background:transparent; color:var(--muted); font-size:11px; cursor:pointer; }
.pinned-toggle .ic:last-child { margin-left:auto; }
.pinned-toggle[aria-expanded=true] .ic:last-child { transform:rotate(90deg); }
.chat-thread { display:flex; flex-direction:column; min-height:0; min-width:0; position:relative; overflow:hidden; background:#f9f9f8; }
.choose-chat { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:22px; text-align:center; }
.choose-mark { display:grid; place-items:center; width:78px; height:78px; margin-bottom:16px; color:#91969f; background:#f1f0ee; border-radius:24px; }
.choose-chat h2 { font-size:18px; margin:0 0 5px; }
.choose-chat p, .chat-loading { font-size:13px; color:var(--muted); margin:0; }
.chat-loading { align-self:center; margin:auto; }
.thread-header { display:flex; align-items:center; flex:none; min-height:62px; gap:10px; padding:10px 17px; border-bottom:1px solid #e8e8e3; background:#fefefd; }
.thread-header [data-action=chat-back] { display:none; }
.thread-title { min-width:0; }
.thread-title h2 { font-size:16px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.thread-title small { display:flex; gap:6px; color:var(--muted); font-size:11px; }
.thread-title small > span+span::before { content:"·"; margin-right:6px; }
.thread-actions { margin-left:auto; display:flex; align-items:center; gap:2px; }
.thread-actions .btn { min-height:30px; padding:4px 8px; white-space:nowrap; font-size:12px; }
.thread-notices { max-height:30%; overflow:auto; }
.thread-notices:empty { display:none; }
.thread-notices > * { margin:6px 12px; padding:8px 12px; font-size:12px; }
.chat-announcement { background:#f3f2f0; border-radius:6px; }
.chat-announcement b { margin-right:6px; }
.chat-thread .chat-log { flex:1; max-height:none; min-height:0; gap:0; overflow:auto; overscroll-behavior:contain; padding:12px 19px; }
.thread-time, .thread-empty { align-self:center; font-size:11px; color:#777381; margin:6px 0 15px; }
.thread-empty { margin:auto; }
.chat-thread .bubble { display:flex; align-items:flex-start; gap:8px; padding:0; margin:0 0 6px; border-radius:0; max-width:88%; background:transparent; }
.chat-thread .bubble.own { flex-direction:row-reverse; }
.bubble-avatar { flex:none; }
.bubble-avatar .avatar { border-radius:8px; }
.bubble-body { min-width:0; display:flex; flex-direction:column; align-items:flex-start; }
.own .bubble-body { align-items:flex-end; }
.bubble-author { font-size:11px; color:var(--muted); }
.bubble-content { background:white; border:1px solid #ecebe7; border-radius:3px 10px 10px 10px; padding:7px 11px; min-width:0; max-width:100%; overflow-wrap:anywhere; }
.own .bubble-content { background:#dfefd1; border-color:#d7e8c8; border-radius:10px 3px 10px 10px; }
.bubble-content p { margin:0; white-space:pre-wrap; font-size:14px; line-height:1.65; }
.bubble-content.sticker-only { border:0; padding:0; background:transparent; }
.bubble-content .upload { max-height:190px; max-width:100%; object-fit:contain; }
.chat-star-card { display:grid; gap:5px; min-width:140px; padding:5px; }
.chat-star-card strong { font-size:1.05rem; font-variant-numeric:tabular-nums; }
.chat-star-card small { color:var(--muted); }
.chat-star-card.packet { border-left:3px solid #b84e38; padding-left:10px; }
.chat-star-tools { display:flex; gap:5px; }
.chat-tools details:not([open]) .chat-star-tools { display:none; }
.message-actions { display:flex; opacity:0; line-height:1; }
.bubble:hover .message-actions,.bubble:focus-within .message-actions { opacity:1; }
.message-actions .btn { padding:2px 3px; font-size:10px; min-height:18px; }
.chat-composer { margin:0; padding:10px 16px; background:white; border-top:1px solid #e6e5e0; flex:none; }
.chat-composer textarea { display:block; width:100%; min-height:44px; max-height:84px; resize:none; border:0; padding:2px 1px; background:transparent; font:inherit; font-size:14px; }
.chat-composer textarea:focus { outline:0; }
.chat-composer:focus-within { border-top-color:#aaaeb5; }
.composer-footer { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.chat-composer .chat-tools { position:relative; flex-wrap:nowrap; gap:3px; }
.chat-tools summary { display:flex; min-height:33px; align-items:center; gap:4px; padding:4px 6px; color:#626771; border-radius:6px; list-style:none; }
.chat-tools summary::-webkit-details-marker { display:none; }
.chat-tools summary span { font-size:11px; }
.chat-tools summary:hover,.chat-tools details[open] summary { background:#f2f1ee; color:var(--purple); }
.tool-pop { position:absolute; bottom:calc(100% + 6px); left:0; z-index:2; width:max-content; max-width:min(320px,calc(100vw - 54px)); padding:8px; border-radius:10px; border:1px solid var(--line); box-shadow:0 6px 24px #36393e22; background:white; }
.tool-pop input { max-width:100%; }
.tool-pop label { font-size:12px; }
.send-chat { padding:6px 17px; min-height:32px; font-size:13px; border-radius:7px; }
.chat-composer .form-error:empty { display:none; }
.draft-file { color:var(--purple); font-size:12px; }
.greeting-actions { padding:14px; text-align:center; background:white; }
.chat-info h3,.chat-info h4 { margin:12px 0 8px; }
.chat-members { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.history-search { display:flex; gap:8px; }
.history-search .chat-search { flex:1; }
.history-results { max-height:55dvh; overflow:auto; }
.history-results article { padding:10px 2px; border-bottom:1px solid var(--line); }
.history-results header { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:13px; }
.history-results small { color:var(--muted); }
.history-results p { margin:3px 0; white-space:pre-wrap; overflow-wrap:anywhere; }
.chat-thread .support-switch { margin:0; font-size:12px; }
.chat-thread .support-switch button { padding:6px 9px; }
.chat-thread .support-tools { background:white; }
@media (min-width:721px) and (max-width:950px) {
  .chat-workspace { grid-template-columns:54px 210px minmax(0,1fr); }
  .chat-tools summary span { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
}
@media (max-width:720px) {
  #chat-track { inset:65px 12px calc(70px + env(safe-area-inset-bottom)) 12px; }
  #chat-launcher { width:51px; height:51px; border-radius:16px; }
  #chat-window, #chat-window[data-edge="left"] { inset:0; width:100%; height:100dvh; border:0; border-radius:0; padding-top:env(safe-area-inset-top); padding-bottom:env(safe-area-inset-bottom); }
  body:has(#chat-window[open]) { overflow:hidden; }
  body:has(#chat-page) #mobile { position:static; flex:none; }
  #main:has(> #chat-page) { width:100%; padding:0; }
  #chat-page { border:0; border-radius:0; }
  .chat-workspace { grid-template-columns:54px minmax(0,1fr); }
  .chat-window-bar { flex-basis:40px; }
  .chat-rail { padding:16px 3px; }
  .chat-directory { border:0; }
  .chat-directory > header { padding-top:17px; }
  .chat-thread { display:none; }
  .chat-workspace[data-conversation=yes] .chat-rail, .chat-workspace[data-conversation=yes] .chat-directory { display:none; }
  .chat-workspace[data-conversation=yes] .chat-thread { grid-column:1/-1; display:flex; }
  .thread-header { gap:6px; padding:9px 7px; min-height:56px; }
  .thread-header [data-action=chat-back] { display:inline-grid; width:29px; }
  .thread-title h2 { font-size:15px; }
  .thread-header .chat-icon { width:29px; }
  .chat-thread .chat-log { padding:10px; }
  .message-actions { opacity:1; }
  .chat-composer { padding:8px 10px; }
}
@media (max-width:365px) {
  .thread-face { display:none; }
  .chat-tools summary { gap:2px; padding:4px; }
}
