/* chat feature styles: replies, reactions, attachments, composer extras, RCKT. Flat colors only, no pulsing. */

.msg { position: relative; border-radius: var(--radius-md); padding: 2px 6px 2px 0; margin-left: -6px; padding-left: 6px; transition: background .25s; max-width: min(760px, 100%); }
.msg:hover, .msg:focus-within, .msg.tap { background: rgba(255, 255, 255, .03); }
.msg.flash { background: var(--color-accent-soft); transition: background .15s; }
.msg .body { flex: 1; }
.msg .edited { font-size: var(--fs-xs); color: var(--color-text-2); }
.msg .gone { color: var(--color-text-2); font-style: italic; }
.msg.deleted .avatar { opacity: .5; }

/* hover toolbar */
.msg .actions { position: absolute; right: 8px; top: -14px; display: none; gap: 2px; padding: 3px; background: var(--color-pop); border: 1px solid var(--color-line-2); border-radius: var(--radius-md); box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .9); z-index: 2; }
.msg:hover .actions, .msg:focus-within .actions, .msg.tap .actions { display: flex; }
.act-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-text-2); transition: background .15s, color .15s, transform .3s var(--spring, ease); }
.act-btn:hover { background: var(--color-strong); color: var(--color-text); transform: scale(1.1); }
.act-btn.danger:hover { color: var(--color-danger-text); }
.act-btn:active { transform: scale(.88); }

/* quoted reply */
.quote { display: flex; align-items: baseline; gap: var(--space-2); max-width: 100%; margin: 2px 0 4px; padding: 3px 10px; background: transparent; border: 0; border-left: 3px solid var(--color-accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--color-text-2); font-size: var(--fs-sm); text-align: left; cursor: pointer; transition: background .2s; }
.quote:hover { background: var(--color-raised); }
.quote b { flex: none; color: var(--color-accent-text); font-weight: 600; }
.quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* reactions */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.react { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; background: var(--color-raised); border: 1px solid var(--color-border); border-radius: 999px; color: var(--color-text-2); font-size: var(--fs-sm); line-height: 20px; transition: background .2s, border-color .2s, transform .35s var(--spring, ease); }
.react:hover { border-color: var(--color-line-3); transform: translateY(-1px); }
.react:active { transform: scale(.92); }
.react.mine { background: var(--color-accent-soft); border-color: var(--color-accent); color: var(--color-text); }
.react .e { font-size: 15px; }
.react-pop { position: fixed; z-index: 95; display: flex; gap: 2px; padding: 5px; background: var(--color-pop); border: 1px solid var(--color-line-2); border-radius: 999px; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .85); }
.react-pop .emo { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 20px; line-height: 1; transition: background .15s, transform .3s var(--spring, ease); }
.react-pop .emo:hover, .react-pop .emo:focus-visible { background: var(--color-strong); transform: scale(1.25); }

/* attachments */
.att-img { display: block; margin-top: 6px; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-raised); overflow: hidden; cursor: zoom-in; max-width: min(360px, 100%); transition: transform .35s var(--spring, ease), border-color .2s; }
.att-img:hover { border-color: var(--color-line-3); transform: scale(1.015); }
.att-img img { display: block; max-width: 100%; max-height: 320px; width: auto; height: auto; }
.att-file { display: flex; align-items: center; gap: var(--space-3); margin-top: 6px; padding: 10px 14px; max-width: 360px; background: var(--color-raised); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); transition: background .2s, border-color .2s, transform .35s var(--spring, ease); }
.att-file:hover { background: var(--color-strong); border-color: var(--color-line-3); transform: translateY(-1px); }
.att-file svg { flex: none; color: var(--color-text-2); }
.att-file .fmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 18px; }
.att-file .fmeta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); }
.att-file .fmeta span { color: var(--color-text-2); font-size: var(--fs-sm); }

/* composer extras */
.composer-wrap { flex: none; display: flex; flex-direction: column; background: var(--color-bg); }
.composer-wrap .composer { border-top: 1px solid var(--color-border); }
.composer .attach { flex: none; align-self: center; }
.typing { min-height: 20px; padding: 2px var(--space-6) 0; color: var(--color-text-2); font-size: var(--fs-sm); line-height: 18px; }
.typing:empty { min-height: 0; padding: 0; }
.reply-bar, .upload-chip { display: flex; align-items: center; gap: var(--space-3); margin: 0 var(--space-6); padding: 6px 6px 6px 12px; background: var(--color-raised); border: 1px solid var(--color-border); border-bottom: 0; border-radius: var(--radius-md) var(--radius-md) 0 0; color: var(--color-text-2); font-size: var(--fs-sm); animation: rise-spring .4s var(--ease-out, ease-out) backwards; }
.reply-bar[hidden], .upload-chip[hidden] { display: none; }
.reply-bar .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .t b { color: var(--color-text); }
.upload-chip .cname { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 16px; }
.upload-chip .cname b { color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-chip .bar { flex: 0 0 90px; height: 4px; border-radius: 4px; background: var(--color-strong); overflow: hidden; }
.upload-chip .bar i { display: block; height: 100%; background: var(--color-accent); transition: width .2s linear; }
.edit-box { display: flex; flex-direction: column; gap: 4px; margin: 2px 0; }
.edit-input { min-height: 36px; padding: 6px 12px; }
.chat-log.dragging { outline: 2px dashed var(--color-accent); outline-offset: -10px; background: var(--color-accent-soft); }

.msg-author { cursor: pointer; transition: color var(--dur-fast); }
.msg-author:hover { text-decoration: underline; color: var(--color-accent-text); }
.msg .avatar { cursor: pointer; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 56px 16px 72px; background: rgba(0, 0, 0, .88); backdrop-filter: blur(6px); }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); }
.lb-close { position: absolute; top: 12px; right: 12px; }
.lb-bar { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; align-items: center; justify-content: center; gap: var(--space-4); color: var(--color-text-2); font-size: var(--fs-md); }

/* RCKT */
.rckt-badge { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; background: var(--color-accent); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .06em; line-height: 16px; vertical-align: middle; }
.rckt-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-5) var(--space-6); }
.rckt-card.on { border-color: var(--color-accent); }
.rckt-top { display: flex; align-items: center; gap: var(--space-3); }
.rckt-top .rckt-badge { margin: 0; }
.perks { margin: 4px 0 0; padding-left: 18px; color: var(--color-text-2); font-size: var(--fs-md); line-height: 22px; list-style: disc; }
.rckt-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }

@media (max-width: 899px) {
  .typing, .reply-bar, .upload-chip { margin-left: var(--space-4); margin-right: var(--space-4); }
  .typing { padding-left: 0; padding-right: 0; }
  .msg .actions { right: 4px; }
  .att-img img { max-height: 260px; }
}

/* ===== GIF picker, GIF messages, translate + report ===== */
.composer .gif-btn { flex: none; align-self: center; width: 40px; }
.gif-glyph { font-size: 11px; font-weight: 800; letter-spacing: .04em; line-height: 1; padding: 4px 5px; border: 1.5px solid currentColor; border-radius: 6px; }
.gif-btn[aria-expanded="true"] { background: var(--color-accent-soft); color: var(--color-accent-text); }

.gif-pop { position: fixed; z-index: 95; display: flex; flex-direction: column; min-height: 220px; background: var(--color-pop); border: 1px solid var(--color-line-2); border-radius: var(--radius-lg, 16px); box-shadow: 0 24px 50px -14px rgba(0, 0, 0, .9); overflow: hidden; transform-origin: bottom left; }
.gif-head { flex: none; padding: var(--space-3) var(--space-3) 0; }
.gif-search { border-radius: var(--radius-pill, 999px); background: var(--color-raised); }
.gif-pop > .tabs { flex: none; margin: var(--space-2) var(--space-3) 0; }
.gif-note { flex: none; margin: 0; padding: 6px var(--space-4) 0; color: var(--color-text-2); font-size: var(--fs-sm); line-height: 16px; }
.gif-note[hidden] { display: none; }
.gif-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-3); }
.gif-msg { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: 40px var(--space-4); text-align: center; color: var(--color-text-2); font-size: var(--fs-md); line-height: 20px; overflow-wrap: anywhere; }
.gif-msg[hidden] { display: none; }
.gif-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.gif-grid:empty { display: none; }
.gif-cell { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-md); overflow: hidden; background: var(--color-raised); }
.gif-tile { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; transition: transform .35s var(--spring, ease); }
.gif-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gif-tile:hover { transform: scale(1.04); }
.gif-tile:active { transform: scale(.97); }
.gif-heart { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; opacity: .85; transition: transform .35s var(--spring, ease), background .2s, color .2s, opacity .2s; }
.gif-heart:hover, .gif-heart:focus-visible { opacity: 1; transform: scale(1.12); background: rgba(0, 0, 0, .8); }
.gif-heart:active { transform: scale(.88); }
.gif-heart[aria-pressed="true"] { color: #ff6b81; opacity: 1; }
.gif-heart[aria-pressed="true"] svg { fill: currentColor; }

.gif-card { position: relative; display: block; margin-top: 6px; padding: 0; max-width: min(300px, 100%); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-raised); overflow: hidden; cursor: zoom-in; transition: transform .35s var(--spring, ease), border-color .2s; }
.gif-card:hover { border-color: var(--color-line-3); transform: scale(1.015); }
.gif-card img { display: block; max-width: 100%; max-height: 260px; width: auto; height: auto; }
.gif-tag { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .06em; line-height: 16px; }

.msg .txt.translated { color: var(--color-text); }
.tr-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; color: var(--color-text-2); font-size: var(--fs-sm); line-height: 18px; }
.linklike { padding: 0; border: 0; background: none; color: var(--color-accent-text); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linklike:hover { color: var(--color-text); }
.act-btn { position: relative; }
.act-btn.loading svg { opacity: 0; }
.act-btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--color-border); border-top-color: var(--color-text); border-radius: 50%; animation: spin .7s linear infinite; }
.report-quote { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-left: 3px solid var(--color-danger); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--color-raised); font-size: var(--fs-md); line-height: 20px; }
.report-quote span { color: var(--color-text-2); overflow-wrap: anywhere; }

@media (max-width: 899px) {
  .gif-pop { transform-origin: bottom center; }
  .gif-card img { max-height: 220px; }
}

/* Embedded video player */
.att-video { max-width: 100%; max-height: 380px; border-radius: var(--radius-md); background: #000; display: block; margin-top: 6px; box-shadow: var(--shadow-1); }
/* video attachments + read receipts */
.att-video { position: relative; display: block; margin-top: 6px; max-width: min(420px, 100%); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: #000; overflow: hidden; }
.att-video video { display: block; width: 100%; max-height: 340px; background: #000; }
.att-video .att-dl { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; opacity: 0; transition: opacity .2s; }
.att-video:hover .att-dl, .att-video:focus-within .att-dl { opacity: 1; }
@media (hover: none) { .att-video .att-dl { opacity: 1; } }
.seen-note { margin-top: 2px; font-size: var(--fs-xs); color: var(--color-text-2); }
.seen-note.seen { color: var(--color-accent); }
.msg.own .seen-note { text-align: right; }

/* toolbar, pins, search results, voice messages, swipe-to-reply */
.chat-tools { position: sticky; top: 0; z-index: 3; display: flex; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2) 0 var(--space-3); background: linear-gradient(var(--color-bg) 70%, transparent); }
.chat-tool { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-raised); color: var(--color-text-2); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.chat-tool:hover { color: var(--color-text); border-color: var(--color-accent); }
.chat-tool .tool-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--color-accent); color: var(--color-on-accent, #fff); font-size: 11px; line-height: 18px; text-align: center; }
.chat-tool.older { margin-left: auto; }
.pin-flag { display: inline-flex; align-items: center; gap: 3px; color: var(--color-accent); font-size: var(--fs-xs); font-weight: 700; }
.found { display: block; width: 100%; text-align: left; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-raised); color: inherit; font: inherit; cursor: pointer; }
.found:hover { border-color: var(--color-accent); }
.found-top { display: flex; justify-content: space-between; gap: var(--space-3); }
.found-txt { margin: 2px 0 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.att-audio { display: flex; align-items: center; gap: var(--space-3); margin-top: 6px; padding: 6px 10px; max-width: min(360px, 100%); border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-raised); color: var(--color-text-2); }
.att-audio audio { flex: 1; min-width: 0; height: 34px; }
.rec-bar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border); }
.rec-bar[hidden] { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-danger); }
.rec-label { color: var(--color-text-2); }
.rec-time { margin-right: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
.msg { touch-action: pan-y; }
.msg.swipe-ready .body { color: var(--color-accent); }
.chat-tools { position: static; flex: none; padding: var(--space-2) var(--space-6); border-bottom: 1px solid var(--color-border); background: var(--color-bg); }
.chat-tool[hidden] { display: none; }
@media (max-width: 899px) { .chat-tools { padding-left: var(--space-4); padding-right: var(--space-4); } }
