:root {
  --bg-dark: #0A0A0A;
  --bg-card: #1F1F1F;
  --bg-hover: #2A2A2A;
  --accent: #FF6B00;
  --accent-hover: #FF8534;
  --text-primary: #FFFFFF;
  --text-secondary: #A0A0A0;
  --border: #333333;
  --success: #00C853;
  --error: #FF3D00;

  --shadow-1: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 16px 60px rgba(0,0,0,.55);

  --glass: rgba(31,31,31,0.92);
  --glass-border: rgba(255,255,255,0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

a { color: inherit; }

/* ================= Buttons / Inputs ================= */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 34px rgba(255, 107, 0, 0.25);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 12px 18px;
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all .18s;
}
.btn-secondary:hover {
  border-color: rgba(255,107,0,0.45);
  background: rgba(255,107,0,0.10);
}

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(10,10,10,0.75);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color .18s, box-shadow .18s;
}
.form-group textarea { resize: vertical; }
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: rgba(255,107,0,0.65);
  box-shadow: 0 0 0 3px rgba(255,107,0,0.12);
}
.form-group small {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.error-message {
  background: rgba(255,61,0,0.10);
  border: 1px solid rgba(255,61,0,0.45);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  color: var(--error);
  font-size: 14px;
}

/* ================= Auth Pages ================= */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0A0A0A 0%, #1F1F1F 100%);
}
.auth-container { width: 100%; max-width: 420px; padding: 20px; }
.auth-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 40px;
  box-shadow: var(--shadow-1);
}
.auth-card h1 {
  font-size: 28px;
  margin-bottom: 22px;
  text-align: center;
  background: linear-gradient(135deg, var(--accent) 0%, #FFB366 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-switch {
  text-align: center;
  margin-top: 18px;
  color: var(--text-secondary);
}
.auth-switch a { color: var(--accent); font-weight: 900; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ================= Messenger Layout ================= */
.messenger-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 350px;
  background: var(--bg-card);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-profile-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.display-name { font-weight: 900; font-size: 15px; line-height: 1.2; }
.username-small { font-size: 13px; color: var(--text-secondary); line-height: 1.2; }

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

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all .18s;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255,107,0,0.12);
  border-color: rgba(255,107,0,0.35);
  color: #fff;
}

.chats-list { flex: 1; overflow-y: auto; }

.sidebar-section-title{
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: .08em;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.chat-item {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: background .18s;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.chat-item:hover { background: rgba(255,255,255,0.04); }
.chat-item.active { background: rgba(255,255,255,0.04); border-left: 3px solid var(--accent); }

.chat-item-avatar { position: relative; flex-shrink: 0; }

.online-indicator {
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  position: absolute;
  bottom: 0; right: 0;
}
.online-indicator.online { background: var(--success); }

.chat-item-content { flex: 1; min-width: 0; }
.chat-item-header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.chat-item-name {
  font-weight: 900;
  font-size: 15px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.chat-item-preview {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  padding: 0 7px;
}

/* ================= Chat Area ================= */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  min-width: 0;
  position: relative;
}

.no-chat-selected {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 20px;
  text-align: center;
}
.no-chat-selected h2 { margin-top: 18px; color: var(--text-primary); }

.chat-header {
  padding: 16px 24px;
  background: var(--glass);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  backdrop-filter: blur(10px);
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 950; font-size: 16px; line-height: 1.25; display: flex; align-items: center; gap: 8px; }
.chat-header-status { font-size: 13px; color: var(--text-secondary); }
.chat-header-status.online { color: var(--success); }
.chat-header-status.typing { color: var(--accent); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-wrapper { width: 100%; display: flex; position: relative; }

.message {
  display: flex;
  gap: 12px;
  max-width: 72%;
  position: relative;
}
.message.own { margin-left: auto; flex-direction: row-reverse; }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.message-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.message.own .message-content { align-items: flex-end; }

.message-bubble {
  background: rgba(31,31,31,0.92);
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.message.own .message-bubble {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border: 1px solid rgba(255,255,255,0.10);
}

.message-text {
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.message.own .message-time { justify-content: flex-end; }

.message-status{
  font-size: 12px;
  letter-spacing: -1px;
  opacity: 0.9;
}
.message-status.sent{ color: var(--text-secondary); }
.message-status.delivered{ color: rgba(255,255,255,0.75); }
.message-status.read{ color: var(--success); }

.edited-badge{ font-size: 11px; color: var(--text-secondary); opacity: .9; margin-right: 2px; }
.deleted-text{ color: rgba(255,255,255,0.72); font-style: italic; }

/* System messages (DM + group) */
.system-message{
  align-self: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 85%;
  text-align: center;
}

/* Group author label */
.msg-author{
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
  font-weight: 950;
}

/* Right click / hover UI */
.ctx-menu{
  position: fixed;
  z-index: 25000;
  min-width: 220px;
  background: rgba(31,31,31,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  backdrop-filter: blur(10px);
}
.ctx-item{
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background .16s ease;
}
.ctx-item:hover{ background: rgba(255,107,0,0.12); }
.ctx-item.danger:hover{ background: rgba(255,61,0,0.18); }

/* Hover actions (reliably clickable) */
.msg-actions{
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  gap: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s ease, visibility .16s ease;
  z-index: 60;
}
.message:hover .msg-actions,
.msg-actions:hover{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.msg-act{
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(10,10,10,0.65);
  color: var(--text-primary);
  cursor: pointer;
}
.msg-act:hover{
  border-color: rgba(255,107,0,0.6);
  background: rgba(255,107,0,0.12);
}
.msg-act.danger:hover{
  border-color: rgba(255,61,0,0.6);
  background: rgba(255,61,0,0.16);
}

/* Inline edit bar */
.edit-bar{
  width: 100%;
  background: rgba(255,107,0,0.10);
  border: 1px solid rgba(255,107,0,0.25);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.edit-bar.hidden{ display:none; }
.edit-bar-left{ flex:1; min-width:0; }
.edit-bar-title{ font-weight: 950; color: var(--accent); font-size: 13px; margin-bottom: 2px; }
.edit-bar-sub{ color: var(--text-secondary); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-bar-cancel{
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.edit-bar-cancel:hover{ border-color: rgba(255,107,0,0.45); }

/* Pinned bar (DM + groups) */
.pinned-bar{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.pinned-bar.hidden{ display:none; }
.pinned-title{
  font-size:12px;
  color: var(--accent);
  font-weight:950;
  min-width: 70px;
}
.pinned-text{
  flex:1;
  color: var(--text-secondary);
  font-size: 13px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pinned-actions{ display:flex; gap:8px; align-items:center; }
.btn-pin{
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  cursor:pointer;
}
.btn-pin:hover{ border-color: rgba(255,107,0,0.45); }
.btn-pin.danger{
  background: rgba(255,61,0,0.14);
  border-color: rgba(255,61,0,0.35);
}
.pin-nav{
  width: 32px;
  height: 32px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.pin-nav:hover{ border-color: rgba(255,107,0,0.45); }
.pin-counter{
  color: var(--text-secondary);
  font-size: 12px;
  min-width: 44px;
  text-align: center;
}

/* Chat input */
.chat-input-area {
  padding: 16px 24px;
  background: var(--glass);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-shrink: 0;
  flex-wrap: wrap;
  backdrop-filter: blur(10px);
}

.chat-input {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  background: rgba(10,10,10,0.75);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  color: var(--text-primary);
  font-size: 15px;
  resize: none;
  max-height: 120px;
  font-family: inherit;
  transition: border-color .18s, box-shadow .18s;
}
.chat-input:focus {
  outline: none;
  border-color: rgba(255,107,0,0.65);
  box-shadow: 0 0 0 3px rgba(255,107,0,0.12);
}

.media-btn {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  flex-shrink: 0;
}
.media-btn:hover {
  background: rgba(255,107,0,0.12);
  border-color: rgba(255,107,0,0.35);
  color: white;
}
.media-btn.recording {
  background: rgba(255,61,0,0.20);
  border-color: rgba(255,61,0,0.45);
  color: white;
  animation: pulse 1s infinite;
}

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.send-btn:disabled {
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: not-allowed;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Add reaction button (show on hover) */
.add-reaction-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transition: all .18s;
  margin-left: 6px;
  z-index: 40;
}
.add-reaction-btn::before { content: '+'; color: var(--text-secondary); font-weight: 950; }
.message:hover .add-reaction-btn { opacity: 1; }
.add-reaction-btn:hover {
  background: rgba(255,107,0,0.12);
  border-color: rgba(255,107,0,0.35);
}
.message.own .add-reaction-btn {
  order: -1;
  margin-left: 0;
  margin-right: 6px;
}

/* Reactions */
.message-reactions { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.reaction-item{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  cursor:pointer;
  transition: transform .12s, border-color .18s, background .18s;
  user-select:none;
  font-size: 14px;
}
.reaction-item:hover{ transform: scale(1.06); border-color: rgba(255,107,0,0.35); }
.reaction-item.own-reaction { background: rgba(255,107,0,0.18); border-color: rgba(255,107,0,0.35); }
.reaction-count{ font-size: 11px; font-weight: 950; }

/* Reaction picker */
.reaction-picker{
  position:absolute;
  bottom:100%;
  left:0;
  background: rgba(31,31,31,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  padding: 8px 12px;
  display:flex;
  gap:8px;
  box-shadow: var(--shadow-2);
  margin-bottom: 8px;
  z-index: 100;
  opacity: 0;
  transform: translateY(10px);
  pointer-events:none;
  transition: all .18s;
  backdrop-filter: blur(10px);
}
.reaction-picker.show{ opacity: 1; transform: translateY(0); pointer-events:auto; }
.reaction-emoji{ font-size: 22px; cursor:pointer; transition: transform .12s; user-select:none; }
.reaction-emoji:hover{ transform: scale(1.2); }

/* Reply preview */
.reply-preview-container {
  background: rgba(255,255,255,0.06);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.reply-preview-content{ flex:1; min-width:0; }
.reply-preview-author{ font-size: 13px; font-weight: 950; color: var(--accent); margin-bottom: 2px; }
.reply-preview-text{ font-size: 13px; color: var(--text-secondary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.reply-preview-close{
  background:none;
  border:none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor:pointer;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  transition: background .18s, color .18s;
}
.reply-preview-close:hover{ background: rgba(255,255,255,0.06); color: var(--text-primary); }

/* Reply in message */
.message-reply{
  background: rgba(0,0,0,0.22);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  cursor:pointer;
  transition: background .18s;
}
.message-reply:hover{ background: rgba(255,255,255,0.06); }
.message-reply-author{ font-size: 12px; font-weight: 950; color: var(--accent); margin-bottom: 2px; }
.message-reply-text{ font-size: 13px; color: var(--text-secondary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Files */
.message-file{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  min-width: 260px;
  border: 1px solid rgba(255,255,255,0.08);
}
.message.own .message-file{ background: rgba(255,255,255,0.12); }
.file-icon{ font-size: 30px; flex-shrink:0; }
.file-info{ flex:1; min-width:0; }
.file-name{ font-size: 14px; font-weight: 950; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.file-size{ font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.file-download{
  color: var(--accent);
  text-decoration:none;
  flex-shrink:0;
  width: 36px;
  height: 36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  transition: all .18s;
}
.file-download:hover{
  background: rgba(255,107,0,0.18);
  border-color: rgba(255,107,0,0.35);
  color:#fff;
}

/* Photo */
.message-photo{
  max-width: 420px;
  border-radius: 12px;
  overflow:hidden;
  cursor:pointer;
  border: 1px solid rgba(255,255,255,0.08);
}
.message-photo img{
  width:100%;
  max-height: 420px;
  object-fit: cover;
  display:block;
}

/* Video */
.video-message-container{
  position: relative;
  max-width: 420px;
  border-radius: 12px;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}
.video-message-container video{ width:100%; display:block; max-height: 320px; }

/* Video note */
.video-note-container{
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow:hidden;
  cursor:pointer;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.video-note-video{ width: 100%; height: 100%; object-fit: cover; }
.video-note-overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.25);
  transition: opacity .18s;
}
.video-note-container.playing .video-note-overlay{ opacity: 0; }
.video-note-play-btn{
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: rgba(255,107,0,0.85);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  font-size: 22px;
  cursor:pointer;
}
.video-note-progress{
  position:absolute;
  bottom:0; left:0;
  width:100%;
  height:4px;
  background: rgba(0,0,0,0.25);
}
.video-note-progress-bar{ height:100%; width:0%; background: var(--accent); }
.video-note-duration{
  position:absolute;
  bottom:8px; right:8px;
  background: rgba(0,0,0,0.55);
  color:#fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
}

/* Voice */
.voice-message-container{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 20px;
  min-width: 200px;
  max-width: 320px;
}
.message.own .voice-message-container{ background: rgba(255,255,255,0.16); }
.voice-play-btn{
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.18);
  color:#fff;
  cursor:pointer;
  flex-shrink:0;
}
.voice-play-btn:hover{ background: rgba(0,0,0,0.35); }
.voice-waveform{
  flex:1;
  display:flex;
  gap:2px;
  align-items:center;
  height: 36px;
  cursor:pointer;
}
.voice-wave-bar{ flex:1; height: 16px; background: rgba(255,255,255,0.75); opacity: .5; border-radius: 2px; }
.voice-wave-bar.active{ opacity: 1; background: rgba(255,255,255,1); }
.voice-duration{ font-size: 12px; color: var(--text-secondary); min-width: 40px; text-align:right; }

/* Image lightbox */
.image-lightbox{
  position: fixed;
  inset:0;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  display:none;
  align-items:center;
  justify-content:center;
  padding: 20px;
}
.image-lightbox.active{ display:flex; }
.image-lightbox img{
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
}
.image-lightbox-close{
  position:absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.10);
  color:#fff;
  font-size: 28px;
  cursor:pointer;
  transition: all .18s;
}
.image-lightbox-close:hover{
  background: rgba(255,107,0,0.25);
  border-color: rgba(255,107,0,0.45);
}

/* ================= Search Page ================= */
.search-container { max-width: 800px; margin: 0 auto; padding: 24px; }
.search-header { display:flex; align-items:center; gap: 16px; margin-bottom: 24px; }
.back-btn { color: var(--accent); text-decoration:none; font-size: 18px; }
.back-btn:hover { color: var(--accent-hover); }
.search-box { position: relative; margin-bottom: 24px; }
.search-box input {
  width: 100%;
  padding: 16px 48px 16px 16px;
  background: rgba(31,31,31,0.90);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  color: var(--text-primary);
  font-size: 16px;
}
.search-box input:focus{ outline:none; border-color: rgba(255,107,0,0.55); box-shadow: 0 0 0 3px rgba(255,107,0,0.12); }
.search-icon { position:absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
.search-results {
  background: rgba(31,31,31,0.90);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  overflow: hidden;
}
.user-result {
  padding: 16px;
  display:flex;
  align-items:center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.user-result:last-child { border-bottom: none; }
.user-result:hover { background: rgba(255,255,255,0.04); }
.user-info { flex:1; min-width:0; }

/* ================= Settings Page ================= */
.settings-container { max-width: 900px; margin: 0 auto; padding: 24px; }
.settings-header { display:flex; align-items:center; gap: 16px; margin-bottom: 28px; }
.settings-header h1 { font-size: 30px; }
.settings-content { display:flex; flex-direction:column; gap: 18px; }
.settings-section {
  background: rgba(31,31,31,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.25);
}
.settings-section h2 { font-size: 18px; margin-bottom: 14px; color: var(--accent); font-weight: 950; }

.avatar-upload-section { display:flex; gap: 20px; align-items:center; flex-wrap: wrap; }
.current-avatar {
  width: 120px;
  height: 120px;
  border-radius: 999px;
  object-fit: cover;
  border: 4px solid var(--accent);
}
.hint { margin-top: 8px; font-size: 13px; color: var(--text-secondary); }

.info-row {
  display:flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-secondary); }
.info-row .value { font-weight: 900; }

.ntfy-topic-box {
  display:flex;
  gap: 12px;
  align-items:center;
  background: rgba(10,10,10,0.55);
  border: 1px solid rgba(255,255,255,0.10);
  padding: 12px 14px;
  border-radius: 12px;
  margin: 12px 0;
}
.ntfy-topic-box code { flex:1; color: var(--accent); font-size: 14px; }
.btn-copy {
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color:#fff;
  border:none;
  border-radius: 10px;
  cursor:pointer;
}
.btn-copy:hover { background: var(--accent-hover); }

/* ================= Modals ================= */
.modal{
  display:none;
  position: fixed;
  inset:0;
  background: rgba(0,0,0,0.82);
  z-index: 1000;
  align-items:center;
  justify-content:center;
  padding: 18px;
}
.modal.active{ display:flex; }
.modal-content{
  background: rgba(31,31,31,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  display:flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(10px);
}
.modal-header{
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display:flex;
  justify-content: space-between;
  align-items:center;
}
.modal-header h2{ font-size: 18px; }
.close-btn{
  background:none;
  border:none;
  color: var(--text-secondary);
  font-size: 32px;
  cursor:pointer;
  width: 36px;
  height: 36px;
}
.close-btn:hover{ color: var(--text-primary); }

.modal-actions{
  padding: 18px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display:flex;
  justify-content:flex-end;
  gap: 12px;
}

.crop-container{ flex: 1; padding: 18px; overflow:hidden; }
.crop-container img{ max-width: 100%; display:block; }

/* ================= Upload Progress ================= */
.upload-progress-overlay{
  position: fixed;
  inset:0;
  background: rgba(0,0,0,0.75);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 9999;
}
.upload-progress-container{
  background: rgba(31,31,31,0.95);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 28px;
  min-width: 320px;
  text-align:center;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(10px);
}
.upload-progress-icon{ font-size: 42px; margin-bottom: 10px; }
.upload-progress-text{ font-size: 16px; font-weight: 950; margin-bottom: 12px; }
.upload-progress-bar-container{
  width:100%;
  height:8px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow:hidden;
  margin-bottom: 8px;
}
.upload-progress-bar{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width .25s;
}
.upload-progress-percent{ font-size: 13px; color: var(--text-secondary); }

/* ================= Drag overlay ================= */
.drag-overlay{
  position: fixed;
  inset:0;
  background: rgba(10,10,10,0.92);
  z-index: 9998;
  display:none;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}
.drag-overlay.active{ display:flex; }
.drag-content{
  text-align:center;
  padding: 40px;
  background: rgba(31,31,31,0.96);
  border-radius: 20px;
  border: 3px dashed rgba(255,107,0,0.65);
  box-shadow: var(--shadow-2);
}
.drag-icon{ font-size: 80px; margin-bottom: 16px; }
.drag-text{ font-size: 20px; font-weight: 950; color: var(--accent); }

/* ================= Toasts ================= */
.toast-container{
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20000;
  display:flex;
  flex-direction: column;
  gap: 10px;
  pointer-events:none;
}
.toast{
  background: rgba(31,31,31,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(10px);
  transition: all .22s ease;
  pointer-events:none;
  max-width: min(520px, calc(100vw - 30px));
}
.toast.show{ opacity: 1; transform: translateY(0); }
.toast-ok{ border-color: rgba(0,200,83,0.4); }
.toast-warn{ border-color: rgba(255,107,0,0.5); }
.toast-err{ border-color: rgba(255,61,0,0.55); }

/* ================= Tabs / grids ================= */
.tabs{
  display:flex;
  gap:8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tab-btn{
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  color: var(--text-primary);
  cursor:pointer;
}
.tab-btn.active{
  border-color: rgba(255,107,0,0.55);
  background: rgba(255,107,0,0.10);
}
.tab-panel.hidden{ display:none; }

.grid-list{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.grid-item{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow:hidden;
}
.grid-item img, .grid-item video{
  width:100%;
  height:140px;
  object-fit:cover;
  display:block;
}

.list-box{
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.file-row{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px;
  display:flex;
  gap: 12px;
  align-items:center;
}
.file-row-name{ font-weight:950; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.file-row-meta{ color: var(--text-secondary); font-size: 12px; }
.file-row-dl{ color: var(--accent); text-decoration:none; }
.search-row{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px;
  cursor:pointer;
}
.search-row:hover{ border-color: rgba(255,107,0,0.45); }
.search-row-title{ font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.search-row-text{ color: var(--text-primary); }

/* ================= Pretty checkbox ================= */
.nice-check{ display:flex; align-items:center; }
.nice-check input{ display:none; }
.nice-check span{
  width: 22px;
  height: 22px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(10,10,10,0.6);
  display:inline-block;
  position: relative;
}
.nice-check input:checked + span{
  border-color: rgba(255,107,0,0.6);
  background: rgba(255,107,0,0.14);
}
.nice-check input:checked + span::after{
  content:'';
  position:absolute;
  left: 6px; top: 3px;
  width: 7px; height: 12px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(40deg);
}

/* ================= Right panel (Telegram-like) ================= */
.right-panel{
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 92vw;
  height: 100vh;
  background: rgba(31,31,31,0.96);
  border-left: 1px solid rgba(255,255,255,0.10);
  box-shadow: var(--shadow-2);
  transform: translateX(100%);
  transition: transform .18s ease;
  z-index: 22000;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}
.right-panel.open{ transform: translateX(0); }

.right-panel-header{
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.right-panel-title{
  font-weight: 950;
  font-size: 15px;
}
.right-panel-close{
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  cursor: pointer;
}
.right-panel-close:hover{
  border-color: rgba(255,107,0,0.45);
  background: rgba(255,107,0,0.10);
}
.right-panel-body{
  flex: 1;
  overflow: auto;
  padding: 16px;
}
.right-user-card{
  display:flex;
  gap: 12px;
  align-items:center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}
.right-user-meta{ min-width:0; flex:1; }
.right-user-name{ font-weight: 950; }
.right-user-username{ color: var(--text-secondary); font-size: 13px; }
.right-user-about{
  margin-top: 8px;
  color: rgba(255,255,255,0.86);
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.right-section-title{
  margin: 14px 0 8px;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: .08em;
}
.right-list{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

/* ================= Birthday badge + popover ================= */
.birthday-badge{
  display: inline-flex;
  align-items:center;
  justify-content:center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  cursor: pointer;
  user-select:none;
}
.birthday-badge:hover{
  border-color: rgba(255,107,0,0.45);
  background: rgba(255,107,0,0.12);
}

.birthday-popover{
  position: fixed;
  z-index: 23000;
  width: 280px;
  background: rgba(31,31,31,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  padding: 12px;
  backdrop-filter: blur(10px);
}
.bday-title{
  font-weight: 950;
  margin-bottom: 4px;
}
.bday-text{
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 10px;
}
.bday-actions{
  display:flex;
  gap: 10px;
}
.bday-actions button{
  flex:1;
}

/* ================= Upload + Drop placeholders ================= */
.loading, .no-results, .search-hint {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-secondary);
}

/* ================= NTFY / misc ================= */
.ntfy-instructions ol { margin-left: 18px; }
.ntfy-instructions li { margin-bottom: 8px; color: var(--text-secondary); }
.ntfy-instructions a { color: var(--accent); }

/* ================= Scrollbar ================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(10,10,10,0.3); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ================= Responsive ================= */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: absolute;
    z-index: 10;
    height: 100vh;
  }
  .sidebar.hidden { transform: translateX(-100%); }
  .chat-area { width: 100%; }
  .message { max-width: 86%; }
  .settings-container, .search-container { padding: 16px; }
  .right-panel{ width: 100vw; max-width: 100vw; }
}

/* ================= Sound toggle ================= */
#soundToggle { position: relative; }
#soundToggle .sound-on { transition: opacity .18s; }
#soundToggle.muted .sound-on { opacity: 0; }
#soundToggle.muted::after{
  content:'';
  position:absolute;
  top:50%;
  left:50%;
  width:2px;
  height:24px;
  background: currentColor;
  transform: translate(-50%,-50%) rotate(45deg);
}