:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --accent: #5b8cff;
  --accent-2: #4574f5;
  --danger: #ff6b6b;
  --warn: #f0a23b;
  --ok: #45d483;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1f2b, var(--bg));
  color: var(--text);
  height: 100vh;
  height: 100dvh;
}

.hidden {
  display: none !important;
}
.spacer {
  flex: 1;
}
.opt {
  color: var(--muted);
  font-weight: 400;
}
.muted-row {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 6px 2px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

/* ---- Buttons ---- */
button.primary {
  background: var(--accent-2);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
button.primary:hover {
  background: var(--accent);
}
/* Filled red action button (e.g. confirm ban). Must override the ghost
   button.danger style below, so restate text colour, border and padding. */
button.primary.danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 9px;
}
button.primary.danger:hover {
  background: #ff8585;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}

button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
button.danger:hover {
  background: var(--danger);
  color: #fff;
}

.mini {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
}
.mini:hover {
  border-color: var(--muted);
}
.mini.warn {
  color: var(--warn);
  border-color: rgba(240, 162, 59, 0.4);
}
.mini.warn:hover {
  background: var(--warn);
  color: #1a1205;
}
.mini.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}
.mini.danger:hover {
  background: var(--danger);
  color: #fff;
}
.danger-text {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

.badge {
  background: var(--accent-2);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 4px;
}
.tag {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.66rem;
  padding: 1px 6px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tag.ban {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

/* ---- Auth ---- */
.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  padding: 1rem;
}
.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.card h1 {
  margin: 0;
  font-size: 1.5rem;
  text-align: center;
}
.subtitle {
  margin: 4px 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 10px;
}
.tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}
.tab.active {
  background: var(--accent-2);
  color: #fff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
input,
textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  resize: vertical;
}
input:focus,
textarea:focus {
  border-color: var(--accent);
}

.password-wrap {
  position: relative;
  display: flex;
}
.password-wrap input {
  flex: 1;
  padding-right: 58px;
}
.toggle-pw {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.toggle-pw:hover {
  color: var(--text);
}

.error {
  color: var(--danger);
  font-size: 0.82rem;
  margin: 0;
  min-height: 1em;
}
.ok-msg {
  color: var(--ok);
  font-size: 0.82rem;
  margin: 0;
}
.hint {
  color: var(--muted);
  font-size: 0.74rem;
  text-align: center;
  margin: 16px 0 0;
}

/* ---- EULA ---- */
.eula-note {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
  line-height: 1.45;
  margin: 4px 0 0;
}
.eula-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.eula-link:hover {
  text-decoration: underline;
}
.eula-meta {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  margin: 0;
}
.eula-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.eula-h {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}
.eula-p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
}
.eula-list {
  margin: 2px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}
.eula-scroll-hint {
  margin: 2px 0 0;
  text-align: center;
  color: var(--warn);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---- App shell ---- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
}

.sidebar {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.side-head .me {
  color: var(--muted);
  font-size: 0.82rem;
}
.side-nav {
  display: flex;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-btn.active {
  background: var(--panel-2);
  color: var(--text);
}

.panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 4px 10px;
}

.conv-list,
.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.conv {
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}
.conv:hover {
  background: var(--panel-2);
}
.conv.active {
  background: var(--panel-2);
  border-color: var(--border);
}
.conv-top {
  display: flex;
  align-items: center;
  gap: 7px;
}
.conv-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.conv-preview {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.user-id {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.user-id-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.user-ip {
  font-size: 0.72rem;
  color: var(--muted);
}
.user-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.subsection {
  margin-bottom: 14px;
}
.subhead {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 6px 2px;
}

.req-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px;
  margin-bottom: 10px;
}
.req-user {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.req-line {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 2px 0;
  word-break: break-word;
}
.req-card .user-actions {
  margin-top: 8px;
  justify-content: flex-start;
}
.block-hdr {
  margin-top: 18px;
}
.ip-block-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.ip-block-form input {
  flex: 1;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

/* ---- Main chat pane ---- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.chat-header h2 {
  margin: 0;
  font-size: 1.05rem;
}
.general-online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.general-online::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.e2e-badge {
  display: inline-flex;
  align-items: center;
  color: var(--ok);
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid rgba(69, 212, 131, 0.4);
  border-radius: 6px;
  padding: 1px 7px;
}
#back-btn {
  display: none;
} /* shown only on narrow screens via the media query */

/* ---- Responsive: single-column on phones (list <-> chat) ---- */
@media (max-width: 720px) {
  .app {
    max-width: 100%;
  }
  .sidebar {
    width: 100%;
    border-right: none;
  }
  .main {
    display: none;
  }
  .app.viewing-chat .sidebar {
    display: none;
  }
  .app.viewing-chat .main {
    display: flex;
  }
  .app.viewing-chat #back-btn {
    display: inline-flex;
  }
}

.messages {
  list-style: none;
  margin: 0;
  padding: 18px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.date-sep {
  align-self: center;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 2px 12px;
  border-radius: 999px;
  margin: 8px 0;
}

/* A message is a row: avatar + body (bubble + meta + reactions). */
.msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 92%;
  min-width: 0;
}
.msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg:not(.mine) {
  align-self: flex-start;
}
.msg.grouped {
  margin-top: -4px;
}
.msg-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.msg.grouped .msg-avatar {
  visibility: hidden;
  height: 0;
}
.msg-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  position: relative;
}
.msg.mine .msg-body {
  align-items: flex-end;
}
.meta {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0 4px;
}

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 9px 13px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.msg.mine .bubble {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.bubble .text {
  font-size: 0.95rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.system {
  align-self: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

/* @mentions */
.text .mention {
  color: var(--accent);
  font-weight: 600;
}
.msg.mine .text .mention {
  color: #d6e2ff;
}
.text .mention.me {
  background: rgba(91, 140, 255, 0.28);
  border-radius: 4px;
  padding: 0 3px;
}
.mention-badge {
  margin-left: auto;
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  border-radius: 6px;
  padding: 0 6px;
}

/* Image messages + lightbox */
.image-bubble {
  padding: 4px;
}
.msg-image {
  display: block;
  max-width: 280px;
  max-height: 320px;
  border-radius: 10px;
  cursor: zoom-in;
  object-fit: cover;
}
.img-caption {
  padding: 6px 8px 2px;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  padding: 24px;
}
.lightbox img {
  max-width: 95%;
  max-height: 95%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* Polls */
.poll-bubble {
  min-width: 240px;
}
.poll-q {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.poll-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.poll-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  font-size: 0.9rem;
}
.poll-opt:hover {
  border-color: var(--accent);
}
.poll-opt.mine {
  border-color: var(--accent);
}
.msg.mine .poll-opt {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.poll-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(91, 140, 255, 0.25);
  transition: width 0.3s ease;
  z-index: 0;
}
.poll-opt.mine .poll-bar {
  background: rgba(91, 140, 255, 0.45);
}
.poll-label {
  position: relative;
  z-index: 1;
  flex: 1;
}
.poll-pct {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.msg.mine .poll-pct {
  color: rgba(255, 255, 255, 0.85);
}
.poll-total {
  margin-top: 7px;
  font-size: 0.74rem;
  color: var(--muted);
}
.msg.mine .poll-total {
  color: rgba(255, 255, 255, 0.8);
}
.poll-compose {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.reactions:empty {
  display: none;
}
.reaction-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1.6;
}
.reaction-chip.mine {
  background: rgba(91, 140, 255, 0.2);
  border-color: var(--accent);
}
.react-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.85;
  padding: 3px 5px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.12s,
    background 0.12s;
}
.react-btn:hover {
  opacity: 1 !important;
  background: var(--panel-2);
}
.react-picker {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 288px;
  max-height: 232px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.react-picker button {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  transition: transform 0.1s;
}
.react-picker button:hover {
  background: var(--panel-2);
  transform: scale(1.25);
}

/* @mention autocomplete popup (sits above the composer) */
.mention-pop {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 72px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 210px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.5);
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.mention-item.active,
.mention-item:hover {
  background: var(--accent-2);
  color: #fff;
}
.mention-item .avatar {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
}

.post-notice {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.composer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.composer input {
  flex: 1;
}
.composer button.primary {
  padding-left: 22px;
  padding-right: 22px;
}
.composer-btn {
  width: 42px;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.composer-btn:hover {
  border-color: var(--muted);
  color: var(--accent);
}
.attach-menu {
  position: absolute;
  bottom: 74px;
  left: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 20;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
}
.attach-menu button {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 9px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}
.attach-menu button:hover {
  background: var(--panel-2);
}

/* ---- Modal ---- */
.modal-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h3 {
  margin: 0;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 8px;
}
.modal-close:hover {
  color: var(--text);
  background: var(--panel-2);
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.member-pick,
.ban-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 1px;
}
.check-row,
.radio-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.check-row {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  transition:
    border-color 0.12s,
    background 0.12s;
}
.check-row:hover {
  border-color: var(--muted);
}
.check-row:has(input:checked) {
  border-color: var(--accent-2);
  background: rgba(69, 116, 245, 0.12);
}
.check-row:has(input:disabled) {
  opacity: 0.55;
  cursor: default;
}
.check-row input,
.radio-row input {
  width: auto;
  margin: 0;
  accent-color: var(--accent-2);
}
.check-row .member-name {
  flex: 1;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  flex: none;
}
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  text-align: center;
  background: var(--panel-2);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  padding: 14px;
  user-select: all;
}

/* ============ New features: profile, typing, deletion, read receipts ============ */

/* Profile chip in the sidebar header (initials + name, opens the profile modal) */
.me-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
  max-width: 150px;
}
.me-chip:hover {
  background: var(--panel-2);
}
.me-avatar {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.side-head .me {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Per-message action buttons (react + more) sit together below the bubble */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  position: absolute;
  bottom: 0;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.msg:not(.mine) .msg-actions {
  right: 4px;
}
.msg.mine .msg-actions {
  left: 4px;
}
.msg:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
}
.more-btn {
  font-size: 1.15rem;
  line-height: 1;
}

/* Deleted-message tombstone */
.bubble.tombstone {
  background: transparent;
  border: 1px dashed var(--border);
}
.msg.mine .bubble.tombstone {
  background: transparent;
  border: 1px dashed var(--border);
}
.bubble.tombstone .text {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Message context menu (delete for everyone / for me) */
.msg-menu {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.msg-menu-item {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
}
.msg-menu-item:hover {
  background: var(--panel-2);
}
.msg-menu-item.danger-item {
  color: var(--danger);
}
.msg-menu-item.danger-item:hover {
  background: var(--danger);
  color: #fff;
}

/* Typing indicator line above the composer */
.typing-indicator {
  padding: 2px 18px 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  min-height: 0;
}

/* "Seen" read receipt under a DM message */
.seen-receipt {
  font-size: 0.68rem;
  color: var(--muted);
  padding: 1px 4px 0;
  align-self: flex-end;
}

/* Read-by popout (group double-click) */
.reader-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.reader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}
.reader-av {
  width: 26px;
  height: 26px;
  font-size: 0.72rem;
}

/* Profile modal */
.profile-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
}
.profile-av {
  width: 64px;
  height: 64px;
  font-size: 1.6rem;
}
.profile-name {
  font-weight: 600;
  font-size: 1rem;
}
.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.swatch {
  height: 34px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch:hover {
  transform: scale(1.06);
}
.swatch.sel {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}
