/* chat-ui.css — loaded after styles.css. Chat header, wallpaper, bubbles, call button. */
.chat-page {
  --wall-bg: linear-gradient(160deg, #e4e8fb 0%, #ece6fa 55%, #e2f0f6 100%);
  --wall-doodle: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22200%22 height=%22200%22 viewBox=%220 0 200 200%22 fill=%22none%22 stroke=%22%236a5cf0%22 stroke-opacity=%22.2%22 stroke-width=%221.6%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%0A%3Cg transform=%22translate%2818 20%29%22%3E%3Cpath d=%22M20 11.5a7 7 0 0 1-7 7H7l-4 3v-10a7 7 0 0 1 7-7h3a7 7 0 0 1 7 7Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28112 14%29 rotate%2812 12 12%29%22%3E%3Cpath d=%22M12 21s-7-4.4-9-9a5 5 0 0 1 9-3 5 5 0 0 1 9 3c-2 4.6-9 9-9 9Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28150 78%29%22%3E%3Cpath d=%22m12 3 2.7 5.8 6.3.8-4.6 4.3 1.2 6.3L12 17l-5.6 3.2 1.2-6.3L3 9.6l6.3-.8Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%2860 70%29 rotate%28-14 12 12%29%22%3E%3Cpath d=%22M22 2 11 13M22 2l-7 20-4-9-9-4Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%2814 120%29%22%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%229%22/%3E%3Cpath d=%22M9 10h.01M15 10h.01M8 14.5c1 1.2 2.4 1.8 4 1.8s3-.6 4-1.8%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28104 128%29%22%3E%3Cpath d=%22M9 18V5l12-2v13%22/%3E%3Ccircle cx=%226%22 cy=%2218%22 r=%223%22/%3E%3Ccircle cx=%2218%22 cy=%2216%22 r=%223%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%2860 160%29%22%3E%3Cpath d=%22M3 7h3l2-3h8l2 3h3v12H3Z%22/%3E%3Ccircle cx=%2212%22 cy=%2213%22 r=%223.5%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28164 150%29 rotate%2810 12 12%29%22%3E%3Cpath d=%22M13 2 4 14h7l-1 8 9-12h-7Z%22/%3E%3C/g%3E%0A%3C/svg%3E");
  --bubble-in-bg: #fff; --bubble-in-fg: #2b3145; --bubble-in-border: rgba(28,35,61,.07);
  --head-bg: rgba(255,255,255,.92);
}
body[data-theme="dark"] .chat-page {
  --wall-bg: linear-gradient(160deg, #0b0f17 0%, #11101f 55%, #0b1620 100%);
  --wall-doodle: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22200%22 height=%22200%22 viewBox=%220 0 200 200%22 fill=%22none%22 stroke=%22%23a78bfa%22 stroke-opacity=%22.12%22 stroke-width=%221.6%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%0A%3Cg transform=%22translate%2818 20%29%22%3E%3Cpath d=%22M20 11.5a7 7 0 0 1-7 7H7l-4 3v-10a7 7 0 0 1 7-7h3a7 7 0 0 1 7 7Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28112 14%29 rotate%2812 12 12%29%22%3E%3Cpath d=%22M12 21s-7-4.4-9-9a5 5 0 0 1 9-3 5 5 0 0 1 9 3c-2 4.6-9 9-9 9Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28150 78%29%22%3E%3Cpath d=%22m12 3 2.7 5.8 6.3.8-4.6 4.3 1.2 6.3L12 17l-5.6 3.2 1.2-6.3L3 9.6l6.3-.8Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%2860 70%29 rotate%28-14 12 12%29%22%3E%3Cpath d=%22M22 2 11 13M22 2l-7 20-4-9-9-4Z%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%2814 120%29%22%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%229%22/%3E%3Cpath d=%22M9 10h.01M15 10h.01M8 14.5c1 1.2 2.4 1.8 4 1.8s3-.6 4-1.8%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28104 128%29%22%3E%3Cpath d=%22M9 18V5l12-2v13%22/%3E%3Ccircle cx=%226%22 cy=%2218%22 r=%223%22/%3E%3Ccircle cx=%2218%22 cy=%2216%22 r=%223%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%2860 160%29%22%3E%3Cpath d=%22M3 7h3l2-3h8l2 3h3v12H3Z%22/%3E%3Ccircle cx=%2212%22 cy=%2213%22 r=%223.5%22/%3E%3C/g%3E%0A%3Cg transform=%22translate%28164 150%29 rotate%2810 12 12%29%22%3E%3Cpath d=%22M13 2 4 14h7l-1 8 9-12h-7Z%22/%3E%3C/g%3E%0A%3C/svg%3E");
  --bubble-in-bg: #1b2030; --bubble-in-fg: #eef0f6; --bubble-in-border: rgba(255,255,255,.07);
  --head-bg: rgba(22,27,34,.92);
}

/* wallpaper (DM, group, channel all share .thread-messages) */
.chat-page .thread-messages {
  background: var(--wall-bg);
  gap: 3px;
  padding: 14px 12px 10px;
  position: relative;
}
.chat-page .thread-messages { background-image: var(--wall-doodle), var(--wall-bg); background-size: 200px 200px, auto; background-attachment: local, local; }

/* header */
.chat-page .thread-head {
  background: var(--head-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(120,104,233,.14);
  box-shadow: 0 4px 14px rgba(28,35,61,.05);
  gap: 11px; padding: 10px 12px; position: relative; z-index: 2;
}
.chat-page .thread-head strong { font-size: 13px; letter-spacing: -.01em; }
.chat-page .thread-head .thread-avatar-wrap { flex: 0 0 auto; position: relative; }
.chat-page .thread-head .thread-avatar-wrap .mini-avatar { height: 40px; width: 40px; }
.chat-page .thread-head small { font-size: 10.5px; }
.chat-page .thread-head .page-back-button { background: rgba(120,104,233,.1); color: #5c51d1; }
body[data-theme="dark"] .chat-page .thread-head .page-back-button { background: rgba(255,255,255,.07); color: #c9c2ff; }
.thread-head .has-presence-dot::after { background: #17c964; border: 2px solid #fff; border-radius: 50%; bottom: 0; content: ''; height: 11px; position: absolute; right: 0; width: 11px; }
body[data-theme="dark"] .thread-head .has-presence-dot::after { border-color: #161b22; }

.thread-call-button {
  align-items: center; background: linear-gradient(135deg, #1fd66f, #0fa958); border: 0; border-radius: 50%;
  box-shadow: 0 4px 12px rgba(15,169,88,.35); color: #fff; cursor: pointer; display: flex; flex: 0 0 auto;
  height: 38px; justify-content: center; margin-left: auto; transition: transform .15s ease, opacity .15s ease; width: 38px;
}
.thread-call-button svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 18px; }
.thread-call-button:hover { transform: translateY(-1px) scale(1.05); }
.thread-call-button:active { transform: scale(.94); }
.thread-call-button.is-offline { background: #cfd4e2; box-shadow: none; color: #fff; opacity: .85; }
body[data-theme="dark"] .thread-call-button.is-offline { background: #2a3040; color: #7c869b; }
.thread-call-button + .thread-clear-button { margin-left: 0; }

/* bubbles: who sent what is obvious at a glance */
.chat-page .thread-bubble {
  background: var(--bubble-in-bg); border: 1px solid var(--bubble-in-border); border-radius: 4px 18px 18px 18px;
  box-shadow: 0 1px 2px rgba(28,35,61,.12); color: var(--bubble-in-fg); font-size: 12.5px; line-height: 1.45;
  max-width: min(78%, 460px); padding: 7px 11px 5px; word-break: break-word;
}
.chat-page .thread-bubble.mine {
  background: linear-gradient(135deg, #6a5cf0, #4d3fc9); border-color: rgba(255,255,255,.1); border-radius: 18px 4px 18px 18px;
  box-shadow: 0 2px 6px rgba(77,63,201,.3); color: #fff; margin-left: auto;
}
/* consecutive bubbles from the same side tuck together */
.chat-page .thread-bubble.mine + .thread-bubble.mine { border-top-right-radius: 18px; }
.chat-page .thread-bubble:not(.mine) + .thread-bubble:not(.mine) { border-top-left-radius: 18px; }
/* a new run of messages starts with a small label: You / their name */
.chat-page .thread-bubble[data-who]:not(.thread-bubble-sticker):not(.thread-bubble-gif):not(.thread-bubble-voice):not(.thread-bubble.mine + .thread-bubble.mine):not(.thread-bubble:not(.mine) + .thread-bubble:not(.mine))::before {
  color: #6a5cf0; content: attr(data-who); display: block; font-size: 9.5px; font-weight: 800; letter-spacing: .02em; margin-bottom: 2px;
}
body[data-theme="dark"] .chat-page .thread-bubble[data-who]:not(.mine)::before { color: #b7aefc; }
.chat-page .thread-bubble.mine[data-who]::before { color: rgba(255,255,255,.78) !important; text-align: right; }
.chat-page .thread-bubble:not(.mine):not(.thread-bubble:not(.mine) + .thread-bubble:not(.mine)) { margin-top: 8px; }
.chat-page .thread-bubble.mine:not(.thread-bubble.mine + .thread-bubble.mine) { margin-top: 8px; }
.chat-page .thread-bubble-sender { color: #6a5cf0; font-size: 10px; }
body[data-theme="dark"] .chat-page .thread-bubble-sender { color: #b7aefc; }
.chat-page .thread-bubble-sticker, .chat-page .thread-bubble-gif, .chat-page .thread-bubble-voice { border: 0; }

/* composer floats as a clean pill bar over the wallpaper */
.chat-page .thread-compose { background: var(--head-bg); border-top: 1px solid rgba(120,104,233,.14); gap: 8px; }
.chat-page .thread-compose-textarea { background: rgba(120,104,233,.07); border-color: rgba(120,104,233,.18); font-size: 13px; }
body[data-theme="dark"] .chat-page .thread-compose-textarea { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #eef0f6; }
.chat-page .typing-indicator-row { background: transparent; }
.chat-page .thread-empty-messages { background: rgba(255,255,255,.7); border-radius: 14px; margin: auto; padding: 14px 18px; text-align: center; }
body[data-theme="dark"] .chat-page .thread-empty-messages { background: rgba(255,255,255,.06); }


/* ================================================================== */
/* Dark chat wallpaper — Telegram/WhatsApp-style doodle pattern on a    */
/* deep gradient. The old dark rule in styles.css                       */
/* (body[data-theme="dark"] .thread-messages { background:#0d0d0d }) has */
/* higher specificity than the wallpaper above and flattened it to a   */
/* plain black box, so this one is scoped tighter to win.              */
/* ================================================================== */
body[data-theme="dark"] .chat-page .thread-messages {
  background-color: #0a1018;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22256%22 height=%22256%22 viewBox=%220 0 256 256%22 fill=%22none%22 stroke-width=%221.5%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cg transform=%22translate%2814 16%29 rotate%28-8 12 12%29 scale%280.95%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z%22/%3E%3C/g%3E%3Cg transform=%22translate%2892 10%29 rotate%2814 12 12%29 scale%280.85%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z%22/%3E%3C/g%3E%3Cg transform=%22translate%28172 22%29 rotate%280 12 12%29 scale%280.8%29%22 stroke=%22%235eead4%22 stroke-opacity=%220.13%22%3E%3Cpath d=%22M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z%22/%3E%3C/g%3E%3Cg transform=%22translate%28216 92%29 rotate%2812 12 12%29 scale%280.9%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M22 2 11 13%22/%3E%3Cpath d=%22M22 2l-7 20-4-9-9-4 20-7z%22/%3E%3C/g%3E%3Cg transform=%22translate%2854 78%29 rotate%280 12 12%29 scale%280.95%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%2210%22/%3E%3Cpath d=%22M8 14s1.5 2 4 2 4-2 4-2%22/%3E%3Cpath d=%22M9 9h.01M15 9h.01%22/%3E%3C/g%3E%3Cg transform=%22translate%28124 70%29 rotate%28-10 12 12%29 scale%280.8%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M9 18V5l12-2v13%22/%3E%3Ccircle cx=%226%22 cy=%2218%22 r=%223%22/%3E%3Ccircle cx=%2218%22 cy=%2216%22 r=%223%22/%3E%3C/g%3E%3Cg transform=%22translate%28176 138%29 rotate%286 12 12%29 scale%280.95%29%22 stroke=%22%235eead4%22 stroke-opacity=%220.13%22%3E%3Cpath d=%22M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z%22/%3E%3Ccircle cx=%2212%22 cy=%2213%22 r=%224%22/%3E%3C/g%3E%3Cg transform=%22translate%2816 142%29 rotate%28-6 12 12%29 scale%280.85%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M13 2 3 14h9l-1 8 10-12h-9l1-8z%22/%3E%3C/g%3E%3Cg transform=%22translate%2896 136%29 rotate%2810 12 12%29 scale%280.85%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z%22/%3E%3C/g%3E%3Cg transform=%22translate%28210 190%29 rotate%280 12 12%29 scale%280.85%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z%22/%3E%3C/g%3E%3Cg transform=%22translate%2858 198%29 rotate%28-8 12 12%29 scale%280.85%29%22 stroke=%22%235eead4%22 stroke-opacity=%220.13%22%3E%3Cpath d=%22M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z%22/%3E%3Cpath d=%22M19 10v2a7 7 0 0 1-14 0v-2M12 19v4%22/%3E%3C/g%3E%3Cg transform=%22translate%28132 206%29 rotate%280 12 12%29 scale%280.8%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22m16 18 6-6-6-6M8 6l-6 6 6 6%22/%3E%3C/g%3E%3Cg transform=%22translate%2812 214%29 rotate%2816 12 12%29 scale%280.75%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Cpath d=%22M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48%22/%3E%3C/g%3E%3Cg transform=%22translate%28104 104%29 rotate%280 12 12%29 scale%281%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Ccircle cx=%225%22 cy=%2212%22 r=%221.2%22/%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%221.2%22/%3E%3Ccircle cx=%2219%22 cy=%2212%22 r=%221.2%22/%3E%3C/g%3E%3Cg transform=%22translate%2830 108%29 rotate%2820 12 12%29 scale%281%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Ccircle cx=%225%22 cy=%2212%22 r=%221.2%22/%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%221.2%22/%3E%3Ccircle cx=%2219%22 cy=%2212%22 r=%221.2%22/%3E%3C/g%3E%3Cg transform=%22translate%28206 246%29 rotate%280 12 12%29 scale%281%29%22 stroke=%22%23a99bff%22 stroke-opacity=%220.16%22%3E%3Ccircle cx=%225%22 cy=%2212%22 r=%221.2%22/%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%221.2%22/%3E%3Ccircle cx=%2219%22 cy=%2212%22 r=%221.2%22/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(120% 55% at 0% 0%, rgba(106,92,240,.24) 0%, rgba(106,92,240,0) 62%),
    radial-gradient(110% 55% at 100% 100%, rgba(23,201,164,.15) 0%, rgba(23,201,164,0) 62%),
    linear-gradient(180deg, #0e1424 0%, #0a1119 100%);
  background-size: 256px 256px, auto, auto, auto;
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-attachment: scroll, scroll, scroll, scroll; /* wallpaper stays put while messages scroll */
}
body[data-theme="dark"] .chat-page { --bubble-in-bg: #1a2233; --bubble-in-border: rgba(255,255,255,.07); }
body[data-theme="dark"] .chat-page .thread-bubble:not(.mine):not(.thread-bubble-sticker):not(.thread-bubble-gif):not(.thread-bubble-voice) { box-shadow: 0 1px 3px rgba(0,0,0,.45); }

/* ================================================================== */
/* Reactions, reply quotes, swipe-to-reply                              */
/* ================================================================== */
.chat-page .thread-messages { overflow-x: hidden; }
.chat-page .thread-bubble[data-message-id] { position: relative; touch-action: pan-y; -webkit-tap-highlight-color: transparent; cursor: pointer; }
.thread-bubble.has-reactions { margin-bottom: 15px; }
.thread-bubble.is-react-target { box-shadow: 0 0 0 2px rgba(167,139,250,.7), 0 8px 20px rgba(20,24,45,.25); }
.thread-bubble.is-flash { animation: msg-flash 1.3s ease; }
@keyframes msg-flash { 0% { box-shadow: 0 0 0 0 rgba(167,139,250,0); } 18% { box-shadow: 0 0 0 5px rgba(167,139,250,.55); } 100% { box-shadow: 0 0 0 0 rgba(167,139,250,0); } }

/* reaction chips sit on the bottom edge of the bubble */
.msg-reactions { bottom: -14px; display: flex; gap: 3px; left: 10px; position: absolute; z-index: 2; }
.thread-bubble.mine .msg-reactions { left: auto; right: 10px; }
.msg-react-chip { align-items: center; background: #fff; border: 1px solid rgba(28,35,61,.12); border-radius: 12px; box-shadow: 0 2px 6px rgba(28,35,61,.18); color: #333a4c; cursor: pointer; display: inline-flex; font-size: 12.5px; gap: 3px; height: 23px; line-height: 1; padding: 0 7px; }
.msg-react-chip b { font-size: 10px; font-weight: 800; }
.msg-react-chip.is-mine { background: #ece9ff; border-color: #7868e9; }
body[data-theme="dark"] .msg-react-chip { background: #232b3d; border-color: rgba(255,255,255,.13); box-shadow: 0 2px 8px rgba(0,0,0,.5); color: #eef0f6; }
body[data-theme="dark"] .msg-react-chip.is-mine { background: #3a3270; border-color: #a78bfa; }
.react-pop .msg-reactions { animation: react-pop .3s cubic-bezier(.2,1.5,.4,1); }
@keyframes react-pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }

/* quoted original inside a reply */
.msg-reply-quote { background: rgba(106,92,240,.1); border-left: 3px solid #6a5cf0; border-radius: 8px; cursor: pointer; display: block; margin: 0 0 6px; max-width: 100%; overflow: hidden; padding: 5px 9px; }
.msg-reply-name { color: #5c51d1; display: block; font-size: 10.5px; font-weight: 800; }
.msg-reply-text { display: block; font-size: 11.5px; line-height: 1.35; opacity: .82; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.thread-bubble.mine .msg-reply-quote { background: rgba(255,255,255,.16); border-left-color: rgba(255,255,255,.9); }
.thread-bubble.mine .msg-reply-name { color: #fff; }
body[data-theme="dark"] .thread-bubble:not(.mine) .msg-reply-quote { background: rgba(255,255,255,.06); border-left-color: #a78bfa; }
body[data-theme="dark"] .thread-bubble:not(.mine) .msg-reply-name { color: #b7aefc; }
.msg-reply-quote.is-deleted { cursor: default; font-style: italic; opacity: .7; }
/* sticker / GIF / voice bubbles have no background of their own — give the quote one */
.thread-bubble-sticker .msg-reply-quote, .thread-bubble-gif .msg-reply-quote, .thread-bubble-voice .msg-reply-quote { background: var(--bubble-in-bg, #fff); border-color: #6a5cf0; box-shadow: 0 1px 3px rgba(0,0,0,.2); color: var(--bubble-in-fg, #2b3145); }
.thread-bubble-sticker .msg-reply-name, .thread-bubble-gif .msg-reply-name, .thread-bubble-voice .msg-reply-name { color: #5c51d1 !important; }
body[data-theme="dark"] .thread-bubble-sticker .msg-reply-name, body[data-theme="dark"] .thread-bubble-gif .msg-reply-name, body[data-theme="dark"] .thread-bubble-voice .msg-reply-name { color: #b7aefc !important; }

/* floating emoji bar shown when a message is tapped */
.chat-react-bar { align-items: center; background: #fff; border-radius: 30px; box-shadow: 0 12px 32px rgba(20,24,45,.25), 0 0 0 1px rgba(28,35,61,.06); display: flex; gap: 1px; padding: 5px 8px; position: fixed; transform-origin: 50% 100%; z-index: 9000; }
.chat-react-bar.is-hidden { display: none; }
.chat-react-bar.is-pop { animation: react-bar-in .2s cubic-bezier(.2,1.3,.4,1); }
@keyframes react-bar-in { from { opacity: 0; transform: translateY(8px) scale(.85); } to { opacity: 1; transform: none; } }
.chat-react-option { align-items: center; background: none; border: 0; border-radius: 50%; cursor: pointer; display: flex; font-family: inherit; font-size: 23px; height: 38px; justify-content: center; line-height: 1; padding: 0; transition: transform .12s; width: 38px; }
.chat-react-option:hover, .chat-react-option:active { transform: scale(1.28); }
.chat-react-option.is-picked { background: rgba(120,104,233,.18); }
.chat-react-divider { background: rgba(120,104,233,.22); height: 22px; margin: 0 5px; width: 1px; }
.chat-react-reply { align-items: center; background: rgba(120,104,233,.12); border: 0; border-radius: 50%; color: #5c51d1; cursor: pointer; display: flex; height: 34px; justify-content: center; padding: 0; width: 34px; }
.chat-react-reply svg { fill: none; height: 17px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 17px; }
body[data-theme="dark"] .chat-react-bar { background: #1e2535; box-shadow: 0 14px 36px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08); }
body[data-theme="dark"] .chat-react-option.is-picked { background: rgba(167,139,250,.25); }
body[data-theme="dark"] .chat-react-reply { background: rgba(255,255,255,.09); color: #c9c2ff; }

/* "Replying to …" strip above the composer */
.reply-bar { align-items: center; animation: reply-bar-in .16s ease; background: var(--head-bg, rgba(255,255,255,.95)); border-top: 1px solid rgba(120,104,233,.16); display: flex; flex: 0 0 auto; gap: 10px; padding: 8px 12px 8px 14px; }
.reply-bar.is-hidden { display: none; }
@keyframes reply-bar-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.reply-bar-accent { align-self: stretch; background: #6a5cf0; border-radius: 2px; flex: 0 0 3px; }
.reply-bar-body { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; }
.reply-bar-name { color: #5c51d1; font-size: 11.5px; font-weight: 800; }
.reply-bar-text { color: #6b7388; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-close { align-items: center; background: rgba(120,104,233,.1); border: 0; border-radius: 50%; color: #5c51d1; cursor: pointer; display: flex; flex: 0 0 auto; height: 30px; justify-content: center; padding: 0; width: 30px; }
.reply-bar-close svg { fill: none; height: 15px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; width: 15px; }
body[data-theme="dark"] .reply-bar { border-top-color: rgba(255,255,255,.08); }
body[data-theme="dark"] .reply-bar-name { color: #b7aefc; }
body[data-theme="dark"] .reply-bar-text { color: #9aa3b8; }
body[data-theme="dark"] .reply-bar-close { background: rgba(255,255,255,.08); color: #c9c2ff; }

/* swipe right on a message → reply arrow slides in behind it */
.thread-bubble.is-swiping-reply { -webkit-user-select: none; user-select: none; will-change: transform; }
.swipe-reply-hint { align-items: center; background: rgba(106,92,240,.2); border-radius: 50%; color: #5c51d1; display: flex; height: 32px; justify-content: center; left: -46px; margin-top: -16px; opacity: var(--swipe-progress, 0); pointer-events: none; position: absolute; top: 50%; transform: scale(calc(.5 + var(--swipe-progress, 0) * .5)); width: 32px; }
.swipe-reply-hint svg { fill: none; height: 17px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; width: 17px; }
body[data-theme="dark"] .swipe-reply-hint { background: rgba(255,255,255,.14); color: #d6d0ff; }
@media (prefers-reduced-motion: reduce) { .react-pop .msg-reactions, .chat-react-bar.is-pop, .reply-bar, .thread-bubble.is-flash { animation: none; } }


/* ================================================================== */
/* Smoother long chats — cheaper paint while scrolling                  */
/* ================================================================== */
/* wallpaper stays fixed to the viewport instead of scrolling with the   */
/* content (a "local" background repaints the whole list every frame)    */
.chat-page .thread-messages {
  background-attachment: scroll, scroll;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* glass blur over a scrolling list is costly; the bars are already      */
/* ~92% opaque so the look barely changes                                */
.chat-page .thread-head,
.chat-page .thread-compose { backdrop-filter: none; -webkit-backdrop-filter: none; }
/* opacity-only entrance runs on the compositor and is cheap to batch    */
.chat-page .thread-bubble { animation: kc-bubble-in .16s ease-out both; }
@keyframes kc-bubble-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-page .thread-bubble { animation: none; } }

/* ================================================================== */
/* Composer: auto-growing box + expand ("stretch") button               */
/* ================================================================== */
.chat-page .thread-compose.kc-compose-form { align-items: flex-end; }
.kc-compose-field { display: flex; flex: 1 1 auto; min-width: 0; position: relative; }
.chat-page .thread-compose .thread-compose-textarea.kc-autogrow {
  border-radius: 20px;
  box-sizing: border-box;
  height: 40px;
  line-height: 20px;
  max-height: 104px;
  min-height: 40px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 9px 16px;
  white-space: pre-wrap;
  width: 100%;
  word-break: break-word;
  scrollbar-width: none;
  transition: border-color .15s, box-shadow .15s, padding-right .15s;
}
.chat-page .thread-compose .thread-compose-textarea.kc-autogrow::-webkit-scrollbar { display: none; }
.kc-compose-field.has-expand .thread-compose-textarea.kc-autogrow { padding-right: 42px; }

.chat-page .thread-compose .kc-expand-btn {
  align-items: center;
  background: rgba(120,104,233,.14);
  border-radius: 50%;
  box-shadow: none;
  color: #5c51d1;
  cursor: pointer;
  display: flex;
  height: 28px;
  justify-content: center;
  opacity: 0;
  padding: 0;
  pointer-events: none;
  position: absolute;
  right: 6px;
  top: 6px;
  transform: scale(.6);
  transition: opacity .18s ease, transform .22s cubic-bezier(.3,1.4,.5,1), background .15s;
  width: 28px;
  z-index: 1;
}
.chat-page .thread-compose .kc-expand-btn svg { fill: none; height: 15px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; width: 15px; }
.kc-compose-field.has-expand .kc-expand-btn { opacity: 1; pointer-events: auto; transform: scale(1); }
.chat-page .thread-compose .kc-expand-btn:hover { background: rgba(120,104,233,.24); transform: scale(1.06); }
.chat-page .thread-compose .kc-expand-btn:active { transform: scale(.9); }
body[data-theme="dark"] .chat-page .thread-compose .kc-expand-btn { background: rgba(255,255,255,.1); color: #c9c2ff; }
body[data-theme="dark"] .chat-page .thread-compose .kc-expand-btn:hover { background: rgba(255,255,255,.18); }

/* ================================================================== */
/* Expanded editor — pinned to the top, above the on-screen keyboard    */
/* ================================================================== */
.kc-editor {
  background: rgba(8,13,27,.45);
  display: flex;
  justify-content: center;
  left: 0;
  opacity: 0;
  overscroll-behavior: contain;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transition: opacity .18s ease;
  visibility: hidden;
  z-index: 400;
}
.kc-editor.is-open { opacity: 1; pointer-events: auto; visibility: visible; }
.kc-editor-card {
  background: #fff;
  box-shadow: 0 18px 50px rgba(4,7,20,.35);
  color: #1c2236;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 760px;
  padding-top: env(safe-area-inset-top, 0px);
  transform: translateY(-18px);
  transition: transform .26s cubic-bezier(.2,.9,.3,1);
  width: 100%;
}
.kc-editor.is-open .kc-editor-card { transform: translateY(0); }
.kc-editor-bar {
  align-items: center;
  border-bottom: 1px solid rgba(120,104,233,.16);
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  padding: 10px 12px;
}
.kc-editor-title { display: grid; flex: 1; gap: 1px; min-width: 0; }
.kc-editor-title strong { font-size: 14px; letter-spacing: -.01em; }
.kc-editor-title small { color: #8b92a6; font-size: 11px; }
.kc-editor-collapse, .kc-editor-send {
  align-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  flex: 0 0 auto;
  height: 40px;
  justify-content: center;
  padding: 0;
  transition: transform .12s ease, background .15s ease;
  width: 40px;
}
.kc-editor-collapse { background: rgba(120,104,233,.12); color: #5c51d1; }
.kc-editor-send { background: linear-gradient(135deg, #6a5cf0, #4d3fc9); box-shadow: 0 4px 12px rgba(77,63,201,.35); color: #fff; }
.kc-editor-collapse svg, .kc-editor-send svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; width: 18px; }
.kc-editor-collapse:active, .kc-editor-send:active { transform: scale(.92); }
.kc-editor-input {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  flex: 1 1 auto;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  line-height: 1.55;
  min-height: 0;
  outline: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px max(18px, env(safe-area-inset-bottom, 0px));
  resize: none;
  width: 100%;
}
.kc-editor-input::placeholder { color: #a3a9ba; }
@media (min-width: 700px) {
  .kc-editor-card { border-radius: 0 0 20px 20px; height: min(560px, 100%); }
}
body[data-theme="dark"] .kc-editor-card { background: #141824; color: #eef0f6; }
body[data-theme="dark"] .kc-editor-bar { border-bottom-color: rgba(255,255,255,.08); }
body[data-theme="dark"] .kc-editor-title small { color: #8d96ad; }
body[data-theme="dark"] .kc-editor-collapse { background: rgba(255,255,255,.08); color: #c9c2ff; }
body[data-theme="dark"] .kc-editor-input::placeholder { color: #6b7389; }
html.kc-editor-open, html.kc-editor-open body { overscroll-behavior: none; }
@media (prefers-reduced-motion: reduce) {
  .kc-editor, .kc-editor-card, .chat-page .thread-compose .kc-expand-btn { transition: none; }
}
