/* Forge | chat.css — conversation list + chat screen */

/* ---------- Conversation list ---------- */
.conv-list { display: flex; flex-direction: column; gap: 2px; }

.conv-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--r-md);
  position: relative;
  animation: row-in 340ms var(--ease-in) both;
  animation-delay: calc(var(--i, 0) * 30ms);
  transition: background var(--t-fast) var(--ease-in);
}
.conv-row:active { background: var(--surface-2); }

.conv-row .row-body { flex: 1; min-width: 0; }
.conv-row .row-top {
  display: flex; align-items: baseline; gap: var(--s-2);
}
.conv-row .row-name {
  flex: 1; font-weight: 600; font-size: 15px;
  color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-row .row-time {
  font-size: 11px; color: var(--muted); flex-shrink: 0;
}
.conv-row .row-bottom {
  display: flex; align-items: center; gap: var(--s-2);
  margin-top: 2px;
}
.conv-row .row-preview {
  flex: 1; font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-row .row-preview.unread {
  color: var(--text); font-weight: 500;
}
.conv-row .row-mute {
  width: 14px; height: 14px; color: var(--muted-2); flex-shrink: 0;
}
.conv-row .unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--primary); color: #fff;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.conv-row .pin-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-pink);
  flex-shrink: 0;
}

/* ---------- Chat screen ---------- */
.chat-shell {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: var(--bg);
}

.chat-header {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
}
.chat-header .back {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background var(--t-fast) var(--ease-in);
}
.chat-header .back:hover { background: var(--surface-2); color: var(--text); }
.chat-header .back svg { width: 20px; height: 20px; }
.chat-header .who { flex: 1; min-width: 0; }
.chat-header .who .name {
  font-weight: 600; color: var(--text-strong); font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header .who .status {
  font-size: 12px; color: var(--muted); margin-top: 1px;
  height: 14px;
}
.chat-header .who .status.typing { color: var(--primary); }
.chat-header .who .status.online { color: var(--primary); }
.chat-header .icons { display: flex; gap: 4px; }
.chat-header .icons button {
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast) var(--ease-in);
}
.chat-header .icons button:hover { background: var(--surface-2); color: var(--text); }
.chat-header .icons svg { width: 20px; height: 20px; }

/* messages scroll area */
.msg-area {
  flex: 1; overflow-y: auto;
  padding: var(--s-3) var(--s-4);
  display: flex; flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.msg-area::-webkit-scrollbar { width: 6px; }
.msg-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.load-older {
  text-align: center; padding: 10px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.load-older.clickable { cursor: pointer; color: var(--primary); }

.day-sep {
  text-align: center; margin: 12px 0 6px;
  font-size: 11px; color: var(--muted-2);
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
}
.unread-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 6px;
  color: var(--accent-pink); font-size: 11px;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em;
}
.unread-divider::before, .unread-divider::after {
  content: ''; flex: 1; height: 1px;
  background: color-mix(in srgb, var(--accent-pink) 40%, transparent);
}

/* message row */
.msg { display: flex; gap: 6px; align-items: flex-end; max-width: 100%; }
.msg.mine { flex-direction: row-reverse; }
.msg .msg-av { width: 28px; height: 28px; flex-shrink: 0; }
.msg .msg-av.ghost { visibility: hidden; }

.msg .bubble {
  max-width: 76%;
  padding: 9px 12px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
  animation: bubble-in 200ms var(--ease-in);
  transition: background var(--t-fast) var(--ease-in);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.mine .bubble {
  background: var(--gradient-forge);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg:not(.mine) .bubble {
  border-bottom-left-radius: 6px;
}
.msg .bubble.deleted {
  background: var(--surface-2) !important;
  color: var(--muted) !important;
  font-style: italic;
}
.msg .bubble.system {
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px; font-weight: 500;
  text-align: center;
  padding: 6px 12px;
  border-radius: 999px;
  margin: 0 auto;
  font-style: normal;
}

.msg .bubble .reply-preview {
  border-left: 3px solid rgba(255,255,255,0.45);
  padding: 4px 8px;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  cursor: pointer;
}
.msg:not(.mine) .bubble .reply-preview {
  border-left-color: var(--primary);
  background: var(--primary-soft);
}
.msg .bubble .reply-preview .who {
  font-weight: 700; margin-bottom: 1px;
}
.msg .bubble .reply-preview .txt {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}

.msg .meta {
  font-size: 10px; margin-top: 3px;
  opacity: 0.75;
  display: flex; gap: 4px; align-items: center;
  justify-content: flex-end;
}
.msg.mine .meta { color: rgba(255,255,255,0.9); }
.msg:not(.mine) .meta { color: var(--muted-2); }
.msg .meta .edited { font-style: italic; opacity: 0.7; }
.msg .meta .tick svg { width: 12px; height: 12px; }
.msg .meta .tick.read svg { color: #fff; }

.msg .sender-name {
  font-size: 11px; font-weight: 700; color: var(--primary);
  margin-bottom: 2px;
}

/* reactions row */
.reactions {
  display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap;
}
.reactions .rchip {
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-in);
}
.reactions .rchip.mine {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.msg.mine .reactions .rchip { background: rgba(255,255,255,0.18); border-color: transparent; color: #fff; }
.msg.mine .reactions .rchip.mine { background: rgba(255,255,255,0.35); }

/* composer */
.composer {
  flex-shrink: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  margin-bottom: 6px;
}
.reply-bar .info { flex: 1; min-width: 0; font-size: 12px; color: var(--primary); }
.reply-bar .info .who { font-weight: 700; }
.reply-bar .info .txt {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text); opacity: 0.85;
}
.reply-bar .close {
  width: 26px; height: 26px; border-radius: 50%;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.reply-bar .close:hover { background: var(--surface-2); }
.reply-bar .close svg { width: 14px; height: 14px; }

.composer-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.composer-row .field {
  flex: 1; position: relative;
}
.composer-row textarea {
  width: 100%;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  resize: none;
  outline: none;
  line-height: 1.35;
  transition: border-color var(--t-fast) var(--ease-in);
}
.composer-row textarea:focus { border-color: var(--primary); }
.composer-row .send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--gradient-forge);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(79,126,255,0.35);
  transition: transform var(--t-fast) var(--ease-in), opacity var(--t-fast) var(--ease-in);
}
.composer-row .send:disabled { opacity: 0.4; box-shadow: none; }
.composer-row .send:active:not(:disabled) { transform: scale(0.94); }
.composer-row .send svg { width: 20px; height: 20px; }

/* action sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5,6,12,0.55);
  backdrop-filter: blur(4px);
  animation: fade-in 200ms var(--ease-in);
}
.sheet-list {
  position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 95;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  overflow: hidden;
  animation: sheet-rise 280ms var(--ease-drawer);
}
@keyframes sheet-rise {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.sheet-list .item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  color: var(--text);
  font-size: 15px; font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast) var(--ease-in);
}
.sheet-list .item:last-child { border-bottom: none; }
.sheet-list .item:active { background: var(--surface-2); }
.sheet-list .item.danger { color: var(--error); }
.sheet-list .item svg { width: 20px; height: 20px; }
.sheet-list .emoji-row {
  display: flex; gap: 4px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.sheet-list .emoji-row button {
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast) var(--ease-in), transform var(--t-fast) var(--ease-in);
}
.sheet-list .emoji-row button:active { background: var(--surface-2); transform: scale(1.1); }

/* Jump-to-latest floating button */
.jump-btn {
  position: absolute;
  right: 16px; bottom: 90px;
  width: 44px; height: 44px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(79,126,255,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-normal) var(--ease-in), transform var(--t-fast) var(--ease-in);
}
.jump-btn.show { opacity: 1; pointer-events: auto; }
.jump-btn:active { transform: scale(0.94); }
.jump-btn svg { width: 20px; height: 20px; }

/* ---------- Chat list: groups look different from DMs ---------- */

/* Group avatars are rounded squares, DMs stay circles */
.conv-row .avatar.avatar-group {
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(79,126,255,0.20);
  position: relative;
}
.conv-row .avatar.avatar-group::after {
  content: '';
  position: absolute;
  right: -2px; bottom: -2px;
  width: 18px; height: 18px;
  background: var(--surface);
  border-radius: 6px;
  box-shadow: 0 0 0 2px var(--surface);
}
.conv-row .avatar.avatar-group svg {
  position: absolute;
  right: 0; bottom: 0;
  width: 14px; height: 14px;
  color: var(--primary);
  z-index: 1;
}

/* Small GROUP tag inline with the name */
.conv-row .name-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
