/* Messages: the round button at the bottom right and its DM popup (chat.js). */
.chatfab{position:fixed;right:max(20px,env(safe-area-inset-right,0px));bottom:calc(20px + env(safe-area-inset-bottom,0px));z-index:45;width:54px;height:54px;border-radius:50%;border:0;background:var(--ink);color:var(--accent-ink);display:grid;place-items:center;cursor:pointer;box-shadow:0 2px 6px rgba(0,0,0,.12),0 10px 28px rgba(0,0,0,.16);transition:transform .2s var(--ease,ease),box-shadow .2s}
.chatfab:hover{transform:translateY(-1px) scale(1.03)}
.chatfab:active{transform:scale(.96)}
.chatfab:focus-visible{outline:2px solid var(--ink);outline-offset:3px}
.chatbadge{position:absolute;top:-3px;right:-3px;min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;line-height:20px;text-align:center;box-shadow:0 0 0 2px var(--bg)}
/* Signed-out nudges sit where the button goes; signed in, they move up above it. */
body:has(.chatfab) .claimcard,body:has(.chatfab) .cardpop{bottom:calc(86px + env(safe-area-inset-bottom,0px))}

.chatpop{position:fixed;right:max(20px,env(safe-area-inset-right,0px));bottom:calc(86px + env(safe-area-inset-bottom,0px));z-index:46;width:390px;height:min(600px,calc(100vh - 120px));height:min(600px,calc(100dvh - 120px));display:flex;flex-direction:column;background:var(--surface);border:1px solid var(--line);border-radius:18px;box-shadow:0 2px 6px rgba(0,0,0,.05),0 18px 48px rgba(0,0,0,.14);overflow:hidden;transform-origin:calc(100% - 27px) calc(100% + 40px);animation:chatin .28s var(--ease,ease) both}
@keyframes chatin{from{opacity:0;transform:translateY(8px) scale(.97)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.chatpop{animation:none}}

.chat-head{display:flex;align-items:center;gap:10px;padding:14px 12px 10px 18px;border-bottom:1px solid var(--line)}
.chat-head h2{font-size:20px;flex:1}
.chat-ib{width:34px;height:34px;flex:none;border-radius:50%;border:0;background:none;color:var(--ink);font:inherit;font-size:20px;line-height:1;cursor:pointer;display:grid;place-items:center}
.chat-ib:hover{background:var(--sunk)}
.chat-thead{padding:10px 10px 10px 8px}
.chat-tlink{flex:1;min-width:0;display:flex;align-items:center;gap:10px;padding:4px 10px 4px 4px;border-radius:999px;color:var(--ink);text-decoration:none}
a.chat-tlink:hover{background:var(--sunk)}
a.chat-tlink:focus-visible{outline:2px solid var(--ink);outline-offset:1px}
.chat-tlink .mark{flex:none}
.chat-tlink{gap:8px}
.chat-tlink .mark+.chat-tname{margin-left:2px}
.chat-tname{font-size:16px;font-weight:600;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.chat-tabs{display:flex;border-bottom:1px solid var(--line)}
.chat-tab{flex:1;border:0;background:none;font:inherit;font-size:14px;font-weight:600;color:var(--muted);padding:12px 8px 11px;cursor:pointer;border-bottom:2px solid transparent;display:inline-flex;align-items:center;justify-content:center;gap:6px}
.chat-tab:hover{background:var(--bg)}
.chat-tab.on{color:var(--ink);border-bottom-color:var(--ink)}
.chat-n{min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--ink);color:var(--accent-ink);font-size:11px;line-height:18px}

.chat-list{flex:1;overflow-y:auto;overscroll-behavior:contain}
.chat-row{display:flex;gap:12px;align-items:flex-start;width:100%;text-align:left;border:0;background:none;font:inherit;color:var(--ink);padding:14px 18px;cursor:pointer;border-bottom:1px solid var(--line)}
.chat-row:hover{background:var(--bg)}
.chat-row .mark{flex:none}
.chat-rmain{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
.chat-rtop{display:flex;align-items:baseline;gap:6px}
.chat-rtop b{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-when{margin-left:auto;color:var(--muted);font-size:12px;flex:none}
.chat-re{font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-prev{font-size:14px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-row.unread .chat-rtop b{font-weight:700}
.chat-row.unread .chat-prev{color:var(--ink);font-weight:600}
.chat-row.unread .chat-when::before{content:"";display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--v1);margin-right:6px;vertical-align:1px}
.chat-empty{display:flex;flex-direction:column;gap:6px;padding:40px 28px;text-align:center;color:var(--muted);font-size:14px}
.chat-empty b{color:var(--ink);font-size:16px}

.chat-msgs{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:0 14px 12px;display:flex;flex-direction:column;gap:2px}
.chat-who{display:flex;flex-direction:column;align-items:center;text-align:center;gap:4px;padding:22px 10px 18px;margin:0 -14px 8px;border-bottom:1px solid var(--line)}
.chat-who .mark{margin-bottom:6px}
.chat-who b{font-size:17px;display:inline-flex;align-items:center;gap:6px}
.chat-who .muted{font-size:14px;line-height:1.4}
.chat-meta{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:6px 12px;font-size:13px;color:var(--muted);margin-top:4px}
.chat-meta a{color:var(--ink);font-weight:600}
.chat-note{font-size:12px;color:var(--gold);background:var(--gold-soft);border-radius:8px;padding:6px 10px;margin-top:8px}
.chat-day{align-self:center;font-size:12px;color:var(--muted);margin:12px 0 6px}
.chat-msg{display:flex;flex-direction:column;align-items:flex-start;max-width:82%}
.chat-msg.me{align-self:flex-end;align-items:flex-end}
.chat-bub{background:var(--sunk);color:var(--ink);padding:9px 14px;border-radius:20px 20px 20px 6px;font-size:15px;line-height:1.4;white-space:pre-wrap;overflow-wrap:anywhere}
.chat-msg.me .chat-bub{background:var(--ink);color:var(--accent-ink);border-radius:20px 20px 6px 20px}
.chat-msg.me .chat-bub a{color:inherit}
.chat-msg.end{margin-bottom:8px}
.chat-msg>time,.chat-status{font-size:11px;color:var(--muted);margin:3px 6px 0}
.chat-status.seen{color:var(--ink);font-weight:500}
/* Runs of messages from one side hug each other, like X. */
.chat-msg:not(.end) .chat-bub{border-bottom-left-radius:6px}
.chat-msg.me:not(.end) .chat-bub{border-bottom-left-radius:20px;border-bottom-right-radius:6px}

.chat-foot{border-top:1px solid var(--line);padding:10px 12px calc(12px + env(safe-area-inset-bottom,0px))}
.chat-limit{font-size:12px;color:var(--muted);margin:0 6px 8px;line-height:1.4}
.chat-limit a{color:var(--ink);font-weight:600}
.chat-limit.out{color:var(--gold);background:var(--gold-soft);border-radius:10px;padding:8px 10px;margin:0 0 10px}
.chat-compose{display:flex;gap:8px;align-items:flex-end;background:var(--sunk);border-radius:22px;padding:5px 5px 5px 16px}
.chat-compose textarea{flex:1;border:0;background:none;resize:none;font:inherit;font-size:15px;line-height:1.4;padding:7px 0;max-height:140px;color:var(--ink);outline:none;box-shadow:none;min-height:0}
.chat-compose textarea:disabled{opacity:.6}
.chat-compose .btn{flex:none}

/* Applicant cards and My applications: the Message button. */
.chatapp-cell{text-align:right}

@media (max-width:560px){
  .chatfab{width:50px;height:50px;right:16px;bottom:calc(16px + env(safe-area-inset-bottom,0px))}
  .chatpop{inset:0;width:auto;height:auto;border-radius:0;border:0;padding-top:env(safe-area-inset-top,0px);transform-origin:50% 100%}
  .chatfab.on{display:none}
  html.chat-lock,html.chat-lock body{overflow:hidden}
}
