/* Additive, WhatsApp-like messenger refinement. Original style-v44.css and social-v1.css untouched. */
.msg-screen{top:var(--app-top,0px);overflow:clip;background:linear-gradient(180deg,rgba(10,14,26,.97),rgba(12,18,33,.98))}
.msg-screen .msg-header{background:#151d2c;border-bottom:1px solid rgba(255,255,255,.09);padding:10px 12px}
.msg-screen .msg-title strong{font-weight:750;font-size:16px}
.msg-screen .msg-list{background:linear-gradient(145deg,rgba(17,26,38,.96),rgba(12,20,31,.98));gap:4px;padding:13px 12px 17px}
.msg-screen .msg-list .bubble{width:fit-content;max-width:min(82%,400px);padding:7px 9px 5px;border-radius:11px;position:relative;background:#243245;color:#f9fbff;font-size:14px;line-height:1.45;box-shadow:0 2px 5px rgba(0,0,0,.18);overflow-wrap:anywhere;white-space:normal}
.msg-screen .msg-list .bubble.theirs{align-self:flex-start;border-top-left-radius:3px}
.msg-screen .msg-list .bubble.mine{align-self:flex-end;background:#23544b;border-top-right-radius:3px;border-bottom-right-radius:11px}
.msg-screen .msg-list .bubble-text{padding:0;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;font-size:14px;line-height:1.45}
.msg-screen .msg-list .bubble-meta{margin-top:1px;display:flex;gap:4px;align-items:center;justify-content:flex-end;opacity:.82;min-height:14px}
.msg-screen .msg-list .bubble-meta time{font-size:10px;line-height:12px;letter-spacing:.08px;opacity:.9;margin:0;display:inline-block}
.msg-screen .msg-list .bubble-meta .chat-receipt{margin:0 2px 0 4px;font-size:12px;letter-spacing:-2px;color:#c3c8cf}
.msg-screen .msg-list .bubble-meta .chat-receipt.read{color:#6dc8ff}
.msg-screen .msg-list .bubble-meta .chat-reply-action{font-size:13px;padding:0 3px;opacity:.75}
.msg-screen .msg-composer{background:#141e2c;gap:7px;border-top:1px solid #354257;padding:7px 9px calc(7px + env(safe-area-inset-bottom))}
.msg-screen .msg-composer input{border-radius:25px;background:#26344a;border:1px solid #415067;padding:11px 15px;color:#f8fafc}
.msg-screen .msg-composer .btn{border-radius:50%;width:44px;height:44px;min-width:44px;padding:0;display:grid;place-items:center;background:#26a874;font-size:22px}
.msg-screen .chat-tools{justify-content:space-around;gap:6px;flex-wrap:nowrap;padding:7px 8px;background:#141e2c;border-top:1px solid #354257}
body.kb-open.msg-mode .msg-screen:not(.reading-history) .chat-tools{display:flex}
.msg-screen .chat-tools button{flex:1;min-width:0;max-width:140px;padding:8px 3px;border-radius:16px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:#253348}
.msg-screen .chat-tools [data-action="chat-block-toggle"]{background:#482e36;color:#ffb5c0;max-width:120px}
.msg-screen .chat-tools [data-action="chat-block-toggle"].is-blocked{background:#184c3d;color:#b7f1cf}
.msg-screen .chat-open-media{font-size:13px;border:0;background:rgba(255,255,255,.06);padding:11px 14px;min-width:160px;border-radius:12px;text-align:left;margin:4px 0;color:#e8f9ff}
.msg-screen .chat-photo-preview{width:min(100%,290px);max-height:350px;border-radius:10px;object-fit:cover;cursor:zoom-in}
.msg-screen .chat-voice-player{width:240px;max-width:100%;height:42px;filter:brightness(1.2)}
.msg-screen .chat-reply-compose{border-left:3px solid #26a874;background:#1d2a3b}
.chat-blocked-notice{font-size:12px;line-height:1.4;padding:11px 14px;text-align:center;color:#ffceba;background:#403238;border-top:1px solid rgba(255,255,255,.1)}
.chat-composer-status{padding:6px 12px;text-align:center;font-size:12px;color:var(--muted)}
.msg-screen[data-chat-id] [hidden],
.msg-screen[data-can-reply="0"] .chat-reply-action,
.msg-screen[data-requires-payment="1"] #chat-selection-bar,
.msg-screen[data-requires-payment="1"] #chat-history-pages,
.reading-history .chat-composer-status,
.reading-history .chat-reply-action{display:none!important}
.chat-media-draft{padding:11px 13px;display:grid;gap:9px;background:#192839;border-top:1px solid #385067}
.chat-media-draft[hidden]{display:none!important}
.chat-media-preview{display:flex;align-items:center;gap:12px;min-width:0}
.chat-media-preview img{width:90px;height:90px;object-fit:cover;border-radius:12px}
.chat-media-preview audio{width:100%;max-width:290px;min-width:0;height:41px}
.chat-draft-title{font-size:12px;color:#cceadd;font-weight:700}
.chat-draft-actions{display:flex;gap:9px}
.chat-draft-actions button{flex:1;border-radius:13px;padding:11px 8px;border:1px solid rgba(255,255,255,.1);font-weight:750;color:white;background:#334157}
.chat-draft-actions [data-action="chat-draft-send"]{background:#228c66;border-color:#35af84}
.chat-voice-live{display:flex;align-items:center;gap:10px;padding:10px 13px;background:#273344;border-top:1px solid #44526b;font-size:12px}
.chat-voice-live[hidden]{display:none!important}
.voice-pulse{width:10px;height:10px;border-radius:50%;background:#ff6576;box-shadow:0 0 0 5px #ff657626;animation:voice-breathe 1s infinite alternate}
@keyframes voice-breathe{to{box-shadow:0 0 0 9px #ff65760c;opacity:.62}}
.voice-wave{display:flex;align-items:center;gap:3px;height:22px;flex:1;justify-content:center}
.voice-wave i{width:3px;height:9px;background:#66ddad;border-radius:4px;animation:voice-wave .7s infinite alternate}
.voice-wave i:nth-child(2n){height:16px;animation-delay:.2s}.voice-wave i:nth-child(3n){height:21px;animation-delay:.36s}
@keyframes voice-wave{to{height:4px}}
.chat-voice-live strong{font-variant-numeric:tabular-nums;color:#ffe1e5}
.msg-screen .chat-gift-list{background:#152438;max-height:160px;overflow:auto}
.msg-screen .chat-gift-list button{border-radius:14px;background:linear-gradient(135deg,#293a50,#24324e);font-size:13px}
.msg-screen .chat-gift-list button:active{background:#315c63}
.chat-photo-preview-modal{position:fixed;inset:0;z-index:80;background:rgba(0,0,0,.92);display:grid;place-items:center;padding:16px}
.chat-photo-preview-modal[hidden]{display:none!important}
.chat-photo-preview-modal img{max-width:100%;max-height:82dvh;object-fit:contain}
.chat-photo-preview-modal button{position:absolute;top:24px;right:18px;border:0;border-radius:50%;width:42px;height:42px;font-size:23px;color:white;background:#ffffff30}
@media(max-width:370px){.msg-screen .chat-tools button{font-size:11px}.msg-screen .msg-list .bubble{max-width:86%}}

.thread-toolbar{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:8px;padding:10px 12px;margin-bottom:10px;border-radius:16px;background:#252035;color:#fff}
.thread-toolbar b{flex:1;font-size:13px}
.thread-toolbar button,.gift-sheet button,.voice-control button{font:inherit;color:inherit;cursor:pointer}
.thread-toolbar button{background:#503047;border:0;border-radius:10px;padding:8px}
.chat-row{user-select:none;-webkit-user-select:none;touch-action:pan-y}
.chat-row.thread-picked{outline:2px solid #b998ec;outline-offset:-2px;background:#352941}
.thread-picked::after{content:'✓';color:#eedfff;font-weight:bold}
.gift-sheet{box-sizing:border-box;padding:0;border:1px solid #46435a;border-radius:22px;color:#f7f5ff;background:#1c1a29;width:min(92vw,400px);max-height:76dvh;margin:auto;box-shadow:0 18px 60px #0008}
.gift-sheet::backdrop{background:#080912b8}
.gift-sheet section{padding:18px}
.gift-sheet header{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.gift-sheet button{border:1px solid #494358;border-radius:13px;background:#302c40}
.gift-sheet [data-gift-close]{width:34px;height:34px;font-size:21px}
.gift-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.gift-grid button{display:grid;justify-items:center;gap:4px;padding:9px 3px;font-size:13px}
.gift-grid button span{font-size:26px}
.gift-grid button small{color:#d2c7e7}
.gift-grid [aria-pressed=true]{border-color:#cda3ff;box-shadow:inset 0 0 0 1px #cda3ff;background:#493655}
.gift-sheet [data-gift-send]{width:100%;margin-top:14px;padding:12px;background:#d4b4fa;color:#21172d;font-weight:700}
.gift-sheet [data-gift-send]:disabled{opacity:.45}
.voice-control{direction:ltr;display:flex;align-items:center;gap:9px;width:min(195px,55vw);padding:5px 0}
.voice-control button{flex:none;width:36px;height:36px;border:0;border-radius:50%;background:#ffffff28;color:white}
.voice-control progress{flex:1;min-width:0;height:6px;accent-color:#abefdb;cursor:pointer}
.voice-control time{font:12px monospace;color:#e2efee}

/* <dialog> fallback for WebViews without HTMLDialogElement.showModal(). */
.msg-screen .gift-sheet[data-fallback-modal="1"][open]{
  display:block;position:fixed;left:50%;top:50%;right:auto;bottom:auto;
  transform:translate(-50%,-50%);margin:0;z-index:100;
  width:min(92vw,400px);max-height:min(76dvh,560px);overflow-y:auto;
  box-shadow:0 0 0 100vmax rgba(8,9,18,.78),0 18px 60px rgba(0,0,0,.7);
}
.msg-screen .gift-sheet[data-fallback-modal="1"]:not([open]){display:none}
.msg-screen .chat-tools [data-action="chat-block-toggle"]{
  background:#482e36;color:#ffb5c0;border-color:#7b4750;
}
.msg-screen .chat-tools [data-action="chat-block-toggle"].is-blocked{
  background:#184c3d;color:#b7f1cf;border-color:#347d63;
}

.msg-screen .gift-sheet-scrim{
  position:fixed;inset:0;z-index:80;
  background:rgba(8,9,18,.78);border:0;padding:0;
  cursor:default;-webkit-tap-highlight-color:transparent;
}

#chat-history-pages:not([hidden]) { display:flex; justify-content:center; gap:10px; padding:4px; }
#chat-history-pages button { background:transparent; color:inherit; border:0; text-decoration:underline; cursor:pointer; }
#chat-history-pages button:disabled { opacity:.45; cursor:default; }
.reading-history .msg-composer,.reading-history .chat-tools,.reading-history .chat-media-draft,.reading-history .chat-reply-compose { display:none; }
