:root { --p: #6c47d9; --p2: #5a36c6; --pl: #f1ecff; --ink: #1d1736; --mute: #6f6a85; --line: #ece9f5; --tab: 64px; --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, Segoe UI, Roboto, sans-serif; color: var(--ink); background: #fff; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: currentColor; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--mute); }
input, select { width: 100%; padding: 14px; font-size: 16px; border: 1.5px solid var(--line); border-radius: 14px; background: #faf9fe; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--p); background: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; font-size: 16px; font-weight: 600; border: 0; border-radius: 14px; background: var(--p); color: #fff; text-decoration: none; }
.btn:active { background: var(--p2); }
.btn.big { width: 100%; padding: 16px; font-size: 17px; border-radius: 30px; margin-top: 12px; }
.btn.outline { background: #fff; color: var(--p); border: 2px solid var(--p); }
.btn.full { width: 100%; margin-top: 12px; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn.ghost { background: var(--pl); color: var(--p); }
.btn.danger { background: #fdecec; color: #c62828; }
.err { color: #c62828; min-height: 20px; margin-top: 12px; }
.hint { color: var(--mute); font-size: 13px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #ff4d5e; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-style: normal; }

/* ---------- start screens ---------- */
#login { position: fixed; inset: 0; overflow-y: auto; background: #fff; }
.screen { min-height: 100%; display: flex; flex-direction: column; }
.hero { background: linear-gradient(160deg, #7d5ae6 0%, #5a36c6 100%); color: #fff; padding: calc(48px + var(--sat)) 28px 40px; text-align: center; border-radius: 0 0 36px 36px; }
.hero h1 { margin: 18px 0 8px; font-size: 28px; letter-spacing: -.3px; }
.hero p { margin: 0 auto; max-width: 330px; font-size: 16px; line-height: 1.45; opacity: .92; }
.heroart { position: relative; width: 150px; height: 150px; margin: 0 auto; }
.heroart svg { width: 150px; height: 150px; }
.hb { position: absolute; width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,.2); }
.b1 { background: #ff7a59; left: -8px; top: 22px; } .b2 { background: #2fb67c; right: -10px; top: 8px; } .b3 { background: #2d9cdb; right: 2px; bottom: 6px; }
.welcomebtns { padding: 26px 24px calc(28px + var(--sab)); max-width: 460px; width: 100%; margin: 0 auto; }
.fine { text-align: center; color: var(--mute); font-size: 13px; margin-top: 18px; }
#formScreen { padding: calc(18px + var(--sat)) 24px calc(28px + var(--sab)); max-width: 460px; margin: 0 auto; }
#formScreen h2 { font-size: 26px; margin: 18px 0 6px; letter-spacing: -.3px; }
.back { border: 0; background: none; color: var(--p); font-size: 17px; font-weight: 600; padding: 6px 0; align-self: flex-start; }
.codeinput { font-size: 22px; letter-spacing: 4px; text-transform: uppercase; text-align: center; font-weight: 700; }
.invite { background: var(--pl); border-radius: 16px; padding: 14px; font-size: 15px; line-height: 1.45; margin-bottom: 6px; }
.invite.bad { background: #fdecec; }
.invite details { margin-top: 8px; font-size: 13px; color: var(--mute); }

/* ---------- main ---------- */
#app { position: fixed; inset: 0; overflow: hidden; }
#mapWrap, #map { position: absolute; inset: 0; }
#map { bottom: calc(var(--tab) + var(--sab)); }
.leaflet-control-attribution { font-size: 9px; }
#topbar { position: absolute; z-index: 1100; top: 0; left: 0; right: 0; padding: calc(10px + var(--sat)) 12px 10px; display: flex; align-items: center; gap: 10px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.tbright { display: flex; gap: 8px; margin-left: auto; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #fff; color: var(--p); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(30,20,70,.18); position: relative; flex: none; padding: 0; }
.round svg { width: 22px; height: 22px; }
.round .badge { position: absolute; top: -3px; right: -3px; }
.round.small { width: 40px; height: 40px; box-shadow: none; background: var(--pl); }
#circlePill { flex: 1; max-width: 230px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 4px; height: 44px; padding: 0 14px 0 18px; border-radius: 22px; border: 0; background: var(--p); color: #fff; font-size: 16px; font-weight: 700; box-shadow: 0 3px 12px rgba(90,54,198,.4); }
#circlePill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#circlePill .chev { width: 22px; height: 22px; flex: none; }
#circleMenu { position: absolute; z-index: 1200; top: calc(62px + var(--sat)); left: 50%; transform: translateX(-50%); width: min(300px, 88vw); background: #fff; border-radius: 18px; box-shadow: 0 10px 30px rgba(30,20,70,.25); padding: 8px; }
#circleMenu .cmhead { padding: 10px 12px; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
#circleMenu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px; font-size: 15px; border-radius: 12px; }
#circleMenu button:active { background: var(--pl); }
#banner { position: absolute; z-index: 1050; top: calc(64px + var(--sat)); left: 12px; right: 12px; background: #fff7e0; color: #6b4e00; padding: 9px 12px; font-size: 13px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
#historyBar { position: absolute; z-index: 1050; top: calc(64px + var(--sat)); left: 12px; right: 12px; background: #fff; padding: 8px 12px; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.18); font-size: 14px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }

/* bubble markers with a tail */
.bub { position: relative; width: 52px; height: 62px; filter: drop-shadow(0 3px 4px rgba(30,20,70,.35)); }
.bub .ring { width: 52px; height: 52px; border-radius: 50%; background: #fff; padding: 3px; position: relative; z-index: 1; }
.bub .tail { position: absolute; left: 50%; bottom: 0; width: 18px; height: 18px; margin-left: -9px; background: #fff; transform: rotate(45deg); border-radius: 3px; bottom: 6px; }
.bub.stale { opacity: .6; }
.bub.me .ring { background: var(--p); }
.av { border-radius: 50%; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; background-size: cover; background-position: center; flex: none; overflow: hidden; }
.bub .av { width: 46px; height: 46px; font-size: 19px; }

/* bottom sheet */
#sheet { position: absolute; z-index: 1000; left: 0; right: 0; bottom: calc(var(--tab) + var(--sab)); height: calc(88% - var(--tab)); background: #fff; border-radius: 22px 22px 0 0; box-shadow: 0 -4px 20px rgba(30,20,70,.15); display: flex; flex-direction: column; transition: transform .28s cubic-bezier(.2,.8,.2,1); will-change: transform; }
#sheet.dragging { transition: none; }
.sheetfloat { position: absolute; top: -62px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.sheetfloat > * { pointer-events: auto; }
.round.light { color: var(--ink); }
.fab { display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px 0 14px; border: 0; border-radius: 23px; background: var(--p); color: #fff; font-size: 16px; font-weight: 700; box-shadow: 0 4px 14px rgba(90,54,198,.45); }
.fab svg { width: 22px; height: 22px; }
.grab { padding: 8px 18px 6px; touch-action: none; cursor: grab; flex: none; }
.handle { width: 40px; height: 5px; border-radius: 3px; background: #d9d5e6; margin: 0 auto 10px; }
.sheettitle { display: flex; align-items: baseline; justify-content: space-between; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.sheetbody { flex: 1; overflow-y: auto; padding: 0 0 24px; -webkit-overflow-scrolling: touch; }
.mrow { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border: 0; background: none; width: 100%; text-align: left; }
.mrow:active { background: #faf9fe; }
.mrow .av { width: 52px; height: 52px; font-size: 20px; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c, #ccc); }
.mrow .main { flex: 1; min-width: 0; }
.mrow .nm { font-size: 17px; font-weight: 700; }
.mrow .pl { font-size: 14px; color: var(--ink); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow .sn { font-size: 13px; color: var(--mute); margin-top: 1px; }
.bat { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--mute); font-weight: 600; flex: none; }
.bat i { width: 22px; height: 11px; border: 1.5px solid currentColor; border-radius: 3px; position: relative; display: inline-block; }
.bat i::after { content: ''; position: absolute; right: -4px; top: 2.5px; width: 2px; height: 4px; background: currentColor; border-radius: 1px; }
.bat i b { position: absolute; left: 1px; top: 1px; bottom: 1px; background: #2fb67c; border-radius: 1px; }
.bat.low { color: #e5484d; } .bat.low i b { background: #e5484d; }
.mactions { display: flex; gap: 8px; padding: 0 18px 12px 84px; }
.addrow { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 12px 18px; text-align: left; font-size: 16px; }
.addic { width: 52px; height: 52px; border-radius: 50%; background: var(--pl); color: var(--p); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; flex: none; }
.addrow b { color: var(--p); }
.sectionhead { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 6px; font-size: 18px; font-weight: 700; border-top: 8px solid #f6f5fa; margin-top: 8px; }
.link { border: 0; background: none; color: var(--p); font-weight: 600; font-size: 15px; }
#placeForm { padding: 6px 18px 10px; }
.rowf { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.rowf select { width: auto; padding: 8px; font-size: 14px; }
.prow { display: flex; align-items: center; gap: 14px; padding: 10px 18px; }
.pic { width: 44px; height: 44px; border-radius: 50%; background: var(--pl); color: var(--p); display: flex; align-items: center; justify-content: center; flex: none; }
.pic svg { width: 22px; height: 22px; }
.prow .main { flex: 1; } .prow .sub { font-size: 13px; color: var(--mute); }

/* pages */
.page { position: absolute; z-index: 1150; top: 0; left: 0; right: 0; bottom: calc(var(--tab) + var(--sab)); background: #fff; display: flex; flex-direction: column; padding-top: calc(66px + var(--sat)); }
.pagehead { font-size: 28px; font-weight: 800; letter-spacing: -.4px; padding: 4px 18px 8px; }
.pagebody { flex: 1; overflow-y: auto; padding: 0 16px 20px; }
.card { background: #faf9fe; border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.card p { margin: 6px 0 0; }
.profile { display: flex; gap: 14px; align-items: center; }
.profile .av { width: 64px; height: 64px; font-size: 26px; }
.ev { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.ev .av { width: 40px; height: 40px; font-size: 16px; }
.ev .sub { color: var(--mute); font-size: 12px; margin-top: 2px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 8px; flex: none; }
.chip { flex: none; border: 0; background: var(--pl); color: var(--p); padding: 8px 14px; border-radius: 18px; font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.chip.active { background: var(--p); color: #fff; }
#chatList { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px 14px; }
.msg { max-width: 78%; align-self: flex-start; background: #f2f1f7; border-radius: 18px 18px 18px 6px; padding: 9px 13px; font-size: 15px; word-wrap: break-word; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--p); color: #fff; border-radius: 18px 18px 6px 18px; }
.msg .who { font-size: 12px; font-weight: 700; margin-bottom: 2px; color: var(--p); }
.msg .meta { font-size: 11px; opacity: .7; margin-top: 3px; }
.msg .locbtns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.msg .locbtns a, .msg .locbtns button { font-size: 13px; padding: 5px 10px; border-radius: 10px; border: 0; background: #fff; color: var(--p); text-decoration: none; font-weight: 600; }
.daysep { align-self: center; font-size: 11px; color: var(--mute); margin: 6px 0; }
#chatForm { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); align-items: center; }
#chatForm input { flex: 1; padding: 11px 14px; border-radius: 22px; }

/* tab bar */
#tabbar { position: absolute; z-index: 1300; left: 0; right: 0; bottom: 0; height: calc(var(--tab) + var(--sab)); padding-bottom: var(--sab); background: #fff; border-top: 1px solid var(--line); display: flex; }
#tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #a29db5; font-size: 11px; font-weight: 600; position: relative; }
#tabbar button svg { width: 26px; height: 26px; }
#tabbar button.active { color: var(--p); }
#tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

/* invite modal */
.modal { position: fixed; inset: 0; background: rgba(20,12,50,.45); z-index: 2000; display: flex; align-items: flex-end; justify-content: center; }
.msheet { background: #fff; width: 100%; max-width: 460px; border-radius: 24px 24px 0 0; padding: 10px 20px calc(18px + var(--sab)); text-align: center; max-height: 94vh; overflow-y: auto; }
.msheet h2 { margin: 4px 0 4px; font-size: 21px; }
.modal img.bigqr { width: min(250px, 66vw); height: auto; aspect-ratio: 1; margin: 6px auto 8px; display: block; border-radius: 14px; border: 1px solid var(--line); }
.modal input { margin: 12px 0 0; font-size: 14px; text-align: center; }
.modal .grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 8px 0; }
.modal .btn.small { margin-top: 6px; }
#updateToast { position: fixed; z-index: 3000; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; }
@media (min-width: 760px) { #sheet { left: 16px; right: auto; width: 400px; } }

#setup { position: fixed; inset: 0; overflow-y: auto; background: #fff; z-index: 2500; }
.setuph { font-size: 26px; margin: 18px 0 6px; letter-spacing: -.3px; }
#setup .card { margin-top: 14px; } #setup .card form .btn.big { margin-top: 16px; }
#setup details { margin-top: 12px; font-size: 14px; color: var(--mute); } #setup summary { color: var(--p); font-weight: 600; cursor: pointer; }
.cmc { display: flex !important; align-items: center; gap: 10px; }
.cmc .ck { margin-left: auto; color: var(--p); font-weight: 800; }
.cmc .ci { width: 34px; height: 34px; border-radius: 50%; background: var(--pl); color: var(--p); font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.cmsep { height: 1px; background: var(--line); margin: 4px 0; }
.legacybar { margin: 4px 18px 10px; padding: 12px 14px; background: var(--pl); border-radius: 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.legacybar button { flex: none; }

/* ---- motion & smoothness ---- */
#sheet { transform: translate3d(0,0,0); backface-visibility: hidden; transition: transform .32s cubic-bezier(.22,1,.36,1), opacity .18s ease; }
#sheet.away { opacity: 0; pointer-events: none; transform: translate3d(0,60px,0) !important; }
#grab { touch-action: none; cursor: grab; }
#memberList, .page { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.page.enter { animation: pageIn .2s cubic-bezier(.22,1,.36,1); }
@keyframes pageIn { from { opacity: 0; transform: translate3d(0,14px,0); } to { opacity: 1; transform: none; } }
.btn, .round, #fabInvite, #fabFit, #circlePill, #tabbar button, .chip, #topbar button { transition: transform .12s ease, opacity .12s ease, background-color .15s; will-change: transform; -webkit-tap-highlight-color: transparent; }
.btn:active, .round:active, #fabInvite:active, #fabFit:active, #circlePill:active, #topbar button:active, .chip:active { transform: scale(.94); opacity: .85; }
#tabbar button:active svg { transform: scale(.88); }
#tabbar button svg { transition: transform .12s ease; }
.mrow { transition: background-color .15s; }
.mactions { animation: pageIn .18s ease; }
#circleMenu:not(.hidden) { animation: menuIn .16s cubic-bezier(.22,1,.36,1); transform-origin: top center; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.leaflet-marker-icon { will-change: transform; }
.skel { display: flex; gap: 14px; align-items: center; padding: 12px 18px; }
.skel i { display: block; background: #ece8f7; border-radius: 8px; height: 13px; width: 120px; margin: 6px 0; animation: shim 1.2s ease-in-out infinite; }
.skel i.c { width: 52px; height: 52px; border-radius: 50%; margin: 0; flex: none; }
.skel i.w { width: 180px; height: 11px; }
@keyframes shim { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- map style picker ---- */
.fabgroup { display: flex; gap: 10px; }
#layersPanel { position: absolute; z-index: 1300; left: 12px; right: 12px; bottom: calc(var(--tab) + var(--sab) + 12px); background: #fff; border-radius: 20px; padding: 16px; box-shadow: 0 8px 30px rgba(30,20,70,.25); animation: pageIn .2s cubic-bezier(.22,1,.36,1); }
@media (min-width: 760px) { #layersPanel { right: auto; width: 376px; left: 16px; } }
.lphead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 18px; }
.lphead button { border: 0; background: none; font-size: 20px; color: var(--mute); }
.lpgrid { display: flex; justify-content: space-between; gap: 6px; }
.lpgrid button { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); width: 62px; transition: transform .12s; }
.lpgrid button:active { transform: scale(.94); }
.lpgrid img { width: 58px; height: 58px; border-radius: 14px; border: 3px solid transparent; object-fit: cover; display: block; }
.lpgrid button.on img { border-color: var(--p); }
.lpgrid button.on { color: var(--p); font-weight: 700; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-top.leaflet-right { top: calc(62px + var(--sat, 0px)); }

/* ---- Messenger-style chat ---- */
#page-chat { padding-top: calc(66px + var(--sat)); }
body.in-room #topbar, body.in-room #circleMenu { display: none !important; }
body.in-room #page-chat { padding-top: var(--sat); }
#chatHome, #chatRoom { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#convoList { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.crow { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 9px 16px; text-align: left; transition: background-color .15s; }
.crow:active { background: var(--soft); }
.crow .av { width: 56px; height: 56px; font-size: 22px; flex: none; }
.cm { flex: 1; min-width: 0; } .cn { font-size: 16px; font-weight: 600; } .cp { font-size: 14px; color: var(--mute); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow.unread .cn { font-weight: 800; } .crow.unread .cp { color: var(--ink); font-weight: 700; }
.cp .typ { color: var(--p); }
.ub { font-style: normal; min-width: 22px; height: 22px; border-radius: 11px; background: var(--p); color: #fff; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.gav { position: relative; flex: none; } .gav .av { position: absolute; width: 68% !important; height: 68% !important; font-size: 15px !important; }
.gav .av:first-child { top: 0; right: 0; } .gav .av:last-child { bottom: 0; left: 0; box-shadow: 0 0 0 2px #fff; }
.chead { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #e6e2f0; flex: none; }
.chead button { border: 0; background: none; padding: 4px; display: flex; } .chead button svg { width: 28px; height: 28px; fill: var(--p); }
.chead .av { width: 38px; height: 38px; font-size: 16px; }
.cht { display: flex; flex-direction: column; min-width: 0; flex: 1; } .cht b { font-size: 17px; } .cht span { font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatList { flex: 1; overflow-y: auto; display: block; padding: 10px 10px 6px; overscroll-behavior: contain; }
.tsep { text-align: center; font-size: 12px; color: #8c87a0; font-weight: 600; margin: 12px 0 6px; }
.sname { font-size: 12px; color: var(--mute); margin: 6px 0 2px 46px; }
.mrow2 { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; animation: pop .18s ease-out; }
.mrow2.first { margin-top: 8px; } .mrow2.mine { justify-content: flex-end; } .mrow2.hasrx { margin-bottom: 14px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sav { width: 28px; flex: none; } .sav .av { width: 28px; height: 28px; font-size: 12px; }
.bwrap { max-width: 76%; position: relative; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .12s; }
.bwrap:active { transform: scale(.98); }
.mine .bwrap { align-items: flex-end; }
.cbub { background: #efedf5; color: var(--ink); padding: 8px 13px; font-size: 16px; line-height: 1.32; white-space: pre-wrap; word-wrap: break-word; border-radius: 20px; }
.mine .cbub { background: var(--p); color: #fff; }
.mrow2:not(.mine) .cbub, .mrow2:not(.mine) .bimg { border-top-left-radius: 5px; border-bottom-left-radius: 5px; }
.mrow2.mine .cbub, .mrow2.mine .bimg { border-top-right-radius: 5px; border-bottom-right-radius: 5px; }
.mrow2:not(.mine).first .cbub, .mrow2:not(.mine).first .bimg { border-top-left-radius: 20px; } .mrow2:not(.mine).last .cbub, .mrow2:not(.mine).last .bimg { border-bottom-left-radius: 20px; }
.mrow2.mine.first .cbub, .mrow2.mine.first .bimg { border-top-right-radius: 20px; } .mrow2.mine.last .cbub, .mrow2.mine.last .bimg { border-bottom-right-radius: 20px; }
.bimg { width: 220px; max-width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 20px; background: #eee; margin-bottom: 2px; cursor: zoom-in; }
.quote { background: #f6f5fa; border-radius: 14px; padding: 6px 11px 14px; margin-bottom: -10px; font-size: 14px; color: #5f5a73; max-width: 100%; }
.quote small { display: block; font-size: 12px; color: var(--mute); } .quote div { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cbub .locbtns { display: flex; gap: 6px; margin-top: 8px; } .cbub .locbtns a, .cbub .locbtns button { font-size: 13px; padding: 5px 10px; border-radius: 12px; border: 0; background: #fff; color: var(--p); text-decoration: none; font-weight: 600; }
.rx { position: absolute; bottom: -15px; left: 8px; background: #fff; border-radius: 12px; padding: 1px 6px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.18); white-space: nowrap; }
.mine .rx { left: auto; right: 8px; } .rx small { font-size: 11px; color: var(--mute); margin: 0 2px; }
.seen { display: flex; justify-content: flex-end; align-items: center; gap: 2px; margin-top: 3px; }
.seen .av { width: 15px; height: 15px; font-size: 8px; } .seen span { font-size: 11px; color: var(--mute); margin-right: 4px; }
.dots { display: flex; gap: 4px; background: #efedf5; padding: 13px 14px; border-radius: 20px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #8c87a0; animation: dot 1.1s infinite ease-in-out; } .dots i:nth-child(2) { animation-delay: .16s; } .dots i:nth-child(3) { animation-delay: .32s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.cempty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 30px; } .cempty .av, .cempty .gav { width: 72px; height: 72px; font-size: 28px; } .cempty span { color: var(--mute); font-size: 13px; }
#replyBar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--soft); border-top: 1px solid #e6e2f0; flex: none; }
#replyBar.hidden { display: none; }
.rbq { flex: 1; border-left: 3px solid var(--p); padding-left: 10px; min-width: 0; } .rbq b { display: block; color: var(--p); font-size: 13px; } .rbq span { display: block; color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#replyBar button { border: 0; background: none; font-size: 18px; color: var(--mute); }
#chatForm { display: flex; align-items: flex-end; gap: 4px; padding: 7px 8px; border-top: 1px solid #e6e2f0; flex: none; background: #fff; }
.cbtn { width: 38px; height: 38px; border: 0; background: none; display: flex; align-items: center; justify-content: center; flex: none; padding: 0; transition: transform .12s, opacity .15s; }
.cbtn:active { transform: scale(.88); } .cbtn svg { width: 24px; height: 24px; fill: var(--p); } .cbtn:disabled { opacity: .35; }
#chatText { flex: 1; resize: none; border: 0; background: #f1f0f6; border-radius: 20px; padding: 9px 14px; font: inherit; font-size: 16px; line-height: 20px; max-height: 120px; min-height: 38px; outline: none; }
#reactMenu { position: fixed; inset: 0; z-index: 3000; background: rgba(20,14,40,.55); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadein .15s; }
#reactMenu.hidden { display: none; }
@keyframes fadein { from { opacity: 0; } }
.rmbox { display: flex; flex-direction: column; align-items: center; gap: 12px; animation: menuIn .18s cubic-bezier(.22,1,.36,1); }
.emojibar { display: flex; gap: 2px; background: #fff; border-radius: 30px; padding: 4px 6px; }
.emojibar button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: none; font-size: 28px; transition: transform .12s; } .emojibar button:active { transform: scale(1.25); } .emojibar button.on { background: var(--pl); }
.rmprev { background: #fff; border-radius: 18px; padding: 14px; max-width: 300px; font-size: 15px; white-space: pre-wrap; max-height: 120px; overflow: hidden; }
.rmcard { background: #fff; border-radius: 16px; min-width: 220px; overflow: hidden; } .rmcard button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 14px 18px; font-size: 16px; font-weight: 600; } .rmcard button + button { color: var(--mute); border-top: 1px solid var(--line); }
#photoViewer { position: fixed; inset: 0; z-index: 3100; background: #000; display: flex; align-items: center; justify-content: center; } #photoViewer.hidden { display: none; } #photoViewer img { max-width: 100%; max-height: 90%; }

/* ---- roles, profile sheet, reaction affordances ---- */
.rbadge { display: inline-block; font-size: 10px; font-weight: 800; color: var(--p); background: var(--pl); padding: 2px 7px; border-radius: 8px; vertical-align: 2px; letter-spacing: .3px; }
.rbadge.own { background: var(--p); color: #fff; }
#profileModal { position: fixed; inset: 0; z-index: 2500; } #profileModal.hidden { display: none; }
.pmback { position: absolute; inset: 0; background: rgba(20,14,40,.35); animation: fadein .15s; }
.pmsheet { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 24px 24px 0 0; padding: 8px 20px calc(16px + var(--sab)); max-height: 85%; overflow-y: auto; animation: sheetUp .26s cubic-bezier(.22,1,.36,1); }
@media (min-width: 760px) { .pmsheet { left: 16px; right: auto; width: 400px; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.pmsheet .handle { margin: 0 auto 14px; }
.phead { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 14px; text-align: center; }
.phead .av { width: 84px; height: 84px; font-size: 34px; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c, #ccc); }
.pname { font-size: 22px; font-weight: 800; }
.pacts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.psec { font-size: 13px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .5px; margin: 8px 0 4px; }
.prow { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid #ece9f5; background: none; padding: 12px 4px; }
.prow b { display: block; font-size: 16px; font-weight: 600; } .prow span { display: block; font-size: 13px; color: var(--mute); margin-top: 2px; }
.prow.danger b { color: #e5484d; } .prow:active { background: var(--soft); }
.rx { border: 0; cursor: pointer; font: inherit; display: inline-flex; gap: 2px; align-items: center; padding: 2px 7px; font-size: 14px; }
.rx small { font-size: 12px; font-weight: 700; color: var(--mute); margin-left: 2px; }
.rbtn { opacity: 0; border: 0; background: #f1f0f6; color: var(--mute); width: 28px; height: 28px; border-radius: 50%; font-size: 15px; flex: none; align-self: center; transition: opacity .15s; cursor: pointer; }
.mrow2.mine .rbtn { order: -1; }
@media (hover: hover) { .mrow2:hover .rbtn { opacity: 1; } }
@media (hover: none) { .rbtn { display: none; } }
.heartpop { position: absolute; left: 50%; top: 50%; font-size: 34px; pointer-events: none; transform: translate(-50%, -50%) scale(.4); animation: heart .7s ease-out forwards; }
@keyframes heart { 30% { transform: translate(-50%, -50%) scale(1.25); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* ---- safety ---- */
.sosbtn { background: #e5484d !important; color: #fff !important; font-weight: 900; font-size: 13px; }
#alerts { position: absolute; z-index: 1200; top: calc(64px + var(--sat)); left: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
@media (min-width: 760px) { #alerts { right: auto; width: 400px; left: 16px; } }
.alert { pointer-events: auto; color: #fff; border-radius: 16px; padding: 14px; font-weight: 700; font-size: 15px; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: menuIn .25s cubic-bezier(.22,1,.36,1); }
.alert .arow { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.alert button { border: 0; background: #fff; color: inherit; border-radius: 14px; padding: 6px 12px; font-weight: 700; font-size: 14px; color: #333; }
.alert button.ghost { background: rgba(255,255,255,.25); color: #fff; }
#sosModal { position: fixed; inset: 0; z-index: 4000; background: rgba(170,20,30,.96); display: flex; align-items: center; justify-content: center; padding: 28px; text-align: center; color: #fff; animation: fadein .15s; }
#sosModal.hidden { display: none; }
#sosModal h2 { font-size: 28px; font-weight: 900; margin: 0; } #sosModal p { color: #ffe3e3; font-size: 16px; line-height: 1.4; max-width: 340px; margin: 10px auto 0; }
#sosHold { position: relative; width: 230px; height: 230px; border: 0; background: none; margin: 30px auto; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#sosHold .ring { position: absolute; inset: 0; border-radius: 50%; background: rgba(255,255,255,.35); transform: scale(.62); opacity: .35; transition: transform .2s, opacity .2s; }
#sosHold.holding .ring { transform: scale(1); opacity: 1; transition: transform 3s linear, opacity 3s linear; }
#sosHold b, #sosHold small { position: relative; } #sosHold::before { content: ''; position: absolute; width: 150px; height: 150px; border-radius: 50%; background: #e5484d; border: 4px solid #fff; box-sizing: border-box; }
#sosHold b { font-size: 34px; font-weight: 900; } #sosHold small { color: #ffd6d6; font-weight: 600; }
.sosx { display: block; margin: 10px auto 0; border: 0; background: none; color: #fff; font-size: 17px; font-weight: 700; padding: 14px 40px; border-radius: 28px; }
.sosx.white { background: #fff; color: #e5484d; } .sosx.green { color: #2fb67c; margin-top: 24px; }
.sosn { font-size: 96px; font-weight: 900; margin: 20px 0; }
.srow { display: flex; align-items: center; gap: 10px; padding: 10px 0; } .srow span { flex: 1; } .srow b { display: block; font-size: 15px; } .srow small { display: block; color: var(--mute); font-size: 13px; margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: #ddd; position: relative; flex: none; transition: background .2s; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--p); } .switch:checked::after { transform: translateX(20px); } .switch:disabled { opacity: .5; }
.schips { display: flex; gap: 6px; flex-wrap: wrap; margin: -2px 0 8px; }

/* calling */
.contact { display: flex; gap: 10px; justify-content: center; margin: 4px 0 4px; }
.cbt { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; padding: 9px 6px; border-radius: 14px; background: #f1edfb; color: var(--p); font-size: 12px; font-weight: 600; text-decoration: none; }
.cbt svg { width: 22px; height: 22px; fill: currentColor; }
.cbt.off { opacity: .38; cursor: not-allowed; }
.hint.ctr { text-align: center; margin: 0 0 10px; }
.ccall { margin-left: auto; display: flex; gap: 6px; }
.ccall .cbt { min-width: 0; padding: 8px; border-radius: 50%; background: none; }
#phoneModal { position: fixed; inset: 0; z-index: 2600; } #phoneModal.hidden { display: none; } #phoneModal .pmback { position: absolute; inset: 0; background: rgba(20,16,40,.35); }
.err { color: #c62828; min-height: 1em; }
