/* ---------- Chat list ---------- */
.chat-list { display: grid; }
.chat-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 8px;
  color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line);
  min-height: 64px;
}
.chat-row:hover { background: var(--card); text-decoration: none; }
.chat-row .body { flex: 1; min-width: 0; }
.chat-row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .preview { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .preview.unread { color: var(--text); font-weight: 600; }
.chat-row .meta { display: grid; justify-items: end; gap: 6px; font-size: .75rem; color: var(--faint); flex: none; }
.badge-count {
  min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center;
  border-radius: var(--radius-pill); background: var(--violet-600); color: #fff; font-size: .75rem; font-weight: 700;
}
.search-box { position: relative; }
.search-box > svg { position: absolute; left: 14px; top: 13px; color: var(--faint); pointer-events: none; }
.search-box .input { padding-left: 44px; }

.fab {
  position: fixed; right: 16px; z-index: 15; width: 56px; height: 56px; border-radius: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  display: grid; place-items: center; background: var(--violet-600); color: #fff;
  box-shadow: 0 8px 20px rgba(124, 58, 237, .4);
}
.fab:hover { background: var(--violet-700); text-decoration: none; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

/* ---------- Conversation screen ---------- */
.chat {
  height: 100dvh; display: flex; flex-direction: column;
  max-width: 760px; margin: 0 auto; background: var(--bg);
  padding-top: 0;
}
.chat-head {
  display: flex; align-items: center; gap: 4px; flex: none;
  padding: calc(var(--safe-t) + 6px) 8px 6px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--card-2); text-decoration: none; }
.icon-btn.small { width: 32px; height: 32px; }
.chat-peer {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 8px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); text-align: left; cursor: pointer;
}
.chat-peer:hover { background: var(--card-2); }
.peer-text { min-width: 0; }
.peer-text .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-text .sub { font-size: .75rem; color: var(--muted); }

.chat-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; padding: 12px;
}
.load-older { align-self: center; margin-bottom: 8px; min-height: 40px; font-size: .875rem; }
.msg-list { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.empty-chat { padding: 32px 0; }

.msg {
  max-width: 82%; padding: 8px 12px; border-radius: 18px; background: var(--card-2);
  align-self: flex-start; border-bottom-left-radius: 6px; cursor: pointer;
}
.msg.mine { align-self: flex-end; background: var(--violet-600); color: #fff; border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.msg.deleted { cursor: default; background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }
.msg.deleted .msg-text { font-style: italic; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { margin-top: 2px; font-size: .6875rem; opacity: .75; text-align: right; }
.quote {
  margin-bottom: 4px; padding: 4px 8px; border-left: 3px solid var(--cyan); border-radius: 6px;
  background: rgba(0, 0, 0, .22); font-size: .8125rem;
}
.quote-text { opacity: .85; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.day-sep { align-self: center; margin: 12px 0 6px; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--card); color: var(--faint); font-size: .75rem; }

.chat-foot { flex: none; padding: 8px 8px calc(var(--safe-b) + 8px); border-top: 1px solid var(--line); background: var(--surface); }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea.input { flex: 1; min-height: 44px; max-height: 120px; padding: 10px 16px; border-radius: 22px; resize: none; overflow-y: auto; }
.send-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--violet-600); color: #fff; cursor: pointer;
}
.send-btn[disabled] { opacity: .4; cursor: not-allowed; }
.bar { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; color: var(--muted); font-size: .8125rem; }
.bar-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blocked-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px; color: var(--muted); }

/* ---------- Action sheet / info ---------- */
dialog.sheet { margin-top: auto; margin-bottom: 0; max-width: 520px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
dialog.sheet .dialog-body { display: grid; gap: 4px; padding: 16px 12px calc(var(--safe-b) + 12px); }
.sheet-title { text-align: center; padding-bottom: 6px; font-size: .875rem; }
.sheet-btn {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 12px; width: 100%;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: 1rem; text-align: left; cursor: pointer;
}
.sheet-btn:hover { background: var(--card-2); }
.sheet-btn.danger { color: var(--danger); }
.info { display: grid; justify-items: center; gap: 4px; padding: 8px 8px 16px; text-align: center; }
.info-bio { margin-top: 6px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- Phase 2B: status line, search, reactions, toggles ---------- */
.peer-text .sub.live { color: var(--cyan); }
.search-bar { flex: none; display: grid; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.search-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8125rem; }
.search-row .btn { min-height: 36px; padding: 0 12px; font-size: .8125rem; }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, .22); color: inherit; font-size: .8125rem; cursor: pointer;
}
.react.mine { border-color: var(--cyan); background: rgba(34, 211, 238, .16); }
.react-picker { display: flex; justify-content: space-between; gap: 4px; padding: 0 4px 8px; }
.react-opt {
  width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--card); font-size: 1.5rem; cursor: pointer;
}
.react-opt.on { outline: 2px solid var(--cyan); }
.msg.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--cyan); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .msg.flash { animation: none; outline: 2px solid var(--cyan); } }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; cursor: pointer; }
.toggle-text { display: grid; gap: 2px; min-width: 0; }
.toggle-label { font-weight: 600; }
.toggle-help { font-size: .8125rem; }
.toggle-row input[type=checkbox] { width: 24px; height: 24px; flex: none; accent-color: var(--violet-600); }
