:root {
  --panel-max-width: 420px;
  /* INCREASED OPACITY: User reported transparency issues - Better contrast */
  --panel-bg: rgba(12,18,24,0.96); /* Was 0.92 → Now 0.96 for better visibility */
  --panel-border: rgba(0,255,198,0.25); /* Neon border instead of white for dark theme */
  --panel-radius: 14px;
  /* ENHANCED GLOW: Stronger neon cyan shadow */
  --panel-shadow: 
    0 4px 24px -4px rgba(0,0,0,0.7), 
    0 0 0 1px rgba(0,255,198,0.28), 
    0 0 30px -6px rgba(0,255,198,0.6),
    inset 0 0 0 1px rgba(255,255,255,0.04);
  --panel-scroll-shadow-top: linear-gradient(to bottom, rgba(12,18,24,0.88), rgba(12,18,24,0));
  --panel-scroll-shadow-bottom: linear-gradient(to top, rgba(12,18,24,0.88), rgba(12,18,24,0));
}

.mobile-user-panel {
  position: absolute;
  top: 56px;
  right: 12px;  /* RIGHT alignment - panel's right edge aligns with button */
  width: min(calc(100vw - 24px), var(--panel-max-width));
  max-height: calc(100vh - 72px);
  background: var(--panel-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999; /* CRITICAL: Must be above ALL content (was 1200) */
  isolation: isolate; /* Create new stacking context */
  overflow: hidden;
  padding: 4px 0 0 0;
  transform-origin: top right;  /* Animates from top-right corner */
}

[data-user-panel-open] #quickInboxBtn { outline: 2px solid var(--accent, #00ffc6); }

.mobile-user-panel.hidden { display: none; }

.mobile-user-panel .panel-scroller { 
  overflow-y: auto; 
  overscroll-behavior: contain; 
  padding: 4px 16px 16px 16px; 
  position: relative;
  scrollbar-width: thin;
}
.mobile-user-panel .panel-scroller::-webkit-scrollbar { width: 10px; }
.mobile-user-panel .panel-scroller::-webkit-scrollbar-track { background: transparent; }
.mobile-user-panel .panel-scroller::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; border:2px solid transparent; background-clip: content-box; }
.mobile-user-panel .panel-scroller::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); border:2px solid transparent; }

.mobile-user-panel .panel-section + .panel-section { margin-top: 20px; }
/* BETTER CONTRAST: Stronger border + subtle neon glow */
.mobile-user-panel .profile-header { 
  padding: 2px 0 12px 0; 
  border-bottom: 1px solid rgba(0,255,198,0.22); 
  box-shadow: 0 1px 0 rgba(0,255,198,0.08);
}
.mobile-user-panel .prefs-grid { display: grid; gap: 12px; margin-top: 4px; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); }
.mobile-user-panel .pref-item { display:flex; flex-direction:column; gap:4px; font-size: 13px; }
/* BETTER VISIBILITY: Lighter label color */
.mobile-user-panel .pref-label { 
  font-size: 11px; 
  text-transform: uppercase; 
  letter-spacing: .06em; 
  opacity:.85; /* Was .75 → Now .85 */
  color: #a0b0c0; /* Added explicit color */
}
.mobile-user-panel .panel-actions { display:flex; gap:12px; flex-wrap:wrap; }
.mobile-user-panel .notification-list { margin-top: 10px; max-height: 260px; overflow-y:auto; padding-right:4px; }
.mobile-user-panel .notification-list.compact .notification { padding:6px 8px; border-radius:8px; }
.mobile-user-panel .notification-list .no-notifications { opacity:.7; font-size:13px; padding:8px 0; color:#8fa1b3; }
.mobile-user-panel h3 { 
  font-family: var(--font-display, Orbitron, sans-serif); 
  font-weight:600; 
  font-size:15px; 
  color: #d9e2ec; /* Explicit color for headings */
  text-shadow: 0 0 8px rgba(0,255,198,0.35); /* Subtle neon glow */
}

/* Scroll Shadows */
.mobile-user-panel .panel-scroller:before,
.mobile-user-panel .panel-scroller:after {
  content:""; position: sticky; left:0; right:0; height:18px; pointer-events:none; z-index:5; display:block;
}
.mobile-user-panel .panel-scroller:before { top:0; background: var(--panel-scroll-shadow-top); }
.mobile-user-panel .panel-scroller:after { bottom:0; background: var(--panel-scroll-shadow-bottom); }

/* Open/Close Motion (guarded by JS for reduced motion) */
[data-user-panel-open] .mobile-user-panel[data-open] { animation: panelIn 200ms ease-out; }
@keyframes panelIn { from { opacity:0; transform: translateY(8px) scale(.96); } to { opacity:1; transform: translateY(0) scale(1); } }

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
  [data-user-panel-open] .mobile-user-panel[data-open] { animation: none !important; }
}

/* ===========================================
   NEON REDESIGN 2025-10-03
   - Panel-Close Button: Neon Cyan Glow
   - Combiner Wrapper: Dark Glass Neon Border
   - Icon Buttons: Hover Glow Effects
   - Avatar Upload: Better Contrast + Neon
   =========================================== */

/* Panel-Close Button */
.panel-close,
.panel-close.icon-btn {
  background: linear-gradient(180deg, rgba(0,255,198,0.08) 0%, rgba(0,255,198,0.04) 100%);
  border: 1px solid rgba(0,255,198,0.2);
  color: #00FFC6;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display, Orbitron, sans-serif);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.panel-close:hover,
.panel-close.icon-btn:hover {
  background: linear-gradient(180deg, rgba(0,255,198,0.15) 0%, rgba(0,255,198,0.08) 100%);
  border-color: rgba(0,255,198,0.4);
  box-shadow: 
    0 0 16px rgba(0,255,198,0.4),
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 0 0 1px rgba(255,255,255,0.08);
  transform: translateY(-1px);
  color: #00FFDD;
}

.panel-close:active,
.panel-close.icon-btn:active {
  transform: translateY(0);
  box-shadow: 
    0 0 8px rgba(0,255,198,0.3),
    inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Combiner Wrapper (Notification + Profile Button Container) */
.combiner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(12,18,24,0.92) 0%, rgba(16,22,28,0.88) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0,255,198,0.18);
  border-radius: 12px;
  padding: 4px 6px;
  box-shadow: 
    0 2px 12px rgba(0,0,0,0.4),
    0 0 0 1px rgba(0,255,198,0.12),
    inset 0 0 0 1px rgba(255,255,255,0.03);
  position: relative;
  margin-left: auto; /* Push combiner to the right edge */
  transition: all 0.25s ease;
  
  /* CRITICAL: Must be in same stacking context as .user-area */
  z-index: 10; /* Within .user-area (z-index: 9999) */
}

.combiner:hover {
  border-color: rgba(0,255,198,0.28);
  box-shadow: 
    0 4px 16px rgba(0,0,0,0.5),
    0 0 0 1px rgba(0,255,198,0.22),
    0 0 20px -4px rgba(0,255,198,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.05);
}

/* Icon Buttons (Notifications + Profile) */
.combiner .icon-btn {
  background: transparent;
  border: none;
  color: #a8b8c8;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.combiner .icon-btn:hover {
  background: rgba(0,255,198,0.12);
  color: #00FFC6;
  box-shadow: 0 0 12px rgba(0,255,198,0.25);
}

.combiner .icon-btn:active {
  background: rgba(0,255,198,0.18);
  transform: scale(0.96);
}

/* Active State (Panel Open) */
.combiner .icon-btn[aria-expanded="true"],
.combiner .icon-btn.active {
  background: rgba(0,255,198,0.15);
  color: #00FFC6;
  box-shadow: 
    0 0 16px rgba(0,255,198,0.35),
    inset 0 0 0 1px rgba(0,255,198,0.3);
}

/* Notification Badge (Neon Accent) */
.combiner .icon-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: linear-gradient(135deg, #00FFC6 0%, #00C2FF 100%);
  color: #0a0e14;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  box-shadow: 
    0 0 12px rgba(0,255,198,0.8),
    0 2px 4px rgba(0,0,0,0.3);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 12px rgba(0,255,198,0.8), 0 2px 4px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 20px rgba(0,255,198,1), 0 2px 6px rgba(0,0,0,0.4); }
}

/* Avatar Upload Section */
.mobile-user-panel .avatar-upload {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,255,198,0.15);
}

.mobile-user-panel .avatar-upload .btn,
.mobile-user-panel .avatar-upload button {
  background: linear-gradient(180deg, rgba(0,255,198,0.12) 0%, rgba(0,255,198,0.06) 100%);
  border: 1px solid rgba(0,255,198,0.25);
  color: #d4dce4;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display, Orbitron, sans-serif);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: 0 0 4px rgba(0,255,198,0.3);
}

.mobile-user-panel .avatar-upload .btn:hover,
.mobile-user-panel .avatar-upload button:hover {
  background: linear-gradient(180deg, rgba(0,255,198,0.18) 0%, rgba(0,255,198,0.10) 100%);
  border-color: rgba(0,255,198,0.4);
  color: #e8f0f8;
  box-shadow: 
    0 0 16px rgba(0,255,198,0.35),
    0 2px 8px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

.mobile-user-panel .avatar-upload .btn:active,
.mobile-user-panel .avatar-upload button:active {
  transform: translateY(0);
  box-shadow: 
    0 0 8px rgba(0,255,198,0.25),
    inset 0 2px 4px rgba(0,0,0,0.15);
}

.mobile-user-panel .avatar-upload .btn.secondary {
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%);
  border-color: rgba(255,255,255,0.15);
  color: #b8c4d0;
}

.mobile-user-panel .avatar-upload .btn.secondary:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
  border-color: rgba(255,255,255,0.25);
  color: #d4dce4;
  box-shadow: 0 0 12px rgba(255,255,255,0.1);
}

/* Email Preferences Toggle */
.mobile-user-panel .pref-item input[type="checkbox"] {
  accent-color: #00FFC6;
  width: 18px;
  height: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-user-panel .pref-item input[type="checkbox"]:hover {
  box-shadow: 0 0 8px rgba(0,255,198,0.4);
}

/* Preference Labels (Better Visibility) */
.mobile-user-panel .pref-item label {
  color: #c4d0dc;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.mobile-user-panel .pref-item label:hover {
  color: #00FFC6;
}


/* ===========================================
   MOBILE BREAKPOINTS: Progressive enhancement for smaller screens
   iPhone 13/12/11 (390px), iPhone 13 Pro Max (428px)
   =========================================== */

/* iPhone 13 Pro Max, 13, 12, 11, XR (390-428px) - FULL WIDTH FROM RIGHT */
@media (max-width: 428px) {
  .mobile-user-panel { 
    right: 0 !important; 
    left: auto !important;  /* NOT left: 0 - keep right alignment */
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: calc(100vh - 56px);
    top: 56px;
    border-radius: 0 !important; /* Full width = no border radius */
    border-left: none;
    border-right: none;
    transform-origin: top right !important; /* Slide in from right */
  }
  
  .mobile-user-panel .panel-scroller {
    padding: 8px 20px 20px 20px !important; /* Full width, generous padding */
  }
}

/* Mobile full-width adaptation below 480px */
@media (max-width: 480px) {
  .mobile-user-panel { 
    right: 0; 
    left: auto;  /* NOT left: 0 - keep right alignment */
    width: 100vw;
    max-height: calc(100vh - 60px);
    top: 50px;
    transform-origin: top right; /* Slide in from right */
  }
  
  /* Profile Header: Reduce padding, smaller avatar */
  .mobile-user-panel .profile-header {
    padding: 8px 0;
  }
  
  .mobile-user-panel .profile-header .avatar-sm {
    width: 24px;
    height: 24px;
  }
  
  .mobile-user-panel .user-meta {
    font-size: 13px;
  }
  
  .mobile-user-panel .user-meta .font-semibold {
    font-size: 14px;
  }
  
  .mobile-user-panel .user-meta .sub {
    font-size: 11px;
  }
  
  /* Avatar Upload: Stack buttons vertically */
  .mobile-user-panel .avatar-upload {
    padding-top: 8px;
    margin-top: 8px;
  }
  
  .mobile-user-panel .avatar-upload .flex {
    flex-direction: column;
    align-items: stretch !important;
    gap: 6px !important;
  }
  
  .mobile-user-panel .avatar-upload .btn,
  .mobile-user-panel .avatar-upload button {
    font-size: 12px;
    padding: 8px 12px;
    width: 100%;
  }
  
  /* Preferences: Single column */
  .mobile-user-panel .prefs-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .mobile-user-panel .pref-item {
    font-size: 12px;
  }
  
  .mobile-user-panel .pref-label {
    font-size: 10px;
  }
  
  /* Panel Actions: Stack buttons */
  .mobile-user-panel .panel-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .mobile-user-panel .panel-actions .btn-text {
    width: 100%;
    text-align: center;
    padding: 10px 14px;
    font-size: 12px;
  }
  
  /* Notifications: Reduce spacing */
  .mobile-user-panel .section-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  
  .mobile-user-panel .section-header .ml-auto {
    margin-left: 0 !important;
    width: 100%;
  }
  
  .mobile-user-panel .section-header .flex {
    width: 100%;
    justify-content: space-between;
  }
  
  .mobile-user-panel .section-header .btn-inline {
    font-size: 10px;
    padding: 4px 8px;
  }
  
  .mobile-user-panel h3 {
    font-size: 14px;
  }
  
  /* Panel Scroller: Reduce padding */
  .mobile-user-panel .panel-scroller {
    padding: 4px 12px 12px 12px;
  }
  
  /* Panel Section: Reduce spacing */
  .mobile-user-panel .panel-section + .panel-section {
    margin-top: 12px;
  }
}

/* Extra small screens (< 360px) */
@media (max-width: 360px) {
  .mobile-user-panel {
    right: 4px;
    left: 4px;
    top: 48px;
    max-height: calc(100vh - 52px);
  }
  
  .mobile-user-panel .panel-scroller {
    padding: 2px 8px 8px 8px;
  }
  
  .mobile-user-panel .section-header .btn-inline {
    font-size: 9px;
    padding: 3px 6px;
  }
}

/* Safe area (iOS notch) */
@supports (padding:max(0px)) {
  .mobile-user-panel { padding-top: max(4px, env(safe-area-inset-top)); }
}
