/* Guard chat, on top of the shared app.css */
.sos { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 10px; height: 56px; border-radius: 18px; background: var(--bad); color: #fff !important; font: 700 17px Inter, sans-serif; text-decoration: none !important; box-shadow: 0 10px 28px color-mix(in srgb, var(--bad) 40%, transparent); }
.sos svg.i { width: 22px; height: 22px; }
.auth { padding-bottom: 100px; }
.seg.wide { display: flex; width: 100%; margin-bottom: 18px; }
.seg.wide label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.seg.wide svg.i { width: 18px; height: 18px; }
input.code { text-align: center; font: 700 30px ui-monospace, monospace; letter-spacing: .4em; height: 64px; }

.gbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.gbar .logo { padding: 0; }
.gbar .grow { flex: 1; }
.gmain { max-width: 640px; margin: 0 auto; padding: 24px 16px 110px; }
.gmain h1 { font-size: 26px; }
.sect { font-size: 14px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin: 28px 0 10px; }
.go { color: var(--text-3); }

.chatbody { background: var(--bg); }
.chatbody #app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--bg); }
@media (min-width: 761px) { .chatbody #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.chatbar .mk { width: 34px; height: 34px; }
.chatbar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.chatbar .title strong { font: 600 16px Sora, sans-serif; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatbar .title span { font-size: 13px; color: var(--text-2); }
.sos-pill { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: 12px; background: var(--bad); color: #fff !important; font-weight: 700; text-decoration: none !important; }

.contacts { background: var(--surface); border-bottom: 1px solid var(--line); padding: 6px 16px 10px; }
.contact { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text) !important; text-decoration: none !important; }
.contact .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.contact .who small { color: var(--text-2); }
.contact .call { display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 11px; background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.contacts-foot { display: flex; align-items: center; gap: 6px; padding-top: 6px; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.welcome { margin: auto; text-align: center; color: var(--text-2); max-width: 320px; }
.welcome .big { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; background: var(--brand-soft); color: var(--brand); margin-bottom: 12px; }
.welcome .big svg.i { width: 34px; height: 34px; }
.welcome h3 { color: var(--text); font-size: 19px; margin-bottom: 4px; }
.welcome p { margin: 0; }
.msg { max-width: 82%; align-self: flex-end; background: var(--brand); color: var(--brand-ink); padding: 10px 14px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow); }
.msg.other { align-self: flex-start; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 20px 20px 20px 6px; }
.msg .tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; background: var(--bad); color: #fff; border-radius: 8px; padding: 2px 8px; margin-bottom: 6px; }
.msg img { display: block; max-width: 100%; max-height: 320px; border-radius: 14px; margin-bottom: 6px; }
.msg .meta { display: block; font-size: 11px; opacity: .75; margin-top: 4px; text-align: right; }
.msg.pending { opacity: .6; }
.msg.failed { outline: 2px solid var(--bad); }

.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.quick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line); font: 600 14px Inter, sans-serif; cursor: pointer; }
.chip svg.i { width: 18px; height: 18px; color: var(--bad); }
.chip.active { background: var(--bad); border-color: var(--bad); color: #fff; }
.chip.active svg.i { color: #fff; }
.tagrow, .photorow { display: flex; align-items: center; gap: 10px; padding: 0 0 10px; }
.photorow img { width: 52px; height: 52px; object-fit: cover; border-radius: 12px; }
.photorow select { width: auto; min-height: 44px; padding: 8px 12px; }
.send { display: flex; align-items: flex-end; gap: 8px; }
.send textarea { flex: 1; resize: none; max-height: 140px; min-height: 48px; border-radius: 16px; padding: 12px 16px; }
.camera { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--surface-2); border: 1.5px solid var(--line); color: var(--text-2); cursor: pointer; flex: none; }
.camera svg.i { width: 22px; height: 22px; }
.sendbtn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; border: 0; background: var(--brand); color: var(--brand-ink); cursor: pointer; flex: none; }
.sendbtn svg.i { width: 22px; height: 22px; }
.sendbtn:disabled { opacity: .5; }
.status { color: var(--text-2); min-height: 16px; padding-top: 4px; }
.contacts .search { display: flex; align-items: center; gap: 10px; padding: 6px 12px; margin: 6px 0 4px; border-radius: 14px; background: var(--surface-2); border: 1.5px solid var(--line); color: var(--text-3); }
.contacts .search input { border: 0; background: transparent; min-height: 40px; padding: 0; box-shadow: none !important; }
#contactList { max-height: 50vh; overflow-y: auto; }
.contact .call, .contact .msgbtn { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 12px; font: 700 14px Inter, sans-serif; text-decoration: none !important; border: 0; cursor: pointer; }
.contact .call { background: var(--ok-soft); color: var(--ok) !important; }
.contact .msgbtn { background: var(--brand-soft); color: var(--brand); }
.contact .call svg.i, .contact .msgbtn svg.i { width: 16px; height: 16px; }
.threadbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--brand-soft); border-bottom: 1px solid var(--line); }
.threadbar strong { display: block; }
.threadbar small { color: var(--text-2); }
.pinned { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--warn-soft); color: var(--text); white-space: pre-wrap; }
.pinned svg.i { color: var(--warn); margin-top: 2px; }
@media (max-width: 520px) { .contact .call, .contact .msgbtn { padding: 0 10px; } .contact .call svg.i, .contact .msgbtn svg.i { display: none; } }
.evcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; margin-bottom: 14px; color: var(--text) !important; text-decoration: none !important; box-shadow: var(--shadow); }
.evtop { display: flex; align-items: center; gap: 14px; }
.evtop .txt { flex: 1; min-width: 0; }
.evtop strong { display: block; font: 600 17px Sora, sans-serif; }
.evtop small { color: var(--text-2); }
.evwelcome { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); white-space: pre-wrap; }
.evwelcome svg.i { color: var(--warn); flex: none; margin-top: 2px; }
.chip.act { text-decoration: none !important; }
.chip.act svg.i { color: var(--brand); }
.me-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: #2EA8F0; color: #fff; font: 700 14px Sora, sans-serif; cursor: pointer; }

.msg.theirs { align-self: flex-start; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 20px 20px 20px 6px; }
.msg.ai { align-self: flex-start; background: var(--brand-soft); color: var(--text); border: 1px solid transparent; border-radius: 20px 20px 20px 6px; }
.msg .who { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.msg.ai .who { color: var(--brand); }
.msg .cards { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.msg .cards a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface); color: var(--text) !important; text-decoration: none !important; font-size: 14px; }
.msg .cards a b { color: var(--ok); }
.msg .private { display: block; padding: 18px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 13px; text-align: center; }
.chip.sop { border-color: var(--brand); color: var(--brand); }
.chip.sop svg.i { color: var(--brand); }
.typing { align-self: flex-start; color: var(--text-2); font-size: 13px; padding: 4px 8px; }
