.chat-container {
  display: flex;
  flex-direction: row;
  height: calc(100vh - var(--p-navbar-h, 64px) - 48px);
  min-height: 500px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--p-surface, #fff);
  border: 1px solid var(--p-border, #e2e8f0);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  width: 360px;
  min-width: 320px;
  max-width: 400px;
  border-right: 1px solid var(--p-border, #e2e8f0);
  background: var(--p-surface, #fff);
  overflow: hidden;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--p-border, #e2e8f0);
}

.chat-sidebar-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--p-text, #1e293b);
  letter-spacing: -0.3px;
}

.chat-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 14px 8px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--p-border, #e2e8f0);
  background: var(--p-surface-2, #f8fafc);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-search-wrap:focus-within {
  border-color: var(--p-primary, #8a2be2);
  box-shadow: 0 0 0 3px rgba(138,43,226,0.1);
}

.chat-search-icon { flex-shrink: 0; color: var(--p-text-3, #94a3b8); }

.chat-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 13.5px;
  color: var(--p-text, #1e293b);
  font-family: inherit;
  padding: 2px 0;
}

.chat-search-input::placeholder { color: var(--p-text-3, #94a3b8); }

.chat-search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--p-border, #e2e8f0);
  color: var(--p-text-2, #64748b);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.chat-search-clear:hover { background: var(--p-text-3, #94a3b8); color: #fff; }

.chat-search-result { cursor: pointer; }
.chat-search-result:hover { background: var(--p-sidebar-hover, rgba(138,43,226,0.06)); }

.chat-notif-settings {
  margin: 4px 14px 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--p-border, #e2e8f0);
  background: var(--p-surface-2, #f8fafc);
}

.chat-notif-settings-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--p-text-2, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.chat-notif-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--p-text, #1e293b);
}

.chat-notif-toggle input[type="checkbox"] { accent-color: var(--p-primary, #8a2be2); width: 15px; height: 15px; cursor: pointer; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--p-border, #e2e8f0) transparent;
}

.chat-list::-webkit-scrollbar { width: 5px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--p-border, #e2e8f0); border-radius: 10px; }

.chat-loading { display: flex; align-items: center; justify-content: center; padding: 40px 20px; color: var(--p-text-2, #64748b); font-size: 14px; }

.chat-divider {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--p-text-3, #94a3b8);
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background-color 0.12s;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  position: relative;
}

.chat-item:hover { background: var(--p-sidebar-hover, rgba(138,43,226,0.06)); }
.chat-item.active { background: var(--p-sidebar-active, rgba(138,43,226,0.1)); }
.chat-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--p-primary, #8a2be2);
}

.chat-item-pinned .chat-item-name::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  background: var(--p-text-3, #94a3b8);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='17' x2='12' y2='22'/%3E%3Cpath d='M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z'/%3E%3C/svg%3E") no-repeat center;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='17' x2='12' y2='22'/%3E%3Cpath d='M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z'/%3E%3C/svg%3E") no-repeat center;
  mask-size: contain;
  -webkit-mask-size: contain;
  vertical-align: middle;
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--p-primary-grad, linear-gradient(135deg, #8a2be2, #a855f7));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  font-weight: 700;
  overflow: hidden;
  position: relative;
}

.chat-item-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-item-avatar-public { background: linear-gradient(135deg, #3b82f6, #06b6d4); }

.chat-item-avatar .online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--p-surface, #fff);
  background: #22c55e;
}

.chat-item-info { flex: 1; min-width: 0; }

.chat-item-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--p-text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-name-unread { font-weight: 700; }

.chat-item-preview {
  font-size: 12.5px;
  color: var(--p-text-2, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.chat-item-preview-unread { color: var(--p-text, #1e293b); font-weight: 600; }

.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  min-width: 50px;
}

.chat-item-time { font-size: 11px; color: var(--p-text-3, #94a3b8); white-space: nowrap; }

.chat-item-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 4px rgba(239,68,68,0.3);
}

.chat-panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
  margin-left: 8px;
}

.chat-empty-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
}

.chat-empty-sidebar-icon { font-size: 36px; margin-bottom: 14px; opacity: 0.5; }
.chat-empty-sidebar-text { font-size: 15px; font-weight: 600; color: var(--p-text, #1e293b); margin-bottom: 4px; }
.chat-empty-sidebar-sub { font-size: 13px; color: var(--p-text-2, #64748b); max-width: 220px; }

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--p-surface-2, #f8fafc);
  position: relative;
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px;
  gap: 4px;
}

.chat-empty-icon { margin-bottom: 16px; opacity: 0.4; }
.chat-empty-title { font-size: 20px; font-weight: 700; color: var(--p-text, #1e293b); margin-bottom: 6px; }
.chat-empty-sub { font-size: 14px; color: var(--p-text-2, #64748b); max-width: 300px; line-height: 1.5; }

.chat-room {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-room-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--p-surface, #fff);
  border-bottom: 1px solid var(--p-border, #e2e8f0);
  flex-shrink: 0;
  min-height: 64px;
}

.chat-room-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.chat-room-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--p-primary-grad, linear-gradient(135deg, #8a2be2, #a855f7));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.chat-room-avatar-img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-room-avatar .online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--p-surface, #fff);
  background: #22c55e;
}

.chat-room-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--p-text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-room-subtitle {
  font-size: 12px;
  color: var(--p-text-2, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.chat-room-more {
  background: none;
  border: none;
  color: var(--p-text-2, #64748b);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.12s;
}

.chat-room-more:hover { background: var(--p-sidebar-hover, rgba(138,43,226,0.06)); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--p-border, #e2e8f0) transparent;
  background: var(--p-chat-bg, #f0f2f5);
}

[data-theme="dark"] .chat-messages { background: var(--p-chat-bg, #0b141a); }
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--p-border, #e2e8f0); border-radius: 10px; }

.chat-loading-messages { display: flex; align-items: center; justify-content: center; flex: 1; color: var(--p-text-2, #64748b); font-size: 14px; }
.chat-no-messages { display: flex; align-items: center; justify-content: center; flex: 1; color: var(--p-text-3, #94a3b8); font-size: 13.5px; text-align: center; padding: 40px; }

.chat-date-separator {
  text-align: center;
  padding: 12px 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--p-text-3, #94a3b8);
}

.chat-bubble {
  max-width: 70%;
  padding: 8px 14px;
  border-radius: 16px;
  position: relative;
  word-wrap: break-word;
  animation: chatSlideIn 0.15s ease-out;
  line-height: 1.45;
}

.chat-bubble-mine {
  align-self: flex-end;
  background: var(--p-primary, #8a2be2);
  color: #fff;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}

.chat-bubble-theirs {
  align-self: flex-start;
  background: var(--p-surface, #fff);
  color: var(--p-text, #1e293b);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.chat-bubble-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }

.chat-bubble-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--p-primary-grad, linear-gradient(135deg, #8a2be2, #a855f7));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-bubble-sender { font-size: 12px; font-weight: 700; color: var(--p-primary, #8a2be2); }
.chat-bubble-mine .chat-bubble-sender { color: rgba(255,255,255,0.9); }

.chat-bubble-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.chat-bubble-mine .chat-bubble-text { color: #fff; }

.chat-bubble-footer { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; }
.chat-bubble-time { font-size: 10.5px; opacity: 0.7; white-space: nowrap; }
.chat-bubble-mine .chat-bubble-time { color: rgba(255,255,255,0.8); }

.chat-msg-status { display: inline-flex; align-items: center; opacity: 0.8; color: rgba(255,255,255,0.8); }

.chat-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.chat-bubble-mine .chat-link { color: rgba(255,255,255,0.9); }

.chat-delete-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  color: inherit;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
}

.chat-bubble:hover .chat-delete-btn { display: inline-flex; }
.chat-delete-btn:hover { opacity: 1; background: rgba(239,68,68,0.15); color: #ef4444; }
.chat-bubble-mine .chat-delete-btn { color: rgba(255,255,255,0.6); }
.chat-bubble-mine .chat-delete-btn:hover { color: #fca5a5; background: rgba(255,255,255,0.15); }

.chat-role-badge { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 8px; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0; }
.chat-role-admin { background: rgba(239,68,68,0.15); color: #dc2626; }
.chat-role-teacher { background: rgba(37,99,235,0.15); color: #2563eb; }
.chat-bubble-mine .chat-role-admin { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.95); }
.chat-bubble-mine .chat-role-teacher { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.95); }

.chat-typing-indicator {
  align-self: flex-start;
  font-size: 12px;
  color: var(--p-text-3, #94a3b8);
  font-style: italic;
  padding: 4px 0;
  animation: chatPulse 1.5s ease-in-out infinite;
}

.chat-input-area { padding: 12px 18px 14px; background: var(--p-surface, #fff); border-top: 1px solid var(--p-border, #e2e8f0); flex-shrink: 0; }

.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 18px;
  border-radius: 24px;
  border: 1px solid var(--p-border, #e2e8f0);
  background: var(--p-surface-2, #f8fafc);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrap:focus-within { border-color: var(--p-primary, #8a2be2); box-shadow: 0 0 0 3px rgba(138,43,226,0.08); }

.chat-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--p-text-3, #94a3b8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.chat-attach-btn:hover { color: var(--p-primary, #8a2be2); background: rgba(138,43,226,0.06); }

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 14px;
  color: var(--p-text, #1e293b);
  font-family: inherit;
  padding: 8px 0;
}

.chat-input::placeholder { color: var(--p-text-3, #94a3b8); }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--p-primary, #8a2be2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.chat-send-btn:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(138,43,226,0.3); }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn svg { margin-left: 2px; }

.chat-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--p-text-2, #64748b);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-settings-btn:hover { background: var(--p-sidebar-hover, rgba(138,43,226,0.06)); color: var(--p-primary, #8a2be2); }

.chat-pin-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--p-text-3, #94a3b8);
  transition: color 0.15s, background 0.15s;
}

.chat-item:hover .chat-pin-btn { display: flex; }
.chat-pin-btn:hover { color: var(--p-primary, #8a2be2); background: rgba(138,43,226,0.06); }
.chat-pin-btn.pinned { display: flex; color: var(--p-primary, #8a2be2); }

.chat-delete-chat-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--p-text-3, #94a3b8);
  transition: color 0.15s, background 0.15s;
}

.chat-item:hover .chat-delete-chat-btn { display: flex; }
.chat-delete-chat-btn:hover { color: #ef4444; background: rgba(239,68,68,0.08); }

[data-theme="dark"] .chat-delete-chat-btn { color: var(--p-text-2, #94a3b8); }
[data-theme="dark"] .chat-delete-chat-btn:hover { color: #fca5a5; background: rgba(239,68,68,0.15); }


.chat-sidebar-footer {
  display: none;
  flex-shrink: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--p-border, #e2e8f0);
  background: var(--p-surface, #fff);
  
}

.chat-sidebar-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  background: var(--p-primary, #8a2be2);
  color: #fff;
  cursor: pointer;
  border-radius: 12px;
  transition: opacity 0.15s, transform 0.15s;
  font-size: 14px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chat-sidebar-back-btn:hover { opacity: 0.9; transform: scale(1.01); }
.chat-sidebar-back-btn:active { transform: scale(0.97); }
.chat-sidebar-back-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.chat-room-actions {
  display: none;
  flex-shrink: 0;
  padding: 8px 12px;
  gap: 8px;
  border-top: 1px solid var(--p-border, #e2e8f0);
  background: var(--p-surface, #fff);
  
}

.chat-room-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: opacity 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chat-room-action-btn:first-child {
  background: var(--p-primary, #8a2be2);
  color: #fff;
}

.chat-room-action-btn:last-child {
  background: var(--p-surface-2, #f1f5f9);
  color: var(--p-text, #1e293b);
}

.chat-room-action-btn:hover { opacity: 0.9; transform: scale(1.01); }
.chat-room-action-btn:active { transform: scale(0.97); }
.chat-room-action-btn svg { width: 20px; height: 20px; flex-shrink: 0; }


.chat-room { position: relative; }
.chat-room-slide-enter { animation: chatSlideRight 0.25s ease-out; }
.chat-room-slide-leave { animation: chatSlideRightReverse 0.2s ease-in; }

@keyframes chatSlideRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes chatSlideRightReverse {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}


[data-theme="dark"] .chat-sidebar { background: var(--p-surface, #1e293b); border-right-color: var(--p-border, #334155); }
[data-theme="dark"] .chat-sidebar-header,
[data-theme="dark"] .chat-room-header { background: var(--p-surface, #1e293b); border-color: var(--p-border, #334155); }
[data-theme="dark"] .chat-item { border-color: rgba(255,255,255,0.04); }
[data-theme="dark"] .chat-bubble-theirs { background: var(--p-surface-2, #263347); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
[data-theme="dark"] .chat-input-area { background: var(--p-surface, #1e293b); border-color: var(--p-border, #334155); }
[data-theme="dark"] .chat-input-wrap { background: var(--p-surface-2, #263347); border-color: var(--p-border, #334155); }
[data-theme="dark"] .chat-input { color: var(--p-text, #f8fafc); }
[data-theme="dark"] .chat-main { background: var(--p-surface-2, #0f172a); }
[data-theme="dark"] .chat-empty-state { background: var(--p-surface-2, #0f172a); }
[data-theme="dark"] .chat-role-admin { background: rgba(239,68,68,0.2); color: #fca5a5; }
[data-theme="dark"] .chat-role-teacher { background: rgba(37,99,235,0.2); color: #93c5fd; }
[data-theme="dark"] .chat-search-wrap { background: var(--p-surface-2, #263347); border-color: var(--p-border, #334155); }
[data-theme="dark"] .chat-search-input { color: var(--p-text, #f8fafc); }
[data-theme="dark"] .chat-search-clear { background: var(--p-border, #334155); color: var(--p-text-2, #94a3b8); }
[data-theme="dark"] .chat-settings-btn { color: var(--p-text-2, #94a3b8); }
[data-theme="dark"] .chat-settings-btn:hover { color: var(--p-primary, #a78bfa); background: rgba(167,139,250,0.08); }
[data-theme="dark"] .chat-notif-settings { border-color: var(--p-border, #334155); background: var(--p-surface-2, #263347); }
[data-theme="dark"] .chat-notif-settings-title { color: var(--p-text-2, #94a3b8); }
[data-theme="dark"] .chat-notif-toggle { color: var(--p-text, #f8fafc); }
[data-theme="dark"] .chat-sidebar-footer { background: var(--p-surface, #1e293b); border-color: var(--p-border, #334155); box-shadow: 0 -2px 12px rgba(0,0,0,0.25); }
[data-theme="dark"] .chat-room-actions { background: var(--p-surface, #1e293b); border-color: var(--p-border, #334155); box-shadow: 0 -2px 12px rgba(0,0,0,0.25); }
[data-theme="dark"] .chat-room-action-btn:last-child { background: var(--p-surface-2, #263347); color: var(--p-text, #f8fafc); }
@media (max-width: 767px) {
  [data-theme="dark"] .chat-container.chat-open .chat-main { background: var(--p-surface, #1e293b); }
  [data-theme="dark"] .chat-room-header { background: var(--p-surface, #1e293b); border-color: var(--p-border, #334155); }
  [data-theme="dark"] .chat-input-area { background: var(--p-surface, #1e293b); border-color: var(--p-border, #334155); box-shadow: 0 -1px 6px rgba(0,0,0,0.25); }
}




@media (max-width: 1023px) {
  .chat-container {
    height: calc(100vh - var(--p-navbar-h, 64px) - 24px);
    border-radius: 12px;
  }

  .chat-sidebar {
    width: 320px;
    min-width: 280px;
    max-width: 360px;
  }

  .chat-bubble { max-width: 80%; }
  .chat-messages { padding: 12px 18px; }
  .chat-item { padding: 12px 16px; }
  .chat-item-avatar, .chat-item-avatar-img { width: 44px; height: 44px; }
}


@media (max-width: 767px) {
  .chat-container {
    height: calc(100vh - var(--p-navbar-h, 64px) - 0px);
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-height: 400px;
    position: relative;
  }

  
  .chat-sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: 1;
    display: flex;
    border-right: none;
  }

  .chat-main {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--p-surface, #fff);
    border-radius: 0;
  }

  
  .chat-container.chat-open .chat-sidebar { display: none; }
  .chat-container.chat-open .chat-main { display: flex; }

  .chat-bubble { max-width: 88%; }
  .chat-messages { padding: 10px 12px; }
  .chat-item { padding: 12px 16px; gap: 12px; }
  .chat-item-avatar, .chat-item-avatar-img { width: 44px; height: 44px; font-size: 16px; }

  .chat-sidebar-header { padding: 14px 16px 10px; }
  .chat-sidebar-title { font-size: 19px; }
  .chat-room-header { padding: 10px 14px; }
  .chat-input-area { padding: 10px 12px 12px; }

  
  .chat-sidebar-footer {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1010;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  }

  
  .chat-room-actions {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1010;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  }

  
  .chat-input-area {
    position: fixed;
    left: 0;
    right: 0;
    
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    z-index: 1009;
    padding: 10px 12px;
    border-top: 1px solid var(--p-border, #e2e8f0);
    background: var(--p-surface, #fff);
    box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
  }

  
  .chat-list {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  
  .chat-messages {
    padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
  }

  
  .chat-search-wrap { margin: 8px 12px; padding: 10px 14px; }
  .chat-send-btn { width: 44px; height: 44px; }
  .chat-attach-btn { width: 40px; height: 40px; }
  .chat-input { font-size: 15px; padding: 10px 0; }

  
  .chat-container.chat-open .chat-room {
    animation: chatSlideRight 0.25s ease-out;
  }

  
  .chat-empty-state { padding: 32px 24px; }
  .chat-empty-icon svg { width: 40px; height: 40px; }
  .chat-empty-title { font-size: 17px; }
  .chat-empty-sub { font-size: 13px; }

  
  .chat-pin-btn { display: flex; opacity: 0.5; }
  .chat-delete-chat-btn { display: flex; opacity: 0.5; }
}


@media (max-width: 399px) {
  .chat-item { padding: 10px 12px; gap: 10px; }
  .chat-item-avatar, .chat-item-avatar-img { width: 38px; height: 38px; font-size: 14px; }
  .chat-item-name { font-size: 13.5px; }
  .chat-item-preview { font-size: 12px; }
  .chat-bottom-nav-btn { min-width: 40px; padding: 4px 6px; font-size: 9px; }
  .chat-bottom-nav-btn svg { width: 20px; height: 20px; }
  .chat-search-wrap { margin: 6px 10px; padding: 8px 12px; }
}

@keyframes chatSlideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes chatPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.8; } }
.chat-loading, .chat-loading-messages { animation: chatPulse 1.5s ease-in-out infinite; }
