/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark: #5c5c5c;
  --bg-medium: #6e6e6e;
  --bg-card: #a3a380;
  --bg-card-hover: #b0b090;
  --bg-msg-preview: #4d5843;
  --bg-msg-own: #8a8a6a;
  --bg-msg-other: #a3a380;
  --text-dark: #2a2a2a;
  --text-light: #f0f0f0;
  --text-muted: #ccc;
  --accent: #7a7a5a;
  --avatar-bg: #e8e8e0;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-msg: 18px;
  --shadow: 0 2px 12px rgba(0,0,0,0.15);
  --profile-bg: #888;
  --anim-fast: 0.2s;
  --anim-med: 0.35s;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Login Page ── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-dark), var(--accent));
}

.login-container {
  text-align: center;
  width: 100%;
  max-width: 380px;
  padding: 20px;
  animation: fadeSlideUp var(--anim-med) ease;
}

.login-logo {
  font-size: 2.4rem;
  font-weight: 700;
  margin-bottom: 30px;
  color: var(--text-light);
  transform: rotate(-3deg);
  font-family: 'Courier New', monospace;
  animation: logoWobble 3s ease-in-out infinite;
}

@keyframes logoWobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(2deg); }
}

.login-card {
  background: var(--bg-medium);
  border-radius: var(--radius);
  padding: 30px 25px;
  box-shadow: var(--shadow);
}

.login-tabs {
  display: flex;
  margin-bottom: 25px;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.login-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--anim-fast);
}

.login-tab.active {
  background: var(--bg-card);
  color: var(--text-dark);
  font-weight: 600;
}

.login-form { display: none; flex-direction: column; gap: 14px; }
.login-form.active { display: flex; animation: fadeIn var(--anim-fast) ease; }

.login-form input {
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-dark);
  color: var(--text-light);
  font-size: 0.95rem;
  outline: none;
  transition: box-shadow var(--anim-fast);
}

.login-form input:focus { box-shadow: 0 0 0 2px var(--bg-card); }
.login-form input::placeholder { color: #999; }

.login-btn {
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-dark);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--anim-fast), transform 0.1s;
}

.login-btn:hover { background: var(--bg-card-hover); }
.login-btn:active { transform: scale(0.97); }

.login-error { color: #e88; font-size: 0.85rem; min-height: 1.2em; }

/* ── App Layout ── */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 80px;
  background: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 20px;
  flex-shrink: 0;
  z-index: 30;
}

.sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--avatar-bg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--anim-fast);
}

.sidebar-avatar:hover { transform: scale(1.1); }
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--anim-fast), transform 0.1s;
}

.sidebar-btn:hover { background: rgba(255,255,255,0.25); }
.sidebar-btn:active { transform: scale(0.9); }

.sidebar-label {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  margin-top: auto;
  margin-bottom: 10px;
}

/* ── Chat List Panel ── */
.chat-list-panel {
  width: 360px;
  background: var(--bg-medium);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(0,0,0,0.1);
}

.chat-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 12px;
}

.chat-list-header h2 { font-size: 1.1rem; font-weight: 600; }

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--anim-fast);
}

.icon-btn:hover { background: rgba(255,255,255,0.1); }

.archive-bar {
  text-align: center;
  padding: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: background var(--anim-fast);
}

.archive-bar:hover { background: rgba(255,255,255,0.05); }

.search-bar { padding: 10px 16px; }

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-dark);
  color: var(--text-light);
  font-size: 0.9rem;
  outline: none;
  transition: box-shadow var(--anim-fast);
}

.search-bar input:focus { box-shadow: 0 0 0 2px rgba(163,163,128,0.4); }
.search-bar input::placeholder { color: #999; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 0;
  background: var(--bg-card);
  cursor: pointer;
  transition: background var(--anim-fast), padding-left 0.15s;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.chat-item:nth-child(even) {
  background: rgba(163,163,128,0.75);
}

.chat-item:hover { background: var(--bg-card-hover); padding-left: 22px; }
.chat-item:active { background: var(--bg-card-hover); }
.chat-item.active { background: var(--bg-card-hover); box-shadow: inset 3px 0 0 var(--text-dark); }

.chat-item-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--avatar-bg);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.chat-item-avatar img { width: 100%; height: 100%; object-fit: cover; }

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

.chat-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.chat-item-preview {
  font-size: 0.82rem;
  color: var(--text-dark);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chat-item-time {
  font-size: 0.72rem;
  color: var(--text-dark);
  opacity: 0.6;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6d6;
  border: 2px solid var(--bg-card);
  position: absolute;
  bottom: 0;
  right: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(102,221,102,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(102,221,102,0); }
}

/* ── Chat View ── */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
}

.chat-view-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-medium);
  border-bottom: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--avatar-bg);
  overflow: hidden;
  flex-shrink: 0;
}

.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 600; font-size: 1rem; }
.chat-header-status { font-size: 0.78rem; color: var(--text-muted); }

.chat-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.message {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: msgAppear var(--anim-med) ease backwards;
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.own { align-self: flex-end; }
.message.other { align-self: flex-start; }

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bg-card);
  padding-left: 12px;
}

.message-bubble {
  padding: 10px 16px;
  border-radius: var(--radius-msg);
  font-size: 0.92rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.message.own .message-bubble {
  background: var(--bg-msg-own);
  color: var(--text-light);
  border-bottom-right-radius: 6px;
}

.message.other .message-bubble {
  background: var(--bg-msg-other);
  color: var(--text-dark);
  border-bottom-left-radius: 6px;
}

.message-bubble img {
  max-width: 260px;
  max-height: 300px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform var(--anim-fast);
}

.message-bubble img:hover { transform: scale(1.02); }

.message-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0 12px;
}

.message.own .message-time { text-align: right; }

.typing-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 20px;
  min-height: 24px;
  font-style: italic;
  flex-shrink: 0;
}

/* ── Message Input ── */
.message-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-medium);
  border-top: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
  position: relative;
}

.message-input-area input[type="text"] {
  flex: 1;
  padding: 12px 18px;
  border: none;
  border-radius: 24px;
  background: var(--bg-dark);
  color: var(--text-light);
  font-size: 0.95rem;
  outline: none;
  transition: box-shadow var(--anim-fast);
}

.message-input-area input[type="text"]:focus {
  box-shadow: 0 0 0 2px rgba(163,163,128,0.4);
}

.message-input-area input::placeholder { color: #999; }

.emoji-btn, .attach-btn, .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--anim-fast);
  flex-shrink: 0;
}

.emoji-btn { background: transparent; color: var(--text-light); }
.attach-btn { background: transparent; color: var(--text-light); }
.send-btn { background: var(--bg-card); color: var(--text-dark); }
.send-btn:hover { background: var(--bg-card-hover); transform: scale(1.1); }
.send-btn:active { transform: scale(0.9); }
.emoji-btn:hover, .attach-btn:hover { background: rgba(255,255,255,0.1); }

.emoji-picker {
  display: none;
  position: absolute;
  bottom: 70px;
  left: 16px;
  background: var(--bg-medium);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  max-width: 320px;
  flex-wrap: wrap;
  gap: 4px;
  z-index: 100;
}

.emoji-picker.active { display: flex; animation: scaleIn var(--anim-fast) ease; }

.emoji-picker span {
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.15s;
}

.emoji-picker span:hover { background: rgba(255,255,255,0.1); transform: scale(1.2); }

/* ── Profile Panel ── */
.profile-panel {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: background var(--anim-med);
}

.profile-panel.active {
  display: flex;
  background: rgba(0,0,0,0.5);
}

.profile-card {
  background: var(--profile-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  animation: scaleIn var(--anim-med) ease;
}

.profile-header {
  padding: 40px 24px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform var(--anim-fast);
}

.profile-close:hover { transform: rotate(90deg); }

.profile-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--avatar-bg);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  transition: transform var(--anim-fast);
}

.profile-avatar-large:hover { transform: scale(1.05); }
.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }

.profile-name { font-size: 1.4rem; font-weight: 700; }

.profile-lastseen {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-fields {
  padding: 10px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.profile-field input,
.profile-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: var(--text-light);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: box-shadow var(--anim-fast);
}

.profile-field input:focus,
.profile-field textarea:focus {
  box-shadow: 0 0 0 2px var(--bg-card);
}

.profile-field textarea { resize: vertical; min-height: 60px; }

/* ── Profile Read-Only Info ── */
.profile-info { padding: 8px 24px 20px; }

.profile-info-row {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.profile-info-row:last-child { border-bottom: none; }

.profile-info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.profile-info-value {
  font-size: 0.95rem;
  color: var(--text-light);
}

.profile-save-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-dark);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background var(--anim-fast), transform 0.1s;
  margin-top: 4px;
}

.profile-save-btn:hover { background: var(--bg-card-hover); }
.profile-save-btn:active { transform: scale(0.97); }

/* ── Profile Message Button ── */
.profile-message-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-dark);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--anim-fast), transform 0.1s;
}

.profile-message-btn:hover { background: var(--bg-card-hover); }
.profile-message-btn:active { transform: scale(0.97); }

/* ── Tag Save Button ── */
.tag-save-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-dark);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--anim-fast);
}

.tag-save-btn:hover { background: var(--bg-card-hover); }

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-medium);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  animation: scaleIn var(--anim-med) ease;
}

.modal h3 { margin-bottom: 16px; font-size: 1.1rem; }

.modal input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text-light);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 10px;
  transition: box-shadow var(--anim-fast);
}

.modal input:focus { box-shadow: 0 0 0 2px rgba(163,163,128,0.4); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--anim-fast), transform 0.1s;
}

.modal-actions button:active { transform: scale(0.97); }

.modal-actions .btn-primary { background: var(--bg-card); color: var(--text-dark); font-weight: 600; }
.modal-actions .btn-primary:hover { background: var(--bg-card-hover); }
.modal-actions .btn-secondary { background: rgba(255,255,255,0.1); color: var(--text-light); }
.modal-actions .btn-secondary:hover { background: rgba(255,255,255,0.15); }

.user-search-results {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.user-search-item:hover { background: rgba(255,255,255,0.1); }

.user-search-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--avatar-bg);
  overflow: hidden;
}

.user-search-item-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Group Info ── */
.group-info-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Avatar Crop Modal ── */
.crop-modal {
  background: var(--bg-medium);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  animation: scaleIn var(--anim-med) ease;
}

.crop-modal h3 { margin-bottom: 16px; text-align: center; }

.crop-container {
  width: 280px;
  height: 280px;
  margin: 0 auto 16px;
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  background: #333;
  cursor: grab;
  touch-action: none;
}

.crop-container:active { cursor: grabbing; }

.crop-container img {
  position: absolute;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
}

.crop-circle {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
  pointer-events: none;
}

.crop-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  margin-bottom: 16px;
}

.crop-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  outline: none;
}

.crop-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-card);
  cursor: pointer;
  transition: transform 0.1s;
}

.crop-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ── Toast Notifications ── */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 12px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 340px;
  word-wrap: break-word;
}

.toast.success { background: #4a7a4a; }
.toast.error { background: #8a3a3a; }
.toast.info { background: #4a5a7a; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* ── Global Search ── */
.global-search-results {
  padding: 0 12px 8px;
  overflow-y: auto;
}

.global-search-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--bg-card);
  padding: 10px 6px 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.global-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.global-search-item:hover { background: rgba(255,255,255,0.08); }

.global-search-item-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--avatar-bg);
  overflow: hidden;
  flex-shrink: 0;
}

.global-search-item-avatar img { width: 100%; height: 100%; object-fit: cover; }

.global-search-item-name { font-size: 0.92rem; font-weight: 600; color: var(--text-light); }
.global-search-item-tag { font-size: 0.78rem; color: var(--text-muted); }

/* ── Voice Messages ── */
.voice-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--anim-fast);
  flex-shrink: 0;
  background: var(--bg-card);
  color: var(--text-dark);
}

.voice-btn:hover { background: var(--bg-card-hover); transform: scale(1.1); }
.voice-btn:active { transform: scale(0.9); }
.voice-btn.recording { background: #e55; color: #fff; animation: recPulse 1s ease-in-out infinite; }

@keyframes recPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.voice-recording {
  position: absolute;
  inset: 0;
  background: var(--bg-medium);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  z-index: 10;
}

.voice-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e55;
  animation: recBlink 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.voice-rec-time {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 40px;
}

.voice-rec-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  overflow: hidden;
}

.voice-rec-wave-bar {
  width: 3px;
  border-radius: 2px;
  background: rgba(255,100,100,0.6);
  transition: height 0.1s;
  flex-shrink: 0;
}

.voice-rec-cancel {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--anim-fast);
}

.voice-rec-cancel:hover { background: rgba(255,80,80,0.3); }

.voice-rec-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  color: var(--text-dark);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--anim-fast);
}

.voice-rec-send:hover { background: var(--bg-card-hover); }

.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  width: 100%;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--anim-fast);
}

.message.own .voice-play-btn { background: rgba(255,255,255,0.2); }
.message.other .voice-play-btn { background: rgba(0,0,0,0.1); color: var(--text-dark); }
.voice-play-btn:hover { background: rgba(255,255,255,0.3); }

.voice-wave {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.voice-wave-bar {
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.4);
  transition: height 0.1s;
}

.message.other .voice-wave-bar { background: rgba(0,0,0,0.25); }

.voice-wave-bar.active { background: var(--bg-card); }
.message.other .voice-wave-bar.active { background: var(--text-dark); }

.voice-duration {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  flex-shrink: 0;
  min-width: 30px;
}

.message.other .voice-duration { color: rgba(0,0,0,0.5); }

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .app-container {
    position: relative;
  }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 56px;
    padding: 12px 0;
    gap: 14px;
    z-index: 30;
  }

  .sidebar-label { display: none; }
  .sidebar-avatar { width: 38px; height: 38px; }
  .sidebar-btn { width: 36px; height: 36px; font-size: 1rem; }

  .chat-list-panel {
    position: fixed;
    left: 56px;
    right: 0;
    top: 0;
    bottom: 0;
    width: auto;
    z-index: 10;
    transition: transform var(--anim-med) ease;
  }

  .chat-view {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: none;
  }

  .chat-view.active {
    display: flex;
    animation: slideInRight var(--anim-med) ease;
  }

  .chat-header .back-btn {
    display: flex !important;
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    background: none;
    flex-shrink: 0;
  }

  .chat-header {
    padding: 10px 12px;
    gap: 10px;
  }

  .chat-header-avatar { width: 36px; height: 36px; }
  .chat-header-name { font-size: 0.92rem; }
  .chat-header-status { font-size: 0.72rem; }

  .message { max-width: 82%; }

  .messages-area { padding: 12px 12px 20px; gap: 6px; }

  .message-input-area {
    padding: 8px 10px;
    gap: 6px;
  }

  .message-input-area input[type="text"] {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .emoji-btn, .attach-btn, .send-btn {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
  }

  .emoji-picker {
    max-width: 280px;
    bottom: 60px;
    left: 10px;
  }

  .profile-panel { z-index: 50; }
  .profile-card { max-width: 100%; margin: 0 10px; max-height: 85vh; }
  .modal-overlay { z-index: 50; }
  .modal { max-width: 100%; margin: 0 10px; }
  .crop-modal { max-width: 100%; margin: 0 10px; }
  .crop-container { width: 240px; height: 240px; }

  .vip-badge { width: 22px; height: 22px; }
  .vip-badge-large { width: 30px; height: 30px; }

  .message-bubble { padding: 8px 12px; font-size: 0.88rem; }
  .message-bubble img { max-width: 200px; max-height: 240px; }
  .message-sender { font-size: 0.7rem; padding-left: 8px; }
  .message-time { font-size: 0.64rem; padding: 0 8px; }

  .chat-item { padding: 10px 12px; gap: 10px; }
  .chat-item-avatar { width: 42px; height: 42px; }
  .chat-item-name { font-size: 0.9rem; }
  .chat-item-preview { font-size: 0.78rem; }

  .search-bar { padding: 8px 12px; }
  .search-bar input { padding: 8px 12px; font-size: 0.85rem; }

  .chat-list-header { padding: 12px 14px; }
  .chat-list-header h2 { font-size: 1rem; }

  #toastContainer { top: 10px; right: 10px; left: 10px; }
  .toast { font-size: 0.82rem; padding: 10px 14px; max-width: 100%; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@media (min-width: 769px) {
  .chat-header .back-btn { display: none !important; }
}

@media (max-width: 400px) {
  .sidebar { width: 48px; padding: 8px 0; gap: 10px; }
  .sidebar-avatar { width: 34px; height: 34px; }
  .sidebar-btn { width: 32px; height: 32px; font-size: 0.9rem; border-radius: 10px; }

  .chat-list-panel { left: 48px; }

  .crop-container { width: 200px; height: 200px; }

  .profile-header { padding: 30px 16px 16px; gap: 12px; }
  .profile-avatar-large { width: 60px; height: 60px; }
  .profile-name { font-size: 1.2rem; }
  .profile-fields { padding: 8px 16px 20px; }
  .profile-info { padding: 6px 16px 16px; }
  .vip-award { margin: 0 12px 8px; padding: 10px 14px; }
}

/* ── VIP Profile Card ── */
.profile-card.vip-card {
  background:
    linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #1a1a2e 100%);
  border: 1px solid rgba(197,108,240,0.3);
  position: relative;
  overflow: hidden;
}

.profile-card.vip-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255,221,87,0.05) 60deg,
    transparent 120deg,
    rgba(197,108,240,0.05) 180deg,
    transparent 240deg,
    rgba(56,209,255,0.05) 300deg,
    transparent 360deg
  );
  animation: holoRotate 8s linear infinite;
  pointer-events: none;
}

@keyframes holoRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.profile-card.vip-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255,255,255,0.03) 30%,
    rgba(255,255,255,0.08) 35%,
    transparent 45%
  );
  animation: holoShine 5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes holoShine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(200%); }
}

.profile-card.vip-card .profile-header {
  position: relative;
  z-index: 1;
}

.profile-card.vip-card .profile-info,
.profile-card.vip-card .profile-fields,
.profile-card.vip-card .profile-field,
.profile-card.vip-card .profile-message-btn-wrap {
  position: relative;
  z-index: 1;
}

.profile-card.vip-card .profile-close {
  z-index: 2;
}

.vip-award {
  margin: 0 20px 10px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(255,221,87,0.12), rgba(197,108,240,0.12), rgba(56,209,255,0.08));
  border: 1px solid rgba(255,221,87,0.25);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.vip-award-shimmer {
  display: none;
}

.vip-award-content {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.vip-award-icon {
  font-size: 1.6rem;
  animation: awardBounce 2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(255,221,87,0.5));
}

@keyframes awardBounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.15) rotate(-5deg); }
  75% { transform: scale(1.05) rotate(3deg); }
}

.vip-award-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,221,87,0.95);
  line-height: 1.4;
  text-shadow: 0 0 10px rgba(255,221,87,0.2);
}

.vip-award-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.vip-award-particles span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255,221,87,0.6);
  animation: particle 4s ease-in-out infinite;
}

.vip-award-particles span:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; }
.vip-award-particles span:nth-child(2) { left: 30%; top: 70%; animation-delay: 0.8s; }
.vip-award-particles span:nth-child(3) { left: 60%; top: 30%; animation-delay: 1.6s; }
.vip-award-particles span:nth-child(4) { left: 80%; top: 60%; animation-delay: 2.4s; }
.vip-award-particles span:nth-child(5) { left: 50%; top: 80%; animation-delay: 3.2s; }

@keyframes particle {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0); }
  20% { opacity: 1; transform: translateY(-8px) scale(1); }
  80% { opacity: 0.5; transform: translateY(-20px) scale(0.6); }
}

.profile-card.vip-card .profile-info-row {
  border-bottom-color: rgba(255,255,255,0.06);
}

.profile-card.vip-card .profile-info-label {
  color: rgba(56,209,255,0.7);
}

.profile-card.vip-card .profile-info-value {
  color: rgba(255,255,255,0.92);
}

.profile-card.vip-card .profile-lastseen {
  color: rgba(56,209,255,0.6);
}

.profile-card.vip-card .profile-tag {
  color: rgba(197,108,240,0.8) !important;
}

/* ── VIP Effects ── */
.vip-name {
  background: linear-gradient(90deg, #ffdd57, #ff6b6b, #c56cf0, #38d1ff, #ffdd57);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: vipGradient 4s linear infinite;
  font-weight: 800;
  letter-spacing: 0.3px;
  filter: brightness(1.1) contrast(1.1);
}

.vip-name-chat {
  background: linear-gradient(90deg, #ffdd57, #ff6b6b, #c56cf0, #38d1ff, #ffdd57);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: vipGradient 4s linear infinite;
  font-weight: 700;
}

@keyframes vipGradient {
  0% { background-position: 0% 50%; }
  100% { background-position: 400% 50%; }
}

.vip-badge {
  display: inline-block;
  width: 28px;
  height: 28px;
  vertical-align: middle;
  margin-left: 6px;
  border-radius: 4px;
}

.vip-badge-large {
  width: 36px;
  height: 36px;
}

.vip-avatar-glow {
  animation: avatarGlow 3s ease-in-out infinite;
  border: 2px solid transparent;
  background-clip: padding-box;
}

@keyframes avatarGlow {
  0%, 100% {
    box-shadow:
      0 0 10px rgba(255,107,107,0.6),
      0 0 20px rgba(255,107,107,0.3),
      0 0 40px rgba(197,108,240,0.2);
  }
  33% {
    box-shadow:
      0 0 10px rgba(197,108,240,0.6),
      0 0 20px rgba(56,209,255,0.4),
      0 0 40px rgba(56,209,255,0.2);
  }
  66% {
    box-shadow:
      0 0 10px rgba(56,209,255,0.6),
      0 0 20px rgba(255,221,87,0.4),
      0 0 40px rgba(255,107,107,0.2);
  }
}

.vip-chat-item {
  position: relative;
  overflow: hidden;
}

.vip-chat-item::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  animation: vipShine 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes vipShine {
  0%, 100% { left: -100%; }
  50% { left: 150%; }
}

.vip-bubble {
  border: 1px solid rgba(197,108,240,0.3);
  position: relative;
}

.vip-bubble::after {
  content: '✦';
  position: absolute;
  top: -6px;
  right: -2px;
  font-size: 10px;
  color: #ffdd57;
  animation: vipStar 2s ease-in-out infinite;
}

@keyframes vipStar {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ── Parrots Easter Eggs ── */
.parrot-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(0,0,0,0.92);
  color: #fff;
  padding: 28px 40px;
  border-radius: 24px;
  font-size: 1.2rem;
  font-weight: 700;
  z-index: 10000;
  text-align: center;
  animation: parrotToastAnim 3s ease forwards;
  pointer-events: none;
  border: 2px solid rgba(76,175,80,0.5);
  box-shadow: 0 0 40px rgba(76,175,80,0.3);
}

.parrot-toast .parrot-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
  animation: parrotBounce 0.6s ease infinite alternate;
}

.parrot-toast .parrot-hint {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  margin-top: 6px;
  font-weight: 400;
}

@keyframes parrotToastAnim {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-20deg); }
  12% { transform: translate(-50%, -50%) scale(1.15) rotate(5deg); }
  22% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  78% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.7) rotate(10deg); opacity: 0; }
}

@keyframes parrotBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

.parrot-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.parrot-counter-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.parrot-counter-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Date Picker ── */
::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

::-webkit-datetime-edit { color: var(--text-light); }
::-webkit-datetime-edit-fields-wrapper { padding: 2px; }

input[type="date"] {
  color-scheme: dark;
}

/* ── Misc ── */
.hidden { display: none !important; }

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 1.2rem;
  background: var(--avatar-bg);
}

input[type="file"] { display: none; }

.image-preview {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: pointer;
}

.image-preview.active { display: flex; }
.image-preview img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  animation: scaleIn var(--anim-med) ease;
}

.date-separator {
  text-align: center;
  padding: 8px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
