/* ═══════════════════════════════════════════════════════════════════════════
   bespokeCHAT — Discord-inspired dark theme
   ═══════════════════════════════════════════════════════════════════════════ */

:root,
[data-theme="indigo"] {
  --bg-darkest:   #1a1a2e;
  --bg-darker:    #16213e;
  --bg-dark:      #1e293b;
  --bg-medium:    #253350;
  --bg-light:     #334155;
  --bg-hover:     #3b4a6b;
  --bg-active:    #4a5e8a;

  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-bright:    #f1f5f9;

  --accent:         #6366f1;
  --accent-hover:   #818cf8;
  --accent-subtle:  rgba(99, 102, 241, 0.15);

  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #06b6d4;

  --border:    #2d3a54;
  --shadow:    rgba(0, 0, 0, 0.3);

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --sidebar-width: 260px;
  --members-width: 240px;
  --header-height: 52px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Theme: Crimson (Red/Maroon) ─────────────────────────────────────────── */
[data-theme="crimson"] {
  --bg-darkest:   #1a0a0a;
  --bg-darker:    #2a1215;
  --bg-dark:      #3a1a1e;
  --bg-medium:    #4d2228;
  --bg-light:     #5e2d34;
  --bg-hover:     #7a3a42;
  --bg-active:    #944a54;
  --text-primary:   #f0d8da;
  --text-secondary: #b8888e;
  --text-muted:     #8a5a62;
  --text-bright:    #fce8ea;
  --accent:         #dc2626;
  --accent-hover:   #ef4444;
  --accent-subtle:  rgba(220, 38, 38, 0.15);
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #06b6d4;
  --border:    #5a2a30;
  --shadow:    rgba(0, 0, 0, 0.35);
}

/* ── Theme: Emerald (Green/Forest) ───────────────────────────────────────── */
[data-theme="emerald"] {
  --bg-darkest:   #0a1a0e;
  --bg-darker:    #0f2918;
  --bg-dark:      #153522;
  --bg-medium:    #1e4a30;
  --bg-light:     #2a5c3e;
  --bg-hover:     #37744e;
  --bg-active:    #458c60;
  --text-primary:   #d4f0de;
  --text-secondary: #88b89a;
  --text-muted:     #5a8a6e;
  --text-bright:    #e8faf0;
  --accent:         #10b981;
  --accent-hover:   #34d399;
  --accent-subtle:  rgba(16, 185, 129, 0.15);
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #06b6d4;
  --border:    #2a5a3a;
  --shadow:    rgba(0, 0, 0, 0.35);
}

/* ── Theme: Amber (Gold/Warm) ────────────────────────────────────────────── */
[data-theme="amber"] {
  --bg-darkest:   #1a1408;
  --bg-darker:    #2a2010;
  --bg-dark:      #382c16;
  --bg-medium:    #4a3a1e;
  --bg-light:     #5c4a28;
  --bg-hover:     #745e34;
  --bg-active:    #8c7242;
  --text-primary:   #f0e4cc;
  --text-secondary: #b8a47a;
  --text-muted:     #8a7850;
  --text-bright:    #faf2e2;
  --accent:         #f59e0b;
  --accent-hover:   #fbbf24;
  --accent-subtle:  rgba(245, 158, 11, 0.15);
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #06b6d4;
  --border:    #5a4820;
  --shadow:    rgba(0, 0, 0, 0.35);
}

/* ── Theme: Midnight (Purple/Violet) ─────────────────────────────────────── */
[data-theme="midnight"] {
  --bg-darkest:   #12081e;
  --bg-darker:    #1e1032;
  --bg-dark:      #281842;
  --bg-medium:    #352256;
  --bg-light:     #432e6a;
  --bg-hover:     #563e82;
  --bg-active:    #6a4e9a;
  --text-primary:   #e0d4f0;
  --text-secondary: #a488c4;
  --text-muted:     #7a5e9a;
  --text-bright:    #f0e8fa;
  --accent:         #a855f7;
  --accent-hover:   #c084fc;
  --accent-subtle:  rgba(168, 85, 247, 0.15);
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #06b6d4;
  --border:    #3e2860;
  --shadow:    rgba(0, 0, 0, 0.4);
}

/* ── Theme: Light ────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-darkest:   #e8ecf0;
  --bg-darker:    #f0f2f5;
  --bg-dark:      #ffffff;
  --bg-medium:    #e5e8ec;
  --bg-light:     #d8dce2;
  --bg-hover:     #cdd2da;
  --bg-active:    #bfc6d0;
  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-bright:    #0f172a;
  --accent:         #4f46e5;
  --accent-hover:   #6366f1;
  --accent-subtle:  rgba(79, 70, 229, 0.1);
  --success:   #16a34a;
  --warning:   #d97706;
  --danger:    #dc2626;
  --info:      #0891b2;
  --border:    #cbd5e1;
  --shadow:    rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .hljs {
  background: #f1f5f9 !important;
}
[data-theme="light"] .auth-screen {
  background: linear-gradient(135deg, #e0e7ff 0%, #dbeafe 40%, #f0f9ff 100%);
}
[data-theme="light"] .auth-container {
  background: #ffffff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg-darkest);
  color: var(--text-primary);
  overflow: hidden;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

ul { list-style: none; }

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  outline: none;
}

input, textarea, select {
  font-family: var(--font);
  font-size: 15px;
  outline: none;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-subtle { background: transparent; color: var(--text-secondary); }
.btn-subtle:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  transition: all 0.15s ease;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Form Elements ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea,
.form-group select,
.form-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-select:focus {
  border-color: var(--accent);
}

.form-check label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
}
.form-check small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  margin-left: 24px;
}
.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.form-row {
  display: flex;
  gap: 8px;
}
.form-row .form-select { flex: 1; }

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 8px;
  min-height: 0;
}
.form-success {
  color: #22c55e;
  font-size: 13px;
  margin-bottom: 8px;
}

.admin-reset-pw-btn {
  font-size: 12px;
  padding: 2px 8px;
  margin-left: 6px;
}

/* ═══════════════════ AUTH SCREEN ═══════════════════ */
.auth-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-darkest) 0%, var(--bg-darker) 50%, #0f172a 100%);
}
.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 32px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo h1 {
  font-size: 32px;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 2px;
}
.auth-logo h1 span {
  font-weight: 700;
  color: var(--accent-hover);
}
.auth-tagline {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}
.auth-form {
  background: var(--bg-dark);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: 0 8px 32px var(--shadow);
}
.auth-form h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-bright);
}
.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* ═══════════════════ APP LAYOUT ═══════════════════ */
.app-hidden { display: none !important; }
.app-layout {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  overflow: hidden;
}
.app-layout.members-open {
  grid-template-columns: var(--sidebar-width) 1fr var(--members-width);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-darker);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header h2 {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 1px;
}
.sidebar-header h2 span {
  font-weight: 700;
  color: var(--accent-hover);
}
.instance-name {
  font-weight: 300;
  color: var(--text-muted);
  font-size: 0.85em;
  margin-left: 4px;
  letter-spacing: 0.5px;
}

.channel-list-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.channel-section { margin-bottom: 8px; }
.channel-section-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.channel-section-header:hover { color: var(--text-secondary); }
.section-toggle {
  font-size: 10px;
  transition: transform 0.2s;
}
.section-toggle.collapsed { transform: rotate(-90deg); }
.add-channel-btn {
  margin-left: auto;
  width: 18px;
  height: 18px;
  font-size: 16px;
  font-weight: 600;
}

.channel-list li {
  padding: 6px 12px 6px 20px;
  margin: 1px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.1s;
}
.channel-list li:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-list li.active { background: var(--bg-active); color: var(--text-bright); }
.channel-list li .ch-icon {
  font-size: 16px;
  opacity: 0.6;
  flex-shrink: 0;
}
.channel-list li .ch-name { 
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-list li.has-unread .ch-name {
  color: var(--text-bright);
  font-weight: 600;
}
.channel-list li.has-unread .ch-icon {
  opacity: 1;
}
.channel-list li .unread-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ── Category headers in sidebar ─────────────────────────────────────────── */
.category-section { margin-bottom: 4px; }
.category-section .channel-section-header {
  margin-top: 4px;
}

/* ── DM list items ────────────────────────────────────────────────────────── */
.dm-list li {
  padding: 6px 12px 6px 16px;
  position: relative;
}
.dm-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 10px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.dm-avatar-mini .status-dot-mini {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-darker);
}
.status-dot-mini.online { background: var(--success); }
.status-dot-mini.offline { background: var(--text-muted); }

/* ── DM delete button ─────────────────────────────────────────────────────── */
.dm-delete-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  font-size: 0.7rem;
  padding: 2px 4px;
}
.dm-list li:hover .dm-delete-btn {
  opacity: 1;
}
.dm-delete-btn:hover {
  color: var(--danger) !important;
}

/* ── Group DM icon ────────────────────────────────────────────────────────── */
.dm-group-icon {
  font-size: 11px;
  font-weight: 700;
}

/* ── Clickable member for DM ──────────────────────────────────────────────── */
.members-list li.dm-clickable { cursor: pointer; }
.members-list li.dm-clickable:hover {
  background: var(--bg-active);
}

/* ── Group DM Modal ───────────────────────────────────────────────────────── */
.group-dm-user-list {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  background: var(--bg-darker);
}
.group-dm-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  color: var(--text-normal);
  font-size: 14px;
}
.group-dm-user-item:hover {
  background: var(--bg-active);
}
.group-dm-user-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.group-dm-selected {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-darker);
  font-size: 13px;
  color: var(--text-normal);
  min-height: 32px;
}
.text-muted {
  color: var(--text-muted);
}

/* ── User Panel (bottom of sidebar) ───────────────────────────────────────── */
.user-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-darkest);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-panel-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.avatar-small:hover {
  opacity: 0.8;
  filter: brightness(1.1);
}

.profile-avatar-btn {
  margin-top: 8px;
}

.user-panel-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.user-panel-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-panel-username {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Theme Picker ────────────────────────────────────────────────────────── */
.theme-picker {
  position: absolute;
  bottom: 60px;
  left: 12px;
  width: 236px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 12px;
  z-index: 1100;
}
.theme-picker-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.theme-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-medium);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  transition: border-color 0.15s, background 0.15s;
}
.theme-swatch:hover {
  background: var(--bg-hover);
}
.theme-swatch.active {
  border-color: var(--accent);
}
.swatch-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
}

/* ── Status Picker ────────────────────────────────────────────────────────── */
.status-picker {
  position: absolute;
  bottom: 60px;
  left: 12px;
  width: 280px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 12px;
  z-index: 1100;
}
.status-picker-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.status-picker-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.status-emoji-field {
  width: 44px;
  text-align: center;
  padding: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 18px;
}
.status-text-field {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}
.status-emoji-field:focus, .status-text-field:focus {
  border-color: var(--accent);
  outline: none;
}
.status-picker-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.status-preset {
  padding: 4px 8px;
  background: var(--bg-medium);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.status-preset:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.status-picker-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.member-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.member-status-emoji {
  margin-left: 4px;
}
.member-status-text {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.verify-key-btn {
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  margin-left: auto;
}
li:hover .verify-key-btn {
  opacity: 0.6;
}
.verify-key-btn:hover {
  opacity: 1 !important;
}

/* ── Safety Number Verification ───────────────────────────────────────────── */
.safety-number-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}
.safety-number-display {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 2;
  text-align: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  color: var(--accent);
  word-break: break-all;
  user-select: all;
}
.safety-number-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}
.safety-number-status {
  font-size: 12px;
  text-align: center;
  color: var(--text-secondary);
}
.safety-number-status.verified {
  color: #22c55e;
  font-weight: 600;
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-dark);
}

.channel-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.channel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.channel-hash {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-muted);
}
.channel-header-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
}
.channel-header-divider {
  color: var(--border);
  font-size: 18px;
}
.channel-header-desc {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-header-right {
  display: flex;
  gap: 4px;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.messages-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}
.load-more-area {
  text-align: center;
  padding: 8px;
}

#messages-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 16px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.1s;
  position: relative;
}
.message:hover { background: var(--bg-medium); }
.message.compact { padding-left: 60px; }
.message.compact .message-avatar { display: none; }
.message.compact .message-time-inline {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0;
  width: 48px;
  text-align: right;
}
.message.compact:hover .message-time-inline { opacity: 1; }

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.message-body {
  flex: 1;
  min-width: 0;
}
.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.message-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  cursor: pointer;
}
.message-author:hover { text-decoration: underline; }
.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
}
.message-edited {
  font-size: 10px;
  color: var(--text-muted);
}
.message-content {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.message-content a {
  color: var(--accent-hover);
}

/* E2EE encrypted message indicators */
.encrypted-message {
  color: var(--text-muted);
  font-style: italic;
}
.decryption-failed {
  color: var(--danger);
}
.e2ee-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--success);
  margin-left: 8px;
}
.e2ee-status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.e2ee-status-bar .e2ee-icon {
  color: var(--success);
}

/* ── Reply preview in message ────────────────────────────────────────────── */
.message-reply-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-left: 3px solid var(--accent);
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.message-reply-preview:hover {
  background: rgba(99, 102, 241, 0.25);
}
.message-reply-author {
  font-weight: 600;
  color: var(--accent-hover);
}
.message-reply-content {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Message attachments */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.message-attachment-img {
  max-width: 400px;
  max-height: 300px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
}
.message-attachment-img:hover { opacity: 0.9; }

/* Image Lightbox */
.image-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.image-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 36px;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.lightbox-close:hover { opacity: 1; }

.message-attachment-audio {
  background: var(--bg-medium);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.message-attachment-audio audio {
  display: block;
  height: 36px;
}
.attachment-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Message actions (on hover) */
.message-actions {
  position: absolute;
  top: -12px;
  right: 8px;
  display: none;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}
.message:hover .message-actions { display: flex; }
.message-actions .btn-icon {
  width: 30px;
  height: 28px;
  font-size: 14px;
  border-radius: 0;
}

/* Inline editing */
.message-edit-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.message-edit-area textarea {
  width: 100%;
  padding: 8px;
  background: var(--bg-darkest);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text-primary);
  resize: none;
  font-size: 14px;
}
.message-edit-actions {
  display: flex;
  gap: 8px;
  font-size: 12px;
}
.message-edit-actions span {
  color: var(--text-muted);
}
.message-edit-actions a { font-size: 12px; }

/* ── Typing Indicator ─────────────────────────────────────────────────────── */
.typing-indicator {
  min-height: 24px;
  padding: 2px 20px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Reply Preview Bar (above input) ──────────────────────────────────────── */
.reply-preview-bar {
  padding: 6px 16px;
  background: var(--bg-medium);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.reply-preview-bar strong {
  color: var(--accent-hover);
}
.reply-cancel-btn {
  width: 24px !important;
  height: 24px !important;
  font-size: 12px !important;
}

/* ── Message Input ────────────────────────────────────────────────────────── */
.message-input-area {
  padding: 0 16px 20px;
  flex-shrink: 0;
  position: relative;
}
.message-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-medium);
  border-radius: var(--radius);
  padding: 6px 8px;
  gap: 6px;
}
.message-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 6px;
  resize: none;
  max-height: 200px;
  line-height: 1.4;
  min-height: 24px;
}
.message-input-wrapper textarea::placeholder { color: var(--text-muted); }
.attach-btn, .send-btn { flex-shrink: 0; }
.send-btn { color: var(--accent); }

.message-ttl-select {
  flex-shrink: 0;
  height: 40px;
  padding: 0 10px;
  font-size: 0.875rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
}

.file-preview {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  padding: 6px 0;
}
.file-preview.has-files {
  display: flex;
}
.file-preview-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-dark);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.file-preview-item .remove-file {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
}
.file-preview-item .remove-file:hover { color: var(--danger); }

/* ── Upload Progress ─────────────────────────────────────────────────────── */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
}
.upload-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-darker);
  border-radius: 3px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.15s ease;
}
.upload-progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 100px;
}

/* ── Members Sidebar ──────────────────────────────────────────────────────── */
.members-sidebar {
  background: var(--bg-darker);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: none;
}
.app-layout.members-open .members-sidebar { display: block; }

.members-sidebar h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.members-section { margin-bottom: 20px; }
.members-category {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.members-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
}
.members-list li:hover { background: var(--bg-hover); }
.members-list .member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.members-list .member-avatar .status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-darker);
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.members-list .member-name {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.members-list li:hover .member-name { color: var(--text-primary); }
.members-list .member-role {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  text-transform: uppercase;
}
.member-remove-btn {
  margin-left: auto;
  color: var(--text-muted);
  background: transparent;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.member-remove-btn:hover { color: var(--danger); background: var(--bg-hover); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-dark);
  border-radius: var(--radius-xl);
  width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px var(--shadow);
}
.modal-wide { width: 560px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 20px 24px 24px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.modal-tab:hover { color: var(--text-primary); }
.modal-tab.active {
  color: var(--text-bright);
  border-bottom-color: var(--accent);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Context Menu ─────────────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  min-width: 160px;
  z-index: 2000;
  box-shadow: 0 4px 16px var(--shadow);
}
.context-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  background: transparent;
  border-radius: var(--radius-sm);
  transition: all 0.1s;
}
.context-item:hover { background: var(--accent); color: white; }
.context-item[data-action="delete"] { color: var(--danger); }
.context-item[data-action="delete"]:hover { background: var(--danger); color: white; }

/* ── System Message ───────────────────────────────────────────────────────── */
.system-message {
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Channel Welcome ──────────────────────────────────────────────────────── */
.channel-welcome {
  padding: 16px 0 8px;
}
.channel-welcome h3 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 6px;
}
.channel-welcome p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Image Lightbox ───────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
}

/* ── Loading Spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════════════
   Markdown formatting in messages
   ═══════════════════════════════════════════════════════════════════════════ */
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }
.message-content del { text-decoration: line-through; color: var(--text-muted); }
.md-inline-code {
  background: var(--bg-darkest);
  color: var(--accent-hover);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.9em;
}
.md-codeblock {
  background: var(--bg-darkest);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.9em;
  color: var(--text-primary);
}
/* Let highlight.js handle colors inside code, but keep our bg */
.md-codeblock code {
  background: none !important;
  padding: 0 !important;
}
.md-codeblock code.hljs {
  background: transparent !important;
  padding: 0 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WebSocket reconnecting banner
   ═══════════════════════════════════════════════════════════════════════════ */
.ws-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #ed4245;
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  animation: wsBannerPulse 2s ease-in-out infinite;
}
.ws-banner.connected {
  background: #3ba55d;
  animation: none;
}
@keyframes wsBannerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #666;
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════════════
   @mention highlighting
   ═══════════════════════════════════════════════════════════════════════════ */
.mention {
  background: var(--accent-subtle);
  color: var(--accent-hover);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 500;
  cursor: pointer;
}
.mention:hover {
  background: var(--accent);
  color: white;
}
.mention-self {
  background: rgba(99, 102, 241, 0.3);
}

/* ── @mention autocomplete dropdown ───────────────────────────────────────── */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -4px 16px var(--shadow);
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 4px;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}
.mention-item:hover, .mention-item.active {
  background: var(--accent);
  color: white;
}
.mention-item-username {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}
.mention-item:hover .mention-item-username,
.mention-item.active .mention-item-username {
  color: rgba(255,255,255,0.7);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Emoji Reactions
   ═══════════════════════════════════════════════════════════════════════════ */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.reaction-pill:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}
.reaction-pill.mine {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-hover);
}
.reaction-emoji { font-size: 16px; }
.reaction-count { font-size: 12px; font-weight: 600; }
.reaction-add-btn {
  opacity: 0;
  transition: opacity 0.15s;
}
.message:hover .reaction-add-btn { opacity: 1; }

/* ── Emoji Picker ─────────────────────────────────────────────────────────── */
.emoji-picker {
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  display: flex;
  flex-wrap: wrap;
  padding: 6px;
  gap: 2px;
  width: 240px;
}
.emoji-pick-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}
.emoji-pick-btn:hover {
  background: var(--bg-hover);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Pinned Messages
   ═══════════════════════════════════════════════════════════════════════════ */
.message.pinned {
  border-left: 3px solid var(--warning);
  background: rgba(245, 158, 11, 0.05);
}
.message-pinned-label {
  font-size: 10px;
  color: var(--warning);
  margin-left: 4px;
}
.pinned-message {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-medium);
  margin-bottom: 8px;
}
.pinned-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.pinned-msg-author {
  font-weight: 600;
  font-size: 13px;
}
.pinned-msg-time {
  font-size: 11px;
  color: var(--text-muted);
}
.pinned-msg-content {
  font-size: 14px;
  color: var(--text-primary);
  word-wrap: break-word;
}
.no-pins {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Profile Popup
   ═══════════════════════════════════════════════════════════════════════════ */
.profile-popup {
  position: fixed;
  z-index: 2000;
  width: 280px;
  box-shadow: 0 8px 32px var(--shadow);
}
.profile-card {
  background: var(--bg-dark);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
}
.profile-banner {
  height: 60px;
  opacity: 0.7;
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  margin: -28px 0 0 16px;
  border: 4px solid var(--bg-dark);
  position: relative;
  overflow: hidden;
}
.profile-avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--bg-dark);
}
.profile-info {
  padding: 12px 16px 16px;
}
.profile-info h4 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 2px;
}
.profile-username {
  font-size: 13px;
  color: var(--text-muted);
}
.profile-role {
  font-size: 10px;
  background: var(--accent);
  color: white;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}
.profile-meta {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--text-muted);
}
.profile-status-text { font-size: 12px; }
.profile-dm-btn {
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Scroll-to-Bottom button
   ═══════════════════════════════════════════════════════════════════════════ */
.scroll-bottom-btn {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 12px var(--shadow);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}
.scroll-bottom-btn:hover {
  background: var(--accent-hover);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Drag & Drop visual overlay
   ═══════════════════════════════════════════════════════════════════════════ */
.messages-area.drag-over::after {
  content: 'Drop files to upload';
  position: absolute;
  inset: 0;
  background: rgba(99, 102, 241, 0.15);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-hover);
  z-index: 50;
  pointer-events: none;
}

/* ── Clickable avatar/author in messages ──────────────────────────────────── */
.clickable-avatar, .clickable-author {
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Search Modal
   ═══════════════════════════════════════════════════════════════════════════ */
.search-modal {
  width: 560px;
  max-height: 70vh;
}
.search-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.search-input-wrap input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 15px;
}
.search-input-wrap input:focus {
  border-color: var(--accent);
}
.search-filters {
  font-size: 12px;
  color: var(--text-secondary);
}
.search-filters > label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.search-filters input[type="checkbox"] {
  accent-color: var(--accent);
}
.search-advanced {
  margin-top: 6px;
}
.search-advanced summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  user-select: none;
}
.search-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.search-filter-row label {
  min-width: 70px;
  font-size: 12px;
  color: var(--text-secondary);
}
.search-filter-row input {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
}
.search-filter-row input:focus {
  border-color: var(--accent);
  outline: none;
}
.search-results {
  max-height: 400px;
  overflow-y: auto;
}
.search-result-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-medium); }
.search-result-channel {
  font-size: 11px;
  color: var(--accent-hover);
  font-weight: 600;
  margin-bottom: 2px;
}
.search-result-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.search-result-author {
  font-weight: 600;
  font-size: 13px;
}
.search-result-time {
  font-size: 11px;
  color: var(--text-muted);
}
.search-result-content {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-no-results {
  text-align: center;
  padding: 30px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Link Previews
   ═══════════════════════════════════════════════════════════════════════════ */
.link-preview {
  display: flex;
  border-left: 3px solid var(--accent);
  background: var(--bg-medium);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 12px;
  margin-top: 6px;
  max-width: 480px;
  gap: 12px;
}
.link-preview-body {
  flex: 1;
  min-width: 0;
}
.link-preview-site {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.link-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-hover);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-title a {
  color: inherit;
}
.link-preview-title a:hover {
  text-decoration: underline;
}
.link-preview-desc {
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Admin Panel
   ═══════════════════════════════════════════════════════════════════════════ */
.admin-users-list {
  max-height: 350px;
  overflow-y: auto;
}
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  transition: background 0.1s;
}
.admin-user-row:hover { background: var(--bg-medium); }
.admin-user-row .member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.admin-user-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
}
.admin-user-name strong {
  color: var(--text-bright);
}
.admin-user-name span {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 6px;
}
.admin-role-select {
  padding: 4px 8px;
  background: var(--bg-darkest);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
}

/* Bot token display */
.bot-token-display {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-darkest);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.bot-token-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 6px;
}
.bot-token-value {
  display: block;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-dark);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  margin-bottom: 6px;
  user-select: all;
}
.bot-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  text-transform: uppercase;
}
.bot-actions {
  display: flex;
  gap: 4px;
}
.bot-actions button {
  padding: 3px 8px;
  font-size: 11px;
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.bot-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.bot-actions button.danger:hover {
  background: var(--danger);
  color: white;
}

/* Categories admin */
.admin-categories-list {
  margin-top: 12px;
}
.admin-category-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
}
.admin-category-row:hover { background: var(--bg-medium); }
.admin-category-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}
.admin-category-row .btn-icon {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

/* Audit log */
.audit-log-list {
  max-height: 350px;
  overflow-y: auto;
}
.audit-log-entry {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.audit-log-entry:last-child { border-bottom: none; }
.audit-log-action {
  font-weight: 600;
  color: var(--accent-hover);
}
.audit-log-user {
  color: var(--text-secondary);
}
.audit-log-time {
  font-size: 11px;
  color: var(--text-muted);
  float: right;
}
.audit-log-details {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Call Buttons (header) ────────────────────────────────────────────────── */
.call-e2ee-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
}
.call-e2ee-opt:hover {
  color: var(--text-color);
}
.call-e2ee-opt input {
  cursor: pointer;
  accent-color: var(--success);
}

.call-btn {
  color: var(--success) !important;
  font-size: 16px;
}
.call-btn:hover {
  background: rgba(34, 197, 94, 0.15) !important;
}

/* ── Incoming Call Modal ─────────────────────────────────────────────────── */
.call-incoming-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}
.call-incoming-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 300px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}
.call-incoming-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: white;
  animation: callPulse 2s ease-in-out infinite;
  overflow: hidden;
}
.call-incoming-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.call-incoming-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
}
.call-incoming-label {
  font-size: 14px;
  color: var(--text-secondary);
}
.call-incoming-actions {
  display: flex;
  gap: 24px;
  margin-top: 8px;
}
.call-action-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.call-action-btn:hover {
  transform: scale(1.1);
}
.call-accept {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
}
.call-accept:hover {
  box-shadow: 0 6px 24px rgba(34, 197, 94, 0.5);
}
.call-decline {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}
.call-decline:hover {
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.5);
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 0 0 16px rgba(99, 102, 241, 0); }
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── In-Call Overlay ─────────────────────────────────────────────────────── */
.call-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-darkest);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}
.call-overlay-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
}
.call-overlay-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
}
.call-overlay-status {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 2px 10px;
  background: var(--bg-medium);
  border-radius: 10px;
}
.call-overlay-status.connected {
  color: var(--success);
  background: rgba(34, 197, 94, 0.12);
}

/* Video area */
.call-video-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a1a;
  overflow: hidden;
}
.call-remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.call-local-video {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 200px;
  height: 150px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  object-fit: cover;
  z-index: 2;
  background: #000;
  cursor: move;
}
.call-no-video {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1;
}
.call-no-video-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 700;
  color: white;
  overflow: hidden;
}
.call-no-video-name {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-bright);
}

/* Call controls bar */
.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  background: var(--bg-darker);
  border-top: 1px solid var(--border);
}
.call-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-medium);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 22px;
  transition: background 0.15s, transform 0.1s;
  min-width: 80px;
}
.call-control-btn:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
}
.call-control-btn.active {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.call-control-label {
  font-size: 11px;
  color: var(--text-secondary);
}
.call-control-btn.active .call-control-label {
  color: rgba(255, 255, 255, 0.8);
}
.call-hangup-btn {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: white !important;
}
.call-hangup-btn:hover {
  background: #dc2626 !important;
}
.call-hangup-btn .call-control-label {
  color: rgba(255, 255, 255, 0.8);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Voice Channels
   ═══════════════════════════════════════════════════════════════════════════ */

.voice-channel-list {
  padding: 0 !important;
  list-style: none;
}

.voice-channel-item {
  padding: 6px 10px;
  margin: 2px 8px;
  border-radius: 6px;
  cursor: default;
  transition: background 0.15s;
}

.voice-channel-item:hover {
  background: var(--bg-hover);
}

.voice-channel-item.voice-active {
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
}

.voice-channel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
}

.voice-channel-header .ch-name {
  flex: 1;
}

.voice-count {
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

.voice-delete-btn {
  margin-left: auto;
  opacity: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: opacity 0.15s, color 0.15s;
}
.voice-channel-item:hover .voice-delete-btn {
  opacity: 1;
}
.voice-delete-btn:hover {
  color: var(--danger) !important;
}

/* Participants inside a voice channel card */
.voice-participants {
  padding: 4px 0 2px 22px;
}

.voice-participant {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.voice-participant.broadcaster {
  color: var(--success);
  font-weight: 600;
}

.voice-participant.listener {
  color: var(--text-muted);
}

.voice-participant-icon {
  font-size: 0.7rem;
}

.voice-participant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Action buttons inside voice channel card */
.voice-channel-actions {
  display: flex;
  gap: 6px;
  padding: 5px 0 2px 22px;
}

.voice-channel-actions .btn-sm {
  padding: 3px 10px;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-medium);
  color: var(--text-primary);
  transition: all 0.15s;
}

.voice-channel-actions .btn-sm:hover {
  background: var(--bg-hover);
}

.voice-channel-actions .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.voice-channel-actions .btn-primary:hover {
  background: var(--accent-hover);
}

.voice-channel-actions .btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.voice-channel-actions .btn-danger:hover {
  background: #dc2626;
}

/* ── Voice Status Bar (persistent bottom bar when in a voice channel) ──── */

.voice-status-bar {
  background: var(--bg-medium);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.voice-status-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-status-icon {
  font-size: 1.1rem;
}

.voice-status-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.voice-status-role {
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.voice-status-channel {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.voice-status-controls {
  display: flex;
  gap: 6px;
}

.voice-status-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.voice-status-btn:hover {
  background: var(--bg-active);
}

.voice-status-disconnect {
  background: var(--danger) !important;
  color: white !important;
}

.voice-status-disconnect:hover {
  background: #dc2626 !important;
}

/* ── Mobile hamburger (hidden on desktop) ─────────────────────────────────── */
.mobile-menu-btn { display: none; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1099;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* -- Layout: fixed full-screen container on mobile ----------------------- */
  .app-layout {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    height: auto;
    overflow: hidden;
  }
  .app-hidden { display: none !important; }
  .main-content {
    -webkit-flex: 1 1 0%;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
  }
  .messages-scroll {
    -webkit-overflow-scrolling: touch;
  }
  .messages-area {
    -webkit-flex: 1;
    flex: 1;
    min-height: 0;
  }

  /* -- Sidebar: off-screen slide-in overlay ------------------------------- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  /* -- Members sidebar: slide-in from right ------------------------------- */
  .members-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 260px;
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    background: var(--bg-darker);
    border-left: 1px solid var(--border);
  }
  .app-layout.members-open .members-sidebar {
    transform: translateX(0);
  }

  /* -- Hamburger button visible ------------------------------------------- */
  .mobile-menu-btn {
    display: flex;
    font-size: 20px;
    margin-right: 4px;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
  }

  /* -- Channel header: tighter on mobile ---------------------------------- */
  .channel-header {
    padding: 0 10px;
  }
  .channel-header-divider,
  .channel-header-desc {
    display: none;
  }
  .channel-header-right {
    gap: 2px;
  }
  .channel-header-right .btn-icon {
    min-width: 36px;
    min-height: 36px;
  }

  /* -- Auth screen: mobile-friendly --------------------------------------- */
  .auth-container {
    padding: 16px;
    max-width: 100%;
  }
  .auth-form {
    padding: 20px 16px;
  }
  .auth-logo h1 {
    font-size: 26px;
  }

  /* -- Message input: reduce padding -------------------------------------- */
  .message-input-area {
    padding: 0 10px 12px;
  }

  /* -- Messages: reduce side padding -------------------------------------- */
  #messages-container {
    padding: 0 8px;
  }
  .message {
    padding: 4px 4px;
  }

  /* -- Attachments: fit viewport ------------------------------------------ */
  .message-attachment-img {
    max-width: 100%;
  }
  .link-preview {
    max-width: 100%;
  }
  .link-preview-img {
    width: 60px;
    height: 60px;
  }

  /* -- Modals: fit mobile viewport ---------------------------------------- */
  .modal {
    width: calc(100vw - 32px);
    max-width: 440px;
    max-height: 85vh;
  }
  .modal-wide {
    width: calc(100vw - 32px);
    max-width: 560px;
  }
  .search-modal {
    width: calc(100vw - 32px);
    max-width: 560px;
  }
  .modal-header {
    padding: 16px 16px 0;
  }
  .modal-body {
    padding: 16px;
  }

  /* -- Profile popup: fit viewport ---------------------------------------- */
  .profile-popup {
    width: calc(100vw - 32px);
    max-width: 280px;
    left: 16px !important;
  }

  /* -- Theme picker: constrain to viewport -------------------------------- */
  .theme-picker {
    width: calc(100vw - 48px);
    max-width: 236px;
    left: 8px;
  }

  /* -- Emoji picker: constrain to viewport -------------------------------- */
  .emoji-picker {
    width: calc(100vw - 48px);
    max-width: 240px;
  }

  /* -- Mention dropdown: full width --------------------------------------- */
  .mention-dropdown {
    left: 0;
    right: 0;
    max-width: 100%;
  }

  /* -- Context menu: constrain to viewport -------------------------------- */
  .context-menu {
    max-width: calc(100vw - 16px);
  }

  /* -- Touch targets: minimum 44px ---------------------------------------- */
  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
  .channel-list li {
    min-height: 40px;
    display: flex;
    align-items: center;
  }
  .members-list li {
    min-height: 40px;
  }

  /* -- Call UI: compact on mobile ----------------------------------------- */
  .call-local-video {
    width: 120px;
    height: 90px;
    bottom: 10px;
    right: 10px;
  }
  .call-controls {
    gap: 12px;
    padding: 12px;
  }
  .call-control-btn {
    min-width: 64px;
    padding: 10px 14px;
    font-size: 18px;
  }
  .call-incoming-card {
    width: calc(100vw - 32px);
    max-width: 340px;
    min-width: auto;
  }

  /* -- User panel: ensure tap targets ------------------------------------- */
  .user-panel .btn-icon {
    min-width: 36px;
    min-height: 36px;
  }

  /* -- Channel welcome: smaller heading ----------------------------------- */
  .channel-welcome h3 {
    font-size: 22px;
  }

  /* -- Scroll-to-bottom button: easier to tap ----------------------------- */
  .scroll-bottom-btn {
    min-height: 40px;
    padding: 8px 16px;
  }

  /* -- Form actions: stack on small screens ------------------------------- */
  .form-actions {
    flex-direction: column;
    gap: 8px;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* -- Admin panel tabs: scrollable --------------------------------------- */
  .modal-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .modal-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* -- Reply preview bar: compact ----------------------------------------- */
  .reply-preview-bar {
    padding: 6px 10px;
  }

  /* -- Toast: wider on mobile --------------------------------------------- */
  .toast {
    width: calc(100vw - 32px);
    max-width: 360px;
    text-align: center;
  }
}

/* ── Toast notifications ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { background: #22c55e; }
.toast-error { background: #ef4444; }
.toast-info { background: var(--accent); }
