/* v98 Messages (messages.js). Site colours only: --accent, --accent-text, --accent-rgb, --accent-ink, --surface, --surface2,
   --line, --bg, --text, --muted, so it follows light/dark theme and the chosen accent colour. Classes start msg-
   (plus .pf-n5 for the 5-item Profile sub-nav). Load after profile.css. */

/* ---------- Profile sub-nav with 5 items (Photos, Friends, Messages, Find, Account) ---------- */
.pf-n5{grid-template-columns:repeat(5,minmax(0,1fr))}
@media(max-width:419px){
  .pf-n5{gap:2px;padding:4px}
  .pf-n5 [role=tab]{font-size:11.5px;padding:4px 0;letter-spacing:-.01em}
  .pf-n5 [role=tab] svg{width:19px;height:19px}
  .pf-n5 .fr-n{right:calc(50% - 25px);min-width:17px;height:17px;font-size:10.5px;padding:0 4px}}
@media(min-width:560px) and (max-width:699px){.pf-n5 [role=tab]{gap:5px;font-size:13.5px}.pf-n5 [role=tab] svg{width:18px;height:18px}}

/* ---------- unread badge on the bottom-bar Profile tab ---------- */
.tabbar .tb-me .msg-tb-n{position:absolute;top:5px;left:calc(50% + 3px);min-width:18px;height:18px;padding:0 5px;box-sizing:border-box;border-radius:999px;
  display:grid;place-items:center;font-size:11px;font-weight:800;line-height:1;background:var(--accent);color:var(--accent-ink,#000);box-shadow:0 0 0 2px var(--bg);pointer-events:none}
@media(min-width:900px){.tabbar .tb-me .msg-tb-n{top:3px;left:24px}}

/* ---------- the Messages panel ---------- */
.pf-msgs{overflow:visible;min-height:320px}
#pfMessages{min-height:320px;display:block}
.msg-cols{display:block}
.msg-inbox{min-width:0}
.msg-ih{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px 8px}
.msg-ih h2{margin:0}
.msg-ih p{margin:2px 0 0}
.msg-new{flex:none}
.msg-list{list-style:none;margin:0;padding:0 8px 8px;display:grid;gap:2px}
.msg-row{appearance:none;width:100%;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;align-items:center;min-height:68px;padding:10px;
  border:0;border-radius:14px;background:none;color:var(--text);font:inherit;text-align:left;cursor:pointer;box-sizing:border-box;transition:background .15s}
.msg-row:hover{background:rgba(var(--accent-rgb),.08)}
.msg-row.on{background:rgba(var(--accent-rgb),.14)}
.msg-row:focus-visible{outline:3px solid var(--accent-text);outline-offset:-3px}
.msg-av.fr-av{width:48px;height:48px;font-size:18px}
.msg-rt{display:grid;min-width:0;gap:2px}
.msg-rn{display:flex;align-items:center;gap:4px;min-width:0}
.msg-rn b,.msg-rt>b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15.5px}
.msg-rp,.msg-rt small{color:var(--muted);font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.msg-rt small{font-size:13px;font-weight:600}
.msg-rp i{font-style:italic}
.msg-row.unread .msg-rn b{font-weight:900}
.msg-row.unread .msg-rp{color:var(--text);font-weight:700}
.msg-rm{display:flex;flex-direction:column;align-items:flex-end;gap:6px;font-size:12.5px;color:var(--muted);font-weight:600;white-space:nowrap}
.msg-row.unread time{color:var(--accent-text);font-weight:800}
.msg-n{min-width:22px;height:22px}
.msg-rn .fr-tick,.msg-rt small .fr-tick,.msg-rp .fr-tick{display:inline-block;flex:none;width:16px;height:16px;vertical-align:-3px;margin-left:3px}
.msg-rn .fr-tick svg,.msg-rt .fr-tick svg{width:100%;height:100%;display:block}
.msg-empty,.msg-pick,.msg-hello{display:flex;flex-direction:column;align-items:center;text-align:center;gap:10px;padding:28px 18px}
.msg-empty h3,.msg-pick h2,.msg-hello h3{margin:0;font-size:17px}
.msg-empty p,.msg-pick p,.msg-hello p{margin:0;max-width:44ch;font-size:14.5px;line-height:1.45}
.msg-empty .fr-btn{min-width:220px}
.msg-wait{padding:16px;margin:0}
.msg-pane[hidden]{display:none}

/* ---------- a conversation ---------- */
.msg-thread{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;width:100%;background:var(--surface)}
.msg-th{display:flex;align-items:center;gap:6px;padding:8px 10px;border-bottom:1px solid var(--line);background:var(--surface);flex:none}
.msg-ic.fr-btn{width:44px;min-width:44px;padding:0;flex:none;border-color:transparent;background:transparent}
.msg-ic.fr-btn:hover{background:rgba(var(--accent-rgb),.1)}
.msg-who{appearance:none;flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:10px;background:none;border:0;color:inherit;font:inherit;text-align:left;cursor:pointer;min-height:48px;border-radius:12px;padding:2px 6px}
.msg-who:focus-visible{outline:3px solid var(--accent-text);outline-offset:1px}
.msg-who .msg-av.fr-av{width:40px;height:40px;font-size:16px}
.msg-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:10px 12px 6px;background:var(--bg);-webkit-overflow-scrolling:touch}
.msg-scroll:focus-visible{outline:3px solid var(--accent-text);outline-offset:-3px}
.msg-older{display:flex;justify-content:center;margin:4px 0 8px}
.msg-ol{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:3px}
.msg-day{align-self:center;margin:10px 0 8px}
.msg-day span{display:inline-block;padding:4px 10px;border-radius:999px;background:var(--surface);border:1px solid var(--line);font-size:12px;font-weight:800;color:var(--muted)}
.msg-b{display:flex;flex-direction:column;max-width:min(80%,560px);min-width:0}
.msg-b.me{align-self:flex-end;align-items:flex-end}
.msg-b.them{align-self:flex-start;align-items:flex-start}
.msg-b.end{margin-bottom:8px}
.msg-bub{appearance:none;display:block;border:1px solid transparent;font:inherit;text-align:left;cursor:pointer;min-height:44px;padding:10px 14px;border-radius:20px;
  font-size:15.5px;line-height:1.4;max-width:100%;box-sizing:border-box;color:inherit;margin:0}
.msg-bub:focus-visible{outline:3px solid var(--accent-text);outline-offset:2px}
.me .msg-bub{background:var(--accent);color:var(--accent-ink,#000);border-bottom-right-radius:6px}
.them .msg-bub{background:var(--surface2);color:var(--text);border-color:var(--line);border-bottom-left-radius:6px}
.me:not(.end)+.me .msg-bub{border-top-right-radius:6px}
.them:not(.end)+.them .msg-bub{border-top-left-radius:6px}
.msg-tx{display:block;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}
.msg-bub.del{display:flex;align-items:center;font-style:italic;font-size:14px;color:var(--muted);background:transparent;border:1px dashed var(--line);cursor:default}
.msg-meta{font-size:12px;color:var(--muted);margin:3px 6px 0;font-weight:600}
.msg-foot{flex:none;border-top:1px solid var(--line);padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:var(--surface)}
.msg-form{display:flex;align-items:flex-end;gap:8px}
.msg-form textarea{flex:1 1 auto;min-width:0;width:auto;min-height:46px;max-height:140px;resize:none;border-radius:22px;padding:11px 16px;font:inherit;font-size:16px;line-height:1.4;
  background:var(--bg);border:1px solid var(--line);color:var(--text);box-sizing:border-box;margin:0}
.msg-form textarea:focus{outline:2px solid var(--accent-text);outline-offset:1px;border-color:transparent}
.msg-send{appearance:none;width:46px;height:46px;border-radius:50%;border:0;background:var(--accent);color:var(--accent-ink,#000);display:grid;place-items:center;flex:none;cursor:pointer;padding:0}
.msg-send svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.msg-send:disabled{opacity:.4;cursor:not-allowed}
.msg-send:focus-visible{outline:3px solid var(--accent-text);outline-offset:2px}
.msg-sub{display:flex;justify-content:space-between;align-items:baseline;gap:10px;font-size:12px;margin:6px 6px 0}
.msg-count{color:var(--muted);font-weight:700;white-space:nowrap;font-variant-numeric:tabular-nums}
.msg-count.over{color:var(--danger,#e5484d)}
.msg-serr{margin:8px 4px 0}
.msg-note{margin:0;font-size:14px;color:var(--muted);text-align:center;padding:6px 4px;line-height:1.45}
.msg-quote{white-space:pre-wrap;overflow-wrap:anywhere;padding:10px 12px;border-radius:12px;background:var(--surface2);border:1px solid var(--line);font-size:14.5px}
.msg-mfine{margin:4px 2px 0!important}
.msg-pl{margin-top:4px}
.msg-pl li{border-top:1px solid var(--line)}.msg-pl li:first-child{border-top:0}
.msg-pl .msg-row{min-height:60px}

/* phones and tablets: an open conversation fills the screen */
html.msg-lock,html.msg-lock body{overflow:hidden}
.msg-full{position:fixed;inset:0;z-index:1000;display:flex;flex-direction:column;background:var(--surface);height:100%;height:100dvh;padding-top:env(safe-area-inset-top);box-sizing:border-box}
.msg-full .msg-thread{flex:1 1 auto}
.msg-full .msg-b{max-width:84%}

/* wide screens: list on the left, conversation on the right */
@media(min-width:860px){
  .msg-cols{display:grid;grid-template-columns:minmax(280px,340px) minmax(0,1fr);height:min(720px,calc(100vh - var(--pf-top,64px) - 96px));min-height:480px}
  .msg-inbox{border-right:1px solid var(--line);overflow-y:auto}
  .msg-ih{position:sticky;top:0;background:var(--surface);z-index:1}
  .msg-pane{display:flex;min-height:0;min-width:0}
  .msg-pane .msg-backb{display:none}
  .msg-pick{margin:auto}
}
@media(prefers-reduced-motion:reduce){.msg-row{transition:none}}

/* v193 empty-state: reserved slots so Messages never looks broken/blank */
.msg-empty{min-height:280px;justify-content:flex-start;padding:20px 16px 28px;gap:12px}
.msg-empty .fr-big-ic{width:56px;height:56px;border-radius:16px;background:rgba(var(--accent-rgb),.12);display:grid;place-items:center;color:var(--accent-text,var(--accent))}
.msg-empty .fr-big-ic svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.msg-slots{list-style:none;margin:8px 0 0;padding:0;width:100%;max-width:420px;display:grid;gap:8px}
.msg-slot{
  display:grid;grid-template-columns:48px minmax(0,1fr);gap:12px;align-items:center;
  min-height:68px;padding:10px 12px;border-radius:14px;box-sizing:border-box;
  border:1px dashed var(--line,#d1d5db);background:var(--surface2,rgba(0,0,0,.03));
}
.msg-slot-av{width:48px;height:48px;border-radius:50%;background:rgba(var(--accent-rgb),.1)}
.msg-slot-lines{display:grid;gap:8px}
.msg-slot-lines i{display:block;height:10px;border-radius:6px;background:rgba(0,0,0,.08)}
html[data-theme=dark] .msg-slot-lines i{background:rgba(255,255,255,.12)}
.msg-slot-lines i:first-child{width:42%}
.msg-slot-lines i:last-child{width:72%;opacity:.7}
.msg-inbox{min-height:300px}
.msg-cols{min-height:300px}

/* v193 media / links / share */
.msg-media{display:block;max-width:min(260px,70vw);border-radius:14px;margin:4px 0;overflow:hidden;border:1px solid var(--line)}
.msg-media img,.msg-media video{display:block;width:100%;height:auto;max-height:320px;object-fit:cover;background:var(--bg)}
.msg-link{color:inherit;text-decoration:underline;word-break:break-all;font-weight:700;cursor:pointer}
.me .msg-link{color:var(--accent-ink,#000)}
.msg-attach{appearance:none;width:42px;height:42px;border-radius:50%;border:1px solid var(--line);background:var(--bg);color:var(--text);display:grid;place-items:center;flex:none;cursor:pointer;padding:0}
.msg-attach svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.msg-attach:focus-visible{outline:3px solid var(--accent-text);outline-offset:2px}
.msg-form{align-items:flex-end}
.msg-dl{appearance:none;margin-top:6px;padding:6px 10px;border-radius:999px;border:1px solid var(--line);background:var(--surface);color:var(--text);font:inherit;font-size:12px;font-weight:700;cursor:pointer}
.msg-share-row{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:4px}
.msg-req{margin:0 12px 10px;padding:12px;border-radius:14px;border:1px solid rgba(var(--accent-rgb),.35);background:rgba(var(--accent-rgb),.08)}
.msg-req p{margin:0 0 10px;font-size:14px;line-height:1.4}
.msg-req-agree{display:flex;align-items:flex-start;gap:10px;margin:0 0 12px;font-size:14px;line-height:1.35;cursor:pointer}
.msg-req-agree input{margin-top:3px;flex:none;width:18px;height:18px}
.msg-req .fr-btns{display:flex;gap:8px;flex-wrap:wrap}
.msg-req .fr-btns .fr-btn[disabled]{opacity:.45;cursor:not-allowed}
.msg-view{max-width:960px;margin:0 auto;padding:12px 12px 24px}
.msg-view-h{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}
.msg-view-h :is(h1,h2:where(.vh1)){margin:0;font-size:22px}
.msg-view #msgStandHost{min-height:420px;background:var(--surface);border:1px solid var(--line);border-radius:16px;overflow:hidden}

/* v344: visible ⋯ on your own bubbles so delete is reachable without a hidden long-press. */
.msg-own{display:flex;align-items:center;gap:4px;max-width:100%;min-width:0}
.msg-b.me .msg-own{flex-direction:row;justify-content:flex-end}
.msg-more{appearance:none;flex:none;width:36px;height:36px;margin:0;padding:0;border:0;border-radius:999px;
  background:transparent;color:var(--muted,#a0a0a0);display:grid;place-items:center;cursor:pointer;
  font:800 20px/1 system-ui,sans-serif;letter-spacing:0}
.msg-more span{display:block;transform:translateY(-2px)}
.msg-more:hover,.msg-more:focus-visible{background:var(--surface2,#161616);color:var(--text,#f5f5f5)}
.msg-more:focus-visible{outline:3px solid var(--accent-text,var(--accent));outline-offset:2px}
html[data-theme=dark] .msg-more{color:#c8c8c8}
html[data-theme=dark] .msg-more:hover,html[data-theme=dark] .msg-more:focus-visible{background:#1c1c1c;color:#f5f5f5}
