.nav-profile-menu {
  position: relative;
  display: inline-flex;
}

.profile-head {
  margin-bottom: 16px;
}

.nav-profile-link {
  width: 42px;
  height: 42px;
  margin-left: 18px;
  border-radius: 999px;
  border: 1px solid rgba(76, 111, 255, 0.2);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.2) 28%, transparent 29%),
    linear-gradient(135deg, rgba(76, 111, 255, 0.18), rgba(0, 229, 255, 0.22));
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
  padding: 0;
  appearance: none;
  cursor: pointer;
}

.nav-profile-link img,
.nav-profile-fallback {
  width: 100%;
  height: 100%;
}

.nav-profile-link img {
  display: block;
  object-fit: cover;
}

.nav-profile-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #163267;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe 55%, #93c5fd);
}

body.theme-dark .nav-profile-link {
  border-color: rgba(96, 165, 250, 0.28);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 26%, transparent 27%),
    linear-gradient(135deg, rgba(96, 165, 250, 0.22), rgba(45, 212, 191, 0.24));
}

body.theme-dark .nav-profile-fallback {
  color: #eff6ff;
  background: linear-gradient(135deg, #1d4ed8, #2563eb 58%, #0ea5e9);
}

.nav-profile-link:focus-visible,
.nav-profile-menu-item:focus-visible {
  outline: 2px solid rgba(76, 111, 255, 0.45);
  outline-offset: 3px;
}

.nav-profile-menu.is-open .nav-profile-link {
  border-color: rgba(76, 111, 255, 0.45);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

body.theme-dark .nav-profile-menu.is-open .nav-profile-link {
  border-color: rgba(96, 165, 250, 0.5);
}

.nav-profile-menu-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(320px, calc(100vw - 24px));
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card-strong);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
  z-index: 45;
}

.nav-profile-menu-panel[hidden] {
  display: none;
}

.nav-profile-menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-profile-menu-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid rgba(76, 111, 255, 0.18);
}

.nav-profile-menu-avatar img,
.nav-profile-menu-avatar .nav-profile-fallback {
  width: 100%;
  height: 100%;
}

.nav-profile-menu-avatar img {
  display: block;
  object-fit: cover;
}

.nav-profile-menu-avatar .nav-profile-fallback {
  font-size: 12px;
}

.nav-profile-menu-head-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.nav-profile-menu-head-copy strong {
  font-size: 14px;
  line-height: 1.3;
}

.nav-profile-menu-head-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-profile-menu-list {
  display: grid;
  gap: 8px;
}

.nav-profile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.04);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
}

.nav-profile-menu-item:hover {
  border-color: rgba(76, 111, 255, 0.18);
  background: rgba(76, 111, 255, 0.08);
}

body.theme-dark .nav-profile-menu-item {
  background: rgba(15, 23, 42, 0.55);
}

body.theme-dark .nav-profile-menu-item:hover {
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.14);
}

.nav-profile-menu-item.is-danger:hover {
  border-color: rgba(220, 38, 38, 0.18);
  background: rgba(220, 38, 38, 0.08);
}

body.theme-dark .nav-profile-menu-item.is-danger:hover {
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.12);
}

.nav-profile-menu-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #1d4ed8;
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.95), rgba(191, 219, 254, 0.85));
}

body.theme-dark .nav-profile-menu-item-icon {
  color: #dbeafe;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.65), rgba(14, 165, 233, 0.4));
}

.nav-profile-menu-item.is-danger .nav-profile-menu-item-icon {
  color: #b91c1c;
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.96), rgba(252, 165, 165, 0.82));
}

body.theme-dark .nav-profile-menu-item.is-danger .nav-profile-menu-item-icon {
  color: #fee2e2;
  background: linear-gradient(135deg, rgba(153, 27, 27, 0.66), rgba(220, 38, 38, 0.38));
}

.nav-profile-menu-item-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.nav-profile-menu-item-label {
  min-width: 0;
  line-height: 1.35;
}

#profile-overview,
#profile-settings,
#profile-stats,
#profile-notes {
  scroll-margin-top: 96px;
}
