/* ═══════════════════════════════════════════════════
   Skritka – Chat Area
   ═══════════════════════════════════════════════════ */

/* ─── Main Content Panel ─── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-mid);
  overflow: hidden;
}

/* ─── Chat Header ─── */

.chat-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.3);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.chat-header .channel-hash {
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 600;
}

.chat-header-name {
  font-weight: 700;
  font-size: 15px;
}

.chat-header-verified {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  cursor: pointer;
  margin-left: 2px;
  transition: color var(--transition);
}

.chat-header-verified .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 1;
}

.chat-header-verified:hover {
  color: var(--accent-hover);
}

.chat-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.encryption-badge {
  font-size: 12px;
  background: var(--accent-glow);
  color: var(--green);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s;
}

.encryption-badge:hover {
  background: rgba(16, 185, 129, 0.2);
}

.encryption-badge.verified {
  color: var(--accent);
  background: rgba(88, 101, 242, 0.12);
}

.encryption-badge.verified:hover {
  background: rgba(88, 101, 242, 0.2);
}

/* ─── Verify Safety Number Modal ─── */

.verify-modal-body {
  text-align: center;
}

.verify-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.verify-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 16px 0;
  text-align: left;
}

.verify-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

.verify-status .material-symbols-outlined {
  font-size: 18px;
}

.verify-status.verified {
  background: rgba(88, 101, 242, 0.12);
  color: var(--accent);
}

.verify-status.unverified {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.verify-status.warning {
  background: rgba(244, 63, 94, 0.1);
  color: var(--red);
}

/* Signal-style safety number grid (4 rows × 3 columns of 5-digit groups) */
.safety-number-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 16px;
  padding: 16px 20px;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  margin: 16px 0;
  user-select: all;
}

.safety-number-group {
  font-family: 'Courier New', Courier, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 3px;
  text-align: center;
  padding: 4px 0;
}

/* QR code */
.safety-number-qr {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.safety-number-qr svg {
  width: 180px;
  height: 180px;
  background: #fff;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.verify-fingerprints {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.verify-fp-block {
  flex: 1;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.verify-fp-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.verify-fp-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  line-height: 1.6;
  user-select: all;
}

.verify-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.verify-actions .btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.verify-actions .btn .material-symbols-outlined {
  font-size: 18px;
}

.verify-actions .btn-primary {
  background: var(--accent);
  color: #fff;
}

.verify-actions .btn-primary:hover {
  background: var(--accent-hover);
}

.verify-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.verify-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ─── Profile Panel: Encryption Section ─── */

.profile-encryption-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.profile-encryption-status.verified {
  background: rgba(88, 101, 242, 0.12);
  color: var(--accent);
}

.profile-encryption-status.encrypted {
  background: rgba(59, 165, 93, 0.12);
  color: var(--green);
}

.profile-encryption-status.warning {
  background: rgba(244, 63, 94, 0.1);
  color: var(--red);
}

.profile-encryption-status.none {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.profile-verify-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.profile-verify-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ─── Chat Area ─── */

.chat-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.messages-welcome {
  padding: 32px 16px 16px;
}

.messages-welcome h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.messages-welcome p {
  color: var(--text-secondary);
}

#messages-list {
  padding: 0 16px;
}

/* ─── Message Styles ─── */

.message {
  display: flex;
  gap: 16px;
  padding: 4px 48px 4px 0;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  position: relative;
}

.message:hover {
  background: rgba(0,0,0,0.08);
}

.message:hover .msg-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-body {
  min-width: 0;
  flex: 1;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.message-author {
  font-weight: 600;
  font-size: 15px;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
}

.message-content {
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--text-primary);
}

.message-content img.emoji {
  width: 1.375em;
  height: 1.375em;
  vertical-align: -0.3em;
  margin: 0 1px;
  object-fit: contain;
}

/* Global fallback for twemoji images anywhere */
img.emoji {
  width: 1.375em;
  height: 1.375em;
  vertical-align: -0.3em;
  margin: 0 1px;
  object-fit: contain;
}

.message-content code {
  background: rgba(0,0,0,0.3);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
}

.message-encrypted-icon {
  color: var(--green);
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
}

.message-encrypted-icon .material-symbols-outlined {
  font-size: 13px;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.message-encrypted-icon.key-changed {
  color: var(--yellow, #fdcb6e);
}

.message-encrypted-icon.undecryptable {
  color: var(--text-muted, #aaa);
}

/* ─── Encrypted / Blurred Messages ─── */

.encrypted-blur {
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
  display: inline-block;
  color: var(--text-secondary);
  transition: filter 0.3s;
}

.encrypted-blur-time {
  font-size: inherit;
  filter: blur(4px);
}

.message.encrypted-message {
  opacity: 0.85;
}

.message.encrypted-message .message-content {
  position: relative;
}

/* After key change — subtle left border warning */
.message.after-key-change {
  border-left: 3px solid var(--yellow, #fdcb6e);
  padding-left: 13px;
}

/* ─── Key Change System Notice ─── */

.key-change-notice {
  text-align: center;
  padding: 12px 16px !important;
  margin: 8px 0;
}

.key-change-notice-content {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(253, 203, 110, 0.08);
  border: 1px solid rgba(253, 203, 110, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  max-width: 500px;
  text-align: left;
}

.key-change-notice-content > .material-symbols-outlined {
  font-size: 24px;
  color: var(--yellow, #fdcb6e);
  font-variation-settings: 'FILL' 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.key-change-notice-content strong {
  display: block;
  color: var(--yellow, #fdcb6e);
  font-size: 13px;
  margin-bottom: 4px;
}

.key-change-notice-content p {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}

/* ─── Member Join System Message ─── */

.member-join-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 48px 6px 16px !important;
  margin: 2px 0;
  background: transparent;
  min-height: auto;
}

.member-join-message:hover {
  background: var(--bg-hover);
}

.member-join-message .system-message-icon {
  flex-shrink: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.member-join-message .system-message-icon .material-symbols-outlined {
  font-size: 22px;
  color: #57F287;
  font-variation-settings: 'FILL' 1;
}

.member-join-message .system-message-body {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.member-join-message .system-message-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
}

.member-join-message .system-message-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.member-join-message .message-timestamp {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

/* Grouped messages (same author within 5 min) */
.message.grouped {
  padding-top: 0;
  margin-top: -2px;
}

.message.grouped .message-avatar {
  visibility: hidden;
  height: 0;
  width: 40px;
}

.message.grouped .message-header {
  display: none;
}

/* ─── Typing Indicator ─── */

.typing-indicator {
  padding: 4px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 24px;
}

/* ─── Message Input ─── */

.message-input-container {
  padding: 0 16px 16px;
  flex-shrink: 0;
  position: relative;
}

/* ─── @Mention Autocomplete Popup ─── */

.mention-popup {
  position: absolute;
  bottom: 100%;
  left: 16px;
  right: 16px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-dark);
  border: 1px solid var(--bg-lighter);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 4px;
  margin-bottom: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 100;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.mention-item.active {
  background: var(--bg-hover);
}

.mention-item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.mention-item-avatar .avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mention-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.mention-item-username {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Mention Highlights in Messages ─── */

.mention {
  background: rgba(88, 101, 242, 0.15);
  color: #7289da;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
  cursor: pointer;
}

.mention:hover {
  background: rgba(88, 101, 242, 0.3);
  color: #99aab5;
}

.mention.mention-me {
  background: rgba(88, 101, 242, 0.25);
  color: #dee0fc;
}

.message-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 4px 12px;
  border: 1px solid transparent;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.message-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.message-input-wrapper input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  padding: 10px 4px;
  outline: none;
}

.message-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn .material-symbols-outlined {
  font-size: 20px;
}

.send-btn:hover {
  background: var(--accent-glow);
  color: var(--green);
}

/* ─── Emoji Button ─── */

.emoji-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-btn .material-symbols-outlined {
  font-size: 20px;
}

.emoji-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.emoji-btn.active {
  color: var(--accent);
}

/* ─── Emoji Picker ─── */

.emoji-picker {
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 352px;
  height: 420px;
  background: var(--bg-dark);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 1200;
  margin-bottom: 8px;
}

.emoji-picker-header {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.emoji-search {
  width: 100%;
  background: var(--bg-mid);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
}

.emoji-search:focus {
  border-color: var(--accent);
}

.emoji-search::placeholder {
  color: var(--text-muted);
}

.emoji-picker-categories {
  display: flex;
  padding: 0 8px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  justify-content: space-between;
}

.emoji-cat-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-cat-btn .material-symbols-outlined {
  font-size: 20px;
}

.emoji-cat-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.emoji-cat-btn.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.emoji-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  min-height: 0;
}

.emoji-category-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 0 4px;
  letter-spacing: 0.5px;
}

.emoji-category-items {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-item {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  text-align: center;
  transition: background 0.1s, transform 0.1s;
}

.emoji-item img.emoji {
  width: 22px;
  height: 22px;
  vertical-align: -0.1em;
}

.emoji-item:hover {
  background: rgba(255,255,255,0.1);
  transform: scale(1.2);
}

/* ─── GIF Button ─── */

.gif-btn {
  background: none;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-right: 2px;
}

.gif-btn-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.gif-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.gif-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── GIF Picker ─── */

.gif-picker {
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 420px;
  height: 480px;
  background: var(--bg-dark);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 1200;
  margin-bottom: 8px;
}

.gif-picker-header {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.gif-search {
  width: 100%;
  background: var(--bg-mid);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
}

.gif-search:focus {
  border-color: var(--accent);
}

.gif-search::placeholder {
  color: var(--text-muted);
}

.gif-picker-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 12px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.gif-cat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-mid);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px 12px 4px 4px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  overflow: hidden;
}

.gif-cat-chip img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.gif-cat-chip:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--accent);
}

.gif-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
  column-count: 2;
  column-gap: 6px;
}

.gif-item {
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.15s;
  position: relative;
  background: var(--bg-mid);
  break-inside: avoid;
  margin-bottom: 6px;
}

.gif-item img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
}

.gif-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 1;
}

.gif-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 14px;
}

.gif-picker-attribution {
  flex-shrink: 0;
  padding: 6px 12px;
  text-align: right;
  border-top: 1px solid rgba(255,255,255,0.06);
  opacity: 0.6;
}

.gif-picker-attribution img {
  height: 14px;
}

.message-input-container {
  position: relative;
}

/* ─── Message Hover Toolbar ─── */

.msg-toolbar {
  position: absolute;
  top: -16px;
  right: 4px;
  display: flex;
  gap: 0;
  background: var(--bg-dark);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.msg-toolbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.msg-toolbar-btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.msg-toolbar-btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.msg-toolbar-btn .material-symbols-outlined {
  font-size: 18px;
}

.msg-toolbar-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

/* ─── Message Context Menu ─── */

.msg-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-dark);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 200px;
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.msg-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.msg-ctx-item .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.msg-ctx-item:hover {
  background: var(--accent);
  color: #fff;
}

.msg-ctx-item:hover .material-symbols-outlined {
  color: #fff;
}

.msg-ctx-item.danger:hover {
  background: var(--red, #ed4245);
}

.msg-ctx-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 0;
}

/* ─── Message Editing ─── */

.message.editing {
  background: rgba(88, 101, 242, 0.06);
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}

.msg-edit-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-edit-input {
  width: 100%;
  background: var(--bg-light);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.msg-edit-input:focus {
  border-color: var(--accent);
}

.msg-edit-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-edit-link {
  color: var(--accent);
  cursor: pointer;
}

.msg-edit-link:hover {
  text-decoration: underline;
}

/* ─── Edited Tag ─── */

.message-edited {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ─── Message Blockquote ─── */

.msg-blockquote {
  border-left: 3px solid rgba(255,255,255,0.16);
  padding: 2px 0 2px 12px;
  margin: 4px 0;
  color: var(--text-muted);
}

/* ─── Message Embeds ─── */

.msg-embed {
  margin-top: 8px;
  max-width: 400px;
  border-radius: 8px;
  overflow: hidden;
}

.msg-embed-image img {
  max-width: 400px;
  max-height: 300px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
  object-fit: contain;
}

.msg-embed-image a {
  display: block;
  line-height: 0;
}

.msg-embed-video {
  max-width: 400px;
  border-radius: 8px;
  overflow: hidden;
}

.msg-embed-video iframe,
.msg-embed-video video {
  border-radius: 8px;
  display: block;
  max-width: 100%;
}

/* ─── YouTube Discord-style embed card ─── */
.msg-embed-yt {
  max-width: 432px;
  margin-top: 4px;
}

.yt-embed-card {
  background: var(--bg-dark, #2f3136);
  border-left: 4px solid #ff0000;
  border-radius: 4px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.yt-embed-provider {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
}

.yt-embed-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent, #00b0f4);
  text-decoration: none;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.yt-embed-title:hover {
  text-decoration: underline;
}

.yt-embed-player {
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
  line-height: 0;
}

.yt-embed-player iframe {
  width: 400px;
  height: 225px;
  max-width: 100%;
  border: none;
  border-radius: 4px;
  display: block;
}

.msg-embed-tenor img {
  max-width: 300px;
  max-height: 250px;
  border-radius: 8px;
  display: block;
}

/* ─── Twitter/X Discord-style embed card ─── */
.msg-embed-x {
  max-width: 432px;
  margin-top: 4px;
}

.x-embed-card {
  background: var(--bg-dark, #2f3136);
  border-left: 4px solid #1d9bf0;
  border-radius: 4px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.x-embed-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.x-embed-logo {
  color: var(--text-normal, #dcddde);
  flex-shrink: 0;
}

.x-embed-provider {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.x-embed-author {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.x-embed-displayname {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal, #dcddde);
  text-decoration: none;
}

a.x-embed-displayname:hover {
  text-decoration: underline;
}

.x-embed-username {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.x-embed-text {
  font-size: 14px;
  color: var(--text-normal, #dcddde);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

.x-embed-media {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.x-embed-media img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
  object-fit: cover;
}
.x-embed-media img:hover {
  opacity: 0.9;
}

/* When message content is just a URL + embed, make link text subtle */
.message-content > a:first-child:last-of-type {
  /* Keep normal styling — embed appears below */
}

/* ─── Forward Label (Discord-style) ─── */

.message-forward-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.message-forward-label .material-symbols-outlined {
  font-size: 14px;
}

/* ─── Reply Bar (above input) ─── */

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-dark);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 8px 12px;
  border-bottom: 2px solid var(--accent);
  gap: 8px;
}

.reply-bar-content {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

.reply-bar-icon {
  font-size: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

.reply-bar-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.reply-bar-close:hover {
  color: var(--text-normal);
  background: rgba(255,255,255,0.08);
}

.reply-bar-close .material-symbols-outlined {
  font-size: 18px;
}

/* ─── Reply Reference (Discord-style, inside message-body) ─── */

/* Spine connector: L-shape from avatar column up to reply ref */
.message.has-reply {
  position: relative;
}

.message.has-reply > .message-avatar {
  /* push avatar below the reply-ref row, like Discord */
  z-index: 1;
  margin-top: 22px;
}

.message.has-reply::before {
  content: '';
  position: absolute;
  /* center of avatar column (avatar is 40px wide) */
  left: 20px;
  /* vertical center of reply-ref area */
  top: 12px;
  /* extend down to where avatar starts */
  height: 18px;
  /* horizontal span from avatar center to start of message-body */
  width: 36px;
  border-left: 2px solid var(--text-muted);
  border-top: 2px solid var(--text-muted);
  border-top-left-radius: 6px;
  opacity: 0.35;
}

.message-reply-ref {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  cursor: pointer;
  padding: 2px 0;
}

.message-reply-ref:hover .reply-ref-text {
  color: var(--text-normal);
}

/* Small avatar for the replied-to user */
.reply-ref-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}

.reply-ref-avatar img,
img.reply-ref-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
}

.reply-ref-author {
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.reply-ref-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.1s;
}

/* ─── Message Highlight (scroll-to) ─── */

.message.highlight {
  background: rgba(88, 101, 242, 0.12);
  transition: background 0.5s ease-out;
}

/* ─── Forward Modal ─── */

.forward-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.forward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.forward-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-normal);
}

.forward-item .material-symbols-outlined {
  font-size: 20px;
  opacity: 0.6;
}

.forward-item-name {
  font-size: 14px;
}

.forward-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ─── Reaction Pills ─── */

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.reaction-pill:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}

.reaction-pill.mine {
  background: rgba(88, 101, 242, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.reaction-pill.mine:hover {
  background: rgba(88, 101, 242, 0.25);
}

.reaction-pill img.emoji {
  width: 16px;
  height: 16px;
}

.add-reaction-pill {
  border-style: dashed;
  color: var(--text-muted);
  opacity: 0.6;
}

.add-reaction-pill:hover {
  opacity: 1;
}

/* ─── Reactions Modal (Discord-style) ─── */

.reactions-modal-tabs {
  display: flex;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.reactions-modal-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.reactions-modal-tab:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-normal);
}

.reactions-modal-tab.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--accent);
}

.reactions-modal-panel {
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
}

.reactions-modal-panel.active {
  display: flex;
}

.reactions-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.reactions-user-row:hover {
  background: rgba(255,255,255,0.04);
}

.reactions-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  overflow: hidden;
}

.reactions-user-avatar img,
img.reactions-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.reactions-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.reactions-user-name {
  font-weight: 600;
  font-size: 14px;
}

.reactions-user-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.reactions-remove-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 0;
}

.reactions-remove-btn .material-symbols-outlined {
  font-size: 18px;
}

.reactions-remove-btn:hover {
  color: var(--danger, #ed4245);
  background: rgba(237, 66, 69, 0.1);
}

.reactions-user-row.is-me:hover .reactions-remove-btn {
  display: flex;
}
