/* ═══════════════════════════════════════════════════════════════════════
   Chat panel – collapsible, resizable side panel
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Chat panel container ──────────────────────────────────────────────── */
/* A #root flex layout része – úgy tolja a tartalmat, mint a kedvencek sáv. */
#chat-panel {
  position: relative;
  flex-shrink: 0;
  width: 340px;
  height: 100vh;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: row;
  z-index: 500;
  transition: width 0.2s ease;
  overflow: hidden;
}
#chat-panel.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
  overflow: hidden;
}
#chat-panel.collapsed .chat-main,
#chat-panel.collapsed #chat-resize-handle,
#chat-panel.collapsed .chat-rail,
#chat-panel.collapsed #chat-collapse-btn,
#chat-panel.collapsed #chat-collapsed-badge {
  display: none;
}

/* Resize handle (bal széle) */
#chat-resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
}
#chat-resize-handle::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 40px;
  background: var(--border2);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.15s;
}
#chat-panel:not(.collapsed) #chat-resize-handle:hover::after { opacity: 1; }

/* ── Collapse button (collapsed állapotban látható) ────────────────────── */
#chat-collapse-btn {
  position: absolute;
  left: 0;
  top: 8px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--card);
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--txt2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 11;
  transition: background 0.15s, color 0.15s;
}
#chat-collapse-btn:hover { background: var(--hover); color: var(--primary); }
#chat-panel.collapsed #chat-collapse-btn {
  top: 6px;
  left: 4px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border-left: none;
}

/* Collapsed badge (olvasatlan összesen) */
#chat-collapsed-badge {
  position: absolute;
  left: 22px;
  top: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  z-index: 12;
}
#chat-collapsed-badge[hidden] { display: none; }
#chat-panel.collapsed #chat-collapsed-badge { left: 26px; top: 2px; }

/* ── Rail (vékony ikon sáv bal oldalon) ────────────────────────────────── */
.chat-rail {
  width: 44px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 0 6px;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
#chat-panel.collapsed .chat-rail {
  padding: 48px 0 4px;
  border-right: none;
}
.chat-rail::-webkit-scrollbar { width: 0; }

.chat-rail-item {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, transform 0.12s;
  flex-shrink: 0;
  font-size: 16px;
}
.chat-rail-item:hover {
  background: var(--hover);
  transform: scale(1.05);
}
.chat-rail-item.active {
  background: var(--pri-light);
  border: 2px solid var(--primary);
}
.chat-rail-item .chat-rail-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.chat-rail-item .chat-rail-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--bg);
}
.chat-rail-item .chat-rail-badge[hidden] { display: none; }
.chat-rail-item .chat-rail-online {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg);
}
.chat-rail-item .chat-rail-online.available { background: var(--suc-dark); }
.chat-rail-item .chat-rail-online.away { background: var(--warn); }
.chat-rail-item .chat-rail-online.dnd { background: var(--danger); }
.chat-rail-item .chat-rail-online.offline { background: var(--border2); }

/* Rail tooltip */
.chat-rail-tooltip {
  position: fixed;
  background: var(--txt);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.chat-rail-tooltip[hidden] { display: none; }

/* Rail separator */
.chat-rail-sep {
  width: 24px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  flex-shrink: 0;
}

/* Pulse animation – új üzenet és panel csukva */
@keyframes chat-rail-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.chat-rail-item.has-unread {
  animation: chat-rail-pulse 1.8s ease-in-out infinite;
}

/* Leave conversation gomb a header-ben */
.chat-header-leave {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--txt2);
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.chat-header-leave:hover { background: var(--danger); color: #fff; }

/* ── Chat main (rail mellett) ───────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Chat header ───────────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 44px;
  position: relative;
}
/* Színes felső sáv – beszélgetés típusonként */
.chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
  border-radius: 3px 3px 0 0;
}
.chat-header.conv-general::before { background: var(--primary); }
.chat-header.conv-direct::before { background: #3b82f6; }
.chat-header.conv-group::before { background: #8b5cf6; }

.chat-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
/* Header avatar */
.chat-header-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.chat-header-avatar.group {
  background: #8b5cf6;
  font-size: 13px;
}
.chat-header-avatar.general {
  background: var(--primary);
  font-size: 13px;
}
/* Header név + státusz konténer */
.chat-header-name-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-header-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-header-sub {
  font-size: 10px;
  color: var(--txt2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-header-status-dot.available { background: var(--suc-dark); }
.chat-header-status-dot.away { background: var(--warn); }
.chat-header-status-dot.dnd { background: var(--danger); }
.chat-header-status-dot.offline { background: var(--border2); }
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--txt2);
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.chat-header-btn:hover { background: var(--hover); color: var(--txt); }

/* My status indicator a header-ben */
.chat-my-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-my-status.available { background: var(--suc-dark); }
.chat-my-status.away { background: var(--warn); }
.chat-my-status.dnd { background: var(--danger); }

/* ── Context menu (jobb klick a header-re) ─────────────────────────────── */
.chat-context-menu {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px;
  z-index: 600;
  min-width: 160px;
}
.chat-context-menu[hidden] { display: none; }
.chat-context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--txt);
  transition: background 0.1s;
}
.chat-context-item:hover { background: var(--hover); }
.chat-context-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-context-dot.available { background: var(--suc-dark); }
.chat-context-dot.away { background: var(--warn); }
.chat-context-dot.dnd { background: var(--danger); }
.chat-context-item.active { font-weight: 700; background: var(--pri-light); }

/* ── Új beszélgetés modal ──────────────────────────────────────────────── */
.chat-new-conv-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-new-conv-modal[hidden] { display: none; }
.chat-new-conv-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-new-conv-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-new-conv-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
}
.chat-new-conv-name {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}
.chat-new-conv-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.chat-new-conv-user:hover { background: var(--hover); }
.chat-new-conv-user.selected { background: var(--pri-light); }
.chat-new-conv-user input[type="checkbox"] {
  margin-right: 4px;
}
.chat-new-conv-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Conversations list (left side of chat panel) ──────────────────────── */
.chat-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.chat-conv-item:hover { background: var(--hover); }
.chat-conv-item.active { background: var(--pri-light); }
.chat-conv-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--border);
}
.chat-conv-item.active .chat-conv-icon { background: var(--primary); color: #fff; }
.chat-conv-info {
  flex: 1;
  min-width: 0;
}
.chat-conv-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-conv-sub {
  font-size: 11px;
  color: var(--txt2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-conv-badge {
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.chat-conv-badge[hidden] { display: none; }

/* Online dot a conversation item-en (DM-nél) */
.chat-conv-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-conv-online-dot.online { background: var(--suc-dark); }
.chat-conv-online-dot.offline { background: var(--border2); }

/* ── Messages area ─────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

/* Date separator */
.chat-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--txt2);
  padding: 8px 0 4px;
  position: relative;
}
.chat-date-sep::before,
.chat-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 40px);
  height: 1px;
  background: var(--border);
}
.chat-date-sep::before { left: 0; }
.chat-date-sep::after { right: 0; }

/* Load more indicator */
.chat-load-more {
  text-align: center;
  font-size: 11px;
  color: var(--txt2);
  padding: 6px 0;
}

/* Unread messages separator */
.chat-unread-sep {
  text-align: center;
  font-size: 11px;
  color: var(--pri, #4a90d9);
  font-weight: 600;
  padding: 6px 0;
  position: relative;
}
.chat-unread-sep::before,
.chat-unread-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 50px);
  height: 1px;
  background: var(--pri, #4a90d9);
  opacity: 0.4;
}
.chat-unread-sep::before { left: 0; }
.chat-unread-sep::after { right: 0; }

/* Message bubble */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  animation: chat-msg-in 0.15s ease;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
/* #11/#12: Pending / failed states */
.chat-msg.pending { opacity: 0.5; }
.chat-msg.failed { opacity: 0.7; border: 1px solid #e74c3c; }
.chat-msg.failed .failed-retry { color: #e74c3c; cursor: pointer; font-weight: 600; }
/* #18: @mention highlight */
.chat-mention { color: var(--pri, #4a90d9); font-weight: 600; background: rgba(74,144,217,0.1); padding: 0 2px; border-radius: 3px; }
/* #13: Connection status */
.chat-conn-status {
  text-align: center;
  font-size: 11px;
  padding: 4px 10px;
  background: rgba(231,76,60,0.1);
  color: #e74c3c;
}
.chat-conn-status.hidden { display: none; }
/* #16: Input toggles */
.chat-input-toggles {
  display: flex;
  gap: 4px;
  padding-top: 4px;
}
.chat-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.chat-toggle-btn:hover { background: var(--hover); opacity: 1; }
/* #18: Mention popup */
.chat-mention-popup {
  position: fixed;
  z-index: 10000;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 4px;
  min-width: 160px;
}
.chat-mention-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.chat-mention-item:hover { background: var(--hover); }
.chat-msg.mine {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-msg.other {
  align-self: flex-start;
  background: var(--row-alt);
  color: var(--txt);
  border-bottom-left-radius: 3px;
}
.chat-msg-sender {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 2px;
  opacity: 0.85;
}
.chat-msg.mine .chat-msg-sender { display: none; }
.chat-msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 2px;
  text-align: right;
}

/* Reply quote */
.chat-msg-reply {
  font-size: 11px;
  opacity: 0.7;
  border-left: 2px solid currentColor;
  padding-left: 6px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* File path link */
.chat-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.08);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12px;
  text-decoration: none;
  color: inherit;
  margin: 2px 0;
  word-break: break-all;
  cursor: pointer;
  transition: background 0.1s;
}
.chat-msg.mine .chat-file-link { background: rgba(255,255,255,0.15); color: #fff; }
.chat-msg.other .chat-file-link { background: var(--pri-light); color: var(--primary); }
.chat-file-link:hover { filter: brightness(0.95); }
.chat-file-link .chat-file-copy {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 4px;
  cursor: pointer;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 4px;
}
.chat-file-link .chat-file-copy:hover { opacity: 1; }

/* Reactions */
.chat-msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.chat-reaction {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  background: rgba(0,0,0,0.06);
  transition: background 0.1s, transform 0.1s;
}
.chat-msg.mine .chat-reaction { background: rgba(255,255,255,0.15); }
.chat-reaction:hover { transform: scale(1.15); }
.chat-reaction.mine { border: 1px solid var(--primary); }
.chat-reaction-count { font-size: 10px; font-weight: 600; opacity: 0.8; }

/* Reaction picker */
.chat-reaction-picker {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  padding: 4px 6px;
  display: flex;
  gap: 2px;
  z-index: 550;
}
.chat-reaction-picker[hidden] { display: none; }
.chat-reaction-picker button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 50%;
  transition: background 0.1s, transform 0.1s;
}
.chat-reaction-picker button:hover { background: var(--hover); transform: scale(1.2); }

/* ── Typing indicator ──────────────────────────────────────────────────── */
.chat-typing {
  font-size: 11px;
  color: var(--txt2);
  padding: 2px 10px;
  font-style: italic;
  height: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-typing-dots {
  display: inline-flex;
  gap: 2px;
}
.chat-typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--txt2);
  animation: typing-bounce 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Input area ────────────────────────────────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-input-reply-preview {
  font-size: 11px;
  color: var(--txt2);
  background: var(--pri-light);
  border-radius: 6px;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-input-reply-preview[hidden] { display: none; }
.chat-input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  max-height: 100px;
  min-height: 36px;
  line-height: 1.4;
  transition: border-color 0.15s;
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}
.chat-send-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--pri-dark); }
.chat-send-btn:disabled { opacity: 0.5; cursor: default; }

/* Drag & drop overlay */
.chat-drag-overlay {
  position: absolute;
  inset: 0;
  background: rgba(74, 122, 103, 0.1);
  border: 2px dashed var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  z-index: 50;
  pointer-events: none;
}
.chat-drag-overlay[hidden] { display: none; }

/* ── "New messages" gomb ───────────────────────────────────────────────── */
.chat-scroll-btn {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 20;
  transition: opacity 0.2s;
}
.chat-scroll-btn[hidden] { display: none; }

/* ── Search bar ────────────────────────────────────────────────────────── */
.chat-search {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-search[hidden] { display: none; }
.chat-search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--txt2);
  font-size: 13px;
  gap: 8px;
  padding: 20px;
  text-align: center;
}

/* ── User avatar (színkódolt) ──────────────────────────────────────────── */
.chat-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ── User list ─────────────────────────────────────────────────────────── */
.chat-user-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Mobilon a chat panel overlay-ként működik, nem tolja a tartalmat */
  #chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: 100% !important;
    z-index: 9005;
    border-left: none;
    box-shadow: 0 0 30px rgba(0,0,0,0.25);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
    transform: translateX(0);
  }
  #chat-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    transform: translateX(100%);
    pointer-events: none;
    opacity: 0;
    display: none;
  }
  #chat-panel #chat-resize-handle {
    display: none !important;
  }
  #chat-panel #chat-collapse-btn {
    display: none !important;
  }
  /* Rail sáv mobilon: off-canvas drawer, alapból rejtve */
  #chat-panel .chat-rail {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80px;
    z-index: 10;
    background: var(--card);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex !important;
    flex-direction: column;
    padding: 52px 0 4px;
  }
  #chat-panel .chat-rail.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  /* Beszélgetés lista gomb: csak mobilon látható */
  .chat-conv-list-btn { display: inline-flex !important; }
  @media (min-width: 1025px) {
    .chat-conv-list-btn { display: none !important; }
    #chat-panel .chat-rail {
      transform: none;
      position: relative;
      width: 44px;
      padding: 0;
      flex-shrink: 0;
      background: var(--bg);
      border-right: 1px solid var(--border);
    }
  }
  .chat-header {
    padding: 12px 14px;
    min-height: 52px;
  }
  .chat-header-btn, .chat-header-leave {
    padding: 8px 10px;
    min-height: 38px;
    min-width: 38px;
    font-size: 16px;
  }
  .chat-messages {
    padding: 12px 14px;
  }
  .chat-input-area {
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  /* Chat fullscreen overlay mobilon: input a nav sáv felett */
  #chat-panel:not(.collapsed) .chat-input-area {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }
  .chat-input {
    font-size: 16px !important;
    min-height: 42px;
    padding: 10px 12px;
  }
  .chat-send-btn {
    padding: 10px 16px;
    min-height: 42px;
    font-size: 16px;
  }
}

/* #15: Rail typing indicator */
.chat-rail-typing {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 8px;
  animation: chat-typing-pulse 1s ease-in-out infinite;
}
@keyframes chat-typing-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* #19: Context menu separator */
.chat-context-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* #13: Rail tooltip preview */
.chat-rail-tooltip {
  max-width: 220px;
  line-height: 1.3;
}

/* #11: Search highlight */
.chat-msg-body mark {
  background: rgba(255, 213, 0, 0.4);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

/* #16: Keyboard navigation focus */
.chat-rail-item.kb-focus {
  outline: 2px solid var(--accent, #4a90d9);
  outline-offset: -2px;
}
