/* ---- Messages --------------------------------------------------------------- */
.convo-item .li-top { display: flex; align-items: baseline; gap: 8px; }
.convo-item .li-time { margin-left: auto; font-size: 11.5px; color: var(--text-3); flex-shrink: 0; }
.convo-item.unread .li-title, .convo-item.unread .li-sub { color: var(--text); font-weight: 600; }
.convo-item.unread .li-time { color: var(--accent); font-weight: 600; }
.thread { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.thread-scroll { flex: 1; overflow-y: auto; padding: 18px 20px 8px; overscroll-behavior: contain; }
@media (max-width: 760px) { .thread-scroll { padding: 14px 10px 6px; } }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.new-sep { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 11.5px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.new-sep::after { content: ""; flex: 1; height: 1px; background: var(--accent); opacity: .5; }
.msg-group { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.msg-group.mine { flex-direction: row-reverse; }
.msg-group .avatar-slot { width: 32px; flex-shrink: 0; }
.msg-stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; max-width: min(72%, 640px); align-items: flex-start; }
.msg-group.mine .msg-stack { align-items: flex-end; }
@media (max-width: 760px) { .msg-stack { max-width: 84%; } }
.msg-author { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 12px 2px; }
.msg { position: relative; display: flex; flex-direction: column; align-items: inherit; max-width: 100%; }
.msg-group.mine .msg { align-items: flex-end; }
.bubble {
  position: relative; padding: 9px 14px 7px; border-radius: 15px; background: var(--theirs); color: var(--theirs-text);
  border: 1px solid var(--border); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; max-width: 100%;
  animation: fadeUp .25s ease both;
}
.msg-group.mine .bubble { background: var(--mine); color: var(--mine-text); border-color: transparent; }
/* The last bubble in a run carries the tail, as the hub's always have. */
.msg-group:not(.mine) .msg:last-child .bubble { border-bottom-left-radius: 4px; }
.msg-group.mine .msg:last-child .bubble { border-bottom-right-radius: 4px; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble .stamp { float: right; margin: 6px 0 -2px 10px; font-size: 10.5px; line-height: 1.6; opacity: .72; white-space: nowrap; user-select: none; }
.bubble.emoji-only { background: none !important; border-color: transparent !important; font-size: 38px; line-height: 1.1; padding: 2px 4px; }
.bubble.emoji-only .stamp { color: var(--text-3); opacity: 1; float: none; display: block; text-align: right; margin: 0; }
.bubble.media-only { padding: 0; background: none !important; }
.bubble .reply-quote { display: block; margin: 2px 0 6px; padding: 5px 9px; border-left: 3px solid currentColor; border-radius: 6px; background: rgba(0,0,0,.08); font-size: 12.5px; opacity: .88; cursor: pointer; white-space: normal; }
.msg-group.mine .bubble .reply-quote { background: rgba(255,255,255,.16); }
.msg-meta { font-size: 11px; color: var(--text-3); margin: 3px 10px 0; display: flex; gap: 6px; align-items: center; }
.msg-tools {
  position: absolute; top: -16px; display: none; align-items: center; gap: 1px; padding: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); z-index: 3;
}
.msg-group:not(.mine) .msg-tools { right: -8px; transform: translateX(100%); top: 50%; margin-top: -17px; }
.msg-group.mine .msg-tools { left: -8px; transform: translateX(-100%); top: 50%; margin-top: -17px; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools, .msg.tools-open .msg-tools { display: flex; }
@media (hover: none) { .msg-tools { display: none !important; } .msg.tools-open .msg-tools { display: flex !important; position: static; transform: none; margin: 4px 0 0; } }
.msg-tools button { width: 30px; height: 30px; display: grid; place-items: center; border: none; background: none; border-radius: 7px; color: var(--text-2); font-size: 16px; }
.msg-tools button:hover { background: var(--hover); color: var(--text); }
.msg-tools svg { width: 16px; height: 16px; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: -4px; z-index: 1; padding: 0 6px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 7px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; box-shadow: var(--shadow-sm); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction span { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.att-grid { display: grid; gap: 3px; border-radius: 16px; overflow: hidden; max-width: 380px; }
.att-grid.n2 { grid-template-columns: 1fr 1fr; }
.att-grid.n3 { grid-template-columns: 1fr 1fr; } .att-grid.n3 > :first-child { grid-column: span 2; }
.att-grid.n4 { grid-template-columns: 1fr 1fr; }
.att-media { display: block; width: 100%; max-height: 360px; object-fit: cover; background: var(--surface-3); border: none; padding: 0; cursor: zoom-in; min-height: 60px; }
.att-grid.n1 .att-media { object-fit: contain; max-height: 420px; width: auto; max-width: 100%; }
.att-video { display: block; max-width: 100%; max-height: 380px; border-radius: 14px; background: #000; }
.att-audio { width: 280px; max-width: 100%; }
.file-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 220px; max-width: 320px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-align: left; }
.file-card:hover { border-color: var(--border-strong); text-decoration: none; }
.file-card .fc-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; font-size: 10px; font-weight: 800; letter-spacing: .02em; }
.file-card .fc-name { font-size: 13.5px; font-weight: 600; }
.file-card .fc-meta { font-size: 12px; color: var(--text-3); }
.typing { display: flex; align-items: center; gap: 8px; padding: 4px 20px 8px; font-size: 12.5px; color: var(--text-3); min-height: 26px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; } .typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.jump-down { position: absolute; right: 22px; bottom: 96px; z-index: 5; box-shadow: var(--shadow-lg); border-radius: var(--r-full); }

.composer { padding: 10px 16px 16px; flex-shrink: 0; }
@media (max-width: 760px) { .composer { padding: 8px 8px 10px; } }
.composer-box { position: relative; background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 16px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
  backdrop-filter: blur(var(--glass-blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%); }
.composer-box::before { content: ""; position: absolute; inset: 0; background: var(--sheen); pointer-events: none; opacity: .7; border-radius: inherit; }
.composer-box > * { position: relative; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; padding: 6px; }
.composer textarea:focus-visible, .aria-composer textarea:focus-visible { box-shadow: none; }
.composer textarea { flex: 1; min-height: 38px; max-height: 220px; padding: 9px 8px; border: none; background: none; resize: none; outline: none; font-size: 14.5px; line-height: 1.45; }
.composer .send, .aria-composer .send { width: 34px; height: 34px; border-radius: 9px; border: none; display: grid; place-items: center; background: var(--text); color: var(--bg); flex-shrink: 0; transition: background .2s var(--ease), color .2s var(--ease), opacity .15s; }
.composer .send:hover:not(:disabled), .aria-composer .send:hover:not(:disabled) { background: var(--accent); color: #fff; }
.composer .send:disabled, .aria-composer .send:disabled { opacity: .35; cursor: default; }
.composer .send svg, .aria-composer .send svg { width: 17px; height: 17px; }
.composer-banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.composer-banner b { color: var(--text); font-weight: 600; }
.pending { display: flex; gap: 8px; padding: 10px 10px 2px; overflow-x: auto; }
.pending-item { position: relative; flex-shrink: 0; width: 76px; }
.pending-thumb { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; color: var(--text-2); font-size: 10px; font-weight: 800; }
.pending-thumb img, .pending-thumb video { width: 100%; height: 100%; object-fit: cover; }
.pending-name { font-size: 11px; color: var(--text-2); margin-top: 3px; }
.pending-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); background: var(--text); color: var(--bg); display: grid; place-items: center; }
.pending-x svg { width: 12px; height: 12px; }
.pending .progress { position: absolute; left: 6px; right: 6px; bottom: 26px; }
.drop-overlay { position: absolute; inset: 8px; z-index: 30; border: 2px dashed var(--accent); border-radius: var(--r-xl); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); display: grid; place-items: center; color: var(--accent); font-weight: 600; pointer-events: none; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 240px; overflow-y: auto; padding: 4px; }
.emoji-grid button { border: none; background: none; height: 34px; border-radius: 8px; font-size: 20px; }
.emoji-grid button:hover { background: var(--hover); }
.gif-grid { columns: 2; column-gap: 6px; max-height: 340px; overflow-y: auto; padding: 4px; }
.gif-grid button { display: block; width: 100%; border: none; padding: 0; margin: 0 0 6px; background: var(--surface-2); border-radius: 8px; overflow: hidden; break-inside: avoid; }
.gif-grid img { display: block; width: 100%; }

/* Details page */
.details-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 12px 0 24px; }
.details-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.details-actions .act { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 84px; padding: 12px 6px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 500; color: var(--text-2); }
.details-actions .act:hover { color: var(--text); border-color: var(--border-strong); }
.details-actions .act svg { width: 20px; height: 20px; }
.details-actions .act.danger { color: var(--danger); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.media-grid button { aspect-ratio: 1; border: none; padding: 0; border-radius: 10px; overflow: hidden; background: var(--surface-3); position: relative; }
.media-grid img, .media-grid video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.25); }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.92); display: flex; flex-direction: column; animation: fade .15s; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-bar .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px 24px; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

/* ---- Group roles ---------------------------------------------------------------- */
.role-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; letter-spacing: .02em; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.role-tag.owner { background: var(--accent); color: var(--bg); }
.role-tag.muted-tag { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.sys-msg { display: table; max-width: 86%; margin: 8px auto; padding: 5px 12px; border-radius: 99px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); text-align: center; }
.sys-msg b { color: var(--text); font-weight: 600; }
